mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package fixtures
|
|
|
|
import (
|
|
"github.com/zap-proto/zip"
|
|
|
|
"github.com/hanzoai/commerce/config"
|
|
"github.com/hanzoai/commerce/datastore"
|
|
"github.com/hanzoai/commerce/models/blockchains"
|
|
"github.com/hanzoai/commerce/models/wallet"
|
|
)
|
|
|
|
// This wallet stores special platform level Addresses
|
|
var PlatformWallet = New("platform-wallet", func(c *zip.Ctx) *wallet.Wallet {
|
|
BlockchainNamespace(c)
|
|
|
|
db := datastore.New(c.Context())
|
|
|
|
w := wallet.New(db)
|
|
w.Id_ = "platform-wallet"
|
|
w.UseStringKey = true
|
|
w.GetOrCreate("Id_=", "platform-wallet")
|
|
|
|
if _, ok := w.GetAccountByName("Ethereum Ropsten Test Account"); !ok {
|
|
if _, err := w.CreateAccount("Ethereum Ropsten Test Account", blockchains.EthereumRopstenType, []byte(config.Ethereum.TestPassword)); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
if _, ok := w.GetAccountByName("Ethereum Deposit Account"); !ok {
|
|
if _, err := w.CreateAccount("Ethereum Deposit Account", blockchains.EthereumType, []byte(config.Ethereum.DepositPassword)); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
if _, ok := w.GetAccountByName("Bitcoin Test Account"); !ok {
|
|
if _, err := w.CreateAccount("Bitcoin Test Account", blockchains.BitcoinTestnetType, []byte(config.Bitcoin.TestPassword)); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
if _, ok := w.GetAccountByName("Bitcoin Deposit Account"); !ok {
|
|
if _, err := w.CreateAccount("Bitcoin Deposit Account", blockchains.BitcoinType, []byte(config.Bitcoin.DepositPassword)); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
return w
|
|
})
|