package dca import ( _ "gno.land/r/gnoswap/rbac/v1" // registers the roles read through access "errors" pdca "gno.land/p/gnoswap/order/dca/v0" "gno.land/p/gnoswap/store/v1" "gno.land/p/gnoswap/version_manager/v1" ) var ( currentAddress address kvStore store.KVStore versionManager version_manager.VersionManager implementation pdca.IDCAOrder ) func init(cur realm) { currentAddress = cur.Address() kvStore = store.NewKVStore(currentAddress) versionManager = version_manager.NewVersionManager( cur.PkgPath(), kvStore, initializeDomainStore, ) implementation = nil } func initializeDomainStore(_ int, rlm realm, kvStore store.KVStore) any { return NewDCAOrderStore(kvStore) } // Address returns the realm address that escrows order funds. // Users approve it before CreateOrder. func Address() address { return currentAddress } func getImplementation() pdca.IDCAOrder { if implementation == nil { panic(errImplNotInitialized) } return implementation } func updateImplementation() error { result := versionManager.GetCurrentImplementation() if result == nil { return errors.New(errImplNotInitialized) } impl, ok := result.(pdca.IDCAOrder) if !ok { return errors.New(errInvalidImpl) } implementation = impl return nil }