mirror of
https://github.com/luxfi/bank.git
synced 2026-10-30 17:02:07 +00:00
Each Ensure creates its collection once and returns early ever after, so the owner-scoped rules of v1.5.0 only ever applied to a fresh database. One created by an earlier release kept list/view open to anyone on accounts, balances, transactions, wallets and cards through every upgrade. The rules are now one table, used at creation and re-asserted on every boot. The users collection's anonymous create is closed the same way: identity is Lux ID, so no anonymous caller makes a users record. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_016dDw5Lp9sZFctwvZLn4nVz
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package collections
|
|
|
|
import "github.com/hanzoai/base/core"
|
|
|
|
const WalletCollectionName = "wallets"
|
|
|
|
func EnsureWalletCollection(app core.App) error {
|
|
_, err := app.FindCollectionByNameOrId(WalletCollectionName)
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
c := core.NewBaseCollection(WalletCollectionName, WalletCollectionName)
|
|
|
|
c.Fields.Add(
|
|
&core.RelationField{
|
|
Name: "account",
|
|
CollectionId: AccountCollectionName,
|
|
Required: true,
|
|
MaxSelect: 1,
|
|
},
|
|
&core.TextField{
|
|
Name: "currency",
|
|
Required: true,
|
|
Min: 3,
|
|
Max: 3,
|
|
},
|
|
&core.TextField{Name: "walletId"}, // the custodian's handle for this holding (Wallet.Ref)
|
|
&core.TextField{Name: "address"}, // where this account receives
|
|
&core.TextField{Name: "network"}, // e.g. "lux-mainnet"
|
|
&core.TextField{Name: "status"}, // active, provisioning, suspended, closed
|
|
&core.AutodateField{Name: "created", OnCreate: true},
|
|
&core.AutodateField{Name: "updated", OnCreate: true, OnUpdate: true},
|
|
)
|
|
|
|
readable(c)
|
|
|
|
return app.Save(c)
|
|
}
|