Files
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

50 lines
1.3 KiB
Go

package blockaddress
import (
"github.com/hanzoai/commerce/datastore"
"github.com/hanzoai/commerce/models/mixin"
"github.com/hanzoai/commerce/util/nscontext"
"github.com/hanzoai/orm"
. "github.com/hanzoai/commerce/models/blockchains"
)
func init() { orm.Register[BlockAddress]("blockaddress") }
// This is a reference to an address the blockchain reader needs to watch for
type WatchedAddress struct {
// This is the namespace where the wallet is stored
WalletNamespace string `json:"walletNamespace"`
// This is the id of the wallet
WalletId string `json:"walletId"`
}
// BlockAddress denotes an address on the blockchain that we wnat ot keep track
// of
type BlockAddress struct {
mixin.Model[BlockAddress]
WatchedAddress
// Address on the blockchain
Address string `json:"address"`
// Which blockchain contains the address
Type Type `json:"type"`
}
func New(db *datastore.Datastore) *BlockAddress {
b := new(BlockAddress)
// Embed BlockchainNamespace in the context so SQLite uses it for reads and writes.
nsCtx := nscontext.WithNamespace(db.Context, BlockchainNamespace)
nsDb := datastore.New(nsCtx)
nsDb.SetNamespace(BlockchainNamespace)
b.Init(nsDb)
return b
}
func Query(db *datastore.Datastore) datastore.Query {
return db.Query("blockaddress")
}