Files
commerce/models/fixtures/platform-wallet.go
zeekay 1943f1c093 Hanzo Commerce
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
2026-09-23 21:52:16 -07:00

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
})