From 11f5ff848b39cab9f3678d946e155907152cb540 Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:43:55 +0200 Subject: [PATCH 01/29] Initial abstract manager implementation --- package-lock.json | 2 + package.json | 2 + .../formulas/contract/abstract/manager.ts | 60 ++++ .../formulas/contract/abstract/types/index.ts | 2 + .../contract/abstract/types/manager.ts | 289 ++++++++++++++++++ .../contract/abstract/types/versionControl.ts | 213 +++++++++++++ .../contract/abstract/versionControl.ts | 229 ++++++++++++++ .../transformers/abstract/manager.ts | 0 8 files changed, 797 insertions(+) create mode 100644 src/formulas/formulas/contract/abstract/manager.ts create mode 100644 src/formulas/formulas/contract/abstract/types/index.ts create mode 100644 src/formulas/formulas/contract/abstract/types/manager.ts create mode 100644 src/formulas/formulas/contract/abstract/types/versionControl.ts create mode 100644 src/formulas/formulas/contract/abstract/versionControl.ts create mode 100644 src/transformers/transformers/abstract/manager.ts diff --git a/package-lock.json b/package-lock.json index 1860e5ce..f3111f72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "pg-hstore": "^2.3.4", "pusher": "^5.1.2", "reflect-metadata": "^0.1.13", + "semver": "^7.6.2", "sequelize": "^6.26.0", "sequelize-typescript": "^2.1.5", "supertest": "^6.3.3", @@ -65,6 +66,7 @@ "@types/node": "^18.11.10", "@types/prettier": "^2.7.1", "@types/redis-info": "^3.0.1", + "@types/semver": "^7.5.8", "@types/supertest": "^2.0.12", "@types/validator": "^13.7.10", "@types/ws": "^8.5.5", diff --git a/package.json b/package.json index 0b6345a1..44569817 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@types/node": "^18.11.10", "@types/prettier": "^2.7.1", "@types/redis-info": "^3.0.1", + "@types/semver": "^7.5.8", "@types/supertest": "^2.0.12", "@types/validator": "^13.7.10", "@types/ws": "^8.5.5", @@ -111,6 +112,7 @@ "pg-hstore": "^2.3.4", "pusher": "^5.1.2", "reflect-metadata": "^0.1.13", + "semver": "^7.6.2", "sequelize": "^6.26.0", "sequelize-typescript": "^2.1.5", "supertest": "^6.3.3", diff --git a/src/formulas/formulas/contract/abstract/manager.ts b/src/formulas/formulas/contract/abstract/manager.ts new file mode 100644 index 00000000..60b1d47e --- /dev/null +++ b/src/formulas/formulas/contract/abstract/manager.ts @@ -0,0 +1,60 @@ +import { ContractFormula } from '@/types' + +import { ManagerTypes } from './types' + +export const owner: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return ( + (await get(contractAddress, 'ownership')) + ?.owner ?? undefined + ) + }, +} + +export const accountId: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return await get(contractAddress, 'acc_id') + }, +} + +export const suspensionStatus: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return await get(contractAddress, 'is_suspended') + }, +} + +export const config: ContractFormula = + { + compute: async (env) => { + const { contractAddress, get } = env + const accId = await accountId.compute(env) + const isSuspended = await suspensionStatus.compute(env) + + const config = await get< + Pick< + ManagerTypes.ConfigResponse, + 'version_control_address' | 'module_factory_address' + > + >(contractAddress, 'config') + + return ( + accId && + config && { + account_id: accId, + is_suspended: isSuspended ?? false, + ...config, + } + ) + }, + } + +export const moduleInfos: ContractFormula = { + compute: async (env) => { + const { contractAddress, getMap } = env + + const versionControl = await config.compute(env).then(res => res?.version_control_address) + + const modulesMap = + (await getMap(contractAddress, 'modules')) ?? {} + }, +} diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts new file mode 100644 index 00000000..99a8833a --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -0,0 +1,2 @@ +export * as ManagerTypes from './manager' +export * as VersionControlTypes from './versionControl' diff --git a/src/formulas/formulas/contract/abstract/types/manager.ts b/src/formulas/formulas/contract/abstract/types/manager.ts new file mode 100644 index 00000000..b3d016e4 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/manager.ts @@ -0,0 +1,289 @@ +/** + * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @abstract-money/ts-codegen generate command to regenerate this file. + */ +export type AccountTrace = + | 'local' + | { + remote: ChainName[] + } +export type ChainName = string +export type Binary = string +export type Namespace = string +export type ModuleVersion = + | 'latest' + | { + version: string + } +export type GovernanceDetailsForString = + | { + Monarchy: { + monarch: string + [k: string]: unknown + } + } + | { + SubAccount: { + manager: string + proxy: string + [k: string]: unknown + } + } + | { + External: { + governance_address: string + governance_type: string + [k: string]: unknown + } + } +export interface InstantiateMsg { + account_id: AccountId + description?: string | null + install_modules: ModuleInstallConfig[] + link?: string | null + module_factory_address: string + name: string + owner: GovernanceDetailsForString + version_control_address: string +} +export interface AccountId { + seq: number + trace: AccountTrace +} +export interface ModuleInstallConfig { + init_msg?: Binary | null + module: ModuleInfo +} +export interface ModuleInfo { + name: string + namespace: Namespace + version: ModuleVersion +} +export type ExecuteMsg = + | { + exec_on_module: { + exec_msg: Binary + module_id: string + } + } + | { + update_internal_config: Binary + } + | { + install_modules: { + modules: ModuleInstallConfig[] + } + } + | { + register_modules: { + modules: RegisterModuleData[] + } + } + | { + uninstall_module: { + module_id: string + } + } + | { + upgrade: { + modules: [ModuleInfo, Binary | null][] + } + } + | { + create_sub_account: { + base_asset?: AssetEntry | null + description?: string | null + install_modules: ModuleInstallConfig[] + link?: string | null + name: string + namespace?: string | null + } + } + | { + update_info: { + description?: string | null + link?: string | null + name?: string | null + } + } + | { + set_owner: { + owner: GovernanceDetailsForString + } + } + | { + update_status: { + is_suspended?: boolean | null + } + } + | { + update_settings: { + ibc_enabled?: boolean | null + } + } + | { + update_sub_account: UpdateSubAccountAction + } + | { + callback: CallbackMsg + } + | { + update_ownership: Action + } +export type ModuleReference = + | { + account_base: number + } + | { + native: Addr + } + | { + adapter: Addr + } + | { + app: number + } + | { + standalone: number + } +export type Addr = string +export type AssetEntry = string +export type UpdateSubAccountAction = + | { + unregister_sub_account: { + id: number + } + } + | { + register_sub_account: { + id: number + } + } +export type Action = + | { + transfer_ownership: { + expiry?: Expiration | null + new_owner: string + } + } + | 'accept_ownership' + | 'renounce_ownership' +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type Timestamp = Uint64 +export type Uint64 = string +export interface RegisterModuleData { + module: Module + module_address: string +} +export interface Module { + info: ModuleInfo + reference: ModuleReference +} +export interface CallbackMsg {} +export type QueryMsg = + | { + module_versions: { + ids: string[] + } + } + | { + module_addresses: { + ids: string[] + } + } + | { + module_infos: { + limit?: number | null + start_after?: string | null + } + } + | { + config: {} + } + | { + info: {} + } + | { + sub_account_ids: { + limit?: number | null + start_after?: number | null + } + } + | { + ownership: {} + } +export interface MigrateMsg {} +export interface ConfigResponse { + account_id: AccountId + is_suspended: boolean + module_factory_address: Addr + version_control_address: Addr +} +export type GovernanceDetailsForAddr = + | { + Monarchy: { + monarch: Addr + [k: string]: unknown + } + } + | { + SubAccount: { + manager: Addr + proxy: Addr + [k: string]: unknown + } + } + | { + External: { + governance_address: Addr + governance_type: string + [k: string]: unknown + } + } +export interface InfoResponse { + info: AccountInfoForAddr +} +export interface AccountInfoForAddr { + chain_id: string + description?: string | null + governance_details: GovernanceDetailsForAddr + link?: string | null + name: string +} +export interface ModuleAddressesResponse { + modules: [string, Addr][] +} +export interface ModuleInfosResponse { + module_infos: ManagerModuleInfo[] +} +export interface ManagerModuleInfo { + address: Addr + id: string + version: ContractVersion +} +export interface ContractVersion { + contract: string + version: string +} +export interface ModuleVersionsResponse { + versions: ContractVersion[] +} +export interface OwnershipForString { + owner?: string | null + pending_expiry?: Expiration | null + pending_owner?: string | null +} +export interface SubAccountIdsResponse { + sub_accounts: number[] +} +//# sourceMappingURL=Manager.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/types/versionControl.ts b/src/formulas/formulas/contract/abstract/types/versionControl.ts new file mode 100644 index 00000000..e93b3e5d --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/versionControl.ts @@ -0,0 +1,213 @@ +/** + * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @abstract-money/ts-codegen generate command to regenerate this file. + */ +export type Uint128 = string; +export interface InstantiateMsg { + admin: string; + allow_direct_module_registration_and_updates?: boolean | null; + namespace_registration_fee?: Coin | null; +} +export interface Coin { + amount: Uint128; + denom: string; + [k: string]: unknown; +} +export type ExecuteMsg = { + remove_module: { + module: ModuleInfo; + }; +} | { + yank_module: { + module: ModuleInfo; + }; +} | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][]; + }; +} | { + update_module_configuration: { + module_name: string; + namespace: Namespace; + update_module: UpdateModule; + }; +} | { + approve_or_reject_modules: { + approves: ModuleInfo[]; + rejects: ModuleInfo[]; + }; +} | { + claim_namespace: { + account_id: AccountId; + namespace: string; + }; +} | { + remove_namespaces: { + namespaces: string[]; + }; +} | { + add_account: { + account_base: AccountBase; + account_id: AccountId; + }; +} | { + update_config: { + allow_direct_module_registration_and_updates?: boolean | null; + namespace_registration_fee?: Coin | null; + }; +} | { + set_factory: { + new_factory: string; + }; +} | { + update_ownership: Action; +}; +export type Namespace = string; +export type ModuleVersion = "latest" | { + version: string; +}; +export type ModuleReference = { + account_base: number; +} | { + native: Addr; +} | { + adapter: Addr; +} | { + app: number; +} | { + standalone: number; +}; +export type Addr = string; +export type UpdateModule = { + default: { + metadata: string; + }; +} | { + versioned: { + instantiation_funds?: Coin[] | null; + metadata?: string | null; + monetization?: Monetization | null; + version: string; + }; +}; +export type Monetization = "none" | { + install_fee: FixedFee; +}; +export type AccountTrace = "local" | { + remote: ChainName[]; +}; +export type ChainName = string; +export type Action = { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: string; + }; +} | "accept_ownership" | "renounce_ownership"; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp; +} | { + never: {}; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export interface ModuleInfo { + name: string; + namespace: Namespace; + version: ModuleVersion; +} +export interface FixedFee { + fee: Coin; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export interface AccountBase { + manager: Addr; + proxy: Addr; +} +export type QueryMsg = { + account_base: { + account_id: AccountId; + }; +} | { + modules: { + infos: ModuleInfo[]; + }; +} | { + namespaces: { + accounts: AccountId[]; + }; +} | { + namespace: { + namespace: Namespace; + }; +} | { + config: {}; +} | { + module_list: { + filter?: ModuleFilter | null; + limit?: number | null; + start_after?: ModuleInfo | null; + }; +} | { + namespace_list: { + limit?: number | null; + start_after?: string | null; + }; +} | { + ownership: {}; +}; +export type ModuleStatus = "r_e_g_i_s_t_e_r_e_d" | "p_e_n_d_i_n_g" | "y_a_n_k_e_d"; +export interface ModuleFilter { + name?: string | null; + namespace?: string | null; + status?: ModuleStatus | null; + version?: string | null; +} +export interface MigrateMsg { +} +export interface AccountBaseResponse { + account_base: AccountBase; +} +export interface ConfigResponse { + factory: Addr; +} +export interface ModulesListResponse { + modules: ModuleResponse[]; +} +export interface ModuleResponse { + config: ModuleConfiguration; + module: Module; +} +export interface ModuleConfiguration { + instantiation_funds: Coin[]; + metadata?: string | null; + monetization: Monetization; +} +export interface Module { + info: ModuleInfo; + reference: ModuleReference; +} +export interface ModulesResponse { + modules: ModuleResponse[]; +} +export interface NamespaceResponse { + account_base: AccountBase; + account_id: AccountId; +} +export interface NamespaceListResponse { + namespaces: [Namespace, AccountId][]; +} +export interface NamespacesResponse { + namespaces: [Namespace, AccountId][]; +} +export interface OwnershipForString { + owner?: string | null; + pending_expiry?: Expiration | null; + pending_owner?: string | null; +} +//# sourceMappingURL=VersionControl.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/versionControl.ts b/src/formulas/formulas/contract/abstract/versionControl.ts new file mode 100644 index 00000000..91b0d623 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/versionControl.ts @@ -0,0 +1,229 @@ +/* + pub const CONFIG: Item = Item::new("cfg"); + + // Modules waiting for approvals + pub const PENDING_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("pendm"); + // We can iterate over the map giving just the prefix to get all the versions + pub const REGISTERED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("lib"); + // Reverse map for module info of standalone modules + pub const STANDALONE_INFOS: Map = Map::new("stli"); + // Yanked Modules + pub const YANKED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("yknd"); + // Modules Configuration + pub const MODULE_CONFIG: Map<&ModuleInfo, ModuleConfiguration> = Map::new("cfg"); + // Modules Default Configuration + pub const MODULE_DEFAULT_CONFIG: Map<(&Namespace, &str), ModuleDefaultConfiguration> = + Map::new("dcfg"); + /// Maps Account ID to the address of its core contracts + pub const ACCOUNT_ADDRESSES: Map<&AccountId, AccountBase> = Map::new("accs"); + +pub fn handle_modules_query(deps: Deps, modules: Vec) -> StdResult { + let mut modules_response = ModulesResponse { modules: vec![] }; + for mut module in modules { + let maybe_module_ref = if let ModuleVersion::Version(_) = module.version { + REGISTERED_MODULES.load(deps.storage, &module) + } else { + // get latest + let versions: StdResult> = REGISTERED_MODULES + .prefix((module.namespace.clone(), module.name.clone())) + .range(deps.storage, None, None, Order::Descending) + .take(1) + .collect(); + let (latest_version, id) = versions? + .first() + .ok_or_else(|| StdError::GenericErr { + msg: VCError::ModuleNotFound(module.clone()).to_string(), + })? + .clone(); + module.version = ModuleVersion::Version(latest_version); + Ok(id) + }; + + match maybe_module_ref { + Err(_) => Err(StdError::generic_err( + VCError::ModuleNotFound(module).to_string(), + )), + Ok(mod_ref) => { + modules_response.modules.push(ModuleResponse { + module: Module { + info: module.clone(), + reference: mod_ref, + }, + config: ModuleConfiguration::from_storage(deps.storage, &module)?, + }); + Ok(()) + } + }?; + } + + Ok(modules_response) +} + */ + +import semver from 'semver/preload' + +import { Module } from '@/formulas/formulas/contract/abstract/types/versionControl' +import { ContractFormula } from '@/types' +import { dbKeyForKeys, dbKeyToKeys } from '@/utils' + +import { VersionControlTypes } from './types' + +const VersionControlStorageKeys = { + CONFIG: 'cfg', + PENDING_MODULES: 'pendm', + REGISTERED_MODULES: 'lib', + STANDALONE_INFOS: 'stli', + YANKED_MODULES: 'yknd', + MODULE_CONFIG: 'cfg', + MODULE_DEFAULT_CONFIG: 'dcfg', + ACCOUNT_ADDRESSES: 'accs', +} + +export const registeredModules: ContractFormula> = { + compute: async ({ contractAddress, getMap }) => { + const registeredModulesMap = + (await getMap( + contractAddress, + VersionControlStorageKeys.REGISTERED_MODULES, + { keyType: 'raw' } + )) ?? {} + + return Object.entries(registeredModulesMap).map(([key, reference]) => { + const [namespace, name, version] = dbKeyToKeys(key, [ + false, + false, + false, + ]) as string[] + + const info: VersionControlTypes.ModuleInfo = { + namespace, + name, + version: { version }, + } + return { + info, + reference, + } + }) + }, +} + +const moduleInfoToKey = ({ + namespace, + name, + version, +}: VersionControlTypes.ModuleInfo | ModuleInfoParameter): string => { + const versionKey = version + ? typeof version === 'string' + ? version + : version.version + : 'latest' + return dbKeyForKeys(namespace, name, versionKey) +} + +const DEFAULT_MODULE_CONFIG: VersionControlTypes.ModuleConfiguration = { + monetization: 'none', + instantiation_funds: [], +} + +type ModuleInfoParameter = Omit & { + version?: string +} + +export const moduleConfig: ContractFormula< + VersionControlTypes.ModuleConfiguration | undefined, + ModuleInfoParameter +> = { + compute: async ({ contractAddress, getMap, args }) => { + if (!args || !args.name || !args.namespace) return undefined + const moduleInfo: VersionControlTypes.ModuleInfo = { + namespace: args.namespace, + name: args.name, + version: args.version ? { version: args.version } : 'latest', + } + + const versionedConfigMap = + (await getMap( + contractAddress, + VersionControlStorageKeys.CONFIG, + { + keyType: 'raw', + } + )) ?? {} + + const moduleConfig = + versionedConfigMap[moduleInfoToKey(moduleInfo)] ?? DEFAULT_MODULE_CONFIG + + if (moduleConfig.metadata) { + return moduleConfig + } + + const defaultConfigMap = + (await getMap( + contractAddress, + VersionControlStorageKeys.MODULE_DEFAULT_CONFIG, + { + keyType: 'raw', + } + )) ?? {} + + let moduleDefaultConfig = + defaultConfigMap[dbKeyForKeys(args.namespace, args.name)] + + return { + ...moduleConfig, + metadata: moduleDefaultConfig?.metadata, + } + }, +} + +export const module: ContractFormula< + VersionControlTypes.ModuleResponse | undefined, + ModuleInfoParameter +> = { + compute: async (env) => { + const { args } = env + if (!args || !args.namespace || !args.name) return undefined + const moduleParam = args as ModuleInfoParameter + + const registeredModuleList = await registeredModules.compute(env) + + const filteredModules = registeredModuleList.filter( + ({ info: { name, namespace } }) => { + return namespace === moduleParam.namespace && name === moduleParam.name + } + ) + + let foundModule = undefined + + // Find the latest version of the module + if (!moduleParam.version || moduleParam.version === 'latest') { + const sortedVersions = filteredModules.sort( + ({ info: { version: versionA } }, { info: { version: versionB } }) => { + if (typeof versionA === 'string' || typeof versionB === 'string') { + throw new Error('Cannot compare "latest" versions') + } + return semver.compare(versionA.version, versionB.version) + } + ) + foundModule = sortedVersions[sortedVersions.length - 1] + } + + // Get the proper module version + foundModule = filteredModules.find( + ({ info: { version } }) => + (typeof version === 'string' ? version : version.version) === + (moduleParam as { version: string }).version + ) + + const foundConfig = await moduleConfig.compute(env) + + return ( + foundModule && + foundConfig && { + module: foundModule, + config: foundConfig, + } + ) + }, +} diff --git a/src/transformers/transformers/abstract/manager.ts b/src/transformers/transformers/abstract/manager.ts new file mode 100644 index 00000000..e69de29b From 572d5571dc8ee11afcbd04f51779879e3372137e Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:22:51 +0200 Subject: [PATCH 02/29] Updtae manager with moduleInfos --- .../formulas/contract/abstract/manager.ts | 118 +++++- .../contract/abstract/types/versionControl.ts | 386 ++++++++++-------- .../contract/abstract/versionControl.ts | 50 +-- 3 files changed, 326 insertions(+), 228 deletions(-) diff --git a/src/formulas/formulas/contract/abstract/manager.ts b/src/formulas/formulas/contract/abstract/manager.ts index 60b1d47e..888ca8f4 100644 --- a/src/formulas/formulas/contract/abstract/manager.ts +++ b/src/formulas/formulas/contract/abstract/manager.ts @@ -1,25 +1,77 @@ import { ContractFormula } from '@/types' +import * as Common from '../common' import { ManagerTypes } from './types' +/* + /// Suspension status + pub const SUSPENSION_STATUS: Item = Item::new("\u{0}{12}is_suspended"); + /// Configuration + pub const CONFIG: Item = Item::new("\u{0}{6}config"); + /// Info about the Account + pub const INFO: Item> = Item::new("\u{0}{4}info"); + /// Account owner - managed by cw-ownable + pub const OWNER: Item> = Item::new(OWNERSHIP_STORAGE_KEY); + /// Enabled Abstract modules + pub const ACCOUNT_MODULES: Map = Map::new("modules"); + /// Stores the dependency relationship between modules + /// map module -> modules that depend on module. + pub const DEPENDENTS: Map> = Map::new("dependents"); + /// List of sub-accounts + pub const SUB_ACCOUNTS: Map = Map::new("sub_accs"); + /// Pending new governance + pub const PENDING_GOVERNANCE: Item> = Item::new("pgov"); + /// Context for old adapters that are currently removing authorized addresses + pub const REMOVE_ADAPTER_AUTHORIZED_CONTEXT: Item = Item::new("rm_a_auth"); +} + */ + +const ManagerStorageKeys = { + CONFIG: 'config', + INFO: 'info', + OWNER: 'ownership', + ACCOUNT_MODULES: 'modules', + SUB_ACCOUNTS: 'sub_accs', + IS_SUSPENDED: 'is_suspended', + ACCOUNT_ID: 'acc_id', +} + export const owner: ContractFormula = { compute: async ({ contractAddress, get }) => { return ( - (await get(contractAddress, 'ownership')) - ?.owner ?? undefined + ( + await get( + contractAddress, + ManagerStorageKeys.OWNER + ) + )?.owner ?? undefined ) }, } export const accountId: ContractFormula = { compute: async ({ contractAddress, get }) => { - return await get(contractAddress, 'acc_id') + return await get( + contractAddress, + ManagerStorageKeys.ACCOUNT_ID + ) }, } export const suspensionStatus: ContractFormula = { compute: async ({ contractAddress, get }) => { - return await get(contractAddress, 'is_suspended') + return await get(contractAddress, ManagerStorageKeys.IS_SUSPENDED) + }, +} + +export const info: ContractFormula< + ManagerTypes.AccountInfoForAddr | undefined +> = { + compute: async ({ contractAddress, get }) => { + return await get( + contractAddress, + ManagerStorageKeys.INFO + ) }, } @@ -48,13 +100,61 @@ export const config: ContractFormula = }, } -export const moduleInfos: ContractFormula = { +export const subAccountIds: ContractFormula = { + compute: async ({ contractAddress, getMap }) => { + const subAccountsMap = + (await getMap( + contractAddress, + ManagerStorageKeys.SUB_ACCOUNTS, + { + keyType: 'number', + } + )) ?? {} + + return Object.keys(subAccountsMap).map((seq) => ({ + trace: 'local', + seq: Number(seq), + })) + }, +} + +export const moduleInfos: ContractFormula< + Array< + Omit< + ManagerTypes.ModuleInfosResponse['module_infos'][number], + 'version' + > & { version: string | undefined } + > +> = { compute: async (env) => { - const { contractAddress, getMap } = env + const { contractAddress, getMap, get } = env - const versionControl = await config.compute(env).then(res => res?.version_control_address) + const versionControlAddr = await config + .compute(env) + .then((res) => res?.version_control_address) - const modulesMap = - (await getMap(contractAddress, 'modules')) ?? {} + if (!versionControlAddr) return [] + + const moduleAddressesMap = + (await getMap( + contractAddress, + ManagerStorageKeys.ACCOUNT_MODULES + )) ?? {} + + // Query the info from + return await Promise.all( + Object.entries(moduleAddressesMap).map(async ([moduleId, address]) => { + const contractInfo = await Common.info.compute({ + ...env, + contractAddress: address, + }) + + return { + id: contractInfo?.contract ?? moduleId, + address, + version: contractInfo?.version, + } + }) + ) }, } diff --git a/src/formulas/formulas/contract/abstract/types/versionControl.ts b/src/formulas/formulas/contract/abstract/types/versionControl.ts index e93b3e5d..7d7a92fa 100644 --- a/src/formulas/formulas/contract/abstract/types/versionControl.ts +++ b/src/formulas/formulas/contract/abstract/types/versionControl.ts @@ -3,211 +3,251 @@ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @abstract-money/ts-codegen generate command to regenerate this file. */ -export type Uint128 = string; +export type Uint128 = string export interface InstantiateMsg { - admin: string; - allow_direct_module_registration_and_updates?: boolean | null; - namespace_registration_fee?: Coin | null; + admin: string + allow_direct_module_registration_and_updates?: boolean | null + namespace_registration_fee?: Coin | null } export interface Coin { - amount: Uint128; - denom: string; - [k: string]: unknown; -} -export type ExecuteMsg = { - remove_module: { - module: ModuleInfo; - }; -} | { - yank_module: { - module: ModuleInfo; - }; -} | { - propose_modules: { - modules: [ModuleInfo, ModuleReference][]; - }; -} | { - update_module_configuration: { - module_name: string; - namespace: Namespace; - update_module: UpdateModule; - }; -} | { - approve_or_reject_modules: { - approves: ModuleInfo[]; - rejects: ModuleInfo[]; - }; -} | { - claim_namespace: { - account_id: AccountId; - namespace: string; - }; -} | { - remove_namespaces: { - namespaces: string[]; - }; -} | { - add_account: { - account_base: AccountBase; - account_id: AccountId; - }; -} | { - update_config: { - allow_direct_module_registration_and_updates?: boolean | null; - namespace_registration_fee?: Coin | null; - }; -} | { - set_factory: { - new_factory: string; - }; -} | { - update_ownership: Action; -}; -export type Namespace = string; -export type ModuleVersion = "latest" | { - version: string; -}; -export type ModuleReference = { - account_base: number; -} | { - native: Addr; -} | { - adapter: Addr; -} | { - app: number; -} | { - standalone: number; -}; -export type Addr = string; -export type UpdateModule = { - default: { - metadata: string; - }; -} | { - versioned: { - instantiation_funds?: Coin[] | null; - metadata?: string | null; - monetization?: Monetization | null; - version: string; - }; -}; -export type Monetization = "none" | { - install_fee: FixedFee; -}; -export type AccountTrace = "local" | { - remote: ChainName[]; -}; -export type ChainName = string; -export type Action = { - transfer_ownership: { - expiry?: Expiration | null; - new_owner: string; - }; -} | "accept_ownership" | "renounce_ownership"; -export type Expiration = { - at_height: number; -} | { - at_time: Timestamp; -} | { - never: {}; -}; -export type Timestamp = Uint64; -export type Uint64 = string; + amount: Uint128 + denom: string + [k: string]: unknown +} +export type ExecuteMsg = + | { + remove_module: { + module: ModuleInfo + } + } + | { + yank_module: { + module: ModuleInfo + } + } + | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][] + } + } + | { + update_module_configuration: { + module_name: string + namespace: Namespace + update_module: UpdateModule + } + } + | { + approve_or_reject_modules: { + approves: ModuleInfo[] + rejects: ModuleInfo[] + } + } + | { + claim_namespace: { + account_id: AccountId + namespace: string + } + } + | { + remove_namespaces: { + namespaces: string[] + } + } + | { + add_account: { + account_base: AccountBase + account_id: AccountId + } + } + | { + update_config: { + allow_direct_module_registration_and_updates?: boolean | null + namespace_registration_fee?: Coin | null + } + } + | { + set_factory: { + new_factory: string + } + } + | { + update_ownership: Action + } +export type Namespace = string +export type ModuleVersion = + | 'latest' + | { + version: string + } +export type ModuleReference = + | { + account_base: number + } + | { + native: Addr + } + | { + adapter: Addr + } + | { + app: number + } + | { + standalone: number + } +export type Addr = string +export type UpdateModule = + | { + default: { + metadata: string + } + } + | { + versioned: { + instantiation_funds?: Coin[] | null + metadata?: string | null + monetization?: Monetization | null + version: string + } + } +export type Monetization = + | 'none' + | { + install_fee: FixedFee + } +export type AccountTrace = + | 'local' + | { + remote: ChainName[] + } +export type ChainName = string +export type Action = + | { + transfer_ownership: { + expiry?: Expiration | null + new_owner: string + } + } + | 'accept_ownership' + | 'renounce_ownership' +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type Timestamp = Uint64 +export type Uint64 = string export interface ModuleInfo { - name: string; - namespace: Namespace; - version: ModuleVersion; + name: string + namespace: Namespace + version: ModuleVersion } export interface FixedFee { - fee: Coin; + fee: Coin } export interface AccountId { - seq: number; - trace: AccountTrace; + seq: number + trace: AccountTrace } export interface AccountBase { - manager: Addr; - proxy: Addr; -} -export type QueryMsg = { - account_base: { - account_id: AccountId; - }; -} | { - modules: { - infos: ModuleInfo[]; - }; -} | { - namespaces: { - accounts: AccountId[]; - }; -} | { - namespace: { - namespace: Namespace; - }; -} | { - config: {}; -} | { - module_list: { - filter?: ModuleFilter | null; - limit?: number | null; - start_after?: ModuleInfo | null; - }; -} | { - namespace_list: { - limit?: number | null; - start_after?: string | null; - }; -} | { - ownership: {}; -}; -export type ModuleStatus = "r_e_g_i_s_t_e_r_e_d" | "p_e_n_d_i_n_g" | "y_a_n_k_e_d"; + manager: Addr + proxy: Addr +} +export type QueryMsg = + | { + account_base: { + account_id: AccountId + } + } + | { + modules: { + infos: ModuleInfo[] + } + } + | { + namespaces: { + accounts: AccountId[] + } + } + | { + namespace: { + namespace: Namespace + } + } + | { + config: {} + } + | { + module_list: { + filter?: ModuleFilter | null + limit?: number | null + start_after?: ModuleInfo | null + } + } + | { + namespace_list: { + limit?: number | null + start_after?: string | null + } + } + | { + ownership: {} + } +export type ModuleStatus = + | 'r_e_g_i_s_t_e_r_e_d' + | 'p_e_n_d_i_n_g' + | 'y_a_n_k_e_d' export interface ModuleFilter { - name?: string | null; - namespace?: string | null; - status?: ModuleStatus | null; - version?: string | null; -} -export interface MigrateMsg { + name?: string | null + namespace?: string | null + status?: ModuleStatus | null + version?: string | null } +export interface MigrateMsg {} export interface AccountBaseResponse { - account_base: AccountBase; + account_base: AccountBase } export interface ConfigResponse { - factory: Addr; + factory: Addr } export interface ModulesListResponse { - modules: ModuleResponse[]; + modules: ModuleResponse[] } export interface ModuleResponse { - config: ModuleConfiguration; - module: Module; + config: ModuleConfiguration + module: Module } export interface ModuleConfiguration { - instantiation_funds: Coin[]; - metadata?: string | null; - monetization: Monetization; + instantiation_funds: Coin[] + metadata?: string | null + monetization: Monetization } export interface Module { - info: ModuleInfo; - reference: ModuleReference; + info: ModuleInfo + reference: ModuleReference } export interface ModulesResponse { - modules: ModuleResponse[]; + modules: ModuleResponse[] } export interface NamespaceResponse { - account_base: AccountBase; - account_id: AccountId; + account_base: AccountBase + account_id: AccountId } export interface NamespaceListResponse { - namespaces: [Namespace, AccountId][]; + namespaces: [Namespace, AccountId][] } export interface NamespacesResponse { - namespaces: [Namespace, AccountId][]; + namespaces: [Namespace, AccountId][] } export interface OwnershipForString { - owner?: string | null; - pending_expiry?: Expiration | null; - pending_owner?: string | null; + owner?: string | null + pending_expiry?: Expiration | null + pending_owner?: string | null } //# sourceMappingURL=VersionControl.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/versionControl.ts b/src/formulas/formulas/contract/abstract/versionControl.ts index 91b0d623..05787809 100644 --- a/src/formulas/formulas/contract/abstract/versionControl.ts +++ b/src/formulas/formulas/contract/abstract/versionControl.ts @@ -16,49 +16,7 @@ Map::new("dcfg"); /// Maps Account ID to the address of its core contracts pub const ACCOUNT_ADDRESSES: Map<&AccountId, AccountBase> = Map::new("accs"); - -pub fn handle_modules_query(deps: Deps, modules: Vec) -> StdResult { - let mut modules_response = ModulesResponse { modules: vec![] }; - for mut module in modules { - let maybe_module_ref = if let ModuleVersion::Version(_) = module.version { - REGISTERED_MODULES.load(deps.storage, &module) - } else { - // get latest - let versions: StdResult> = REGISTERED_MODULES - .prefix((module.namespace.clone(), module.name.clone())) - .range(deps.storage, None, None, Order::Descending) - .take(1) - .collect(); - let (latest_version, id) = versions? - .first() - .ok_or_else(|| StdError::GenericErr { - msg: VCError::ModuleNotFound(module.clone()).to_string(), - })? - .clone(); - module.version = ModuleVersion::Version(latest_version); - Ok(id) - }; - - match maybe_module_ref { - Err(_) => Err(StdError::generic_err( - VCError::ModuleNotFound(module).to_string(), - )), - Ok(mod_ref) => { - modules_response.modules.push(ModuleResponse { - module: Module { - info: module.clone(), - reference: mod_ref, - }, - config: ModuleConfiguration::from_storage(deps.storage, &module)?, - }); - Ok(()) - } - }?; - } - - Ok(modules_response) -} - */ +*/ import semver from 'semver/preload' @@ -79,7 +37,7 @@ const VersionControlStorageKeys = { ACCOUNT_ADDRESSES: 'accs', } -export const registeredModules: ContractFormula> = { +export const listRegisteredModules: ContractFormula> = { compute: async ({ contractAddress, getMap }) => { const registeredModulesMap = (await getMap( @@ -186,9 +144,9 @@ export const module: ContractFormula< if (!args || !args.namespace || !args.name) return undefined const moduleParam = args as ModuleInfoParameter - const registeredModuleList = await registeredModules.compute(env) + const registeredModules = await listRegisteredModules.compute(env) - const filteredModules = registeredModuleList.filter( + const filteredModules = registeredModules.filter( ({ info: { name, namespace } }) => { return namespace === moduleParam.namespace && name === moduleParam.name } From 11a1c0d16f6677e84aaad1eb7011434f6286d0b7 Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:40:37 +0200 Subject: [PATCH 03/29] Add basic proxy indexes --- .../formulas/contract/abstract/proxy.ts | 48 ++ .../formulas/contract/abstract/types/index.ts | 1 + .../formulas/contract/abstract/types/proxy.ts | 459 ++++++++++++++++++ 3 files changed, 508 insertions(+) create mode 100644 src/formulas/formulas/contract/abstract/proxy.ts create mode 100644 src/formulas/formulas/contract/abstract/types/proxy.ts diff --git a/src/formulas/formulas/contract/abstract/proxy.ts b/src/formulas/formulas/contract/abstract/proxy.ts new file mode 100644 index 00000000..567bef90 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/proxy.ts @@ -0,0 +1,48 @@ +/* + #[cosmwasm_schema::cw_serde] + pub struct State { + pub modules: Vec, + } + pub const ANS_HOST: Item = Item::new("\u{0}{6}ans_host"); + pub const STATE: Item = Item::new("\u{0}{5}state"); + pub const ADMIN: Admin = Admin::new(ADMIN_NAMESPACE); + */ + +import { ContractFormula } from '@/types' + +import { ProxyTypes } from './types' + +const ProxyStorageKeys = { + ANS_HOST: 'ans_host', + STATE: 'state', + ADMIN: 'admin', + ACCOUNT_ID: 'acc_id', +} + +export const accountId: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return await get( + contractAddress, + ProxyStorageKeys.ACCOUNT_ID + ) + }, +} + +type State = { + modules: string[] +} + +export const config: ContractFormula = { + compute: async ({ contractAddress, get }) => { + const state = await get( + contractAddress, + ProxyStorageKeys.STATE + ) + + return ( + state && { + modules: state.modules, + } + ) + }, +} diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts index 99a8833a..25ff6274 100644 --- a/src/formulas/formulas/contract/abstract/types/index.ts +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -1,2 +1,3 @@ export * as ManagerTypes from './manager' export * as VersionControlTypes from './versionControl' +export * as ProxyTypes from './proxy' diff --git a/src/formulas/formulas/contract/abstract/types/proxy.ts b/src/formulas/formulas/contract/abstract/types/proxy.ts new file mode 100644 index 00000000..c4fe57e8 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/proxy.ts @@ -0,0 +1,459 @@ +/** + * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @abstract-money/ts-codegen generate command to regenerate this file. + */ +export type AccountTrace = "local" | { + remote: ChainName[]; +}; +export type ChainName = string; +export interface InstantiateMsg { + account_id: AccountId; + ans_host_address: string; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export type ExecuteMsg = { + set_admin: { + admin: string; + }; +} | { + module_action: { + msgs: CosmosMsgForEmpty[]; + }; +} | { + module_action_with_data: { + msg: CosmosMsgForEmpty; + }; +} | { + ibc_action: { + msgs: ExecuteMsg1[]; + }; +} | { + add_modules: { + modules: string[]; + }; +} | { + remove_module: { + module: string; + }; +} | { + update_assets: { + to_add: [AssetEntry, UncheckedPriceSource][]; + to_remove: AssetEntry[]; + }; +}; +export type CosmosMsgForEmpty = { + bank: BankMsg; +} | { + custom: Empty; +} | { + staking: StakingMsg; +} | { + distribution: DistributionMsg; +} | { + stargate: { + type_url: string; + value: Binary; + [k: string]: unknown; + }; +} | { + ibc: IbcMsg; +} | { + wasm: WasmMsg; +} | { + gov: GovMsg; +}; +export type BankMsg = { + send: { + amount: Coin[]; + to_address: string; + [k: string]: unknown; + }; +} | { + burn: { + amount: Coin[]; + [k: string]: unknown; + }; +}; +export type Uint128 = string; +export type StakingMsg = { + delegate: { + amount: Coin; + validator: string; + [k: string]: unknown; + }; +} | { + undelegate: { + amount: Coin; + validator: string; + [k: string]: unknown; + }; +} | { + redelegate: { + amount: Coin; + dst_validator: string; + src_validator: string; + [k: string]: unknown; + }; +}; +export type DistributionMsg = { + set_withdraw_address: { + address: string; + [k: string]: unknown; + }; +} | { + withdraw_delegator_reward: { + validator: string; + [k: string]: unknown; + }; +}; +export type Binary = string; +export type IbcMsg = { + transfer: { + amount: Coin; + channel_id: string; + timeout: IbcTimeout; + to_address: string; + [k: string]: unknown; + }; +} | { + send_packet: { + channel_id: string; + data: Binary; + timeout: IbcTimeout; + [k: string]: unknown; + }; +} | { + close_channel: { + channel_id: string; + [k: string]: unknown; + }; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export type WasmMsg = { + execute: { + contract_addr: string; + funds: Coin[]; + msg: Binary; + [k: string]: unknown; + }; +} | { + instantiate: { + admin?: string | null; + code_id: number; + funds: Coin[]; + label: string; + msg: Binary; + [k: string]: unknown; + }; +} | { + migrate: { + contract_addr: string; + msg: Binary; + new_code_id: number; + [k: string]: unknown; + }; +} | { + update_admin: { + admin: string; + contract_addr: string; + [k: string]: unknown; + }; +} | { + clear_admin: { + contract_addr: string; + [k: string]: unknown; + }; +}; +export type GovMsg = { + vote: { + proposal_id: number; + vote: VoteOption; + [k: string]: unknown; + }; +}; +export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; +export type ExecuteMsg1 = { + update_admin: { + admin: string; + }; +} | { + update_config: { + ans_host?: string | null; + version_control?: string | null; + }; +} | { + send_funds: { + funds: Coin[]; + host_chain: string; + }; +} | { + register: { + host_chain: string; + }; +} | { + send_packet: { + action: HostAction; + callback_info?: CallbackInfo | null; + host_chain: string; + retries: number; + }; +} | { + remove_host: { + host_chain: string; + }; +}; +export type HostAction = { + app: { + msg: Binary; + }; +} | { + dispatch: { + msgs: CosmosMsgForEmpty[]; + }; +} | { + query: { + msgs: QueryRequestForEmpty[]; + }; +} | { + send_all_back: {}; +} | { + balances: {}; +} | { + internal: InternalAction; +}; +export type QueryRequestForEmpty = { + bank: BankQuery; +} | { + custom: Empty; +} | { + staking: StakingQuery; +} | { + stargate: { + data: Binary; + path: string; + [k: string]: unknown; + }; +} | { + ibc: IbcQuery; +} | { + wasm: WasmQuery; +}; +export type BankQuery = { + balance: { + address: string; + denom: string; + [k: string]: unknown; + }; +} | { + all_balances: { + address: string; + [k: string]: unknown; + }; +}; +export type StakingQuery = { + bonded_denom: { + [k: string]: unknown; + }; +} | { + all_delegations: { + delegator: string; + [k: string]: unknown; + }; +} | { + delegation: { + delegator: string; + validator: string; + [k: string]: unknown; + }; +} | { + all_validators: { + [k: string]: unknown; + }; +} | { + validator: { + address: string; + [k: string]: unknown; + }; +}; +export type IbcQuery = { + port_id: { + [k: string]: unknown; + }; +} | { + list_channels: { + port_id?: string | null; + [k: string]: unknown; + }; +} | { + channel: { + channel_id: string; + port_id?: string | null; + [k: string]: unknown; + }; +}; +export type WasmQuery = { + smart: { + contract_addr: string; + msg: Binary; + [k: string]: unknown; + }; +} | { + raw: { + contract_addr: string; + key: Binary; + [k: string]: unknown; + }; +} | { + contract_info: { + contract_addr: string; + [k: string]: unknown; + }; +}; +export type InternalAction = "who_am_i" | { + register: { + account_proxy_address: string; + }; +}; +export type AssetEntry = string; +export type UncheckedPriceSource = "None" | { + Pair: DexAssetPairing; +} | { + LiquidityToken: { + [k: string]: unknown; + }; +} | { + ValueAs: { + asset: AssetEntry; + multiplier: Decimal; + [k: string]: unknown; + }; +}; +export type DexAssetPairing = [AssetEntry, AssetEntry, string]; +export type Decimal = string; +export interface Coin { + amount: Uint128; + denom: string; + [k: string]: unknown; +} +export interface Empty { + [k: string]: unknown; +} +export interface IbcTimeout { + block?: IbcTimeoutBlock | null; + timestamp?: Timestamp | null; + [k: string]: unknown; +} +export interface IbcTimeoutBlock { + height: number; + revision: number; + [k: string]: unknown; +} +export interface CallbackInfo { + id: string; + receiver: string; +} +export type QueryMsg = { + config: {}; +} | { + total_value: {}; +} | { + token_value: { + identifier: AssetEntry; + }; +} | { + holding_amount: { + identifier: AssetEntry; + }; +} | { + asset_config: { + identifier: AssetEntry; + }; +} | { + assets_config: { + limit?: number | null; + start_after?: AssetEntry | null; + }; +} | { + assets_info: { + limit?: number | null; + start_after?: AssetInfoBaseForAddr | null; + }; +} | { + base_asset: {}; +}; +export type AssetInfoBaseForAddr = { + native: string; +} | { + cw20: Addr; +}; +export type Addr = string; +export interface MigrateMsg { +} +export interface AssetConfigResponse { + price_source: UncheckedPriceSource; +} +export interface AssetsConfigResponse { + assets: [AssetEntry, UncheckedPriceSource][]; +} +export type PriceSource = "None" | { + Pool: { + address: PoolAddressBaseForAddr; + pair: AssetInfoBaseForAddr[]; + [k: string]: unknown; + }; +} | { + LiquidityToken: { + pool_address: PoolAddressBaseForAddr; + pool_assets: AssetInfoBaseForAddr[]; + [k: string]: unknown; + }; +} | { + ValueAs: { + asset: AssetInfoBaseForAddr; + multiplier: Decimal; + [k: string]: unknown; + }; +}; +export type PoolAddressBaseForAddr = { + separate_addresses: { + liquidity: Addr; + swap: Addr; + }; +} | { + contract: Addr; +} | { + id: number; +}; +export interface AssetsInfoResponse { + assets: [AssetInfoBaseForAddr, OracleAsset][]; +} +export interface OracleAsset { + complexity: number; + price_source: PriceSource; +} +export interface BaseAssetResponse { + base_asset: AssetInfoBaseForAddr; +} +export interface ConfigResponse { + modules: string[]; +} +export interface HoldingAmountResponse { + amount: Uint128; +} +export interface TokenValueResponse { + value: Uint128; +} +export interface AccountValue { + breakdown: [AssetInfoBaseForAddr, Uint128][]; + total_value: AssetBaseForAddr; +} +export interface AssetBaseForAddr { + amount: Uint128; + info: AssetInfoBaseForAddr; +} +//# sourceMappingURL=Proxy.types.d.ts.map From 09729abdf1a8ea217712a10a00430826c6b65809 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 18 Nov 2024 15:51:52 +0200 Subject: [PATCH 04/29] update registry and account types --- .../abstract/{manager.ts => account.ts} | 117 +++-- .../formulas/contract/abstract/proxy.ts | 48 -- .../{versionControl.ts => registry.ts} | 53 +- .../contract/abstract/types/account.ts | 444 +++++++++++++++++ .../formulas/contract/abstract/types/index.ts | 5 +- .../contract/abstract/types/manager.ts | 289 ----------- .../formulas/contract/abstract/types/proxy.ts | 459 ------------------ .../contract/abstract/types/registry.ts | 228 +++++++++ .../contract/abstract/types/versionControl.ts | 253 ---------- 9 files changed, 769 insertions(+), 1127 deletions(-) rename src/formulas/formulas/contract/abstract/{manager.ts => account.ts} (60%) delete mode 100644 src/formulas/formulas/contract/abstract/proxy.ts rename src/formulas/formulas/contract/abstract/{versionControl.ts => registry.ts} (80%) create mode 100644 src/formulas/formulas/contract/abstract/types/account.ts delete mode 100644 src/formulas/formulas/contract/abstract/types/manager.ts delete mode 100644 src/formulas/formulas/contract/abstract/types/proxy.ts create mode 100644 src/formulas/formulas/contract/abstract/types/registry.ts delete mode 100644 src/formulas/formulas/contract/abstract/types/versionControl.ts diff --git a/src/formulas/formulas/contract/abstract/manager.ts b/src/formulas/formulas/contract/abstract/account.ts similarity index 60% rename from src/formulas/formulas/contract/abstract/manager.ts rename to src/formulas/formulas/contract/abstract/account.ts index 888ca8f4..06cce99f 100644 --- a/src/formulas/formulas/contract/abstract/manager.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -1,7 +1,8 @@ import { ContractFormula } from '@/types' import * as Common from '../common' -import { ManagerTypes } from './types' +import { AccountTypes } from './types' +import { Addr, GovernanceDetailsForString } from './types/account' /* /// Suspension status @@ -26,86 +27,90 @@ import { ManagerTypes } from './types' } */ -const ManagerStorageKeys = { - CONFIG: 'config', - INFO: 'info', +const AccountStorageKeys = { + SUSPENSION_STATUS: 'aa', + INFO: 'ab', + ACCOUNT_MODULES: 'ac', + DEPENDENTS: 'ad', + SUB_ACCOUNTS: 'ae', + WHITELISTED_MODULES: 'af', + ACCOUNT_ID: 'ag', OWNER: 'ownership', - ACCOUNT_MODULES: 'modules', - SUB_ACCOUNTS: 'sub_accs', - IS_SUSPENDED: 'is_suspended', - ACCOUNT_ID: 'acc_id', } -export const owner: ContractFormula = { +export const owner: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { return ( ( - await get( + await get( contractAddress, - ManagerStorageKeys.OWNER + AccountStorageKeys.OWNER ) )?.owner ?? undefined ) }, } -export const accountId: ContractFormula = { +export const accountId: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { - return await get( + return await get( contractAddress, - ManagerStorageKeys.ACCOUNT_ID + AccountStorageKeys.ACCOUNT_ID ) }, } export const suspensionStatus: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { - return await get(contractAddress, ManagerStorageKeys.IS_SUSPENDED) + return await get( + contractAddress, + AccountStorageKeys.SUSPENSION_STATUS + ) }, } -export const info: ContractFormula< - ManagerTypes.AccountInfoForAddr | undefined -> = { +export const info: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { - return await get( + return await get( contractAddress, - ManagerStorageKeys.INFO + AccountStorageKeys.INFO ) }, } -export const config: ContractFormula = - { - compute: async (env) => { - const { contractAddress, get } = env - const accId = await accountId.compute(env) - const isSuspended = await suspensionStatus.compute(env) - - const config = await get< - Pick< - ManagerTypes.ConfigResponse, - 'version_control_address' | 'module_factory_address' - > - >(contractAddress, 'config') - - return ( - accId && - config && { - account_id: accId, - is_suspended: isSuspended ?? false, - ...config, - } - ) - }, - } +export const whitelistedModules: ContractFormula | undefined> = { + docs: { + description: '', + }, + compute: async ({ contractAddress, get }) => { + return await get>( + contractAddress, + AccountStorageKeys.WHITELISTED_MODULES + ) + }, +} -export const subAccountIds: ContractFormula = { +export const subAccountIds: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, getMap }) => { const subAccountsMap = (await getMap( contractAddress, - ManagerStorageKeys.SUB_ACCOUNTS, + AccountStorageKeys.SUB_ACCOUNTS, { keyType: 'number', } @@ -121,24 +126,26 @@ export const subAccountIds: ContractFormula = { export const moduleInfos: ContractFormula< Array< Omit< - ManagerTypes.ModuleInfosResponse['module_infos'][number], + AccountTypes.ModuleInfosResponse['module_infos'][number], 'version' > & { version: string | undefined } > > = { + docs: { + description: '', + }, compute: async (env) => { const { contractAddress, getMap, get } = env - const versionControlAddr = await config - .compute(env) - .then((res) => res?.version_control_address) + // TODO: + const RegistryAddr = undefined - if (!versionControlAddr) return [] + if (!RegistryAddr) return [] const moduleAddressesMap = - (await getMap( + (await getMap( contractAddress, - ManagerStorageKeys.ACCOUNT_MODULES + AccountStorageKeys.ACCOUNT_MODULES )) ?? {} // Query the info from @@ -158,3 +165,7 @@ export const moduleInfos: ContractFormula< ) }, } + +type State = { + modules: string[] +} diff --git a/src/formulas/formulas/contract/abstract/proxy.ts b/src/formulas/formulas/contract/abstract/proxy.ts deleted file mode 100644 index 567bef90..00000000 --- a/src/formulas/formulas/contract/abstract/proxy.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - #[cosmwasm_schema::cw_serde] - pub struct State { - pub modules: Vec, - } - pub const ANS_HOST: Item = Item::new("\u{0}{6}ans_host"); - pub const STATE: Item = Item::new("\u{0}{5}state"); - pub const ADMIN: Admin = Admin::new(ADMIN_NAMESPACE); - */ - -import { ContractFormula } from '@/types' - -import { ProxyTypes } from './types' - -const ProxyStorageKeys = { - ANS_HOST: 'ans_host', - STATE: 'state', - ADMIN: 'admin', - ACCOUNT_ID: 'acc_id', -} - -export const accountId: ContractFormula = { - compute: async ({ contractAddress, get }) => { - return await get( - contractAddress, - ProxyStorageKeys.ACCOUNT_ID - ) - }, -} - -type State = { - modules: string[] -} - -export const config: ContractFormula = { - compute: async ({ contractAddress, get }) => { - const state = await get( - contractAddress, - ProxyStorageKeys.STATE - ) - - return ( - state && { - modules: state.modules, - } - ) - }, -} diff --git a/src/formulas/formulas/contract/abstract/versionControl.ts b/src/formulas/formulas/contract/abstract/registry.ts similarity index 80% rename from src/formulas/formulas/contract/abstract/versionControl.ts rename to src/formulas/formulas/contract/abstract/registry.ts index 05787809..30dab0d5 100644 --- a/src/formulas/formulas/contract/abstract/versionControl.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -20,29 +20,32 @@ import semver from 'semver/preload' -import { Module } from '@/formulas/formulas/contract/abstract/types/versionControl' +import { Module } from '@/formulas/formulas/contract/abstract/types/registry' import { ContractFormula } from '@/types' import { dbKeyForKeys, dbKeyToKeys } from '@/utils' -import { VersionControlTypes } from './types' +import { RegistryTypes } from './types' -const VersionControlStorageKeys = { +const RegistryStorageKeys = { CONFIG: 'cfg', - PENDING_MODULES: 'pendm', - REGISTERED_MODULES: 'lib', - STANDALONE_INFOS: 'stli', - YANKED_MODULES: 'yknd', - MODULE_CONFIG: 'cfg', - MODULE_DEFAULT_CONFIG: 'dcfg', - ACCOUNT_ADDRESSES: 'accs', + PENDING_MODULES: 'ca', + REGISTERED_MODULES: 'cb', + STANDALONE_INFOS: 'cd', + YANKED_MODULES: 'ce', + MODULE_CONFIG: 'cf', + MODULE_DEFAULT_CONFIG: 'cg', + ACCOUNT_ADDRESSES: 'ch', } export const listRegisteredModules: ContractFormula> = { + docs: { + description: 'Lists registered modules in registry', + }, compute: async ({ contractAddress, getMap }) => { const registeredModulesMap = - (await getMap( + (await getMap( contractAddress, - VersionControlStorageKeys.REGISTERED_MODULES, + RegistryStorageKeys.REGISTERED_MODULES, { keyType: 'raw' } )) ?? {} @@ -53,7 +56,7 @@ export const listRegisteredModules: ContractFormula> = { false, ]) as string[] - const info: VersionControlTypes.ModuleInfo = { + const info: RegistryTypes.ModuleInfo = { namespace, name, version: { version }, @@ -70,7 +73,7 @@ const moduleInfoToKey = ({ namespace, name, version, -}: VersionControlTypes.ModuleInfo | ModuleInfoParameter): string => { +}: RegistryTypes.ModuleInfo | ModuleInfoParameter): string => { const versionKey = version ? typeof version === 'string' ? version @@ -79,31 +82,34 @@ const moduleInfoToKey = ({ return dbKeyForKeys(namespace, name, versionKey) } -const DEFAULT_MODULE_CONFIG: VersionControlTypes.ModuleConfiguration = { +const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { monetization: 'none', instantiation_funds: [], } -type ModuleInfoParameter = Omit & { +type ModuleInfoParameter = Omit & { version?: string } export const moduleConfig: ContractFormula< - VersionControlTypes.ModuleConfiguration | undefined, + RegistryTypes.ModuleConfiguration | undefined, ModuleInfoParameter > = { + docs: { + description: 'Configuration of the module installation', + }, compute: async ({ contractAddress, getMap, args }) => { if (!args || !args.name || !args.namespace) return undefined - const moduleInfo: VersionControlTypes.ModuleInfo = { + const moduleInfo: RegistryTypes.ModuleInfo = { namespace: args.namespace, name: args.name, version: args.version ? { version: args.version } : 'latest', } const versionedConfigMap = - (await getMap( + (await getMap( contractAddress, - VersionControlStorageKeys.CONFIG, + RegistryStorageKeys.CONFIG, { keyType: 'raw', } @@ -119,7 +125,7 @@ export const moduleConfig: ContractFormula< const defaultConfigMap = (await getMap( contractAddress, - VersionControlStorageKeys.MODULE_DEFAULT_CONFIG, + RegistryStorageKeys.MODULE_DEFAULT_CONFIG, { keyType: 'raw', } @@ -136,9 +142,12 @@ export const moduleConfig: ContractFormula< } export const module: ContractFormula< - VersionControlTypes.ModuleResponse | undefined, + RegistryTypes.ModuleResponse | undefined, ModuleInfoParameter > = { + docs: { + description: 'Module info', + }, compute: async (env) => { const { args } = env if (!args || !args.namespace || !args.name) return undefined diff --git a/src/formulas/formulas/contract/abstract/types/account.ts b/src/formulas/formulas/contract/abstract/types/account.ts new file mode 100644 index 00000000..a74ef553 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/account.ts @@ -0,0 +1,444 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +export type AccountTrace = "local" | { + remote: TruncatedChainId[]; +}; +export type TruncatedChainId = string; +export type AddAuthenticator = { + Secp256K1: { + id: number; + pubkey: Binary; + signature: Binary; + }; +} | { + Ed25519: { + id: number; + pubkey: Binary; + signature: Binary; + }; +} | { + EthWallet: { + address: string; + id: number; + signature: Binary; + }; +} | { + Jwt: { + aud: string; + id: number; + sub: string; + token: Binary; + }; +} | { + Secp256R1: { + id: number; + pubkey: Binary; + signature: Binary; + }; +} | { + Passkey: { + credential: Binary; + id: number; + url: string; + }; +}; +export type Binary = string; +export type Namespace = string; +export type ModuleVersion = "latest" | { + version: string; +}; +export type GovernanceDetailsForString = { + monarchy: { + monarch: string; + }; +} | { + sub_account: { + account: string; + }; +} | { + external: { + governance_address: string; + governance_type: string; + }; +} | { + n_f_t: { + collection_addr: string; + token_id: string; + }; +} | { + abstract_account: { + address: Addr; + }; +} | { + renounced: {}; +}; +export type Addr = string; +export interface InstantiateMsg { + account_id?: AccountId | null; + authenticator?: AddAuthenticator | null; + description?: string | null; + install_modules?: ModuleInstallConfig[]; + link?: string | null; + name?: string | null; + namespace?: string | null; + owner: GovernanceDetailsForString; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export interface ModuleInstallConfig { + init_msg?: Binary | null; + module: ModuleInfo; +} +export interface ModuleInfo { + name: string; + namespace: Namespace; + version: ModuleVersion; +} +export type ExecuteMsg = { + execute: { + msgs: CosmosMsgForEmpty[]; + }; +} | { + execute_with_data: { + msg: CosmosMsgForEmpty; + }; +} | { + execute_on_module: { + exec_msg: Binary; + funds: Coin[]; + module_id: string; + }; +} | { + admin_execute: { + addr: string; + msg: Binary; + }; +} | { + admin_execute_on_module: { + module_id: string; + msg: Binary; + }; +} | { + ica_action: { + action_query_msg: Binary; + }; +} | { + update_internal_config: InternalConfigAction; +} | { + install_modules: { + modules: ModuleInstallConfig[]; + }; +} | { + uninstall_module: { + module_id: string; + }; +} | { + upgrade: { + modules: [ModuleInfo, Binary | null][]; + }; +} | { + create_sub_account: { + account_id?: number | null; + description?: string | null; + install_modules: ModuleInstallConfig[]; + link?: string | null; + name?: string | null; + namespace?: string | null; + }; +} | { + update_info: { + description?: string | null; + link?: string | null; + name?: string | null; + }; +} | { + update_status: { + is_suspended?: boolean | null; + }; +} | { + update_sub_account: UpdateSubAccountAction; +} | { + update_ownership: GovAction; +} | { + add_auth_method: { + add_authenticator: AddAuthenticator; + }; +} | { + remove_auth_method: { + id: number; + }; +}; +export type CosmosMsgForEmpty = { + bank: BankMsg; +} | { + custom: Empty; +} | { + staking: StakingMsg; +} | { + distribution: DistributionMsg; +} | { + stargate: { + type_url: string; + value: Binary; + }; +} | { + any: AnyMsg; +} | { + ibc: IbcMsg; +} | { + wasm: WasmMsg; +} | { + gov: GovMsg; +}; +export type BankMsg = { + send: { + amount: Coin[]; + to_address: string; + }; +} | { + burn: { + amount: Coin[]; + }; +}; +export type Uint128 = string; +export type StakingMsg = { + delegate: { + amount: Coin; + validator: string; + }; +} | { + undelegate: { + amount: Coin; + validator: string; + }; +} | { + redelegate: { + amount: Coin; + dst_validator: string; + src_validator: string; + }; +}; +export type DistributionMsg = { + set_withdraw_address: { + address: string; + }; +} | { + withdraw_delegator_reward: { + validator: string; + }; +} | { + fund_community_pool: { + amount: Coin[]; + }; +}; +export type IbcMsg = { + transfer: { + amount: Coin; + channel_id: string; + memo?: string | null; + timeout: IbcTimeout; + to_address: string; + }; +} | { + send_packet: { + channel_id: string; + data: Binary; + timeout: IbcTimeout; + }; +} | { + close_channel: { + channel_id: string; + }; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export type WasmMsg = { + execute: { + contract_addr: string; + funds: Coin[]; + msg: Binary; + }; +} | { + instantiate: { + admin?: string | null; + code_id: number; + funds: Coin[]; + label: string; + msg: Binary; + }; +} | { + instantiate2: { + admin?: string | null; + code_id: number; + funds: Coin[]; + label: string; + msg: Binary; + salt: Binary; + }; +} | { + migrate: { + contract_addr: string; + msg: Binary; + new_code_id: number; + }; +} | { + update_admin: { + admin: string; + contract_addr: string; + }; +} | { + clear_admin: { + contract_addr: string; + }; +}; +export type GovMsg = { + vote: { + option: VoteOption; + proposal_id: number; + }; +} | { + vote_weighted: { + options: WeightedVoteOption[]; + proposal_id: number; + }; +}; +export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; +export type Decimal = string; +export type InternalConfigAction = { + update_module_addresses: { + to_add: [string, string][]; + to_remove: string[]; + }; +} | { + update_whitelist: { + to_add: string[]; + to_remove: string[]; + }; +}; +export type UpdateSubAccountAction = { + unregister_sub_account: { + id: number; + }; +} | { + register_sub_account: { + id: number; + }; +}; +export type GovAction = { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: GovernanceDetailsForString; + }; +} | "accept_ownership" | "renounce_ownership"; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp; +} | { + never: {}; +}; +export interface Coin { + amount: Uint128; + denom: string; +} +export interface Empty {} +export interface AnyMsg { + type_url: string; + value: Binary; +} +export interface IbcTimeout { + block?: IbcTimeoutBlock | null; + timestamp?: Timestamp | null; +} +export interface IbcTimeoutBlock { + height: number; + revision: number; +} +export interface WeightedVoteOption { + option: VoteOption; + weight: Decimal; +} +export type QueryMsg = { + config: {}; +} | { + module_versions: { + ids: string[]; + }; +} | { + module_addresses: { + ids: string[]; + }; +} | { + module_infos: { + limit?: number | null; + start_after?: string | null; + }; +} | { + info: {}; +} | { + sub_account_ids: { + limit?: number | null; + start_after?: number | null; + }; +} | { + top_level_owner: {}; +} | { + ownership: {}; +} | { + authenticator_by_i_d: { + id: number; + }; +} | { + authenticator_i_ds: {}; +}; +export interface MigrateMsg {} +export interface ConfigResponse { + account_id: AccountId; + is_suspended: boolean; + module_factory_address: Addr; + registry_address: Addr; + whitelisted_addresses: Addr[]; +} +export interface InfoResponse { + info: AccountInfo; +} +export interface AccountInfo { + description?: string | null; + link?: string | null; + name?: string | null; +} +export interface ModuleAddressesResponse { + modules: [string, Addr][]; +} +export interface ModuleInfosResponse { + module_infos: AccountModuleInfo[]; +} +export interface AccountModuleInfo { + address: Addr; + id: string; + version: ContractVersion; +} +export interface ContractVersion { + contract: string; + version: string; +} +export interface ModuleVersionsResponse { + versions: ContractVersion[]; +} +export interface OwnershipForString { + owner: GovernanceDetailsForString; + pending_expiry?: Expiration | null; + pending_owner?: GovernanceDetailsForString | null; +} +export interface SubAccountIdsResponse { + sub_accounts: number[]; +} +export interface TopLevelOwnerResponse { + address: Addr; +} \ No newline at end of file diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts index 25ff6274..cc7815af 100644 --- a/src/formulas/formulas/contract/abstract/types/index.ts +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -1,3 +1,2 @@ -export * as ManagerTypes from './manager' -export * as VersionControlTypes from './versionControl' -export * as ProxyTypes from './proxy' +export * as AccountTypes from './account'; +export * as RegistryTypes from './registry'; diff --git a/src/formulas/formulas/contract/abstract/types/manager.ts b/src/formulas/formulas/contract/abstract/types/manager.ts deleted file mode 100644 index b3d016e4..00000000 --- a/src/formulas/formulas/contract/abstract/types/manager.ts +++ /dev/null @@ -1,289 +0,0 @@ -/** - * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @abstract-money/ts-codegen generate command to regenerate this file. - */ -export type AccountTrace = - | 'local' - | { - remote: ChainName[] - } -export type ChainName = string -export type Binary = string -export type Namespace = string -export type ModuleVersion = - | 'latest' - | { - version: string - } -export type GovernanceDetailsForString = - | { - Monarchy: { - monarch: string - [k: string]: unknown - } - } - | { - SubAccount: { - manager: string - proxy: string - [k: string]: unknown - } - } - | { - External: { - governance_address: string - governance_type: string - [k: string]: unknown - } - } -export interface InstantiateMsg { - account_id: AccountId - description?: string | null - install_modules: ModuleInstallConfig[] - link?: string | null - module_factory_address: string - name: string - owner: GovernanceDetailsForString - version_control_address: string -} -export interface AccountId { - seq: number - trace: AccountTrace -} -export interface ModuleInstallConfig { - init_msg?: Binary | null - module: ModuleInfo -} -export interface ModuleInfo { - name: string - namespace: Namespace - version: ModuleVersion -} -export type ExecuteMsg = - | { - exec_on_module: { - exec_msg: Binary - module_id: string - } - } - | { - update_internal_config: Binary - } - | { - install_modules: { - modules: ModuleInstallConfig[] - } - } - | { - register_modules: { - modules: RegisterModuleData[] - } - } - | { - uninstall_module: { - module_id: string - } - } - | { - upgrade: { - modules: [ModuleInfo, Binary | null][] - } - } - | { - create_sub_account: { - base_asset?: AssetEntry | null - description?: string | null - install_modules: ModuleInstallConfig[] - link?: string | null - name: string - namespace?: string | null - } - } - | { - update_info: { - description?: string | null - link?: string | null - name?: string | null - } - } - | { - set_owner: { - owner: GovernanceDetailsForString - } - } - | { - update_status: { - is_suspended?: boolean | null - } - } - | { - update_settings: { - ibc_enabled?: boolean | null - } - } - | { - update_sub_account: UpdateSubAccountAction - } - | { - callback: CallbackMsg - } - | { - update_ownership: Action - } -export type ModuleReference = - | { - account_base: number - } - | { - native: Addr - } - | { - adapter: Addr - } - | { - app: number - } - | { - standalone: number - } -export type Addr = string -export type AssetEntry = string -export type UpdateSubAccountAction = - | { - unregister_sub_account: { - id: number - } - } - | { - register_sub_account: { - id: number - } - } -export type Action = - | { - transfer_ownership: { - expiry?: Expiration | null - new_owner: string - } - } - | 'accept_ownership' - | 'renounce_ownership' -export type Expiration = - | { - at_height: number - } - | { - at_time: Timestamp - } - | { - never: {} - } -export type Timestamp = Uint64 -export type Uint64 = string -export interface RegisterModuleData { - module: Module - module_address: string -} -export interface Module { - info: ModuleInfo - reference: ModuleReference -} -export interface CallbackMsg {} -export type QueryMsg = - | { - module_versions: { - ids: string[] - } - } - | { - module_addresses: { - ids: string[] - } - } - | { - module_infos: { - limit?: number | null - start_after?: string | null - } - } - | { - config: {} - } - | { - info: {} - } - | { - sub_account_ids: { - limit?: number | null - start_after?: number | null - } - } - | { - ownership: {} - } -export interface MigrateMsg {} -export interface ConfigResponse { - account_id: AccountId - is_suspended: boolean - module_factory_address: Addr - version_control_address: Addr -} -export type GovernanceDetailsForAddr = - | { - Monarchy: { - monarch: Addr - [k: string]: unknown - } - } - | { - SubAccount: { - manager: Addr - proxy: Addr - [k: string]: unknown - } - } - | { - External: { - governance_address: Addr - governance_type: string - [k: string]: unknown - } - } -export interface InfoResponse { - info: AccountInfoForAddr -} -export interface AccountInfoForAddr { - chain_id: string - description?: string | null - governance_details: GovernanceDetailsForAddr - link?: string | null - name: string -} -export interface ModuleAddressesResponse { - modules: [string, Addr][] -} -export interface ModuleInfosResponse { - module_infos: ManagerModuleInfo[] -} -export interface ManagerModuleInfo { - address: Addr - id: string - version: ContractVersion -} -export interface ContractVersion { - contract: string - version: string -} -export interface ModuleVersionsResponse { - versions: ContractVersion[] -} -export interface OwnershipForString { - owner?: string | null - pending_expiry?: Expiration | null - pending_owner?: string | null -} -export interface SubAccountIdsResponse { - sub_accounts: number[] -} -//# sourceMappingURL=Manager.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/types/proxy.ts b/src/formulas/formulas/contract/abstract/types/proxy.ts deleted file mode 100644 index c4fe57e8..00000000 --- a/src/formulas/formulas/contract/abstract/types/proxy.ts +++ /dev/null @@ -1,459 +0,0 @@ -/** - * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @abstract-money/ts-codegen generate command to regenerate this file. - */ -export type AccountTrace = "local" | { - remote: ChainName[]; -}; -export type ChainName = string; -export interface InstantiateMsg { - account_id: AccountId; - ans_host_address: string; -} -export interface AccountId { - seq: number; - trace: AccountTrace; -} -export type ExecuteMsg = { - set_admin: { - admin: string; - }; -} | { - module_action: { - msgs: CosmosMsgForEmpty[]; - }; -} | { - module_action_with_data: { - msg: CosmosMsgForEmpty; - }; -} | { - ibc_action: { - msgs: ExecuteMsg1[]; - }; -} | { - add_modules: { - modules: string[]; - }; -} | { - remove_module: { - module: string; - }; -} | { - update_assets: { - to_add: [AssetEntry, UncheckedPriceSource][]; - to_remove: AssetEntry[]; - }; -}; -export type CosmosMsgForEmpty = { - bank: BankMsg; -} | { - custom: Empty; -} | { - staking: StakingMsg; -} | { - distribution: DistributionMsg; -} | { - stargate: { - type_url: string; - value: Binary; - [k: string]: unknown; - }; -} | { - ibc: IbcMsg; -} | { - wasm: WasmMsg; -} | { - gov: GovMsg; -}; -export type BankMsg = { - send: { - amount: Coin[]; - to_address: string; - [k: string]: unknown; - }; -} | { - burn: { - amount: Coin[]; - [k: string]: unknown; - }; -}; -export type Uint128 = string; -export type StakingMsg = { - delegate: { - amount: Coin; - validator: string; - [k: string]: unknown; - }; -} | { - undelegate: { - amount: Coin; - validator: string; - [k: string]: unknown; - }; -} | { - redelegate: { - amount: Coin; - dst_validator: string; - src_validator: string; - [k: string]: unknown; - }; -}; -export type DistributionMsg = { - set_withdraw_address: { - address: string; - [k: string]: unknown; - }; -} | { - withdraw_delegator_reward: { - validator: string; - [k: string]: unknown; - }; -}; -export type Binary = string; -export type IbcMsg = { - transfer: { - amount: Coin; - channel_id: string; - timeout: IbcTimeout; - to_address: string; - [k: string]: unknown; - }; -} | { - send_packet: { - channel_id: string; - data: Binary; - timeout: IbcTimeout; - [k: string]: unknown; - }; -} | { - close_channel: { - channel_id: string; - [k: string]: unknown; - }; -}; -export type Timestamp = Uint64; -export type Uint64 = string; -export type WasmMsg = { - execute: { - contract_addr: string; - funds: Coin[]; - msg: Binary; - [k: string]: unknown; - }; -} | { - instantiate: { - admin?: string | null; - code_id: number; - funds: Coin[]; - label: string; - msg: Binary; - [k: string]: unknown; - }; -} | { - migrate: { - contract_addr: string; - msg: Binary; - new_code_id: number; - [k: string]: unknown; - }; -} | { - update_admin: { - admin: string; - contract_addr: string; - [k: string]: unknown; - }; -} | { - clear_admin: { - contract_addr: string; - [k: string]: unknown; - }; -}; -export type GovMsg = { - vote: { - proposal_id: number; - vote: VoteOption; - [k: string]: unknown; - }; -}; -export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; -export type ExecuteMsg1 = { - update_admin: { - admin: string; - }; -} | { - update_config: { - ans_host?: string | null; - version_control?: string | null; - }; -} | { - send_funds: { - funds: Coin[]; - host_chain: string; - }; -} | { - register: { - host_chain: string; - }; -} | { - send_packet: { - action: HostAction; - callback_info?: CallbackInfo | null; - host_chain: string; - retries: number; - }; -} | { - remove_host: { - host_chain: string; - }; -}; -export type HostAction = { - app: { - msg: Binary; - }; -} | { - dispatch: { - msgs: CosmosMsgForEmpty[]; - }; -} | { - query: { - msgs: QueryRequestForEmpty[]; - }; -} | { - send_all_back: {}; -} | { - balances: {}; -} | { - internal: InternalAction; -}; -export type QueryRequestForEmpty = { - bank: BankQuery; -} | { - custom: Empty; -} | { - staking: StakingQuery; -} | { - stargate: { - data: Binary; - path: string; - [k: string]: unknown; - }; -} | { - ibc: IbcQuery; -} | { - wasm: WasmQuery; -}; -export type BankQuery = { - balance: { - address: string; - denom: string; - [k: string]: unknown; - }; -} | { - all_balances: { - address: string; - [k: string]: unknown; - }; -}; -export type StakingQuery = { - bonded_denom: { - [k: string]: unknown; - }; -} | { - all_delegations: { - delegator: string; - [k: string]: unknown; - }; -} | { - delegation: { - delegator: string; - validator: string; - [k: string]: unknown; - }; -} | { - all_validators: { - [k: string]: unknown; - }; -} | { - validator: { - address: string; - [k: string]: unknown; - }; -}; -export type IbcQuery = { - port_id: { - [k: string]: unknown; - }; -} | { - list_channels: { - port_id?: string | null; - [k: string]: unknown; - }; -} | { - channel: { - channel_id: string; - port_id?: string | null; - [k: string]: unknown; - }; -}; -export type WasmQuery = { - smart: { - contract_addr: string; - msg: Binary; - [k: string]: unknown; - }; -} | { - raw: { - contract_addr: string; - key: Binary; - [k: string]: unknown; - }; -} | { - contract_info: { - contract_addr: string; - [k: string]: unknown; - }; -}; -export type InternalAction = "who_am_i" | { - register: { - account_proxy_address: string; - }; -}; -export type AssetEntry = string; -export type UncheckedPriceSource = "None" | { - Pair: DexAssetPairing; -} | { - LiquidityToken: { - [k: string]: unknown; - }; -} | { - ValueAs: { - asset: AssetEntry; - multiplier: Decimal; - [k: string]: unknown; - }; -}; -export type DexAssetPairing = [AssetEntry, AssetEntry, string]; -export type Decimal = string; -export interface Coin { - amount: Uint128; - denom: string; - [k: string]: unknown; -} -export interface Empty { - [k: string]: unknown; -} -export interface IbcTimeout { - block?: IbcTimeoutBlock | null; - timestamp?: Timestamp | null; - [k: string]: unknown; -} -export interface IbcTimeoutBlock { - height: number; - revision: number; - [k: string]: unknown; -} -export interface CallbackInfo { - id: string; - receiver: string; -} -export type QueryMsg = { - config: {}; -} | { - total_value: {}; -} | { - token_value: { - identifier: AssetEntry; - }; -} | { - holding_amount: { - identifier: AssetEntry; - }; -} | { - asset_config: { - identifier: AssetEntry; - }; -} | { - assets_config: { - limit?: number | null; - start_after?: AssetEntry | null; - }; -} | { - assets_info: { - limit?: number | null; - start_after?: AssetInfoBaseForAddr | null; - }; -} | { - base_asset: {}; -}; -export type AssetInfoBaseForAddr = { - native: string; -} | { - cw20: Addr; -}; -export type Addr = string; -export interface MigrateMsg { -} -export interface AssetConfigResponse { - price_source: UncheckedPriceSource; -} -export interface AssetsConfigResponse { - assets: [AssetEntry, UncheckedPriceSource][]; -} -export type PriceSource = "None" | { - Pool: { - address: PoolAddressBaseForAddr; - pair: AssetInfoBaseForAddr[]; - [k: string]: unknown; - }; -} | { - LiquidityToken: { - pool_address: PoolAddressBaseForAddr; - pool_assets: AssetInfoBaseForAddr[]; - [k: string]: unknown; - }; -} | { - ValueAs: { - asset: AssetInfoBaseForAddr; - multiplier: Decimal; - [k: string]: unknown; - }; -}; -export type PoolAddressBaseForAddr = { - separate_addresses: { - liquidity: Addr; - swap: Addr; - }; -} | { - contract: Addr; -} | { - id: number; -}; -export interface AssetsInfoResponse { - assets: [AssetInfoBaseForAddr, OracleAsset][]; -} -export interface OracleAsset { - complexity: number; - price_source: PriceSource; -} -export interface BaseAssetResponse { - base_asset: AssetInfoBaseForAddr; -} -export interface ConfigResponse { - modules: string[]; -} -export interface HoldingAmountResponse { - amount: Uint128; -} -export interface TokenValueResponse { - value: Uint128; -} -export interface AccountValue { - breakdown: [AssetInfoBaseForAddr, Uint128][]; - total_value: AssetBaseForAddr; -} -export interface AssetBaseForAddr { - amount: Uint128; - info: AssetInfoBaseForAddr; -} -//# sourceMappingURL=Proxy.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/types/registry.ts b/src/formulas/formulas/contract/abstract/types/registry.ts new file mode 100644 index 00000000..cf698ab7 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/registry.ts @@ -0,0 +1,228 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +export type Uint128 = string; +export interface InstantiateMsg { + admin: string; + namespace_registration_fee?: Coin | null; + security_disabled?: boolean | null; +} +export interface Coin { + amount: Uint128; + denom: string; +} +export type ExecuteMsg = { + remove_module: { + module: ModuleInfo; + }; +} | { + yank_module: { + module: ModuleInfo; + }; +} | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][]; + }; +} | { + update_module_configuration: { + module_name: string; + namespace: Namespace; + update_module: UpdateModule; + }; +} | { + approve_or_reject_modules: { + approves: ModuleInfo[]; + rejects: ModuleInfo[]; + }; +} | { + claim_namespace: { + account_id: AccountId; + namespace: string; + }; +} | { + forgo_namespace: { + namespaces: string[]; + }; +} | { + add_account: { + creator: string; + namespace?: string | null; + }; +} | { + update_config: { + namespace_registration_fee?: ClearableForCoin | null; + security_disabled?: boolean | null; + }; +} | { + update_ownership: Action; +}; +export type Namespace = string; +export type ModuleVersion = "latest" | { + version: string; +}; +export type ModuleReference = { + account: number; +} | { + native: Addr; +} | { + adapter: Addr; +} | { + app: number; +} | { + standalone: number; +} | { + service: Addr; +}; +export type Addr = string; +export type UpdateModule = { + default: { + metadata: string; + }; +} | { + versioned: { + instantiation_funds?: Coin[] | null; + metadata?: string | null; + monetization?: Monetization | null; + version: string; + }; +}; +export type Monetization = "none" | { + install_fee: FixedFee; +}; +export type AccountTrace = "local" | { + remote: TruncatedChainId[]; +}; +export type TruncatedChainId = string; +export type ClearableForCoin = "clear" | { + set: Coin; +}; +export type Action = { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: string; + }; +} | "accept_ownership" | "renounce_ownership"; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp; +} | { + never: {}; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export interface ModuleInfo { + name: string; + namespace: Namespace; + version: ModuleVersion; +} +export interface FixedFee { + fee: Coin; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export type QueryMsg = { + accounts: { + account_ids: AccountId[]; + }; +} | { + modules: { + infos: ModuleInfo[]; + }; +} | { + namespaces: { + accounts: AccountId[]; + }; +} | { + namespace: { + namespace: Namespace; + }; +} | { + config: {}; +} | { + account_list: { + limit?: number | null; + start_after?: AccountId | null; + }; +} | { + module_list: { + filter?: ModuleFilter | null; + limit?: number | null; + start_after?: ModuleInfo | null; + }; +} | { + namespace_list: { + limit?: number | null; + start_after?: string | null; + }; +} | { + ownership: {}; +}; +export type ModuleStatus = "registered" | "pending" | "yanked"; +export interface ModuleFilter { + name?: string | null; + namespace?: string | null; + status?: ModuleStatus | null; + version?: string | null; +} +export type MigrateMsg = { + instantiate: InstantiateMsg; +} | { + migrate: {}; +}; +export type AccountForAddr = Addr; +export interface AccountListResponse { + accounts: [AccountId, AccountForAddr][]; +} +export interface AccountsResponse { + accounts: AccountForAddr[]; +} +export interface ConfigResponse { + local_account_sequence: number; + namespace_registration_fee?: Coin | null; + security_disabled: boolean; +} +export interface ModulesListResponse { + modules: ModuleResponse[]; +} +export interface ModuleResponse { + config: ModuleConfiguration; + module: Module; +} +export interface ModuleConfiguration { + instantiation_funds: Coin[]; + metadata?: string | null; + monetization: Monetization; +} +export interface Module { + info: ModuleInfo; + reference: ModuleReference; +} +export interface ModulesResponse { + modules: ModuleResponse[]; +} +export type NamespaceResponse = { + claimed: NamespaceInfo; +} | { + unclaimed: {}; +}; +export interface NamespaceInfo { + account: AccountForAddr; + account_id: AccountId; +} +export interface NamespaceListResponse { + namespaces: [Namespace, AccountId][]; +} +export interface NamespacesResponse { + namespaces: [Namespace, AccountId][]; +} +export interface OwnershipForString { + owner?: string | null; + pending_expiry?: Expiration | null; + pending_owner?: string | null; +} \ No newline at end of file diff --git a/src/formulas/formulas/contract/abstract/types/versionControl.ts b/src/formulas/formulas/contract/abstract/types/versionControl.ts deleted file mode 100644 index 7d7a92fa..00000000 --- a/src/formulas/formulas/contract/abstract/types/versionControl.ts +++ /dev/null @@ -1,253 +0,0 @@ -/** - * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @abstract-money/ts-codegen generate command to regenerate this file. - */ -export type Uint128 = string -export interface InstantiateMsg { - admin: string - allow_direct_module_registration_and_updates?: boolean | null - namespace_registration_fee?: Coin | null -} -export interface Coin { - amount: Uint128 - denom: string - [k: string]: unknown -} -export type ExecuteMsg = - | { - remove_module: { - module: ModuleInfo - } - } - | { - yank_module: { - module: ModuleInfo - } - } - | { - propose_modules: { - modules: [ModuleInfo, ModuleReference][] - } - } - | { - update_module_configuration: { - module_name: string - namespace: Namespace - update_module: UpdateModule - } - } - | { - approve_or_reject_modules: { - approves: ModuleInfo[] - rejects: ModuleInfo[] - } - } - | { - claim_namespace: { - account_id: AccountId - namespace: string - } - } - | { - remove_namespaces: { - namespaces: string[] - } - } - | { - add_account: { - account_base: AccountBase - account_id: AccountId - } - } - | { - update_config: { - allow_direct_module_registration_and_updates?: boolean | null - namespace_registration_fee?: Coin | null - } - } - | { - set_factory: { - new_factory: string - } - } - | { - update_ownership: Action - } -export type Namespace = string -export type ModuleVersion = - | 'latest' - | { - version: string - } -export type ModuleReference = - | { - account_base: number - } - | { - native: Addr - } - | { - adapter: Addr - } - | { - app: number - } - | { - standalone: number - } -export type Addr = string -export type UpdateModule = - | { - default: { - metadata: string - } - } - | { - versioned: { - instantiation_funds?: Coin[] | null - metadata?: string | null - monetization?: Monetization | null - version: string - } - } -export type Monetization = - | 'none' - | { - install_fee: FixedFee - } -export type AccountTrace = - | 'local' - | { - remote: ChainName[] - } -export type ChainName = string -export type Action = - | { - transfer_ownership: { - expiry?: Expiration | null - new_owner: string - } - } - | 'accept_ownership' - | 'renounce_ownership' -export type Expiration = - | { - at_height: number - } - | { - at_time: Timestamp - } - | { - never: {} - } -export type Timestamp = Uint64 -export type Uint64 = string -export interface ModuleInfo { - name: string - namespace: Namespace - version: ModuleVersion -} -export interface FixedFee { - fee: Coin -} -export interface AccountId { - seq: number - trace: AccountTrace -} -export interface AccountBase { - manager: Addr - proxy: Addr -} -export type QueryMsg = - | { - account_base: { - account_id: AccountId - } - } - | { - modules: { - infos: ModuleInfo[] - } - } - | { - namespaces: { - accounts: AccountId[] - } - } - | { - namespace: { - namespace: Namespace - } - } - | { - config: {} - } - | { - module_list: { - filter?: ModuleFilter | null - limit?: number | null - start_after?: ModuleInfo | null - } - } - | { - namespace_list: { - limit?: number | null - start_after?: string | null - } - } - | { - ownership: {} - } -export type ModuleStatus = - | 'r_e_g_i_s_t_e_r_e_d' - | 'p_e_n_d_i_n_g' - | 'y_a_n_k_e_d' -export interface ModuleFilter { - name?: string | null - namespace?: string | null - status?: ModuleStatus | null - version?: string | null -} -export interface MigrateMsg {} -export interface AccountBaseResponse { - account_base: AccountBase -} -export interface ConfigResponse { - factory: Addr -} -export interface ModulesListResponse { - modules: ModuleResponse[] -} -export interface ModuleResponse { - config: ModuleConfiguration - module: Module -} -export interface ModuleConfiguration { - instantiation_funds: Coin[] - metadata?: string | null - monetization: Monetization -} -export interface Module { - info: ModuleInfo - reference: ModuleReference -} -export interface ModulesResponse { - modules: ModuleResponse[] -} -export interface NamespaceResponse { - account_base: AccountBase - account_id: AccountId -} -export interface NamespaceListResponse { - namespaces: [Namespace, AccountId][] -} -export interface NamespacesResponse { - namespaces: [Namespace, AccountId][] -} -export interface OwnershipForString { - owner?: string | null - pending_expiry?: Expiration | null - pending_owner?: string | null -} -//# sourceMappingURL=VersionControl.types.d.ts.map From 963704e2c07fec76fae7553a1366dfdb6952ead2 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 18 Nov 2024 15:54:01 +0200 Subject: [PATCH 05/29] export abstract contract formulas --- src/formulas/formulas/contract/abstract/index.ts | 2 ++ src/formulas/formulas/contract/abstract/types/index.ts | 4 ++-- src/formulas/formulas/contract/index.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 src/formulas/formulas/contract/abstract/index.ts diff --git a/src/formulas/formulas/contract/abstract/index.ts b/src/formulas/formulas/contract/abstract/index.ts new file mode 100644 index 00000000..fd19b39d --- /dev/null +++ b/src/formulas/formulas/contract/abstract/index.ts @@ -0,0 +1,2 @@ +export * as account from './account' +export * as registry from './registry' diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts index cc7815af..50d51c84 100644 --- a/src/formulas/formulas/contract/abstract/types/index.ts +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -1,2 +1,2 @@ -export * as AccountTypes from './account'; -export * as RegistryTypes from './registry'; +export * as AccountTypes from './account' +export * as RegistryTypes from './registry' diff --git a/src/formulas/formulas/contract/index.ts b/src/formulas/formulas/contract/index.ts index c6610231..9f624274 100644 --- a/src/formulas/formulas/contract/index.ts +++ b/src/formulas/formulas/contract/index.ts @@ -8,5 +8,6 @@ export * from './proposal' export * from './staking' export * as valence from './valence' export * from './voting' +export * from './abstract' export * from './common' From 344ec58bee25d0d9afc851300378171a9844f7d6 Mon Sep 17 00:00:00 2001 From: Buckram Date: Thu, 21 Nov 2024 17:02:00 +0200 Subject: [PATCH 06/29] progress --- .eslintignore | 1 + config.json.example | 3 +- .../formulas/contract/abstract/account.ts | 49 +- .../formulas/contract/abstract/registry.ts | 97 +++- .../transformers/abstract/account.ts | 42 ++ .../transformers/abstract/index.ts | 3 + .../transformers/abstract/manager.ts | 0 src/transformers/transformers/index.ts | 2 + src/transformers/utils.ts | 17 + static/openapi.json | 441 ++++++++++++++++++ 10 files changed, 597 insertions(+), 58 deletions(-) create mode 100644 src/transformers/transformers/abstract/account.ts create mode 100644 src/transformers/transformers/abstract/index.ts delete mode 100644 src/transformers/transformers/abstract/manager.ts diff --git a/.eslintignore b/.eslintignore index 603130a7..62041ff1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ src/protobuf/codegen/ +src/formulas/contract/abstract/types diff --git a/config.json.example b/config.json.example index 0c22bd87..2d5a7a39 100644 --- a/config.json.example +++ b/config.json.example @@ -36,7 +36,8 @@ "cw4-group": [178], "polytone-note": [], "polytone-voice": [], - "valence-account": [] + "valence-account": [], + "abstract:account": [7693], }, "daoDaoBase": "https://testnet.daodao.zone", "discordNotifierApiKey": "key", diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index 06cce99f..aa8e114e 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -1,32 +1,10 @@ +import { loadConfig } from '@/config' import { ContractFormula } from '@/types' import * as Common from '../common' import { AccountTypes } from './types' import { Addr, GovernanceDetailsForString } from './types/account' -/* - /// Suspension status - pub const SUSPENSION_STATUS: Item = Item::new("\u{0}{12}is_suspended"); - /// Configuration - pub const CONFIG: Item = Item::new("\u{0}{6}config"); - /// Info about the Account - pub const INFO: Item> = Item::new("\u{0}{4}info"); - /// Account owner - managed by cw-ownable - pub const OWNER: Item> = Item::new(OWNERSHIP_STORAGE_KEY); - /// Enabled Abstract modules - pub const ACCOUNT_MODULES: Map = Map::new("modules"); - /// Stores the dependency relationship between modules - /// map module -> modules that depend on module. - pub const DEPENDENTS: Map> = Map::new("dependents"); - /// List of sub-accounts - pub const SUB_ACCOUNTS: Map = Map::new("sub_accs"); - /// Pending new governance - pub const PENDING_GOVERNANCE: Item> = Item::new("pgov"); - /// Context for old adapters that are currently removing authorized addresses - pub const REMOVE_ADAPTER_AUTHORIZED_CONTEXT: Item = Item::new("rm_a_auth"); -} - */ - const AccountStorageKeys = { SUSPENSION_STATUS: 'aa', INFO: 'ab', @@ -38,6 +16,11 @@ const AccountStorageKeys = { OWNER: 'ownership', } +// Replace with transformer +function registryAddress(): string { + return loadConfig().abstractRegistry as string +} + export const owner: ContractFormula = { docs: { description: '', @@ -135,12 +118,7 @@ export const moduleInfos: ContractFormula< description: '', }, compute: async (env) => { - const { contractAddress, getMap, get } = env - - // TODO: - const RegistryAddr = undefined - - if (!RegistryAddr) return [] + const { contractAddress, getMap } = env const moduleAddressesMap = (await getMap( @@ -148,7 +126,7 @@ export const moduleInfos: ContractFormula< AccountStorageKeys.ACCOUNT_MODULES )) ?? {} - // Query the info from + // Query the info from registry return await Promise.all( Object.entries(moduleAddressesMap).map(async ([moduleId, address]) => { const contractInfo = await Common.info.compute({ @@ -166,6 +144,13 @@ export const moduleInfos: ContractFormula< }, } -type State = { - modules: string[] +export const accountTxs: ContractFormula = { + docs: { + description: '', + }, + compute: async (env) => { + const { contractAddress, getTxEvents } = env + const events = await getTxEvents(contractAddress) + return events ?? [] + }, } diff --git a/src/formulas/formulas/contract/abstract/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts index 30dab0d5..6392ef00 100644 --- a/src/formulas/formulas/contract/abstract/registry.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -1,23 +1,3 @@ -/* - pub const CONFIG: Item = Item::new("cfg"); - - // Modules waiting for approvals - pub const PENDING_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("pendm"); - // We can iterate over the map giving just the prefix to get all the versions - pub const REGISTERED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("lib"); - // Reverse map for module info of standalone modules - pub const STANDALONE_INFOS: Map = Map::new("stli"); - // Yanked Modules - pub const YANKED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("yknd"); - // Modules Configuration - pub const MODULE_CONFIG: Map<&ModuleInfo, ModuleConfiguration> = Map::new("cfg"); - // Modules Default Configuration - pub const MODULE_DEFAULT_CONFIG: Map<(&Namespace, &str), ModuleDefaultConfiguration> = - Map::new("dcfg"); - /// Maps Account ID to the address of its core contracts - pub const ACCOUNT_ADDRESSES: Map<&AccountId, AccountBase> = Map::new("accs"); -*/ - import semver from 'semver/preload' import { Module } from '@/formulas/formulas/contract/abstract/types/registry' @@ -30,11 +10,15 @@ const RegistryStorageKeys = { CONFIG: 'cfg', PENDING_MODULES: 'ca', REGISTERED_MODULES: 'cb', - STANDALONE_INFOS: 'cd', + STANDALONE_INFOS: 'cc', + SERVICE_INFOS: 'cd', YANKED_MODULES: 'ce', MODULE_CONFIG: 'cf', MODULE_DEFAULT_CONFIG: 'cg', ACCOUNT_ADDRESSES: 'ch', + LOCAL_ACCOUNT_SEQUENCE: 'ci', + NAMESPACES: 'cj', + REV_NAMESPACES: 'ck', } export const listRegisteredModules: ContractFormula> = { @@ -88,7 +72,7 @@ const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { } type ModuleInfoParameter = Omit & { - version?: string + version: string } export const moduleConfig: ContractFormula< @@ -96,14 +80,42 @@ export const moduleConfig: ContractFormula< ModuleInfoParameter > = { docs: { - description: 'Configuration of the module installation', + description: 'Configuration of the module installation huh', + args: [ + { + name: 'name', + description: 'name of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'namespace', + description: 'namespace of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'version', + description: 'semver version of the module', + // TODO: it's possible to make it false with transformer and saving latest version of the module + required: true, + schema: { + type: 'string', + }, + }, + ], }, compute: async ({ contractAddress, getMap, args }) => { - if (!args || !args.name || !args.namespace) return undefined + if (!args || !args.name || !args.namespace || !args.version) + return undefined const moduleInfo: RegistryTypes.ModuleInfo = { namespace: args.namespace, name: args.name, - version: args.version ? { version: args.version } : 'latest', + version: { version: args.version }, } const versionedConfigMap = @@ -194,3 +206,38 @@ export const module: ContractFormula< ) }, } + +export const listLocalAccounts: ContractFormula = + { + docs: { + description: 'Lists local accounts on chain', + }, + compute: async ({ contractAddress, getMap }) => { + const registeredModulesMap = + (await getMap( + contractAddress, + RegistryStorageKeys.ACCOUNT_ADDRESSES, + { keyType: 'raw' } + )) ?? {} + + const accounts = Object.entries(registeredModulesMap).map( + ([key, reference]) => { + const [trace_raw, sequence] = dbKeyToKeys(key, [false, true]) + let trace + if (trace_raw === 'local') { + trace = 'local' + } else { + trace = { remote: (trace_raw as string).split('>') } + } + return [ + { + seq: sequence as number, + trace, + }, + reference, + ] as [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] + } + ) + return { accounts } + }, + } diff --git a/src/transformers/transformers/abstract/account.ts b/src/transformers/transformers/abstract/account.ts new file mode 100644 index 00000000..3bf28763 --- /dev/null +++ b/src/transformers/transformers/abstract/account.ts @@ -0,0 +1,42 @@ +import { makeTransformer, makeTransformerForMap } from '@/transformers/utils' + +const CODE_IDS_KEYS = ['abstract-account'] + +const AccountStorageKeys = { + SUSPENSION_STATUS: 'aa', + INFO: 'ab', + ACCOUNT_MODULES: 'ac', + DEPENDENTS: 'ad', + SUB_ACCOUNTS: 'ae', + WHITELISTED_MODULES: 'af', + ACCOUNT_ID: 'ag', + OWNER: 'ownership', +} + +const suspended = makeTransformer( + CODE_IDS_KEYS, + 'suspended', + AccountStorageKeys.SUSPENSION_STATUS +) + +const accountId = makeTransformer( + CODE_IDS_KEYS, + 'accountId', + AccountStorageKeys.ACCOUNT_ID +) + +const accountModules = makeTransformerForMap( + CODE_IDS_KEYS, + 'accountModules', + AccountStorageKeys.ACCOUNT_MODULES +) + +const subAccounts = makeTransformerForMap( + CODE_IDS_KEYS, + 'subAccounts', + AccountStorageKeys.SUB_ACCOUNTS +) + +export default [ + // suspended, accountId, accountModules, subAccounts +] diff --git a/src/transformers/transformers/abstract/index.ts b/src/transformers/transformers/abstract/index.ts new file mode 100644 index 00000000..f340c476 --- /dev/null +++ b/src/transformers/transformers/abstract/index.ts @@ -0,0 +1,3 @@ +import account from './account' + +export default [...account] diff --git a/src/transformers/transformers/abstract/manager.ts b/src/transformers/transformers/abstract/manager.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/src/transformers/transformers/index.ts b/src/transformers/transformers/index.ts index 63d19b19..004ad5e9 100644 --- a/src/transformers/transformers/index.ts +++ b/src/transformers/transformers/index.ts @@ -8,6 +8,7 @@ import { TransformerMaker, } from '@/types' +import abstract from './abstract' import common from './common' import dao from './dao' import distribution from './distribution' @@ -40,6 +41,7 @@ export const getProcessedTransformers = ( ...staking, ...valence, ...voting, + ...abstract, // Makers. ...transformerMakers.map((maker) => maker(config)), diff --git a/src/transformers/utils.ts b/src/transformers/utils.ts index 5295ddf0..d1508407 100644 --- a/src/transformers/utils.ts +++ b/src/transformers/utils.ts @@ -23,6 +23,23 @@ export const makeTransformer = ( } } +export const makeAddressTransformer = ( + contractAddresses: string[], + name: string, + keyOrKeys?: string | string[] +): Transformer => { + const dbKeys = [keyOrKeys || name].flat().map((key) => dbKeyForKeys(key)) + + return { + filter: { + contractAddresses, + matches: (event) => dbKeys.includes(event.key), + }, + name, + getValue: defaultGetValue, + } +} + interface TransformerForMapOptions { numericKey?: boolean getValue?: Transformer['getValue'] diff --git a/static/openapi.json b/static/openapi.json index a385ace8..5374101b 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -26,9 +26,284 @@ "servers": [ { "url": "https://indexer.daodao.zone" + }, + { + "url": "http://localhost:3420" } ], "paths": { + "/{chainId}/contract/{address}/account/accountId": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > accountId", + "description": "`account/accountId`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/accountTxs": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > accountTxs", + "description": "`account/accountTxs`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/info": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > info", + "description": "`account/info`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/moduleInfos": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > moduleInfos", + "description": "`account/moduleInfos`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/owner": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > owner", + "description": "`account/owner`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/subAccountIds": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > subAccountIds", + "description": "`account/subAccountIds`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/suspensionStatus": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > suspensionStatus", + "description": "`account/suspensionStatus`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/whitelistedModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > whitelistedModules", + "description": "`account/whitelistedModules`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, "/{chainId}/contract/{address}/cw1Whitelist/adminList": { "get": { "tags": [ @@ -10270,6 +10545,172 @@ } } }, + "/{chainId}/contract/{address}/registry/listLocalAccounts": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > listLocalAccounts", + "description": "Lists local accounts on chain", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/registry/listRegisteredModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > listRegisteredModules", + "description": "Lists registered modules in registry", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/registry/module": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > module", + "description": "Module info", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/registry/moduleConfig": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > moduleConfig", + "description": "Configuration of the module installation huh", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, "/{chainId}/contract/{address}/valence/account/admin": { "get": { "tags": [ From 7ae4e3c576305f96820e17ace1c62af5d46830c8 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 03:33:35 +0200 Subject: [PATCH 07/29] list accountsOwnedBy --- .../formulas/account/abstractAccount.ts | 82 +++++++++++++++++++ src/formulas/formulas/account/index.ts | 1 + .../formulas/contract/abstract/account.ts | 21 ++--- .../formulas/contract/abstract/registry.ts | 18 ++-- .../transformers/abstract/account.ts | 28 +------ static/openapi.json | 46 +++++++++++ 6 files changed, 150 insertions(+), 46 deletions(-) create mode 100644 src/formulas/formulas/account/abstractAccount.ts diff --git a/src/formulas/formulas/account/abstractAccount.ts b/src/formulas/formulas/account/abstractAccount.ts new file mode 100644 index 00000000..f5b3b706 --- /dev/null +++ b/src/formulas/formulas/account/abstractAccount.ts @@ -0,0 +1,82 @@ +import { AccountFormula } from '@/types' +import { AccountTypes } from '../contract/abstract/types' + +/** + * Get all contracts with the account governance owner set to this address. + */ +export const accountsOwnedBy: AccountFormula< + string[], + { + /** + * Optionally filter by code ID key. + */ + key?: string + } +> = { + docs: { + description: + 'retrieves account (that use abstract governance to manage ownership) where the account is the owner', + args: [ + { + name: 'key', + description: 'optional code ID key to filter by', + required: false, + schema: { + type: 'string', + }, + }, + ], + }, + compute: async (env) => { + const { + args: { key }, + address, + getTransformationMatches, + getCodeIdsForKeys, + } = env + + const monarchyOwned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + monarchy: { + monarch: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + key ? getCodeIdsForKeys(key) : undefined + ) + )?.map(({ contractAddress }) => contractAddress) || [] + + const subAccountOwned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + sub_account: { + account: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + key ? getCodeIdsForKeys(key) : undefined + ) + )?.map(({ contractAddress }) => contractAddress) || [] + + const abstractAccountOwned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + abstract_account: { + address: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + key ? getCodeIdsForKeys(key) : undefined + ) + )?.map(({ contractAddress }) => contractAddress) || [] + + return monarchyOwned.concat(subAccountOwned, abstractAccountOwned) + }, +} diff --git a/src/formulas/formulas/account/index.ts b/src/formulas/formulas/account/index.ts index 1690b43f..934fe8ab 100644 --- a/src/formulas/formulas/account/index.ts +++ b/src/formulas/formulas/account/index.ts @@ -8,3 +8,4 @@ export * as tokens from './tokens' export * as valence from './valence' export * as vesting from './vesting' export * as veto from './veto' +export * as abstractAccount from './abstractAccount' diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index aa8e114e..7ff4b5fe 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -144,13 +144,14 @@ export const moduleInfos: ContractFormula< }, } -export const accountTxs: ContractFormula = { - docs: { - description: '', - }, - compute: async (env) => { - const { contractAddress, getTxEvents } = env - const events = await getTxEvents(contractAddress) - return events ?? [] - }, -} +// TODO: account txs +// export const accountTxs: ContractFormula = { +// docs: { +// description: '', +// }, +// compute: async (env) => { +// const { contractAddress, getTxEvents } = env +// const events = await getTxEvents(contractAddress) +// return events || [] +// }, +// } diff --git a/src/formulas/formulas/contract/abstract/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts index 6392ef00..a9c37616 100644 --- a/src/formulas/formulas/contract/abstract/registry.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -222,20 +222,20 @@ export const listLocalAccounts: ContractFormula { - const [trace_raw, sequence] = dbKeyToKeys(key, [false, true]) - let trace - if (trace_raw === 'local') { - trace = 'local' - } else { - trace = { remote: (trace_raw as string).split('>') } - } + const [trace_raw, sequence] = dbKeyToKeys(key, [false, true]) as [ + string, + number + ] + + const trace = + trace_raw === 'local' ? 'local' : { remote: trace_raw.split('>') } return [ { - seq: sequence as number, + seq: sequence, trace, }, reference, - ] as [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] + ] satisfies [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] } ) return { accounts } diff --git a/src/transformers/transformers/abstract/account.ts b/src/transformers/transformers/abstract/account.ts index 3bf28763..1099a94c 100644 --- a/src/transformers/transformers/abstract/account.ts +++ b/src/transformers/transformers/abstract/account.ts @@ -13,30 +13,4 @@ const AccountStorageKeys = { OWNER: 'ownership', } -const suspended = makeTransformer( - CODE_IDS_KEYS, - 'suspended', - AccountStorageKeys.SUSPENSION_STATUS -) - -const accountId = makeTransformer( - CODE_IDS_KEYS, - 'accountId', - AccountStorageKeys.ACCOUNT_ID -) - -const accountModules = makeTransformerForMap( - CODE_IDS_KEYS, - 'accountModules', - AccountStorageKeys.ACCOUNT_MODULES -) - -const subAccounts = makeTransformerForMap( - CODE_IDS_KEYS, - 'subAccounts', - AccountStorageKeys.SUB_ACCOUNTS -) - -export default [ - // suspended, accountId, accountModules, subAccounts -] +export default [] diff --git a/static/openapi.json b/static/openapi.json index 5374101b..88278945 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -11109,6 +11109,52 @@ } } }, + "/{chainId}/account/{address}/abstractAccount/accountsOwnedBy": { + "get": { + "tags": [ + "account" + ], + "summary": "abstractAccount > accountsOwnedBy", + "description": "retrieves account (that use abstract governance to manage ownership) where the account is the owner", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "account address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "key", + "description": "optional code ID key to filter by", + "required": false, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, "/{chainId}/account/{address}/bank/balance": { "get": { "tags": [ From 500fd31b1f5ff46fdd56bbc528db18de3242f7ac Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:12:37 +0200 Subject: [PATCH 08/29] update module formula --- .../formulas/contract/abstract/account.ts | 21 +++---- .../formulas/contract/abstract/registry.ts | 57 ++++++++++++++----- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index 7ff4b5fe..2bcf882a 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -16,14 +16,9 @@ const AccountStorageKeys = { OWNER: 'ownership', } -// Replace with transformer -function registryAddress(): string { - return loadConfig().abstractRegistry as string -} - export const owner: ContractFormula = { docs: { - description: '', + description: 'Get the owner of the account', }, compute: async ({ contractAddress, get }) => { return ( @@ -39,7 +34,7 @@ export const owner: ContractFormula = { export const accountId: ContractFormula = { docs: { - description: '', + description: 'Get accountId of the account', }, compute: async ({ contractAddress, get }) => { return await get( @@ -51,7 +46,7 @@ export const accountId: ContractFormula = { export const suspensionStatus: ContractFormula = { docs: { - description: '', + description: 'Get suspension status of the account', }, compute: async ({ contractAddress, get }) => { return await get( @@ -63,7 +58,7 @@ export const suspensionStatus: ContractFormula = { export const info: ContractFormula = { docs: { - description: '', + description: 'Get the account info', }, compute: async ({ contractAddress, get }) => { return await get( @@ -75,7 +70,7 @@ export const info: ContractFormula = { export const whitelistedModules: ContractFormula | undefined> = { docs: { - description: '', + description: 'Get a list of whitelisted modules', }, compute: async ({ contractAddress, get }) => { return await get>( @@ -87,7 +82,7 @@ export const whitelistedModules: ContractFormula | undefined> = { export const subAccountIds: ContractFormula = { docs: { - description: '', + description: 'Get sub-accounts owned by this account', }, compute: async ({ contractAddress, getMap }) => { const subAccountsMap = @@ -115,7 +110,7 @@ export const moduleInfos: ContractFormula< > > = { docs: { - description: '', + description: 'Get module infos that are installed on this account', }, compute: async (env) => { const { contractAddress, getMap } = env @@ -126,7 +121,7 @@ export const moduleInfos: ContractFormula< AccountStorageKeys.ACCOUNT_MODULES )) ?? {} - // Query the info from registry + // Query the info from the address of the module return await Promise.all( Object.entries(moduleAddressesMap).map(async ([moduleId, address]) => { const contractInfo = await Common.info.compute({ diff --git a/src/formulas/formulas/contract/abstract/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts index a9c37616..b9427dd9 100644 --- a/src/formulas/formulas/contract/abstract/registry.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -72,7 +72,7 @@ const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { } type ModuleInfoParameter = Omit & { - version: string + version?: string } export const moduleConfig: ContractFormula< @@ -80,7 +80,7 @@ export const moduleConfig: ContractFormula< ModuleInfoParameter > = { docs: { - description: 'Configuration of the module installation huh', + description: 'Configuration of the module installation', args: [ { name: 'name', @@ -101,7 +101,7 @@ export const moduleConfig: ContractFormula< { name: 'version', description: 'semver version of the module', - // TODO: it's possible to make it false with transformer and saving latest version of the module + // We force version here required: true, schema: { type: 'string', @@ -158,7 +158,33 @@ export const module: ContractFormula< ModuleInfoParameter > = { docs: { - description: 'Module info', + description: 'Module details', + args: [ + { + name: 'name', + description: 'name of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'namespace', + description: 'namespace of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'version', + description: 'semver version of the module', + required: false, + schema: { + type: 'string', + }, + }, + ], }, compute: async (env) => { const { args } = env @@ -173,7 +199,7 @@ export const module: ContractFormula< } ) - let foundModule = undefined + let foundModule: Module | undefined // Find the latest version of the module if (!moduleParam.version || moduleParam.version === 'latest') { @@ -186,16 +212,21 @@ export const module: ContractFormula< } ) foundModule = sortedVersions[sortedVersions.length - 1] + } else { + // Get the proper module version + foundModule = filteredModules.find( + ({ info: { version } }) => + (typeof version === 'string' ? version : version.version) === + (moduleParam as { version: string }).version + ) } - // Get the proper module version - foundModule = filteredModules.find( - ({ info: { version } }) => - (typeof version === 'string' ? version : version.version) === - (moduleParam as { version: string }).version - ) - - const foundConfig = await moduleConfig.compute(env) + // Maybe we found latest already so let's use it + const version = foundModule?.info.version as { version: string } + const foundConfig = await moduleConfig.compute({ + ...env, + ...{ args: { version: version.version, ...args } }, + }) return ( foundModule && From 2946b4333e3a67ab64ac26451e15ddd67df4dad5 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:14:47 +0200 Subject: [PATCH 09/29] openapi update --- static/openapi.json | 82 +++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/static/openapi.json b/static/openapi.json index 88278945..b2ee1449 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -38,41 +38,7 @@ "contract" ], "summary": "account > accountId", - "description": "`account/accountId`", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "success" - } - } - } - }, - "/{chainId}/contract/{address}/account/accountTxs": { - "get": { - "tags": [ - "contract" - ], - "summary": "account > accountTxs", - "description": "`account/accountTxs`", + "description": "Get accountId of the account", "parameters": [ { "name": "chainId", @@ -106,7 +72,7 @@ "contract" ], "summary": "account > info", - "description": "`account/info`", + "description": "Get the account info", "parameters": [ { "name": "chainId", @@ -140,7 +106,7 @@ "contract" ], "summary": "account > moduleInfos", - "description": "`account/moduleInfos`", + "description": "Get module infos that are installed on this account", "parameters": [ { "name": "chainId", @@ -174,7 +140,7 @@ "contract" ], "summary": "account > owner", - "description": "`account/owner`", + "description": "Get the owner of the account", "parameters": [ { "name": "chainId", @@ -208,7 +174,7 @@ "contract" ], "summary": "account > subAccountIds", - "description": "`account/subAccountIds`", + "description": "Get sub-accounts owned by this account", "parameters": [ { "name": "chainId", @@ -242,7 +208,7 @@ "contract" ], "summary": "account > suspensionStatus", - "description": "`account/suspensionStatus`", + "description": "Get suspension status of the account", "parameters": [ { "name": "chainId", @@ -276,7 +242,7 @@ "contract" ], "summary": "account > whitelistedModules", - "description": "`account/whitelistedModules`", + "description": "Get a list of whitelisted modules", "parameters": [ { "name": "chainId", @@ -10619,7 +10585,7 @@ "contract" ], "summary": "registry > module", - "description": "Module info", + "description": "Module details", "parameters": [ { "name": "chainId", @@ -10638,11 +10604,41 @@ "schema": { "type": "string" } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": false, + "schema": { + "type": "string" + }, + "in": "query" } ], "responses": { "200": { "description": "success" + }, + "400": { + "description": "missing required arguments" } } } @@ -10653,7 +10649,7 @@ "contract" ], "summary": "registry > moduleConfig", - "description": "Configuration of the module installation huh", + "description": "Configuration of the module installation", "parameters": [ { "name": "chainId", From 1672739867549d5546cfcdaedaf9e4bf1e0ff9fc Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:18:00 +0200 Subject: [PATCH 10/29] dodged transformers --- .../transformers/abstract/account.ts | 16 ---------------- src/transformers/transformers/abstract/index.ts | 3 --- src/transformers/transformers/index.ts | 2 -- 3 files changed, 21 deletions(-) delete mode 100644 src/transformers/transformers/abstract/account.ts delete mode 100644 src/transformers/transformers/abstract/index.ts diff --git a/src/transformers/transformers/abstract/account.ts b/src/transformers/transformers/abstract/account.ts deleted file mode 100644 index 1099a94c..00000000 --- a/src/transformers/transformers/abstract/account.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { makeTransformer, makeTransformerForMap } from '@/transformers/utils' - -const CODE_IDS_KEYS = ['abstract-account'] - -const AccountStorageKeys = { - SUSPENSION_STATUS: 'aa', - INFO: 'ab', - ACCOUNT_MODULES: 'ac', - DEPENDENTS: 'ad', - SUB_ACCOUNTS: 'ae', - WHITELISTED_MODULES: 'af', - ACCOUNT_ID: 'ag', - OWNER: 'ownership', -} - -export default [] diff --git a/src/transformers/transformers/abstract/index.ts b/src/transformers/transformers/abstract/index.ts deleted file mode 100644 index f340c476..00000000 --- a/src/transformers/transformers/abstract/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import account from './account' - -export default [...account] diff --git a/src/transformers/transformers/index.ts b/src/transformers/transformers/index.ts index 004ad5e9..63d19b19 100644 --- a/src/transformers/transformers/index.ts +++ b/src/transformers/transformers/index.ts @@ -8,7 +8,6 @@ import { TransformerMaker, } from '@/types' -import abstract from './abstract' import common from './common' import dao from './dao' import distribution from './distribution' @@ -41,7 +40,6 @@ export const getProcessedTransformers = ( ...staking, ...valence, ...voting, - ...abstract, // Makers. ...transformerMakers.map((maker) => maker(config)), From 4925996c7356206d3b4d12e32b1a105a4d13651b Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:19:41 +0200 Subject: [PATCH 11/29] cleanup --- src/transformers/utils.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/transformers/utils.ts b/src/transformers/utils.ts index d1508407..5295ddf0 100644 --- a/src/transformers/utils.ts +++ b/src/transformers/utils.ts @@ -23,23 +23,6 @@ export const makeTransformer = ( } } -export const makeAddressTransformer = ( - contractAddresses: string[], - name: string, - keyOrKeys?: string | string[] -): Transformer => { - const dbKeys = [keyOrKeys || name].flat().map((key) => dbKeyForKeys(key)) - - return { - filter: { - contractAddresses, - matches: (event) => dbKeys.includes(event.key), - }, - name, - getValue: defaultGetValue, - } -} - interface TransformerForMapOptions { numericKey?: boolean getValue?: Transformer['getValue'] From 7cf23b84422f102c4fce817f86dc5c54d3f50542 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 14:19:53 +0200 Subject: [PATCH 12/29] rename api path --- config.json.example | 1 - .../formulas/contract/abstract/index.ts | 4 +- static/openapi.json | 420 +++++++++--------- 3 files changed, 212 insertions(+), 213 deletions(-) diff --git a/config.json.example b/config.json.example index 2d5a7a39..1c0ce1e2 100644 --- a/config.json.example +++ b/config.json.example @@ -37,7 +37,6 @@ "polytone-note": [], "polytone-voice": [], "valence-account": [], - "abstract:account": [7693], }, "daoDaoBase": "https://testnet.daodao.zone", "discordNotifierApiKey": "key", diff --git a/src/formulas/formulas/contract/abstract/index.ts b/src/formulas/formulas/contract/abstract/index.ts index fd19b39d..4f093f70 100644 --- a/src/formulas/formulas/contract/abstract/index.ts +++ b/src/formulas/formulas/contract/abstract/index.ts @@ -1,2 +1,2 @@ -export * as account from './account' -export * as registry from './registry' +export * as abstractAccount from './account' +export * as abstractRegistry from './registry' diff --git a/static/openapi.json b/static/openapi.json index b2ee1449..5dd96dc0 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -32,12 +32,12 @@ } ], "paths": { - "/{chainId}/contract/{address}/account/accountId": { + "/{chainId}/contract/{address}/abstractAccount/accountId": { "get": { "tags": [ "contract" ], - "summary": "account > accountId", + "summary": "abstractAccount > accountId", "description": "Get accountId of the account", "parameters": [ { @@ -66,12 +66,12 @@ } } }, - "/{chainId}/contract/{address}/account/info": { + "/{chainId}/contract/{address}/abstractAccount/info": { "get": { "tags": [ "contract" ], - "summary": "account > info", + "summary": "abstractAccount > info", "description": "Get the account info", "parameters": [ { @@ -100,12 +100,12 @@ } } }, - "/{chainId}/contract/{address}/account/moduleInfos": { + "/{chainId}/contract/{address}/abstractAccount/moduleInfos": { "get": { "tags": [ "contract" ], - "summary": "account > moduleInfos", + "summary": "abstractAccount > moduleInfos", "description": "Get module infos that are installed on this account", "parameters": [ { @@ -134,12 +134,12 @@ } } }, - "/{chainId}/contract/{address}/account/owner": { + "/{chainId}/contract/{address}/abstractAccount/owner": { "get": { "tags": [ "contract" ], - "summary": "account > owner", + "summary": "abstractAccount > owner", "description": "Get the owner of the account", "parameters": [ { @@ -168,12 +168,12 @@ } } }, - "/{chainId}/contract/{address}/account/subAccountIds": { + "/{chainId}/contract/{address}/abstractAccount/subAccountIds": { "get": { "tags": [ "contract" ], - "summary": "account > subAccountIds", + "summary": "abstractAccount > subAccountIds", "description": "Get sub-accounts owned by this account", "parameters": [ { @@ -202,12 +202,12 @@ } } }, - "/{chainId}/contract/{address}/account/suspensionStatus": { + "/{chainId}/contract/{address}/abstractAccount/suspensionStatus": { "get": { "tags": [ "contract" ], - "summary": "account > suspensionStatus", + "summary": "abstractAccount > suspensionStatus", "description": "Get suspension status of the account", "parameters": [ { @@ -236,12 +236,12 @@ } } }, - "/{chainId}/contract/{address}/account/whitelistedModules": { + "/{chainId}/contract/{address}/abstractAccount/whitelistedModules": { "get": { "tags": [ "contract" ], - "summary": "account > whitelistedModules", + "summary": "abstractAccount > whitelistedModules", "description": "Get a list of whitelisted modules", "parameters": [ { @@ -270,6 +270,202 @@ } } }, + "/{chainId}/contract/{address}/abstractRegistry/listLocalAccounts": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > listLocalAccounts", + "description": "Lists local accounts on chain", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/abstractRegistry/listRegisteredModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > listRegisteredModules", + "description": "Lists registered modules in registry", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/abstractRegistry/module": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > module", + "description": "Module details", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": false, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, + "/{chainId}/contract/{address}/abstractRegistry/moduleConfig": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > moduleConfig", + "description": "Configuration of the module installation", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, "/{chainId}/contract/{address}/cw1Whitelist/adminList": { "get": { "tags": [ @@ -10511,202 +10707,6 @@ } } }, - "/{chainId}/contract/{address}/registry/listLocalAccounts": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > listLocalAccounts", - "description": "Lists local accounts on chain", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "success" - } - } - } - }, - "/{chainId}/contract/{address}/registry/listRegisteredModules": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > listRegisteredModules", - "description": "Lists registered modules in registry", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "success" - } - } - } - }, - "/{chainId}/contract/{address}/registry/module": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > module", - "description": "Module details", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "description": "name of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "namespace", - "description": "namespace of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "version", - "description": "semver version of the module", - "required": false, - "schema": { - "type": "string" - }, - "in": "query" - } - ], - "responses": { - "200": { - "description": "success" - }, - "400": { - "description": "missing required arguments" - } - } - } - }, - "/{chainId}/contract/{address}/registry/moduleConfig": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > moduleConfig", - "description": "Configuration of the module installation", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "description": "name of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "namespace", - "description": "namespace of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "version", - "description": "semver version of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - } - ], - "responses": { - "200": { - "description": "success" - }, - "400": { - "description": "missing required arguments" - } - } - } - }, "/{chainId}/contract/{address}/valence/account/admin": { "get": { "tags": [ From 208b0f1d1674aa5a3549b86219b9f6be8b52802b Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Fri, 20 Dec 2024 18:27:12 -0500 Subject: [PATCH 13/29] optimized abstractAccount/accountsOwnedBy query --- .../formulas/account/abstractAccount.ts | 57 ++++++++----------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/src/formulas/formulas/account/abstractAccount.ts b/src/formulas/formulas/account/abstractAccount.ts index f5b3b706..07126636 100644 --- a/src/formulas/formulas/account/abstractAccount.ts +++ b/src/formulas/formulas/account/abstractAccount.ts @@ -1,4 +1,7 @@ +import { Op } from 'sequelize' + import { AccountFormula } from '@/types' + import { AccountTypes } from '../contract/abstract/types' /** @@ -35,48 +38,34 @@ export const accountsOwnedBy: AccountFormula< getCodeIdsForKeys, } = env - const monarchyOwned = - ( - await getTransformationMatches( - undefined, - 'owner', - { - monarchy: { - monarch: address, - }, - } satisfies AccountTypes.GovernanceDetailsForString, - key ? getCodeIdsForKeys(key) : undefined - ) - )?.map(({ contractAddress }) => contractAddress) || [] - - const subAccountOwned = - ( - await getTransformationMatches( - undefined, - 'owner', - { - sub_account: { - account: address, - }, - } satisfies AccountTypes.GovernanceDetailsForString, - key ? getCodeIdsForKeys(key) : undefined - ) - )?.map(({ contractAddress }) => contractAddress) || [] - - const abstractAccountOwned = + const owned = ( await getTransformationMatches( undefined, 'owner', { - abstract_account: { - address: address, - }, - } satisfies AccountTypes.GovernanceDetailsForString, + [Op.or]: [ + { + monarchy: { + monarch: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + { + sub_account: { + account: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + { + abstract_account: { + address: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + ], + }, key ? getCodeIdsForKeys(key) : undefined ) )?.map(({ contractAddress }) => contractAddress) || [] - return monarchyOwned.concat(subAccountOwned, abstractAccountOwned) + return owned }, } From cbe05d0ea0e4957c4c00821d0c332c03bd645eb4 Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:43:55 +0200 Subject: [PATCH 14/29] Initial abstract manager implementation --- package-lock.json | 2 + package.json | 2 + .../formulas/contract/abstract/manager.ts | 60 ++++ .../formulas/contract/abstract/types/index.ts | 2 + .../contract/abstract/types/manager.ts | 289 ++++++++++++++++++ .../contract/abstract/types/versionControl.ts | 213 +++++++++++++ .../contract/abstract/versionControl.ts | 229 ++++++++++++++ .../transformers/abstract/manager.ts | 0 8 files changed, 797 insertions(+) create mode 100644 src/formulas/formulas/contract/abstract/manager.ts create mode 100644 src/formulas/formulas/contract/abstract/types/index.ts create mode 100644 src/formulas/formulas/contract/abstract/types/manager.ts create mode 100644 src/formulas/formulas/contract/abstract/types/versionControl.ts create mode 100644 src/formulas/formulas/contract/abstract/versionControl.ts create mode 100644 src/transformers/transformers/abstract/manager.ts diff --git a/package-lock.json b/package-lock.json index c85215c6..4f267375 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "pg-hstore": "^2.3.4", "pusher": "^5.1.2", "reflect-metadata": "^0.1.13", + "semver": "^7.6.2", "sequelize": "^6.26.0", "sequelize-typescript": "^2.1.5", "supertest": "^6.3.3", @@ -68,6 +69,7 @@ "@types/node": "^18.11.10", "@types/prettier": "^2.7.1", "@types/redis-info": "^3.0.1", + "@types/semver": "^7.5.8", "@types/supertest": "^2.0.12", "@types/validator": "^13.7.10", "@types/ws": "^8.5.5", diff --git a/package.json b/package.json index ccd080a0..2b10b8be 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@types/node": "^18.11.10", "@types/prettier": "^2.7.1", "@types/redis-info": "^3.0.1", + "@types/semver": "^7.5.8", "@types/supertest": "^2.0.12", "@types/validator": "^13.7.10", "@types/ws": "^8.5.5", @@ -118,6 +119,7 @@ "pg-hstore": "^2.3.4", "pusher": "^5.1.2", "reflect-metadata": "^0.1.13", + "semver": "^7.6.2", "sequelize": "^6.26.0", "sequelize-typescript": "^2.1.5", "supertest": "^6.3.3", diff --git a/src/formulas/formulas/contract/abstract/manager.ts b/src/formulas/formulas/contract/abstract/manager.ts new file mode 100644 index 00000000..60b1d47e --- /dev/null +++ b/src/formulas/formulas/contract/abstract/manager.ts @@ -0,0 +1,60 @@ +import { ContractFormula } from '@/types' + +import { ManagerTypes } from './types' + +export const owner: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return ( + (await get(contractAddress, 'ownership')) + ?.owner ?? undefined + ) + }, +} + +export const accountId: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return await get(contractAddress, 'acc_id') + }, +} + +export const suspensionStatus: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return await get(contractAddress, 'is_suspended') + }, +} + +export const config: ContractFormula = + { + compute: async (env) => { + const { contractAddress, get } = env + const accId = await accountId.compute(env) + const isSuspended = await suspensionStatus.compute(env) + + const config = await get< + Pick< + ManagerTypes.ConfigResponse, + 'version_control_address' | 'module_factory_address' + > + >(contractAddress, 'config') + + return ( + accId && + config && { + account_id: accId, + is_suspended: isSuspended ?? false, + ...config, + } + ) + }, + } + +export const moduleInfos: ContractFormula = { + compute: async (env) => { + const { contractAddress, getMap } = env + + const versionControl = await config.compute(env).then(res => res?.version_control_address) + + const modulesMap = + (await getMap(contractAddress, 'modules')) ?? {} + }, +} diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts new file mode 100644 index 00000000..99a8833a --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -0,0 +1,2 @@ +export * as ManagerTypes from './manager' +export * as VersionControlTypes from './versionControl' diff --git a/src/formulas/formulas/contract/abstract/types/manager.ts b/src/formulas/formulas/contract/abstract/types/manager.ts new file mode 100644 index 00000000..b3d016e4 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/manager.ts @@ -0,0 +1,289 @@ +/** + * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @abstract-money/ts-codegen generate command to regenerate this file. + */ +export type AccountTrace = + | 'local' + | { + remote: ChainName[] + } +export type ChainName = string +export type Binary = string +export type Namespace = string +export type ModuleVersion = + | 'latest' + | { + version: string + } +export type GovernanceDetailsForString = + | { + Monarchy: { + monarch: string + [k: string]: unknown + } + } + | { + SubAccount: { + manager: string + proxy: string + [k: string]: unknown + } + } + | { + External: { + governance_address: string + governance_type: string + [k: string]: unknown + } + } +export interface InstantiateMsg { + account_id: AccountId + description?: string | null + install_modules: ModuleInstallConfig[] + link?: string | null + module_factory_address: string + name: string + owner: GovernanceDetailsForString + version_control_address: string +} +export interface AccountId { + seq: number + trace: AccountTrace +} +export interface ModuleInstallConfig { + init_msg?: Binary | null + module: ModuleInfo +} +export interface ModuleInfo { + name: string + namespace: Namespace + version: ModuleVersion +} +export type ExecuteMsg = + | { + exec_on_module: { + exec_msg: Binary + module_id: string + } + } + | { + update_internal_config: Binary + } + | { + install_modules: { + modules: ModuleInstallConfig[] + } + } + | { + register_modules: { + modules: RegisterModuleData[] + } + } + | { + uninstall_module: { + module_id: string + } + } + | { + upgrade: { + modules: [ModuleInfo, Binary | null][] + } + } + | { + create_sub_account: { + base_asset?: AssetEntry | null + description?: string | null + install_modules: ModuleInstallConfig[] + link?: string | null + name: string + namespace?: string | null + } + } + | { + update_info: { + description?: string | null + link?: string | null + name?: string | null + } + } + | { + set_owner: { + owner: GovernanceDetailsForString + } + } + | { + update_status: { + is_suspended?: boolean | null + } + } + | { + update_settings: { + ibc_enabled?: boolean | null + } + } + | { + update_sub_account: UpdateSubAccountAction + } + | { + callback: CallbackMsg + } + | { + update_ownership: Action + } +export type ModuleReference = + | { + account_base: number + } + | { + native: Addr + } + | { + adapter: Addr + } + | { + app: number + } + | { + standalone: number + } +export type Addr = string +export type AssetEntry = string +export type UpdateSubAccountAction = + | { + unregister_sub_account: { + id: number + } + } + | { + register_sub_account: { + id: number + } + } +export type Action = + | { + transfer_ownership: { + expiry?: Expiration | null + new_owner: string + } + } + | 'accept_ownership' + | 'renounce_ownership' +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type Timestamp = Uint64 +export type Uint64 = string +export interface RegisterModuleData { + module: Module + module_address: string +} +export interface Module { + info: ModuleInfo + reference: ModuleReference +} +export interface CallbackMsg {} +export type QueryMsg = + | { + module_versions: { + ids: string[] + } + } + | { + module_addresses: { + ids: string[] + } + } + | { + module_infos: { + limit?: number | null + start_after?: string | null + } + } + | { + config: {} + } + | { + info: {} + } + | { + sub_account_ids: { + limit?: number | null + start_after?: number | null + } + } + | { + ownership: {} + } +export interface MigrateMsg {} +export interface ConfigResponse { + account_id: AccountId + is_suspended: boolean + module_factory_address: Addr + version_control_address: Addr +} +export type GovernanceDetailsForAddr = + | { + Monarchy: { + monarch: Addr + [k: string]: unknown + } + } + | { + SubAccount: { + manager: Addr + proxy: Addr + [k: string]: unknown + } + } + | { + External: { + governance_address: Addr + governance_type: string + [k: string]: unknown + } + } +export interface InfoResponse { + info: AccountInfoForAddr +} +export interface AccountInfoForAddr { + chain_id: string + description?: string | null + governance_details: GovernanceDetailsForAddr + link?: string | null + name: string +} +export interface ModuleAddressesResponse { + modules: [string, Addr][] +} +export interface ModuleInfosResponse { + module_infos: ManagerModuleInfo[] +} +export interface ManagerModuleInfo { + address: Addr + id: string + version: ContractVersion +} +export interface ContractVersion { + contract: string + version: string +} +export interface ModuleVersionsResponse { + versions: ContractVersion[] +} +export interface OwnershipForString { + owner?: string | null + pending_expiry?: Expiration | null + pending_owner?: string | null +} +export interface SubAccountIdsResponse { + sub_accounts: number[] +} +//# sourceMappingURL=Manager.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/types/versionControl.ts b/src/formulas/formulas/contract/abstract/types/versionControl.ts new file mode 100644 index 00000000..e93b3e5d --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/versionControl.ts @@ -0,0 +1,213 @@ +/** + * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @abstract-money/ts-codegen generate command to regenerate this file. + */ +export type Uint128 = string; +export interface InstantiateMsg { + admin: string; + allow_direct_module_registration_and_updates?: boolean | null; + namespace_registration_fee?: Coin | null; +} +export interface Coin { + amount: Uint128; + denom: string; + [k: string]: unknown; +} +export type ExecuteMsg = { + remove_module: { + module: ModuleInfo; + }; +} | { + yank_module: { + module: ModuleInfo; + }; +} | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][]; + }; +} | { + update_module_configuration: { + module_name: string; + namespace: Namespace; + update_module: UpdateModule; + }; +} | { + approve_or_reject_modules: { + approves: ModuleInfo[]; + rejects: ModuleInfo[]; + }; +} | { + claim_namespace: { + account_id: AccountId; + namespace: string; + }; +} | { + remove_namespaces: { + namespaces: string[]; + }; +} | { + add_account: { + account_base: AccountBase; + account_id: AccountId; + }; +} | { + update_config: { + allow_direct_module_registration_and_updates?: boolean | null; + namespace_registration_fee?: Coin | null; + }; +} | { + set_factory: { + new_factory: string; + }; +} | { + update_ownership: Action; +}; +export type Namespace = string; +export type ModuleVersion = "latest" | { + version: string; +}; +export type ModuleReference = { + account_base: number; +} | { + native: Addr; +} | { + adapter: Addr; +} | { + app: number; +} | { + standalone: number; +}; +export type Addr = string; +export type UpdateModule = { + default: { + metadata: string; + }; +} | { + versioned: { + instantiation_funds?: Coin[] | null; + metadata?: string | null; + monetization?: Monetization | null; + version: string; + }; +}; +export type Monetization = "none" | { + install_fee: FixedFee; +}; +export type AccountTrace = "local" | { + remote: ChainName[]; +}; +export type ChainName = string; +export type Action = { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: string; + }; +} | "accept_ownership" | "renounce_ownership"; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp; +} | { + never: {}; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export interface ModuleInfo { + name: string; + namespace: Namespace; + version: ModuleVersion; +} +export interface FixedFee { + fee: Coin; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export interface AccountBase { + manager: Addr; + proxy: Addr; +} +export type QueryMsg = { + account_base: { + account_id: AccountId; + }; +} | { + modules: { + infos: ModuleInfo[]; + }; +} | { + namespaces: { + accounts: AccountId[]; + }; +} | { + namespace: { + namespace: Namespace; + }; +} | { + config: {}; +} | { + module_list: { + filter?: ModuleFilter | null; + limit?: number | null; + start_after?: ModuleInfo | null; + }; +} | { + namespace_list: { + limit?: number | null; + start_after?: string | null; + }; +} | { + ownership: {}; +}; +export type ModuleStatus = "r_e_g_i_s_t_e_r_e_d" | "p_e_n_d_i_n_g" | "y_a_n_k_e_d"; +export interface ModuleFilter { + name?: string | null; + namespace?: string | null; + status?: ModuleStatus | null; + version?: string | null; +} +export interface MigrateMsg { +} +export interface AccountBaseResponse { + account_base: AccountBase; +} +export interface ConfigResponse { + factory: Addr; +} +export interface ModulesListResponse { + modules: ModuleResponse[]; +} +export interface ModuleResponse { + config: ModuleConfiguration; + module: Module; +} +export interface ModuleConfiguration { + instantiation_funds: Coin[]; + metadata?: string | null; + monetization: Monetization; +} +export interface Module { + info: ModuleInfo; + reference: ModuleReference; +} +export interface ModulesResponse { + modules: ModuleResponse[]; +} +export interface NamespaceResponse { + account_base: AccountBase; + account_id: AccountId; +} +export interface NamespaceListResponse { + namespaces: [Namespace, AccountId][]; +} +export interface NamespacesResponse { + namespaces: [Namespace, AccountId][]; +} +export interface OwnershipForString { + owner?: string | null; + pending_expiry?: Expiration | null; + pending_owner?: string | null; +} +//# sourceMappingURL=VersionControl.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/versionControl.ts b/src/formulas/formulas/contract/abstract/versionControl.ts new file mode 100644 index 00000000..91b0d623 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/versionControl.ts @@ -0,0 +1,229 @@ +/* + pub const CONFIG: Item = Item::new("cfg"); + + // Modules waiting for approvals + pub const PENDING_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("pendm"); + // We can iterate over the map giving just the prefix to get all the versions + pub const REGISTERED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("lib"); + // Reverse map for module info of standalone modules + pub const STANDALONE_INFOS: Map = Map::new("stli"); + // Yanked Modules + pub const YANKED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("yknd"); + // Modules Configuration + pub const MODULE_CONFIG: Map<&ModuleInfo, ModuleConfiguration> = Map::new("cfg"); + // Modules Default Configuration + pub const MODULE_DEFAULT_CONFIG: Map<(&Namespace, &str), ModuleDefaultConfiguration> = + Map::new("dcfg"); + /// Maps Account ID to the address of its core contracts + pub const ACCOUNT_ADDRESSES: Map<&AccountId, AccountBase> = Map::new("accs"); + +pub fn handle_modules_query(deps: Deps, modules: Vec) -> StdResult { + let mut modules_response = ModulesResponse { modules: vec![] }; + for mut module in modules { + let maybe_module_ref = if let ModuleVersion::Version(_) = module.version { + REGISTERED_MODULES.load(deps.storage, &module) + } else { + // get latest + let versions: StdResult> = REGISTERED_MODULES + .prefix((module.namespace.clone(), module.name.clone())) + .range(deps.storage, None, None, Order::Descending) + .take(1) + .collect(); + let (latest_version, id) = versions? + .first() + .ok_or_else(|| StdError::GenericErr { + msg: VCError::ModuleNotFound(module.clone()).to_string(), + })? + .clone(); + module.version = ModuleVersion::Version(latest_version); + Ok(id) + }; + + match maybe_module_ref { + Err(_) => Err(StdError::generic_err( + VCError::ModuleNotFound(module).to_string(), + )), + Ok(mod_ref) => { + modules_response.modules.push(ModuleResponse { + module: Module { + info: module.clone(), + reference: mod_ref, + }, + config: ModuleConfiguration::from_storage(deps.storage, &module)?, + }); + Ok(()) + } + }?; + } + + Ok(modules_response) +} + */ + +import semver from 'semver/preload' + +import { Module } from '@/formulas/formulas/contract/abstract/types/versionControl' +import { ContractFormula } from '@/types' +import { dbKeyForKeys, dbKeyToKeys } from '@/utils' + +import { VersionControlTypes } from './types' + +const VersionControlStorageKeys = { + CONFIG: 'cfg', + PENDING_MODULES: 'pendm', + REGISTERED_MODULES: 'lib', + STANDALONE_INFOS: 'stli', + YANKED_MODULES: 'yknd', + MODULE_CONFIG: 'cfg', + MODULE_DEFAULT_CONFIG: 'dcfg', + ACCOUNT_ADDRESSES: 'accs', +} + +export const registeredModules: ContractFormula> = { + compute: async ({ contractAddress, getMap }) => { + const registeredModulesMap = + (await getMap( + contractAddress, + VersionControlStorageKeys.REGISTERED_MODULES, + { keyType: 'raw' } + )) ?? {} + + return Object.entries(registeredModulesMap).map(([key, reference]) => { + const [namespace, name, version] = dbKeyToKeys(key, [ + false, + false, + false, + ]) as string[] + + const info: VersionControlTypes.ModuleInfo = { + namespace, + name, + version: { version }, + } + return { + info, + reference, + } + }) + }, +} + +const moduleInfoToKey = ({ + namespace, + name, + version, +}: VersionControlTypes.ModuleInfo | ModuleInfoParameter): string => { + const versionKey = version + ? typeof version === 'string' + ? version + : version.version + : 'latest' + return dbKeyForKeys(namespace, name, versionKey) +} + +const DEFAULT_MODULE_CONFIG: VersionControlTypes.ModuleConfiguration = { + monetization: 'none', + instantiation_funds: [], +} + +type ModuleInfoParameter = Omit & { + version?: string +} + +export const moduleConfig: ContractFormula< + VersionControlTypes.ModuleConfiguration | undefined, + ModuleInfoParameter +> = { + compute: async ({ contractAddress, getMap, args }) => { + if (!args || !args.name || !args.namespace) return undefined + const moduleInfo: VersionControlTypes.ModuleInfo = { + namespace: args.namespace, + name: args.name, + version: args.version ? { version: args.version } : 'latest', + } + + const versionedConfigMap = + (await getMap( + contractAddress, + VersionControlStorageKeys.CONFIG, + { + keyType: 'raw', + } + )) ?? {} + + const moduleConfig = + versionedConfigMap[moduleInfoToKey(moduleInfo)] ?? DEFAULT_MODULE_CONFIG + + if (moduleConfig.metadata) { + return moduleConfig + } + + const defaultConfigMap = + (await getMap( + contractAddress, + VersionControlStorageKeys.MODULE_DEFAULT_CONFIG, + { + keyType: 'raw', + } + )) ?? {} + + let moduleDefaultConfig = + defaultConfigMap[dbKeyForKeys(args.namespace, args.name)] + + return { + ...moduleConfig, + metadata: moduleDefaultConfig?.metadata, + } + }, +} + +export const module: ContractFormula< + VersionControlTypes.ModuleResponse | undefined, + ModuleInfoParameter +> = { + compute: async (env) => { + const { args } = env + if (!args || !args.namespace || !args.name) return undefined + const moduleParam = args as ModuleInfoParameter + + const registeredModuleList = await registeredModules.compute(env) + + const filteredModules = registeredModuleList.filter( + ({ info: { name, namespace } }) => { + return namespace === moduleParam.namespace && name === moduleParam.name + } + ) + + let foundModule = undefined + + // Find the latest version of the module + if (!moduleParam.version || moduleParam.version === 'latest') { + const sortedVersions = filteredModules.sort( + ({ info: { version: versionA } }, { info: { version: versionB } }) => { + if (typeof versionA === 'string' || typeof versionB === 'string') { + throw new Error('Cannot compare "latest" versions') + } + return semver.compare(versionA.version, versionB.version) + } + ) + foundModule = sortedVersions[sortedVersions.length - 1] + } + + // Get the proper module version + foundModule = filteredModules.find( + ({ info: { version } }) => + (typeof version === 'string' ? version : version.version) === + (moduleParam as { version: string }).version + ) + + const foundConfig = await moduleConfig.compute(env) + + return ( + foundModule && + foundConfig && { + module: foundModule, + config: foundConfig, + } + ) + }, +} diff --git a/src/transformers/transformers/abstract/manager.ts b/src/transformers/transformers/abstract/manager.ts new file mode 100644 index 00000000..e69de29b From 8b0ced3348c3ac173276527b77674b1a6976f410 Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:22:51 +0200 Subject: [PATCH 15/29] Updtae manager with moduleInfos --- .../formulas/contract/abstract/manager.ts | 118 +++++- .../contract/abstract/types/versionControl.ts | 386 ++++++++++-------- .../contract/abstract/versionControl.ts | 50 +-- 3 files changed, 326 insertions(+), 228 deletions(-) diff --git a/src/formulas/formulas/contract/abstract/manager.ts b/src/formulas/formulas/contract/abstract/manager.ts index 60b1d47e..888ca8f4 100644 --- a/src/formulas/formulas/contract/abstract/manager.ts +++ b/src/formulas/formulas/contract/abstract/manager.ts @@ -1,25 +1,77 @@ import { ContractFormula } from '@/types' +import * as Common from '../common' import { ManagerTypes } from './types' +/* + /// Suspension status + pub const SUSPENSION_STATUS: Item = Item::new("\u{0}{12}is_suspended"); + /// Configuration + pub const CONFIG: Item = Item::new("\u{0}{6}config"); + /// Info about the Account + pub const INFO: Item> = Item::new("\u{0}{4}info"); + /// Account owner - managed by cw-ownable + pub const OWNER: Item> = Item::new(OWNERSHIP_STORAGE_KEY); + /// Enabled Abstract modules + pub const ACCOUNT_MODULES: Map = Map::new("modules"); + /// Stores the dependency relationship between modules + /// map module -> modules that depend on module. + pub const DEPENDENTS: Map> = Map::new("dependents"); + /// List of sub-accounts + pub const SUB_ACCOUNTS: Map = Map::new("sub_accs"); + /// Pending new governance + pub const PENDING_GOVERNANCE: Item> = Item::new("pgov"); + /// Context for old adapters that are currently removing authorized addresses + pub const REMOVE_ADAPTER_AUTHORIZED_CONTEXT: Item = Item::new("rm_a_auth"); +} + */ + +const ManagerStorageKeys = { + CONFIG: 'config', + INFO: 'info', + OWNER: 'ownership', + ACCOUNT_MODULES: 'modules', + SUB_ACCOUNTS: 'sub_accs', + IS_SUSPENDED: 'is_suspended', + ACCOUNT_ID: 'acc_id', +} + export const owner: ContractFormula = { compute: async ({ contractAddress, get }) => { return ( - (await get(contractAddress, 'ownership')) - ?.owner ?? undefined + ( + await get( + contractAddress, + ManagerStorageKeys.OWNER + ) + )?.owner ?? undefined ) }, } export const accountId: ContractFormula = { compute: async ({ contractAddress, get }) => { - return await get(contractAddress, 'acc_id') + return await get( + contractAddress, + ManagerStorageKeys.ACCOUNT_ID + ) }, } export const suspensionStatus: ContractFormula = { compute: async ({ contractAddress, get }) => { - return await get(contractAddress, 'is_suspended') + return await get(contractAddress, ManagerStorageKeys.IS_SUSPENDED) + }, +} + +export const info: ContractFormula< + ManagerTypes.AccountInfoForAddr | undefined +> = { + compute: async ({ contractAddress, get }) => { + return await get( + contractAddress, + ManagerStorageKeys.INFO + ) }, } @@ -48,13 +100,61 @@ export const config: ContractFormula = }, } -export const moduleInfos: ContractFormula = { +export const subAccountIds: ContractFormula = { + compute: async ({ contractAddress, getMap }) => { + const subAccountsMap = + (await getMap( + contractAddress, + ManagerStorageKeys.SUB_ACCOUNTS, + { + keyType: 'number', + } + )) ?? {} + + return Object.keys(subAccountsMap).map((seq) => ({ + trace: 'local', + seq: Number(seq), + })) + }, +} + +export const moduleInfos: ContractFormula< + Array< + Omit< + ManagerTypes.ModuleInfosResponse['module_infos'][number], + 'version' + > & { version: string | undefined } + > +> = { compute: async (env) => { - const { contractAddress, getMap } = env + const { contractAddress, getMap, get } = env - const versionControl = await config.compute(env).then(res => res?.version_control_address) + const versionControlAddr = await config + .compute(env) + .then((res) => res?.version_control_address) - const modulesMap = - (await getMap(contractAddress, 'modules')) ?? {} + if (!versionControlAddr) return [] + + const moduleAddressesMap = + (await getMap( + contractAddress, + ManagerStorageKeys.ACCOUNT_MODULES + )) ?? {} + + // Query the info from + return await Promise.all( + Object.entries(moduleAddressesMap).map(async ([moduleId, address]) => { + const contractInfo = await Common.info.compute({ + ...env, + contractAddress: address, + }) + + return { + id: contractInfo?.contract ?? moduleId, + address, + version: contractInfo?.version, + } + }) + ) }, } diff --git a/src/formulas/formulas/contract/abstract/types/versionControl.ts b/src/formulas/formulas/contract/abstract/types/versionControl.ts index e93b3e5d..7d7a92fa 100644 --- a/src/formulas/formulas/contract/abstract/types/versionControl.ts +++ b/src/formulas/formulas/contract/abstract/types/versionControl.ts @@ -3,211 +3,251 @@ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, * and run the @abstract-money/ts-codegen generate command to regenerate this file. */ -export type Uint128 = string; +export type Uint128 = string export interface InstantiateMsg { - admin: string; - allow_direct_module_registration_and_updates?: boolean | null; - namespace_registration_fee?: Coin | null; + admin: string + allow_direct_module_registration_and_updates?: boolean | null + namespace_registration_fee?: Coin | null } export interface Coin { - amount: Uint128; - denom: string; - [k: string]: unknown; -} -export type ExecuteMsg = { - remove_module: { - module: ModuleInfo; - }; -} | { - yank_module: { - module: ModuleInfo; - }; -} | { - propose_modules: { - modules: [ModuleInfo, ModuleReference][]; - }; -} | { - update_module_configuration: { - module_name: string; - namespace: Namespace; - update_module: UpdateModule; - }; -} | { - approve_or_reject_modules: { - approves: ModuleInfo[]; - rejects: ModuleInfo[]; - }; -} | { - claim_namespace: { - account_id: AccountId; - namespace: string; - }; -} | { - remove_namespaces: { - namespaces: string[]; - }; -} | { - add_account: { - account_base: AccountBase; - account_id: AccountId; - }; -} | { - update_config: { - allow_direct_module_registration_and_updates?: boolean | null; - namespace_registration_fee?: Coin | null; - }; -} | { - set_factory: { - new_factory: string; - }; -} | { - update_ownership: Action; -}; -export type Namespace = string; -export type ModuleVersion = "latest" | { - version: string; -}; -export type ModuleReference = { - account_base: number; -} | { - native: Addr; -} | { - adapter: Addr; -} | { - app: number; -} | { - standalone: number; -}; -export type Addr = string; -export type UpdateModule = { - default: { - metadata: string; - }; -} | { - versioned: { - instantiation_funds?: Coin[] | null; - metadata?: string | null; - monetization?: Monetization | null; - version: string; - }; -}; -export type Monetization = "none" | { - install_fee: FixedFee; -}; -export type AccountTrace = "local" | { - remote: ChainName[]; -}; -export type ChainName = string; -export type Action = { - transfer_ownership: { - expiry?: Expiration | null; - new_owner: string; - }; -} | "accept_ownership" | "renounce_ownership"; -export type Expiration = { - at_height: number; -} | { - at_time: Timestamp; -} | { - never: {}; -}; -export type Timestamp = Uint64; -export type Uint64 = string; + amount: Uint128 + denom: string + [k: string]: unknown +} +export type ExecuteMsg = + | { + remove_module: { + module: ModuleInfo + } + } + | { + yank_module: { + module: ModuleInfo + } + } + | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][] + } + } + | { + update_module_configuration: { + module_name: string + namespace: Namespace + update_module: UpdateModule + } + } + | { + approve_or_reject_modules: { + approves: ModuleInfo[] + rejects: ModuleInfo[] + } + } + | { + claim_namespace: { + account_id: AccountId + namespace: string + } + } + | { + remove_namespaces: { + namespaces: string[] + } + } + | { + add_account: { + account_base: AccountBase + account_id: AccountId + } + } + | { + update_config: { + allow_direct_module_registration_and_updates?: boolean | null + namespace_registration_fee?: Coin | null + } + } + | { + set_factory: { + new_factory: string + } + } + | { + update_ownership: Action + } +export type Namespace = string +export type ModuleVersion = + | 'latest' + | { + version: string + } +export type ModuleReference = + | { + account_base: number + } + | { + native: Addr + } + | { + adapter: Addr + } + | { + app: number + } + | { + standalone: number + } +export type Addr = string +export type UpdateModule = + | { + default: { + metadata: string + } + } + | { + versioned: { + instantiation_funds?: Coin[] | null + metadata?: string | null + monetization?: Monetization | null + version: string + } + } +export type Monetization = + | 'none' + | { + install_fee: FixedFee + } +export type AccountTrace = + | 'local' + | { + remote: ChainName[] + } +export type ChainName = string +export type Action = + | { + transfer_ownership: { + expiry?: Expiration | null + new_owner: string + } + } + | 'accept_ownership' + | 'renounce_ownership' +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type Timestamp = Uint64 +export type Uint64 = string export interface ModuleInfo { - name: string; - namespace: Namespace; - version: ModuleVersion; + name: string + namespace: Namespace + version: ModuleVersion } export interface FixedFee { - fee: Coin; + fee: Coin } export interface AccountId { - seq: number; - trace: AccountTrace; + seq: number + trace: AccountTrace } export interface AccountBase { - manager: Addr; - proxy: Addr; -} -export type QueryMsg = { - account_base: { - account_id: AccountId; - }; -} | { - modules: { - infos: ModuleInfo[]; - }; -} | { - namespaces: { - accounts: AccountId[]; - }; -} | { - namespace: { - namespace: Namespace; - }; -} | { - config: {}; -} | { - module_list: { - filter?: ModuleFilter | null; - limit?: number | null; - start_after?: ModuleInfo | null; - }; -} | { - namespace_list: { - limit?: number | null; - start_after?: string | null; - }; -} | { - ownership: {}; -}; -export type ModuleStatus = "r_e_g_i_s_t_e_r_e_d" | "p_e_n_d_i_n_g" | "y_a_n_k_e_d"; + manager: Addr + proxy: Addr +} +export type QueryMsg = + | { + account_base: { + account_id: AccountId + } + } + | { + modules: { + infos: ModuleInfo[] + } + } + | { + namespaces: { + accounts: AccountId[] + } + } + | { + namespace: { + namespace: Namespace + } + } + | { + config: {} + } + | { + module_list: { + filter?: ModuleFilter | null + limit?: number | null + start_after?: ModuleInfo | null + } + } + | { + namespace_list: { + limit?: number | null + start_after?: string | null + } + } + | { + ownership: {} + } +export type ModuleStatus = + | 'r_e_g_i_s_t_e_r_e_d' + | 'p_e_n_d_i_n_g' + | 'y_a_n_k_e_d' export interface ModuleFilter { - name?: string | null; - namespace?: string | null; - status?: ModuleStatus | null; - version?: string | null; -} -export interface MigrateMsg { + name?: string | null + namespace?: string | null + status?: ModuleStatus | null + version?: string | null } +export interface MigrateMsg {} export interface AccountBaseResponse { - account_base: AccountBase; + account_base: AccountBase } export interface ConfigResponse { - factory: Addr; + factory: Addr } export interface ModulesListResponse { - modules: ModuleResponse[]; + modules: ModuleResponse[] } export interface ModuleResponse { - config: ModuleConfiguration; - module: Module; + config: ModuleConfiguration + module: Module } export interface ModuleConfiguration { - instantiation_funds: Coin[]; - metadata?: string | null; - monetization: Monetization; + instantiation_funds: Coin[] + metadata?: string | null + monetization: Monetization } export interface Module { - info: ModuleInfo; - reference: ModuleReference; + info: ModuleInfo + reference: ModuleReference } export interface ModulesResponse { - modules: ModuleResponse[]; + modules: ModuleResponse[] } export interface NamespaceResponse { - account_base: AccountBase; - account_id: AccountId; + account_base: AccountBase + account_id: AccountId } export interface NamespaceListResponse { - namespaces: [Namespace, AccountId][]; + namespaces: [Namespace, AccountId][] } export interface NamespacesResponse { - namespaces: [Namespace, AccountId][]; + namespaces: [Namespace, AccountId][] } export interface OwnershipForString { - owner?: string | null; - pending_expiry?: Expiration | null; - pending_owner?: string | null; + owner?: string | null + pending_expiry?: Expiration | null + pending_owner?: string | null } //# sourceMappingURL=VersionControl.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/versionControl.ts b/src/formulas/formulas/contract/abstract/versionControl.ts index 91b0d623..05787809 100644 --- a/src/formulas/formulas/contract/abstract/versionControl.ts +++ b/src/formulas/formulas/contract/abstract/versionControl.ts @@ -16,49 +16,7 @@ Map::new("dcfg"); /// Maps Account ID to the address of its core contracts pub const ACCOUNT_ADDRESSES: Map<&AccountId, AccountBase> = Map::new("accs"); - -pub fn handle_modules_query(deps: Deps, modules: Vec) -> StdResult { - let mut modules_response = ModulesResponse { modules: vec![] }; - for mut module in modules { - let maybe_module_ref = if let ModuleVersion::Version(_) = module.version { - REGISTERED_MODULES.load(deps.storage, &module) - } else { - // get latest - let versions: StdResult> = REGISTERED_MODULES - .prefix((module.namespace.clone(), module.name.clone())) - .range(deps.storage, None, None, Order::Descending) - .take(1) - .collect(); - let (latest_version, id) = versions? - .first() - .ok_or_else(|| StdError::GenericErr { - msg: VCError::ModuleNotFound(module.clone()).to_string(), - })? - .clone(); - module.version = ModuleVersion::Version(latest_version); - Ok(id) - }; - - match maybe_module_ref { - Err(_) => Err(StdError::generic_err( - VCError::ModuleNotFound(module).to_string(), - )), - Ok(mod_ref) => { - modules_response.modules.push(ModuleResponse { - module: Module { - info: module.clone(), - reference: mod_ref, - }, - config: ModuleConfiguration::from_storage(deps.storage, &module)?, - }); - Ok(()) - } - }?; - } - - Ok(modules_response) -} - */ +*/ import semver from 'semver/preload' @@ -79,7 +37,7 @@ const VersionControlStorageKeys = { ACCOUNT_ADDRESSES: 'accs', } -export const registeredModules: ContractFormula> = { +export const listRegisteredModules: ContractFormula> = { compute: async ({ contractAddress, getMap }) => { const registeredModulesMap = (await getMap( @@ -186,9 +144,9 @@ export const module: ContractFormula< if (!args || !args.namespace || !args.name) return undefined const moduleParam = args as ModuleInfoParameter - const registeredModuleList = await registeredModules.compute(env) + const registeredModules = await listRegisteredModules.compute(env) - const filteredModules = registeredModuleList.filter( + const filteredModules = registeredModules.filter( ({ info: { name, namespace } }) => { return namespace === moduleParam.namespace && name === moduleParam.name } From be07e089150c83f0caa998bdff8195dbef43d94d Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:40:37 +0200 Subject: [PATCH 16/29] Add basic proxy indexes --- .../formulas/contract/abstract/proxy.ts | 48 ++ .../formulas/contract/abstract/types/index.ts | 1 + .../formulas/contract/abstract/types/proxy.ts | 459 ++++++++++++++++++ 3 files changed, 508 insertions(+) create mode 100644 src/formulas/formulas/contract/abstract/proxy.ts create mode 100644 src/formulas/formulas/contract/abstract/types/proxy.ts diff --git a/src/formulas/formulas/contract/abstract/proxy.ts b/src/formulas/formulas/contract/abstract/proxy.ts new file mode 100644 index 00000000..567bef90 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/proxy.ts @@ -0,0 +1,48 @@ +/* + #[cosmwasm_schema::cw_serde] + pub struct State { + pub modules: Vec, + } + pub const ANS_HOST: Item = Item::new("\u{0}{6}ans_host"); + pub const STATE: Item = Item::new("\u{0}{5}state"); + pub const ADMIN: Admin = Admin::new(ADMIN_NAMESPACE); + */ + +import { ContractFormula } from '@/types' + +import { ProxyTypes } from './types' + +const ProxyStorageKeys = { + ANS_HOST: 'ans_host', + STATE: 'state', + ADMIN: 'admin', + ACCOUNT_ID: 'acc_id', +} + +export const accountId: ContractFormula = { + compute: async ({ contractAddress, get }) => { + return await get( + contractAddress, + ProxyStorageKeys.ACCOUNT_ID + ) + }, +} + +type State = { + modules: string[] +} + +export const config: ContractFormula = { + compute: async ({ contractAddress, get }) => { + const state = await get( + contractAddress, + ProxyStorageKeys.STATE + ) + + return ( + state && { + modules: state.modules, + } + ) + }, +} diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts index 99a8833a..25ff6274 100644 --- a/src/formulas/formulas/contract/abstract/types/index.ts +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -1,2 +1,3 @@ export * as ManagerTypes from './manager' export * as VersionControlTypes from './versionControl' +export * as ProxyTypes from './proxy' diff --git a/src/formulas/formulas/contract/abstract/types/proxy.ts b/src/formulas/formulas/contract/abstract/types/proxy.ts new file mode 100644 index 00000000..c4fe57e8 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/proxy.ts @@ -0,0 +1,459 @@ +/** + * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @abstract-money/ts-codegen generate command to regenerate this file. + */ +export type AccountTrace = "local" | { + remote: ChainName[]; +}; +export type ChainName = string; +export interface InstantiateMsg { + account_id: AccountId; + ans_host_address: string; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export type ExecuteMsg = { + set_admin: { + admin: string; + }; +} | { + module_action: { + msgs: CosmosMsgForEmpty[]; + }; +} | { + module_action_with_data: { + msg: CosmosMsgForEmpty; + }; +} | { + ibc_action: { + msgs: ExecuteMsg1[]; + }; +} | { + add_modules: { + modules: string[]; + }; +} | { + remove_module: { + module: string; + }; +} | { + update_assets: { + to_add: [AssetEntry, UncheckedPriceSource][]; + to_remove: AssetEntry[]; + }; +}; +export type CosmosMsgForEmpty = { + bank: BankMsg; +} | { + custom: Empty; +} | { + staking: StakingMsg; +} | { + distribution: DistributionMsg; +} | { + stargate: { + type_url: string; + value: Binary; + [k: string]: unknown; + }; +} | { + ibc: IbcMsg; +} | { + wasm: WasmMsg; +} | { + gov: GovMsg; +}; +export type BankMsg = { + send: { + amount: Coin[]; + to_address: string; + [k: string]: unknown; + }; +} | { + burn: { + amount: Coin[]; + [k: string]: unknown; + }; +}; +export type Uint128 = string; +export type StakingMsg = { + delegate: { + amount: Coin; + validator: string; + [k: string]: unknown; + }; +} | { + undelegate: { + amount: Coin; + validator: string; + [k: string]: unknown; + }; +} | { + redelegate: { + amount: Coin; + dst_validator: string; + src_validator: string; + [k: string]: unknown; + }; +}; +export type DistributionMsg = { + set_withdraw_address: { + address: string; + [k: string]: unknown; + }; +} | { + withdraw_delegator_reward: { + validator: string; + [k: string]: unknown; + }; +}; +export type Binary = string; +export type IbcMsg = { + transfer: { + amount: Coin; + channel_id: string; + timeout: IbcTimeout; + to_address: string; + [k: string]: unknown; + }; +} | { + send_packet: { + channel_id: string; + data: Binary; + timeout: IbcTimeout; + [k: string]: unknown; + }; +} | { + close_channel: { + channel_id: string; + [k: string]: unknown; + }; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export type WasmMsg = { + execute: { + contract_addr: string; + funds: Coin[]; + msg: Binary; + [k: string]: unknown; + }; +} | { + instantiate: { + admin?: string | null; + code_id: number; + funds: Coin[]; + label: string; + msg: Binary; + [k: string]: unknown; + }; +} | { + migrate: { + contract_addr: string; + msg: Binary; + new_code_id: number; + [k: string]: unknown; + }; +} | { + update_admin: { + admin: string; + contract_addr: string; + [k: string]: unknown; + }; +} | { + clear_admin: { + contract_addr: string; + [k: string]: unknown; + }; +}; +export type GovMsg = { + vote: { + proposal_id: number; + vote: VoteOption; + [k: string]: unknown; + }; +}; +export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; +export type ExecuteMsg1 = { + update_admin: { + admin: string; + }; +} | { + update_config: { + ans_host?: string | null; + version_control?: string | null; + }; +} | { + send_funds: { + funds: Coin[]; + host_chain: string; + }; +} | { + register: { + host_chain: string; + }; +} | { + send_packet: { + action: HostAction; + callback_info?: CallbackInfo | null; + host_chain: string; + retries: number; + }; +} | { + remove_host: { + host_chain: string; + }; +}; +export type HostAction = { + app: { + msg: Binary; + }; +} | { + dispatch: { + msgs: CosmosMsgForEmpty[]; + }; +} | { + query: { + msgs: QueryRequestForEmpty[]; + }; +} | { + send_all_back: {}; +} | { + balances: {}; +} | { + internal: InternalAction; +}; +export type QueryRequestForEmpty = { + bank: BankQuery; +} | { + custom: Empty; +} | { + staking: StakingQuery; +} | { + stargate: { + data: Binary; + path: string; + [k: string]: unknown; + }; +} | { + ibc: IbcQuery; +} | { + wasm: WasmQuery; +}; +export type BankQuery = { + balance: { + address: string; + denom: string; + [k: string]: unknown; + }; +} | { + all_balances: { + address: string; + [k: string]: unknown; + }; +}; +export type StakingQuery = { + bonded_denom: { + [k: string]: unknown; + }; +} | { + all_delegations: { + delegator: string; + [k: string]: unknown; + }; +} | { + delegation: { + delegator: string; + validator: string; + [k: string]: unknown; + }; +} | { + all_validators: { + [k: string]: unknown; + }; +} | { + validator: { + address: string; + [k: string]: unknown; + }; +}; +export type IbcQuery = { + port_id: { + [k: string]: unknown; + }; +} | { + list_channels: { + port_id?: string | null; + [k: string]: unknown; + }; +} | { + channel: { + channel_id: string; + port_id?: string | null; + [k: string]: unknown; + }; +}; +export type WasmQuery = { + smart: { + contract_addr: string; + msg: Binary; + [k: string]: unknown; + }; +} | { + raw: { + contract_addr: string; + key: Binary; + [k: string]: unknown; + }; +} | { + contract_info: { + contract_addr: string; + [k: string]: unknown; + }; +}; +export type InternalAction = "who_am_i" | { + register: { + account_proxy_address: string; + }; +}; +export type AssetEntry = string; +export type UncheckedPriceSource = "None" | { + Pair: DexAssetPairing; +} | { + LiquidityToken: { + [k: string]: unknown; + }; +} | { + ValueAs: { + asset: AssetEntry; + multiplier: Decimal; + [k: string]: unknown; + }; +}; +export type DexAssetPairing = [AssetEntry, AssetEntry, string]; +export type Decimal = string; +export interface Coin { + amount: Uint128; + denom: string; + [k: string]: unknown; +} +export interface Empty { + [k: string]: unknown; +} +export interface IbcTimeout { + block?: IbcTimeoutBlock | null; + timestamp?: Timestamp | null; + [k: string]: unknown; +} +export interface IbcTimeoutBlock { + height: number; + revision: number; + [k: string]: unknown; +} +export interface CallbackInfo { + id: string; + receiver: string; +} +export type QueryMsg = { + config: {}; +} | { + total_value: {}; +} | { + token_value: { + identifier: AssetEntry; + }; +} | { + holding_amount: { + identifier: AssetEntry; + }; +} | { + asset_config: { + identifier: AssetEntry; + }; +} | { + assets_config: { + limit?: number | null; + start_after?: AssetEntry | null; + }; +} | { + assets_info: { + limit?: number | null; + start_after?: AssetInfoBaseForAddr | null; + }; +} | { + base_asset: {}; +}; +export type AssetInfoBaseForAddr = { + native: string; +} | { + cw20: Addr; +}; +export type Addr = string; +export interface MigrateMsg { +} +export interface AssetConfigResponse { + price_source: UncheckedPriceSource; +} +export interface AssetsConfigResponse { + assets: [AssetEntry, UncheckedPriceSource][]; +} +export type PriceSource = "None" | { + Pool: { + address: PoolAddressBaseForAddr; + pair: AssetInfoBaseForAddr[]; + [k: string]: unknown; + }; +} | { + LiquidityToken: { + pool_address: PoolAddressBaseForAddr; + pool_assets: AssetInfoBaseForAddr[]; + [k: string]: unknown; + }; +} | { + ValueAs: { + asset: AssetInfoBaseForAddr; + multiplier: Decimal; + [k: string]: unknown; + }; +}; +export type PoolAddressBaseForAddr = { + separate_addresses: { + liquidity: Addr; + swap: Addr; + }; +} | { + contract: Addr; +} | { + id: number; +}; +export interface AssetsInfoResponse { + assets: [AssetInfoBaseForAddr, OracleAsset][]; +} +export interface OracleAsset { + complexity: number; + price_source: PriceSource; +} +export interface BaseAssetResponse { + base_asset: AssetInfoBaseForAddr; +} +export interface ConfigResponse { + modules: string[]; +} +export interface HoldingAmountResponse { + amount: Uint128; +} +export interface TokenValueResponse { + value: Uint128; +} +export interface AccountValue { + breakdown: [AssetInfoBaseForAddr, Uint128][]; + total_value: AssetBaseForAddr; +} +export interface AssetBaseForAddr { + amount: Uint128; + info: AssetInfoBaseForAddr; +} +//# sourceMappingURL=Proxy.types.d.ts.map From 8dede9860d9d01b0e855bca7e3780746e416f1f4 Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 18 Nov 2024 15:51:52 +0200 Subject: [PATCH 17/29] update registry and account types --- .../abstract/{manager.ts => account.ts} | 117 +++-- .../formulas/contract/abstract/proxy.ts | 48 -- .../{versionControl.ts => registry.ts} | 53 +- .../contract/abstract/types/account.ts | 444 +++++++++++++++++ .../formulas/contract/abstract/types/index.ts | 5 +- .../contract/abstract/types/manager.ts | 289 ----------- .../formulas/contract/abstract/types/proxy.ts | 459 ------------------ .../contract/abstract/types/registry.ts | 228 +++++++++ .../contract/abstract/types/versionControl.ts | 253 ---------- 9 files changed, 769 insertions(+), 1127 deletions(-) rename src/formulas/formulas/contract/abstract/{manager.ts => account.ts} (60%) delete mode 100644 src/formulas/formulas/contract/abstract/proxy.ts rename src/formulas/formulas/contract/abstract/{versionControl.ts => registry.ts} (80%) create mode 100644 src/formulas/formulas/contract/abstract/types/account.ts delete mode 100644 src/formulas/formulas/contract/abstract/types/manager.ts delete mode 100644 src/formulas/formulas/contract/abstract/types/proxy.ts create mode 100644 src/formulas/formulas/contract/abstract/types/registry.ts delete mode 100644 src/formulas/formulas/contract/abstract/types/versionControl.ts diff --git a/src/formulas/formulas/contract/abstract/manager.ts b/src/formulas/formulas/contract/abstract/account.ts similarity index 60% rename from src/formulas/formulas/contract/abstract/manager.ts rename to src/formulas/formulas/contract/abstract/account.ts index 888ca8f4..06cce99f 100644 --- a/src/formulas/formulas/contract/abstract/manager.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -1,7 +1,8 @@ import { ContractFormula } from '@/types' import * as Common from '../common' -import { ManagerTypes } from './types' +import { AccountTypes } from './types' +import { Addr, GovernanceDetailsForString } from './types/account' /* /// Suspension status @@ -26,86 +27,90 @@ import { ManagerTypes } from './types' } */ -const ManagerStorageKeys = { - CONFIG: 'config', - INFO: 'info', +const AccountStorageKeys = { + SUSPENSION_STATUS: 'aa', + INFO: 'ab', + ACCOUNT_MODULES: 'ac', + DEPENDENTS: 'ad', + SUB_ACCOUNTS: 'ae', + WHITELISTED_MODULES: 'af', + ACCOUNT_ID: 'ag', OWNER: 'ownership', - ACCOUNT_MODULES: 'modules', - SUB_ACCOUNTS: 'sub_accs', - IS_SUSPENDED: 'is_suspended', - ACCOUNT_ID: 'acc_id', } -export const owner: ContractFormula = { +export const owner: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { return ( ( - await get( + await get( contractAddress, - ManagerStorageKeys.OWNER + AccountStorageKeys.OWNER ) )?.owner ?? undefined ) }, } -export const accountId: ContractFormula = { +export const accountId: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { - return await get( + return await get( contractAddress, - ManagerStorageKeys.ACCOUNT_ID + AccountStorageKeys.ACCOUNT_ID ) }, } export const suspensionStatus: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { - return await get(contractAddress, ManagerStorageKeys.IS_SUSPENDED) + return await get( + contractAddress, + AccountStorageKeys.SUSPENSION_STATUS + ) }, } -export const info: ContractFormula< - ManagerTypes.AccountInfoForAddr | undefined -> = { +export const info: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, get }) => { - return await get( + return await get( contractAddress, - ManagerStorageKeys.INFO + AccountStorageKeys.INFO ) }, } -export const config: ContractFormula = - { - compute: async (env) => { - const { contractAddress, get } = env - const accId = await accountId.compute(env) - const isSuspended = await suspensionStatus.compute(env) - - const config = await get< - Pick< - ManagerTypes.ConfigResponse, - 'version_control_address' | 'module_factory_address' - > - >(contractAddress, 'config') - - return ( - accId && - config && { - account_id: accId, - is_suspended: isSuspended ?? false, - ...config, - } - ) - }, - } +export const whitelistedModules: ContractFormula | undefined> = { + docs: { + description: '', + }, + compute: async ({ contractAddress, get }) => { + return await get>( + contractAddress, + AccountStorageKeys.WHITELISTED_MODULES + ) + }, +} -export const subAccountIds: ContractFormula = { +export const subAccountIds: ContractFormula = { + docs: { + description: '', + }, compute: async ({ contractAddress, getMap }) => { const subAccountsMap = (await getMap( contractAddress, - ManagerStorageKeys.SUB_ACCOUNTS, + AccountStorageKeys.SUB_ACCOUNTS, { keyType: 'number', } @@ -121,24 +126,26 @@ export const subAccountIds: ContractFormula = { export const moduleInfos: ContractFormula< Array< Omit< - ManagerTypes.ModuleInfosResponse['module_infos'][number], + AccountTypes.ModuleInfosResponse['module_infos'][number], 'version' > & { version: string | undefined } > > = { + docs: { + description: '', + }, compute: async (env) => { const { contractAddress, getMap, get } = env - const versionControlAddr = await config - .compute(env) - .then((res) => res?.version_control_address) + // TODO: + const RegistryAddr = undefined - if (!versionControlAddr) return [] + if (!RegistryAddr) return [] const moduleAddressesMap = - (await getMap( + (await getMap( contractAddress, - ManagerStorageKeys.ACCOUNT_MODULES + AccountStorageKeys.ACCOUNT_MODULES )) ?? {} // Query the info from @@ -158,3 +165,7 @@ export const moduleInfos: ContractFormula< ) }, } + +type State = { + modules: string[] +} diff --git a/src/formulas/formulas/contract/abstract/proxy.ts b/src/formulas/formulas/contract/abstract/proxy.ts deleted file mode 100644 index 567bef90..00000000 --- a/src/formulas/formulas/contract/abstract/proxy.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - #[cosmwasm_schema::cw_serde] - pub struct State { - pub modules: Vec, - } - pub const ANS_HOST: Item = Item::new("\u{0}{6}ans_host"); - pub const STATE: Item = Item::new("\u{0}{5}state"); - pub const ADMIN: Admin = Admin::new(ADMIN_NAMESPACE); - */ - -import { ContractFormula } from '@/types' - -import { ProxyTypes } from './types' - -const ProxyStorageKeys = { - ANS_HOST: 'ans_host', - STATE: 'state', - ADMIN: 'admin', - ACCOUNT_ID: 'acc_id', -} - -export const accountId: ContractFormula = { - compute: async ({ contractAddress, get }) => { - return await get( - contractAddress, - ProxyStorageKeys.ACCOUNT_ID - ) - }, -} - -type State = { - modules: string[] -} - -export const config: ContractFormula = { - compute: async ({ contractAddress, get }) => { - const state = await get( - contractAddress, - ProxyStorageKeys.STATE - ) - - return ( - state && { - modules: state.modules, - } - ) - }, -} diff --git a/src/formulas/formulas/contract/abstract/versionControl.ts b/src/formulas/formulas/contract/abstract/registry.ts similarity index 80% rename from src/formulas/formulas/contract/abstract/versionControl.ts rename to src/formulas/formulas/contract/abstract/registry.ts index 05787809..30dab0d5 100644 --- a/src/formulas/formulas/contract/abstract/versionControl.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -20,29 +20,32 @@ import semver from 'semver/preload' -import { Module } from '@/formulas/formulas/contract/abstract/types/versionControl' +import { Module } from '@/formulas/formulas/contract/abstract/types/registry' import { ContractFormula } from '@/types' import { dbKeyForKeys, dbKeyToKeys } from '@/utils' -import { VersionControlTypes } from './types' +import { RegistryTypes } from './types' -const VersionControlStorageKeys = { +const RegistryStorageKeys = { CONFIG: 'cfg', - PENDING_MODULES: 'pendm', - REGISTERED_MODULES: 'lib', - STANDALONE_INFOS: 'stli', - YANKED_MODULES: 'yknd', - MODULE_CONFIG: 'cfg', - MODULE_DEFAULT_CONFIG: 'dcfg', - ACCOUNT_ADDRESSES: 'accs', + PENDING_MODULES: 'ca', + REGISTERED_MODULES: 'cb', + STANDALONE_INFOS: 'cd', + YANKED_MODULES: 'ce', + MODULE_CONFIG: 'cf', + MODULE_DEFAULT_CONFIG: 'cg', + ACCOUNT_ADDRESSES: 'ch', } export const listRegisteredModules: ContractFormula> = { + docs: { + description: 'Lists registered modules in registry', + }, compute: async ({ contractAddress, getMap }) => { const registeredModulesMap = - (await getMap( + (await getMap( contractAddress, - VersionControlStorageKeys.REGISTERED_MODULES, + RegistryStorageKeys.REGISTERED_MODULES, { keyType: 'raw' } )) ?? {} @@ -53,7 +56,7 @@ export const listRegisteredModules: ContractFormula> = { false, ]) as string[] - const info: VersionControlTypes.ModuleInfo = { + const info: RegistryTypes.ModuleInfo = { namespace, name, version: { version }, @@ -70,7 +73,7 @@ const moduleInfoToKey = ({ namespace, name, version, -}: VersionControlTypes.ModuleInfo | ModuleInfoParameter): string => { +}: RegistryTypes.ModuleInfo | ModuleInfoParameter): string => { const versionKey = version ? typeof version === 'string' ? version @@ -79,31 +82,34 @@ const moduleInfoToKey = ({ return dbKeyForKeys(namespace, name, versionKey) } -const DEFAULT_MODULE_CONFIG: VersionControlTypes.ModuleConfiguration = { +const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { monetization: 'none', instantiation_funds: [], } -type ModuleInfoParameter = Omit & { +type ModuleInfoParameter = Omit & { version?: string } export const moduleConfig: ContractFormula< - VersionControlTypes.ModuleConfiguration | undefined, + RegistryTypes.ModuleConfiguration | undefined, ModuleInfoParameter > = { + docs: { + description: 'Configuration of the module installation', + }, compute: async ({ contractAddress, getMap, args }) => { if (!args || !args.name || !args.namespace) return undefined - const moduleInfo: VersionControlTypes.ModuleInfo = { + const moduleInfo: RegistryTypes.ModuleInfo = { namespace: args.namespace, name: args.name, version: args.version ? { version: args.version } : 'latest', } const versionedConfigMap = - (await getMap( + (await getMap( contractAddress, - VersionControlStorageKeys.CONFIG, + RegistryStorageKeys.CONFIG, { keyType: 'raw', } @@ -119,7 +125,7 @@ export const moduleConfig: ContractFormula< const defaultConfigMap = (await getMap( contractAddress, - VersionControlStorageKeys.MODULE_DEFAULT_CONFIG, + RegistryStorageKeys.MODULE_DEFAULT_CONFIG, { keyType: 'raw', } @@ -136,9 +142,12 @@ export const moduleConfig: ContractFormula< } export const module: ContractFormula< - VersionControlTypes.ModuleResponse | undefined, + RegistryTypes.ModuleResponse | undefined, ModuleInfoParameter > = { + docs: { + description: 'Module info', + }, compute: async (env) => { const { args } = env if (!args || !args.namespace || !args.name) return undefined diff --git a/src/formulas/formulas/contract/abstract/types/account.ts b/src/formulas/formulas/contract/abstract/types/account.ts new file mode 100644 index 00000000..a74ef553 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/account.ts @@ -0,0 +1,444 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +export type AccountTrace = "local" | { + remote: TruncatedChainId[]; +}; +export type TruncatedChainId = string; +export type AddAuthenticator = { + Secp256K1: { + id: number; + pubkey: Binary; + signature: Binary; + }; +} | { + Ed25519: { + id: number; + pubkey: Binary; + signature: Binary; + }; +} | { + EthWallet: { + address: string; + id: number; + signature: Binary; + }; +} | { + Jwt: { + aud: string; + id: number; + sub: string; + token: Binary; + }; +} | { + Secp256R1: { + id: number; + pubkey: Binary; + signature: Binary; + }; +} | { + Passkey: { + credential: Binary; + id: number; + url: string; + }; +}; +export type Binary = string; +export type Namespace = string; +export type ModuleVersion = "latest" | { + version: string; +}; +export type GovernanceDetailsForString = { + monarchy: { + monarch: string; + }; +} | { + sub_account: { + account: string; + }; +} | { + external: { + governance_address: string; + governance_type: string; + }; +} | { + n_f_t: { + collection_addr: string; + token_id: string; + }; +} | { + abstract_account: { + address: Addr; + }; +} | { + renounced: {}; +}; +export type Addr = string; +export interface InstantiateMsg { + account_id?: AccountId | null; + authenticator?: AddAuthenticator | null; + description?: string | null; + install_modules?: ModuleInstallConfig[]; + link?: string | null; + name?: string | null; + namespace?: string | null; + owner: GovernanceDetailsForString; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export interface ModuleInstallConfig { + init_msg?: Binary | null; + module: ModuleInfo; +} +export interface ModuleInfo { + name: string; + namespace: Namespace; + version: ModuleVersion; +} +export type ExecuteMsg = { + execute: { + msgs: CosmosMsgForEmpty[]; + }; +} | { + execute_with_data: { + msg: CosmosMsgForEmpty; + }; +} | { + execute_on_module: { + exec_msg: Binary; + funds: Coin[]; + module_id: string; + }; +} | { + admin_execute: { + addr: string; + msg: Binary; + }; +} | { + admin_execute_on_module: { + module_id: string; + msg: Binary; + }; +} | { + ica_action: { + action_query_msg: Binary; + }; +} | { + update_internal_config: InternalConfigAction; +} | { + install_modules: { + modules: ModuleInstallConfig[]; + }; +} | { + uninstall_module: { + module_id: string; + }; +} | { + upgrade: { + modules: [ModuleInfo, Binary | null][]; + }; +} | { + create_sub_account: { + account_id?: number | null; + description?: string | null; + install_modules: ModuleInstallConfig[]; + link?: string | null; + name?: string | null; + namespace?: string | null; + }; +} | { + update_info: { + description?: string | null; + link?: string | null; + name?: string | null; + }; +} | { + update_status: { + is_suspended?: boolean | null; + }; +} | { + update_sub_account: UpdateSubAccountAction; +} | { + update_ownership: GovAction; +} | { + add_auth_method: { + add_authenticator: AddAuthenticator; + }; +} | { + remove_auth_method: { + id: number; + }; +}; +export type CosmosMsgForEmpty = { + bank: BankMsg; +} | { + custom: Empty; +} | { + staking: StakingMsg; +} | { + distribution: DistributionMsg; +} | { + stargate: { + type_url: string; + value: Binary; + }; +} | { + any: AnyMsg; +} | { + ibc: IbcMsg; +} | { + wasm: WasmMsg; +} | { + gov: GovMsg; +}; +export type BankMsg = { + send: { + amount: Coin[]; + to_address: string; + }; +} | { + burn: { + amount: Coin[]; + }; +}; +export type Uint128 = string; +export type StakingMsg = { + delegate: { + amount: Coin; + validator: string; + }; +} | { + undelegate: { + amount: Coin; + validator: string; + }; +} | { + redelegate: { + amount: Coin; + dst_validator: string; + src_validator: string; + }; +}; +export type DistributionMsg = { + set_withdraw_address: { + address: string; + }; +} | { + withdraw_delegator_reward: { + validator: string; + }; +} | { + fund_community_pool: { + amount: Coin[]; + }; +}; +export type IbcMsg = { + transfer: { + amount: Coin; + channel_id: string; + memo?: string | null; + timeout: IbcTimeout; + to_address: string; + }; +} | { + send_packet: { + channel_id: string; + data: Binary; + timeout: IbcTimeout; + }; +} | { + close_channel: { + channel_id: string; + }; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export type WasmMsg = { + execute: { + contract_addr: string; + funds: Coin[]; + msg: Binary; + }; +} | { + instantiate: { + admin?: string | null; + code_id: number; + funds: Coin[]; + label: string; + msg: Binary; + }; +} | { + instantiate2: { + admin?: string | null; + code_id: number; + funds: Coin[]; + label: string; + msg: Binary; + salt: Binary; + }; +} | { + migrate: { + contract_addr: string; + msg: Binary; + new_code_id: number; + }; +} | { + update_admin: { + admin: string; + contract_addr: string; + }; +} | { + clear_admin: { + contract_addr: string; + }; +}; +export type GovMsg = { + vote: { + option: VoteOption; + proposal_id: number; + }; +} | { + vote_weighted: { + options: WeightedVoteOption[]; + proposal_id: number; + }; +}; +export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; +export type Decimal = string; +export type InternalConfigAction = { + update_module_addresses: { + to_add: [string, string][]; + to_remove: string[]; + }; +} | { + update_whitelist: { + to_add: string[]; + to_remove: string[]; + }; +}; +export type UpdateSubAccountAction = { + unregister_sub_account: { + id: number; + }; +} | { + register_sub_account: { + id: number; + }; +}; +export type GovAction = { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: GovernanceDetailsForString; + }; +} | "accept_ownership" | "renounce_ownership"; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp; +} | { + never: {}; +}; +export interface Coin { + amount: Uint128; + denom: string; +} +export interface Empty {} +export interface AnyMsg { + type_url: string; + value: Binary; +} +export interface IbcTimeout { + block?: IbcTimeoutBlock | null; + timestamp?: Timestamp | null; +} +export interface IbcTimeoutBlock { + height: number; + revision: number; +} +export interface WeightedVoteOption { + option: VoteOption; + weight: Decimal; +} +export type QueryMsg = { + config: {}; +} | { + module_versions: { + ids: string[]; + }; +} | { + module_addresses: { + ids: string[]; + }; +} | { + module_infos: { + limit?: number | null; + start_after?: string | null; + }; +} | { + info: {}; +} | { + sub_account_ids: { + limit?: number | null; + start_after?: number | null; + }; +} | { + top_level_owner: {}; +} | { + ownership: {}; +} | { + authenticator_by_i_d: { + id: number; + }; +} | { + authenticator_i_ds: {}; +}; +export interface MigrateMsg {} +export interface ConfigResponse { + account_id: AccountId; + is_suspended: boolean; + module_factory_address: Addr; + registry_address: Addr; + whitelisted_addresses: Addr[]; +} +export interface InfoResponse { + info: AccountInfo; +} +export interface AccountInfo { + description?: string | null; + link?: string | null; + name?: string | null; +} +export interface ModuleAddressesResponse { + modules: [string, Addr][]; +} +export interface ModuleInfosResponse { + module_infos: AccountModuleInfo[]; +} +export interface AccountModuleInfo { + address: Addr; + id: string; + version: ContractVersion; +} +export interface ContractVersion { + contract: string; + version: string; +} +export interface ModuleVersionsResponse { + versions: ContractVersion[]; +} +export interface OwnershipForString { + owner: GovernanceDetailsForString; + pending_expiry?: Expiration | null; + pending_owner?: GovernanceDetailsForString | null; +} +export interface SubAccountIdsResponse { + sub_accounts: number[]; +} +export interface TopLevelOwnerResponse { + address: Addr; +} \ No newline at end of file diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts index 25ff6274..cc7815af 100644 --- a/src/formulas/formulas/contract/abstract/types/index.ts +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -1,3 +1,2 @@ -export * as ManagerTypes from './manager' -export * as VersionControlTypes from './versionControl' -export * as ProxyTypes from './proxy' +export * as AccountTypes from './account'; +export * as RegistryTypes from './registry'; diff --git a/src/formulas/formulas/contract/abstract/types/manager.ts b/src/formulas/formulas/contract/abstract/types/manager.ts deleted file mode 100644 index b3d016e4..00000000 --- a/src/formulas/formulas/contract/abstract/types/manager.ts +++ /dev/null @@ -1,289 +0,0 @@ -/** - * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @abstract-money/ts-codegen generate command to regenerate this file. - */ -export type AccountTrace = - | 'local' - | { - remote: ChainName[] - } -export type ChainName = string -export type Binary = string -export type Namespace = string -export type ModuleVersion = - | 'latest' - | { - version: string - } -export type GovernanceDetailsForString = - | { - Monarchy: { - monarch: string - [k: string]: unknown - } - } - | { - SubAccount: { - manager: string - proxy: string - [k: string]: unknown - } - } - | { - External: { - governance_address: string - governance_type: string - [k: string]: unknown - } - } -export interface InstantiateMsg { - account_id: AccountId - description?: string | null - install_modules: ModuleInstallConfig[] - link?: string | null - module_factory_address: string - name: string - owner: GovernanceDetailsForString - version_control_address: string -} -export interface AccountId { - seq: number - trace: AccountTrace -} -export interface ModuleInstallConfig { - init_msg?: Binary | null - module: ModuleInfo -} -export interface ModuleInfo { - name: string - namespace: Namespace - version: ModuleVersion -} -export type ExecuteMsg = - | { - exec_on_module: { - exec_msg: Binary - module_id: string - } - } - | { - update_internal_config: Binary - } - | { - install_modules: { - modules: ModuleInstallConfig[] - } - } - | { - register_modules: { - modules: RegisterModuleData[] - } - } - | { - uninstall_module: { - module_id: string - } - } - | { - upgrade: { - modules: [ModuleInfo, Binary | null][] - } - } - | { - create_sub_account: { - base_asset?: AssetEntry | null - description?: string | null - install_modules: ModuleInstallConfig[] - link?: string | null - name: string - namespace?: string | null - } - } - | { - update_info: { - description?: string | null - link?: string | null - name?: string | null - } - } - | { - set_owner: { - owner: GovernanceDetailsForString - } - } - | { - update_status: { - is_suspended?: boolean | null - } - } - | { - update_settings: { - ibc_enabled?: boolean | null - } - } - | { - update_sub_account: UpdateSubAccountAction - } - | { - callback: CallbackMsg - } - | { - update_ownership: Action - } -export type ModuleReference = - | { - account_base: number - } - | { - native: Addr - } - | { - adapter: Addr - } - | { - app: number - } - | { - standalone: number - } -export type Addr = string -export type AssetEntry = string -export type UpdateSubAccountAction = - | { - unregister_sub_account: { - id: number - } - } - | { - register_sub_account: { - id: number - } - } -export type Action = - | { - transfer_ownership: { - expiry?: Expiration | null - new_owner: string - } - } - | 'accept_ownership' - | 'renounce_ownership' -export type Expiration = - | { - at_height: number - } - | { - at_time: Timestamp - } - | { - never: {} - } -export type Timestamp = Uint64 -export type Uint64 = string -export interface RegisterModuleData { - module: Module - module_address: string -} -export interface Module { - info: ModuleInfo - reference: ModuleReference -} -export interface CallbackMsg {} -export type QueryMsg = - | { - module_versions: { - ids: string[] - } - } - | { - module_addresses: { - ids: string[] - } - } - | { - module_infos: { - limit?: number | null - start_after?: string | null - } - } - | { - config: {} - } - | { - info: {} - } - | { - sub_account_ids: { - limit?: number | null - start_after?: number | null - } - } - | { - ownership: {} - } -export interface MigrateMsg {} -export interface ConfigResponse { - account_id: AccountId - is_suspended: boolean - module_factory_address: Addr - version_control_address: Addr -} -export type GovernanceDetailsForAddr = - | { - Monarchy: { - monarch: Addr - [k: string]: unknown - } - } - | { - SubAccount: { - manager: Addr - proxy: Addr - [k: string]: unknown - } - } - | { - External: { - governance_address: Addr - governance_type: string - [k: string]: unknown - } - } -export interface InfoResponse { - info: AccountInfoForAddr -} -export interface AccountInfoForAddr { - chain_id: string - description?: string | null - governance_details: GovernanceDetailsForAddr - link?: string | null - name: string -} -export interface ModuleAddressesResponse { - modules: [string, Addr][] -} -export interface ModuleInfosResponse { - module_infos: ManagerModuleInfo[] -} -export interface ManagerModuleInfo { - address: Addr - id: string - version: ContractVersion -} -export interface ContractVersion { - contract: string - version: string -} -export interface ModuleVersionsResponse { - versions: ContractVersion[] -} -export interface OwnershipForString { - owner?: string | null - pending_expiry?: Expiration | null - pending_owner?: string | null -} -export interface SubAccountIdsResponse { - sub_accounts: number[] -} -//# sourceMappingURL=Manager.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/types/proxy.ts b/src/formulas/formulas/contract/abstract/types/proxy.ts deleted file mode 100644 index c4fe57e8..00000000 --- a/src/formulas/formulas/contract/abstract/types/proxy.ts +++ /dev/null @@ -1,459 +0,0 @@ -/** - * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @abstract-money/ts-codegen generate command to regenerate this file. - */ -export type AccountTrace = "local" | { - remote: ChainName[]; -}; -export type ChainName = string; -export interface InstantiateMsg { - account_id: AccountId; - ans_host_address: string; -} -export interface AccountId { - seq: number; - trace: AccountTrace; -} -export type ExecuteMsg = { - set_admin: { - admin: string; - }; -} | { - module_action: { - msgs: CosmosMsgForEmpty[]; - }; -} | { - module_action_with_data: { - msg: CosmosMsgForEmpty; - }; -} | { - ibc_action: { - msgs: ExecuteMsg1[]; - }; -} | { - add_modules: { - modules: string[]; - }; -} | { - remove_module: { - module: string; - }; -} | { - update_assets: { - to_add: [AssetEntry, UncheckedPriceSource][]; - to_remove: AssetEntry[]; - }; -}; -export type CosmosMsgForEmpty = { - bank: BankMsg; -} | { - custom: Empty; -} | { - staking: StakingMsg; -} | { - distribution: DistributionMsg; -} | { - stargate: { - type_url: string; - value: Binary; - [k: string]: unknown; - }; -} | { - ibc: IbcMsg; -} | { - wasm: WasmMsg; -} | { - gov: GovMsg; -}; -export type BankMsg = { - send: { - amount: Coin[]; - to_address: string; - [k: string]: unknown; - }; -} | { - burn: { - amount: Coin[]; - [k: string]: unknown; - }; -}; -export type Uint128 = string; -export type StakingMsg = { - delegate: { - amount: Coin; - validator: string; - [k: string]: unknown; - }; -} | { - undelegate: { - amount: Coin; - validator: string; - [k: string]: unknown; - }; -} | { - redelegate: { - amount: Coin; - dst_validator: string; - src_validator: string; - [k: string]: unknown; - }; -}; -export type DistributionMsg = { - set_withdraw_address: { - address: string; - [k: string]: unknown; - }; -} | { - withdraw_delegator_reward: { - validator: string; - [k: string]: unknown; - }; -}; -export type Binary = string; -export type IbcMsg = { - transfer: { - amount: Coin; - channel_id: string; - timeout: IbcTimeout; - to_address: string; - [k: string]: unknown; - }; -} | { - send_packet: { - channel_id: string; - data: Binary; - timeout: IbcTimeout; - [k: string]: unknown; - }; -} | { - close_channel: { - channel_id: string; - [k: string]: unknown; - }; -}; -export type Timestamp = Uint64; -export type Uint64 = string; -export type WasmMsg = { - execute: { - contract_addr: string; - funds: Coin[]; - msg: Binary; - [k: string]: unknown; - }; -} | { - instantiate: { - admin?: string | null; - code_id: number; - funds: Coin[]; - label: string; - msg: Binary; - [k: string]: unknown; - }; -} | { - migrate: { - contract_addr: string; - msg: Binary; - new_code_id: number; - [k: string]: unknown; - }; -} | { - update_admin: { - admin: string; - contract_addr: string; - [k: string]: unknown; - }; -} | { - clear_admin: { - contract_addr: string; - [k: string]: unknown; - }; -}; -export type GovMsg = { - vote: { - proposal_id: number; - vote: VoteOption; - [k: string]: unknown; - }; -}; -export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; -export type ExecuteMsg1 = { - update_admin: { - admin: string; - }; -} | { - update_config: { - ans_host?: string | null; - version_control?: string | null; - }; -} | { - send_funds: { - funds: Coin[]; - host_chain: string; - }; -} | { - register: { - host_chain: string; - }; -} | { - send_packet: { - action: HostAction; - callback_info?: CallbackInfo | null; - host_chain: string; - retries: number; - }; -} | { - remove_host: { - host_chain: string; - }; -}; -export type HostAction = { - app: { - msg: Binary; - }; -} | { - dispatch: { - msgs: CosmosMsgForEmpty[]; - }; -} | { - query: { - msgs: QueryRequestForEmpty[]; - }; -} | { - send_all_back: {}; -} | { - balances: {}; -} | { - internal: InternalAction; -}; -export type QueryRequestForEmpty = { - bank: BankQuery; -} | { - custom: Empty; -} | { - staking: StakingQuery; -} | { - stargate: { - data: Binary; - path: string; - [k: string]: unknown; - }; -} | { - ibc: IbcQuery; -} | { - wasm: WasmQuery; -}; -export type BankQuery = { - balance: { - address: string; - denom: string; - [k: string]: unknown; - }; -} | { - all_balances: { - address: string; - [k: string]: unknown; - }; -}; -export type StakingQuery = { - bonded_denom: { - [k: string]: unknown; - }; -} | { - all_delegations: { - delegator: string; - [k: string]: unknown; - }; -} | { - delegation: { - delegator: string; - validator: string; - [k: string]: unknown; - }; -} | { - all_validators: { - [k: string]: unknown; - }; -} | { - validator: { - address: string; - [k: string]: unknown; - }; -}; -export type IbcQuery = { - port_id: { - [k: string]: unknown; - }; -} | { - list_channels: { - port_id?: string | null; - [k: string]: unknown; - }; -} | { - channel: { - channel_id: string; - port_id?: string | null; - [k: string]: unknown; - }; -}; -export type WasmQuery = { - smart: { - contract_addr: string; - msg: Binary; - [k: string]: unknown; - }; -} | { - raw: { - contract_addr: string; - key: Binary; - [k: string]: unknown; - }; -} | { - contract_info: { - contract_addr: string; - [k: string]: unknown; - }; -}; -export type InternalAction = "who_am_i" | { - register: { - account_proxy_address: string; - }; -}; -export type AssetEntry = string; -export type UncheckedPriceSource = "None" | { - Pair: DexAssetPairing; -} | { - LiquidityToken: { - [k: string]: unknown; - }; -} | { - ValueAs: { - asset: AssetEntry; - multiplier: Decimal; - [k: string]: unknown; - }; -}; -export type DexAssetPairing = [AssetEntry, AssetEntry, string]; -export type Decimal = string; -export interface Coin { - amount: Uint128; - denom: string; - [k: string]: unknown; -} -export interface Empty { - [k: string]: unknown; -} -export interface IbcTimeout { - block?: IbcTimeoutBlock | null; - timestamp?: Timestamp | null; - [k: string]: unknown; -} -export interface IbcTimeoutBlock { - height: number; - revision: number; - [k: string]: unknown; -} -export interface CallbackInfo { - id: string; - receiver: string; -} -export type QueryMsg = { - config: {}; -} | { - total_value: {}; -} | { - token_value: { - identifier: AssetEntry; - }; -} | { - holding_amount: { - identifier: AssetEntry; - }; -} | { - asset_config: { - identifier: AssetEntry; - }; -} | { - assets_config: { - limit?: number | null; - start_after?: AssetEntry | null; - }; -} | { - assets_info: { - limit?: number | null; - start_after?: AssetInfoBaseForAddr | null; - }; -} | { - base_asset: {}; -}; -export type AssetInfoBaseForAddr = { - native: string; -} | { - cw20: Addr; -}; -export type Addr = string; -export interface MigrateMsg { -} -export interface AssetConfigResponse { - price_source: UncheckedPriceSource; -} -export interface AssetsConfigResponse { - assets: [AssetEntry, UncheckedPriceSource][]; -} -export type PriceSource = "None" | { - Pool: { - address: PoolAddressBaseForAddr; - pair: AssetInfoBaseForAddr[]; - [k: string]: unknown; - }; -} | { - LiquidityToken: { - pool_address: PoolAddressBaseForAddr; - pool_assets: AssetInfoBaseForAddr[]; - [k: string]: unknown; - }; -} | { - ValueAs: { - asset: AssetInfoBaseForAddr; - multiplier: Decimal; - [k: string]: unknown; - }; -}; -export type PoolAddressBaseForAddr = { - separate_addresses: { - liquidity: Addr; - swap: Addr; - }; -} | { - contract: Addr; -} | { - id: number; -}; -export interface AssetsInfoResponse { - assets: [AssetInfoBaseForAddr, OracleAsset][]; -} -export interface OracleAsset { - complexity: number; - price_source: PriceSource; -} -export interface BaseAssetResponse { - base_asset: AssetInfoBaseForAddr; -} -export interface ConfigResponse { - modules: string[]; -} -export interface HoldingAmountResponse { - amount: Uint128; -} -export interface TokenValueResponse { - value: Uint128; -} -export interface AccountValue { - breakdown: [AssetInfoBaseForAddr, Uint128][]; - total_value: AssetBaseForAddr; -} -export interface AssetBaseForAddr { - amount: Uint128; - info: AssetInfoBaseForAddr; -} -//# sourceMappingURL=Proxy.types.d.ts.map diff --git a/src/formulas/formulas/contract/abstract/types/registry.ts b/src/formulas/formulas/contract/abstract/types/registry.ts new file mode 100644 index 00000000..cf698ab7 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/registry.ts @@ -0,0 +1,228 @@ +/** +* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. +* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, +* and run the @cosmwasm/ts-codegen generate command to regenerate this file. +*/ + +export type Uint128 = string; +export interface InstantiateMsg { + admin: string; + namespace_registration_fee?: Coin | null; + security_disabled?: boolean | null; +} +export interface Coin { + amount: Uint128; + denom: string; +} +export type ExecuteMsg = { + remove_module: { + module: ModuleInfo; + }; +} | { + yank_module: { + module: ModuleInfo; + }; +} | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][]; + }; +} | { + update_module_configuration: { + module_name: string; + namespace: Namespace; + update_module: UpdateModule; + }; +} | { + approve_or_reject_modules: { + approves: ModuleInfo[]; + rejects: ModuleInfo[]; + }; +} | { + claim_namespace: { + account_id: AccountId; + namespace: string; + }; +} | { + forgo_namespace: { + namespaces: string[]; + }; +} | { + add_account: { + creator: string; + namespace?: string | null; + }; +} | { + update_config: { + namespace_registration_fee?: ClearableForCoin | null; + security_disabled?: boolean | null; + }; +} | { + update_ownership: Action; +}; +export type Namespace = string; +export type ModuleVersion = "latest" | { + version: string; +}; +export type ModuleReference = { + account: number; +} | { + native: Addr; +} | { + adapter: Addr; +} | { + app: number; +} | { + standalone: number; +} | { + service: Addr; +}; +export type Addr = string; +export type UpdateModule = { + default: { + metadata: string; + }; +} | { + versioned: { + instantiation_funds?: Coin[] | null; + metadata?: string | null; + monetization?: Monetization | null; + version: string; + }; +}; +export type Monetization = "none" | { + install_fee: FixedFee; +}; +export type AccountTrace = "local" | { + remote: TruncatedChainId[]; +}; +export type TruncatedChainId = string; +export type ClearableForCoin = "clear" | { + set: Coin; +}; +export type Action = { + transfer_ownership: { + expiry?: Expiration | null; + new_owner: string; + }; +} | "accept_ownership" | "renounce_ownership"; +export type Expiration = { + at_height: number; +} | { + at_time: Timestamp; +} | { + never: {}; +}; +export type Timestamp = Uint64; +export type Uint64 = string; +export interface ModuleInfo { + name: string; + namespace: Namespace; + version: ModuleVersion; +} +export interface FixedFee { + fee: Coin; +} +export interface AccountId { + seq: number; + trace: AccountTrace; +} +export type QueryMsg = { + accounts: { + account_ids: AccountId[]; + }; +} | { + modules: { + infos: ModuleInfo[]; + }; +} | { + namespaces: { + accounts: AccountId[]; + }; +} | { + namespace: { + namespace: Namespace; + }; +} | { + config: {}; +} | { + account_list: { + limit?: number | null; + start_after?: AccountId | null; + }; +} | { + module_list: { + filter?: ModuleFilter | null; + limit?: number | null; + start_after?: ModuleInfo | null; + }; +} | { + namespace_list: { + limit?: number | null; + start_after?: string | null; + }; +} | { + ownership: {}; +}; +export type ModuleStatus = "registered" | "pending" | "yanked"; +export interface ModuleFilter { + name?: string | null; + namespace?: string | null; + status?: ModuleStatus | null; + version?: string | null; +} +export type MigrateMsg = { + instantiate: InstantiateMsg; +} | { + migrate: {}; +}; +export type AccountForAddr = Addr; +export interface AccountListResponse { + accounts: [AccountId, AccountForAddr][]; +} +export interface AccountsResponse { + accounts: AccountForAddr[]; +} +export interface ConfigResponse { + local_account_sequence: number; + namespace_registration_fee?: Coin | null; + security_disabled: boolean; +} +export interface ModulesListResponse { + modules: ModuleResponse[]; +} +export interface ModuleResponse { + config: ModuleConfiguration; + module: Module; +} +export interface ModuleConfiguration { + instantiation_funds: Coin[]; + metadata?: string | null; + monetization: Monetization; +} +export interface Module { + info: ModuleInfo; + reference: ModuleReference; +} +export interface ModulesResponse { + modules: ModuleResponse[]; +} +export type NamespaceResponse = { + claimed: NamespaceInfo; +} | { + unclaimed: {}; +}; +export interface NamespaceInfo { + account: AccountForAddr; + account_id: AccountId; +} +export interface NamespaceListResponse { + namespaces: [Namespace, AccountId][]; +} +export interface NamespacesResponse { + namespaces: [Namespace, AccountId][]; +} +export interface OwnershipForString { + owner?: string | null; + pending_expiry?: Expiration | null; + pending_owner?: string | null; +} \ No newline at end of file diff --git a/src/formulas/formulas/contract/abstract/types/versionControl.ts b/src/formulas/formulas/contract/abstract/types/versionControl.ts deleted file mode 100644 index 7d7a92fa..00000000 --- a/src/formulas/formulas/contract/abstract/types/versionControl.ts +++ /dev/null @@ -1,253 +0,0 @@ -/** - * This file was automatically generated by @abstract-money/ts-codegen@0.35.4. - * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @abstract-money/ts-codegen generate command to regenerate this file. - */ -export type Uint128 = string -export interface InstantiateMsg { - admin: string - allow_direct_module_registration_and_updates?: boolean | null - namespace_registration_fee?: Coin | null -} -export interface Coin { - amount: Uint128 - denom: string - [k: string]: unknown -} -export type ExecuteMsg = - | { - remove_module: { - module: ModuleInfo - } - } - | { - yank_module: { - module: ModuleInfo - } - } - | { - propose_modules: { - modules: [ModuleInfo, ModuleReference][] - } - } - | { - update_module_configuration: { - module_name: string - namespace: Namespace - update_module: UpdateModule - } - } - | { - approve_or_reject_modules: { - approves: ModuleInfo[] - rejects: ModuleInfo[] - } - } - | { - claim_namespace: { - account_id: AccountId - namespace: string - } - } - | { - remove_namespaces: { - namespaces: string[] - } - } - | { - add_account: { - account_base: AccountBase - account_id: AccountId - } - } - | { - update_config: { - allow_direct_module_registration_and_updates?: boolean | null - namespace_registration_fee?: Coin | null - } - } - | { - set_factory: { - new_factory: string - } - } - | { - update_ownership: Action - } -export type Namespace = string -export type ModuleVersion = - | 'latest' - | { - version: string - } -export type ModuleReference = - | { - account_base: number - } - | { - native: Addr - } - | { - adapter: Addr - } - | { - app: number - } - | { - standalone: number - } -export type Addr = string -export type UpdateModule = - | { - default: { - metadata: string - } - } - | { - versioned: { - instantiation_funds?: Coin[] | null - metadata?: string | null - monetization?: Monetization | null - version: string - } - } -export type Monetization = - | 'none' - | { - install_fee: FixedFee - } -export type AccountTrace = - | 'local' - | { - remote: ChainName[] - } -export type ChainName = string -export type Action = - | { - transfer_ownership: { - expiry?: Expiration | null - new_owner: string - } - } - | 'accept_ownership' - | 'renounce_ownership' -export type Expiration = - | { - at_height: number - } - | { - at_time: Timestamp - } - | { - never: {} - } -export type Timestamp = Uint64 -export type Uint64 = string -export interface ModuleInfo { - name: string - namespace: Namespace - version: ModuleVersion -} -export interface FixedFee { - fee: Coin -} -export interface AccountId { - seq: number - trace: AccountTrace -} -export interface AccountBase { - manager: Addr - proxy: Addr -} -export type QueryMsg = - | { - account_base: { - account_id: AccountId - } - } - | { - modules: { - infos: ModuleInfo[] - } - } - | { - namespaces: { - accounts: AccountId[] - } - } - | { - namespace: { - namespace: Namespace - } - } - | { - config: {} - } - | { - module_list: { - filter?: ModuleFilter | null - limit?: number | null - start_after?: ModuleInfo | null - } - } - | { - namespace_list: { - limit?: number | null - start_after?: string | null - } - } - | { - ownership: {} - } -export type ModuleStatus = - | 'r_e_g_i_s_t_e_r_e_d' - | 'p_e_n_d_i_n_g' - | 'y_a_n_k_e_d' -export interface ModuleFilter { - name?: string | null - namespace?: string | null - status?: ModuleStatus | null - version?: string | null -} -export interface MigrateMsg {} -export interface AccountBaseResponse { - account_base: AccountBase -} -export interface ConfigResponse { - factory: Addr -} -export interface ModulesListResponse { - modules: ModuleResponse[] -} -export interface ModuleResponse { - config: ModuleConfiguration - module: Module -} -export interface ModuleConfiguration { - instantiation_funds: Coin[] - metadata?: string | null - monetization: Monetization -} -export interface Module { - info: ModuleInfo - reference: ModuleReference -} -export interface ModulesResponse { - modules: ModuleResponse[] -} -export interface NamespaceResponse { - account_base: AccountBase - account_id: AccountId -} -export interface NamespaceListResponse { - namespaces: [Namespace, AccountId][] -} -export interface NamespacesResponse { - namespaces: [Namespace, AccountId][] -} -export interface OwnershipForString { - owner?: string | null - pending_expiry?: Expiration | null - pending_owner?: string | null -} -//# sourceMappingURL=VersionControl.types.d.ts.map From d2d5ae6caad4c990785750d409ced4a641e7058f Mon Sep 17 00:00:00 2001 From: Buckram Date: Mon, 18 Nov 2024 15:54:01 +0200 Subject: [PATCH 18/29] export abstract contract formulas --- src/formulas/formulas/contract/abstract/index.ts | 2 ++ src/formulas/formulas/contract/abstract/types/index.ts | 4 ++-- src/formulas/formulas/contract/index.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 src/formulas/formulas/contract/abstract/index.ts diff --git a/src/formulas/formulas/contract/abstract/index.ts b/src/formulas/formulas/contract/abstract/index.ts new file mode 100644 index 00000000..fd19b39d --- /dev/null +++ b/src/formulas/formulas/contract/abstract/index.ts @@ -0,0 +1,2 @@ +export * as account from './account' +export * as registry from './registry' diff --git a/src/formulas/formulas/contract/abstract/types/index.ts b/src/formulas/formulas/contract/abstract/types/index.ts index cc7815af..50d51c84 100644 --- a/src/formulas/formulas/contract/abstract/types/index.ts +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -1,2 +1,2 @@ -export * as AccountTypes from './account'; -export * as RegistryTypes from './registry'; +export * as AccountTypes from './account' +export * as RegistryTypes from './registry' diff --git a/src/formulas/formulas/contract/index.ts b/src/formulas/formulas/contract/index.ts index 6ba9c8f4..8d040ccd 100644 --- a/src/formulas/formulas/contract/index.ts +++ b/src/formulas/formulas/contract/index.ts @@ -9,5 +9,6 @@ export * from './proposal' export * from './staking' export * as valence from './valence' export * from './voting' +export * from './abstract' export * from './common' From f9be91af21a3ade02033237dca504d28a7e9dc9a Mon Sep 17 00:00:00 2001 From: Buckram Date: Thu, 21 Nov 2024 17:02:00 +0200 Subject: [PATCH 19/29] progress --- .eslintignore | 1 + config.json.example | 3 +- .../formulas/contract/abstract/account.ts | 49 +- .../formulas/contract/abstract/registry.ts | 97 +++- .../transformers/abstract/account.ts | 42 ++ .../transformers/abstract/index.ts | 3 + .../transformers/abstract/manager.ts | 0 src/transformers/transformers/index.ts | 2 + src/transformers/utils.ts | 17 + static/openapi.json | 441 ++++++++++++++++++ 10 files changed, 597 insertions(+), 58 deletions(-) create mode 100644 src/transformers/transformers/abstract/account.ts create mode 100644 src/transformers/transformers/abstract/index.ts delete mode 100644 src/transformers/transformers/abstract/manager.ts diff --git a/.eslintignore b/.eslintignore index 603130a7..62041ff1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ src/protobuf/codegen/ +src/formulas/contract/abstract/types diff --git a/config.json.example b/config.json.example index 0c22bd87..2d5a7a39 100644 --- a/config.json.example +++ b/config.json.example @@ -36,7 +36,8 @@ "cw4-group": [178], "polytone-note": [], "polytone-voice": [], - "valence-account": [] + "valence-account": [], + "abstract:account": [7693], }, "daoDaoBase": "https://testnet.daodao.zone", "discordNotifierApiKey": "key", diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index 06cce99f..aa8e114e 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -1,32 +1,10 @@ +import { loadConfig } from '@/config' import { ContractFormula } from '@/types' import * as Common from '../common' import { AccountTypes } from './types' import { Addr, GovernanceDetailsForString } from './types/account' -/* - /// Suspension status - pub const SUSPENSION_STATUS: Item = Item::new("\u{0}{12}is_suspended"); - /// Configuration - pub const CONFIG: Item = Item::new("\u{0}{6}config"); - /// Info about the Account - pub const INFO: Item> = Item::new("\u{0}{4}info"); - /// Account owner - managed by cw-ownable - pub const OWNER: Item> = Item::new(OWNERSHIP_STORAGE_KEY); - /// Enabled Abstract modules - pub const ACCOUNT_MODULES: Map = Map::new("modules"); - /// Stores the dependency relationship between modules - /// map module -> modules that depend on module. - pub const DEPENDENTS: Map> = Map::new("dependents"); - /// List of sub-accounts - pub const SUB_ACCOUNTS: Map = Map::new("sub_accs"); - /// Pending new governance - pub const PENDING_GOVERNANCE: Item> = Item::new("pgov"); - /// Context for old adapters that are currently removing authorized addresses - pub const REMOVE_ADAPTER_AUTHORIZED_CONTEXT: Item = Item::new("rm_a_auth"); -} - */ - const AccountStorageKeys = { SUSPENSION_STATUS: 'aa', INFO: 'ab', @@ -38,6 +16,11 @@ const AccountStorageKeys = { OWNER: 'ownership', } +// Replace with transformer +function registryAddress(): string { + return loadConfig().abstractRegistry as string +} + export const owner: ContractFormula = { docs: { description: '', @@ -135,12 +118,7 @@ export const moduleInfos: ContractFormula< description: '', }, compute: async (env) => { - const { contractAddress, getMap, get } = env - - // TODO: - const RegistryAddr = undefined - - if (!RegistryAddr) return [] + const { contractAddress, getMap } = env const moduleAddressesMap = (await getMap( @@ -148,7 +126,7 @@ export const moduleInfos: ContractFormula< AccountStorageKeys.ACCOUNT_MODULES )) ?? {} - // Query the info from + // Query the info from registry return await Promise.all( Object.entries(moduleAddressesMap).map(async ([moduleId, address]) => { const contractInfo = await Common.info.compute({ @@ -166,6 +144,13 @@ export const moduleInfos: ContractFormula< }, } -type State = { - modules: string[] +export const accountTxs: ContractFormula = { + docs: { + description: '', + }, + compute: async (env) => { + const { contractAddress, getTxEvents } = env + const events = await getTxEvents(contractAddress) + return events ?? [] + }, } diff --git a/src/formulas/formulas/contract/abstract/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts index 30dab0d5..6392ef00 100644 --- a/src/formulas/formulas/contract/abstract/registry.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -1,23 +1,3 @@ -/* - pub const CONFIG: Item = Item::new("cfg"); - - // Modules waiting for approvals - pub const PENDING_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("pendm"); - // We can iterate over the map giving just the prefix to get all the versions - pub const REGISTERED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("lib"); - // Reverse map for module info of standalone modules - pub const STANDALONE_INFOS: Map = Map::new("stli"); - // Yanked Modules - pub const YANKED_MODULES: Map<&ModuleInfo, ModuleReference> = Map::new("yknd"); - // Modules Configuration - pub const MODULE_CONFIG: Map<&ModuleInfo, ModuleConfiguration> = Map::new("cfg"); - // Modules Default Configuration - pub const MODULE_DEFAULT_CONFIG: Map<(&Namespace, &str), ModuleDefaultConfiguration> = - Map::new("dcfg"); - /// Maps Account ID to the address of its core contracts - pub const ACCOUNT_ADDRESSES: Map<&AccountId, AccountBase> = Map::new("accs"); -*/ - import semver from 'semver/preload' import { Module } from '@/formulas/formulas/contract/abstract/types/registry' @@ -30,11 +10,15 @@ const RegistryStorageKeys = { CONFIG: 'cfg', PENDING_MODULES: 'ca', REGISTERED_MODULES: 'cb', - STANDALONE_INFOS: 'cd', + STANDALONE_INFOS: 'cc', + SERVICE_INFOS: 'cd', YANKED_MODULES: 'ce', MODULE_CONFIG: 'cf', MODULE_DEFAULT_CONFIG: 'cg', ACCOUNT_ADDRESSES: 'ch', + LOCAL_ACCOUNT_SEQUENCE: 'ci', + NAMESPACES: 'cj', + REV_NAMESPACES: 'ck', } export const listRegisteredModules: ContractFormula> = { @@ -88,7 +72,7 @@ const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { } type ModuleInfoParameter = Omit & { - version?: string + version: string } export const moduleConfig: ContractFormula< @@ -96,14 +80,42 @@ export const moduleConfig: ContractFormula< ModuleInfoParameter > = { docs: { - description: 'Configuration of the module installation', + description: 'Configuration of the module installation huh', + args: [ + { + name: 'name', + description: 'name of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'namespace', + description: 'namespace of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'version', + description: 'semver version of the module', + // TODO: it's possible to make it false with transformer and saving latest version of the module + required: true, + schema: { + type: 'string', + }, + }, + ], }, compute: async ({ contractAddress, getMap, args }) => { - if (!args || !args.name || !args.namespace) return undefined + if (!args || !args.name || !args.namespace || !args.version) + return undefined const moduleInfo: RegistryTypes.ModuleInfo = { namespace: args.namespace, name: args.name, - version: args.version ? { version: args.version } : 'latest', + version: { version: args.version }, } const versionedConfigMap = @@ -194,3 +206,38 @@ export const module: ContractFormula< ) }, } + +export const listLocalAccounts: ContractFormula = + { + docs: { + description: 'Lists local accounts on chain', + }, + compute: async ({ contractAddress, getMap }) => { + const registeredModulesMap = + (await getMap( + contractAddress, + RegistryStorageKeys.ACCOUNT_ADDRESSES, + { keyType: 'raw' } + )) ?? {} + + const accounts = Object.entries(registeredModulesMap).map( + ([key, reference]) => { + const [trace_raw, sequence] = dbKeyToKeys(key, [false, true]) + let trace + if (trace_raw === 'local') { + trace = 'local' + } else { + trace = { remote: (trace_raw as string).split('>') } + } + return [ + { + seq: sequence as number, + trace, + }, + reference, + ] as [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] + } + ) + return { accounts } + }, + } diff --git a/src/transformers/transformers/abstract/account.ts b/src/transformers/transformers/abstract/account.ts new file mode 100644 index 00000000..3bf28763 --- /dev/null +++ b/src/transformers/transformers/abstract/account.ts @@ -0,0 +1,42 @@ +import { makeTransformer, makeTransformerForMap } from '@/transformers/utils' + +const CODE_IDS_KEYS = ['abstract-account'] + +const AccountStorageKeys = { + SUSPENSION_STATUS: 'aa', + INFO: 'ab', + ACCOUNT_MODULES: 'ac', + DEPENDENTS: 'ad', + SUB_ACCOUNTS: 'ae', + WHITELISTED_MODULES: 'af', + ACCOUNT_ID: 'ag', + OWNER: 'ownership', +} + +const suspended = makeTransformer( + CODE_IDS_KEYS, + 'suspended', + AccountStorageKeys.SUSPENSION_STATUS +) + +const accountId = makeTransformer( + CODE_IDS_KEYS, + 'accountId', + AccountStorageKeys.ACCOUNT_ID +) + +const accountModules = makeTransformerForMap( + CODE_IDS_KEYS, + 'accountModules', + AccountStorageKeys.ACCOUNT_MODULES +) + +const subAccounts = makeTransformerForMap( + CODE_IDS_KEYS, + 'subAccounts', + AccountStorageKeys.SUB_ACCOUNTS +) + +export default [ + // suspended, accountId, accountModules, subAccounts +] diff --git a/src/transformers/transformers/abstract/index.ts b/src/transformers/transformers/abstract/index.ts new file mode 100644 index 00000000..f340c476 --- /dev/null +++ b/src/transformers/transformers/abstract/index.ts @@ -0,0 +1,3 @@ +import account from './account' + +export default [...account] diff --git a/src/transformers/transformers/abstract/manager.ts b/src/transformers/transformers/abstract/manager.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/src/transformers/transformers/index.ts b/src/transformers/transformers/index.ts index 2c5a2f76..f4e8584c 100644 --- a/src/transformers/transformers/index.ts +++ b/src/transformers/transformers/index.ts @@ -8,6 +8,7 @@ import { TransformerMaker, } from '@/types' +import abstract from './abstract' import common from './common' import dao from './dao' import delegation from './delegation' @@ -42,6 +43,7 @@ export const getProcessedTransformers = ( ...staking, ...valence, ...voting, + ...abstract, // Makers. ...transformerMakers.map((maker) => maker(config)), diff --git a/src/transformers/utils.ts b/src/transformers/utils.ts index f0ff7993..8b86701c 100644 --- a/src/transformers/utils.ts +++ b/src/transformers/utils.ts @@ -28,6 +28,23 @@ export const makeTransformer = ( } } +export const makeAddressTransformer = ( + contractAddresses: string[], + name: string, + keyOrKeys?: string | string[] +): Transformer => { + const dbKeys = [keyOrKeys || name].flat().map((key) => dbKeyForKeys(key)) + + return { + filter: { + contractAddresses, + matches: (event) => dbKeys.includes(event.key), + }, + name, + getValue: defaultGetValue, + } +} + interface TransformerForMapOptions { /** * Override the default name generation. The map prefix is automatically diff --git a/static/openapi.json b/static/openapi.json index 1ab43adf..f682c3d5 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -26,9 +26,284 @@ "servers": [ { "url": "https://indexer.daodao.zone" + }, + { + "url": "http://localhost:3420" } ], "paths": { + "/{chainId}/contract/{address}/account/accountId": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > accountId", + "description": "`account/accountId`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/accountTxs": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > accountTxs", + "description": "`account/accountTxs`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/info": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > info", + "description": "`account/info`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/moduleInfos": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > moduleInfos", + "description": "`account/moduleInfos`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/owner": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > owner", + "description": "`account/owner`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/subAccountIds": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > subAccountIds", + "description": "`account/subAccountIds`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/suspensionStatus": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > suspensionStatus", + "description": "`account/suspensionStatus`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/account/whitelistedModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "account > whitelistedModules", + "description": "`account/whitelistedModules`", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, "/{chainId}/contract/{address}/cw1Whitelist/adminList": { "get": { "tags": [ @@ -10648,6 +10923,172 @@ } } }, + "/{chainId}/contract/{address}/registry/listLocalAccounts": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > listLocalAccounts", + "description": "Lists local accounts on chain", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/registry/listRegisteredModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > listRegisteredModules", + "description": "Lists registered modules in registry", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/registry/module": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > module", + "description": "Module info", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/registry/moduleConfig": { + "get": { + "tags": [ + "contract" + ], + "summary": "registry > moduleConfig", + "description": "Configuration of the module installation huh", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, "/{chainId}/contract/{address}/valence/account/admin": { "get": { "tags": [ From bf219678726224b850646c11ec928c60e0b7b7e6 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 03:33:35 +0200 Subject: [PATCH 20/29] list accountsOwnedBy --- .../formulas/account/abstractAccount.ts | 82 +++++++++++++++++++ src/formulas/formulas/account/index.ts | 1 + .../formulas/contract/abstract/account.ts | 21 ++--- .../formulas/contract/abstract/registry.ts | 18 ++-- .../transformers/abstract/account.ts | 28 +------ static/openapi.json | 46 +++++++++++ 6 files changed, 150 insertions(+), 46 deletions(-) create mode 100644 src/formulas/formulas/account/abstractAccount.ts diff --git a/src/formulas/formulas/account/abstractAccount.ts b/src/formulas/formulas/account/abstractAccount.ts new file mode 100644 index 00000000..f5b3b706 --- /dev/null +++ b/src/formulas/formulas/account/abstractAccount.ts @@ -0,0 +1,82 @@ +import { AccountFormula } from '@/types' +import { AccountTypes } from '../contract/abstract/types' + +/** + * Get all contracts with the account governance owner set to this address. + */ +export const accountsOwnedBy: AccountFormula< + string[], + { + /** + * Optionally filter by code ID key. + */ + key?: string + } +> = { + docs: { + description: + 'retrieves account (that use abstract governance to manage ownership) where the account is the owner', + args: [ + { + name: 'key', + description: 'optional code ID key to filter by', + required: false, + schema: { + type: 'string', + }, + }, + ], + }, + compute: async (env) => { + const { + args: { key }, + address, + getTransformationMatches, + getCodeIdsForKeys, + } = env + + const monarchyOwned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + monarchy: { + monarch: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + key ? getCodeIdsForKeys(key) : undefined + ) + )?.map(({ contractAddress }) => contractAddress) || [] + + const subAccountOwned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + sub_account: { + account: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + key ? getCodeIdsForKeys(key) : undefined + ) + )?.map(({ contractAddress }) => contractAddress) || [] + + const abstractAccountOwned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + abstract_account: { + address: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + key ? getCodeIdsForKeys(key) : undefined + ) + )?.map(({ contractAddress }) => contractAddress) || [] + + return monarchyOwned.concat(subAccountOwned, abstractAccountOwned) + }, +} diff --git a/src/formulas/formulas/account/index.ts b/src/formulas/formulas/account/index.ts index 1690b43f..934fe8ab 100644 --- a/src/formulas/formulas/account/index.ts +++ b/src/formulas/formulas/account/index.ts @@ -8,3 +8,4 @@ export * as tokens from './tokens' export * as valence from './valence' export * as vesting from './vesting' export * as veto from './veto' +export * as abstractAccount from './abstractAccount' diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index aa8e114e..7ff4b5fe 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -144,13 +144,14 @@ export const moduleInfos: ContractFormula< }, } -export const accountTxs: ContractFormula = { - docs: { - description: '', - }, - compute: async (env) => { - const { contractAddress, getTxEvents } = env - const events = await getTxEvents(contractAddress) - return events ?? [] - }, -} +// TODO: account txs +// export const accountTxs: ContractFormula = { +// docs: { +// description: '', +// }, +// compute: async (env) => { +// const { contractAddress, getTxEvents } = env +// const events = await getTxEvents(contractAddress) +// return events || [] +// }, +// } diff --git a/src/formulas/formulas/contract/abstract/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts index 6392ef00..a9c37616 100644 --- a/src/formulas/formulas/contract/abstract/registry.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -222,20 +222,20 @@ export const listLocalAccounts: ContractFormula { - const [trace_raw, sequence] = dbKeyToKeys(key, [false, true]) - let trace - if (trace_raw === 'local') { - trace = 'local' - } else { - trace = { remote: (trace_raw as string).split('>') } - } + const [trace_raw, sequence] = dbKeyToKeys(key, [false, true]) as [ + string, + number + ] + + const trace = + trace_raw === 'local' ? 'local' : { remote: trace_raw.split('>') } return [ { - seq: sequence as number, + seq: sequence, trace, }, reference, - ] as [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] + ] satisfies [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] } ) return { accounts } diff --git a/src/transformers/transformers/abstract/account.ts b/src/transformers/transformers/abstract/account.ts index 3bf28763..1099a94c 100644 --- a/src/transformers/transformers/abstract/account.ts +++ b/src/transformers/transformers/abstract/account.ts @@ -13,30 +13,4 @@ const AccountStorageKeys = { OWNER: 'ownership', } -const suspended = makeTransformer( - CODE_IDS_KEYS, - 'suspended', - AccountStorageKeys.SUSPENSION_STATUS -) - -const accountId = makeTransformer( - CODE_IDS_KEYS, - 'accountId', - AccountStorageKeys.ACCOUNT_ID -) - -const accountModules = makeTransformerForMap( - CODE_IDS_KEYS, - 'accountModules', - AccountStorageKeys.ACCOUNT_MODULES -) - -const subAccounts = makeTransformerForMap( - CODE_IDS_KEYS, - 'subAccounts', - AccountStorageKeys.SUB_ACCOUNTS -) - -export default [ - // suspended, accountId, accountModules, subAccounts -] +export default [] diff --git a/static/openapi.json b/static/openapi.json index f682c3d5..75c1db2c 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -11487,6 +11487,52 @@ } } }, + "/{chainId}/account/{address}/abstractAccount/accountsOwnedBy": { + "get": { + "tags": [ + "account" + ], + "summary": "abstractAccount > accountsOwnedBy", + "description": "retrieves account (that use abstract governance to manage ownership) where the account is the owner", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "account address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "key", + "description": "optional code ID key to filter by", + "required": false, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, "/{chainId}/account/{address}/bank/balance": { "get": { "tags": [ From 09a3d0a21b79b493c9a993f2181cacb4c0306a53 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:12:37 +0200 Subject: [PATCH 21/29] update module formula --- .../formulas/contract/abstract/account.ts | 21 +++---- .../formulas/contract/abstract/registry.ts | 57 ++++++++++++++----- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index 7ff4b5fe..2bcf882a 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -16,14 +16,9 @@ const AccountStorageKeys = { OWNER: 'ownership', } -// Replace with transformer -function registryAddress(): string { - return loadConfig().abstractRegistry as string -} - export const owner: ContractFormula = { docs: { - description: '', + description: 'Get the owner of the account', }, compute: async ({ contractAddress, get }) => { return ( @@ -39,7 +34,7 @@ export const owner: ContractFormula = { export const accountId: ContractFormula = { docs: { - description: '', + description: 'Get accountId of the account', }, compute: async ({ contractAddress, get }) => { return await get( @@ -51,7 +46,7 @@ export const accountId: ContractFormula = { export const suspensionStatus: ContractFormula = { docs: { - description: '', + description: 'Get suspension status of the account', }, compute: async ({ contractAddress, get }) => { return await get( @@ -63,7 +58,7 @@ export const suspensionStatus: ContractFormula = { export const info: ContractFormula = { docs: { - description: '', + description: 'Get the account info', }, compute: async ({ contractAddress, get }) => { return await get( @@ -75,7 +70,7 @@ export const info: ContractFormula = { export const whitelistedModules: ContractFormula | undefined> = { docs: { - description: '', + description: 'Get a list of whitelisted modules', }, compute: async ({ contractAddress, get }) => { return await get>( @@ -87,7 +82,7 @@ export const whitelistedModules: ContractFormula | undefined> = { export const subAccountIds: ContractFormula = { docs: { - description: '', + description: 'Get sub-accounts owned by this account', }, compute: async ({ contractAddress, getMap }) => { const subAccountsMap = @@ -115,7 +110,7 @@ export const moduleInfos: ContractFormula< > > = { docs: { - description: '', + description: 'Get module infos that are installed on this account', }, compute: async (env) => { const { contractAddress, getMap } = env @@ -126,7 +121,7 @@ export const moduleInfos: ContractFormula< AccountStorageKeys.ACCOUNT_MODULES )) ?? {} - // Query the info from registry + // Query the info from the address of the module return await Promise.all( Object.entries(moduleAddressesMap).map(async ([moduleId, address]) => { const contractInfo = await Common.info.compute({ diff --git a/src/formulas/formulas/contract/abstract/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts index a9c37616..b9427dd9 100644 --- a/src/formulas/formulas/contract/abstract/registry.ts +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -72,7 +72,7 @@ const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { } type ModuleInfoParameter = Omit & { - version: string + version?: string } export const moduleConfig: ContractFormula< @@ -80,7 +80,7 @@ export const moduleConfig: ContractFormula< ModuleInfoParameter > = { docs: { - description: 'Configuration of the module installation huh', + description: 'Configuration of the module installation', args: [ { name: 'name', @@ -101,7 +101,7 @@ export const moduleConfig: ContractFormula< { name: 'version', description: 'semver version of the module', - // TODO: it's possible to make it false with transformer and saving latest version of the module + // We force version here required: true, schema: { type: 'string', @@ -158,7 +158,33 @@ export const module: ContractFormula< ModuleInfoParameter > = { docs: { - description: 'Module info', + description: 'Module details', + args: [ + { + name: 'name', + description: 'name of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'namespace', + description: 'namespace of the module', + required: true, + schema: { + type: 'string', + }, + }, + { + name: 'version', + description: 'semver version of the module', + required: false, + schema: { + type: 'string', + }, + }, + ], }, compute: async (env) => { const { args } = env @@ -173,7 +199,7 @@ export const module: ContractFormula< } ) - let foundModule = undefined + let foundModule: Module | undefined // Find the latest version of the module if (!moduleParam.version || moduleParam.version === 'latest') { @@ -186,16 +212,21 @@ export const module: ContractFormula< } ) foundModule = sortedVersions[sortedVersions.length - 1] + } else { + // Get the proper module version + foundModule = filteredModules.find( + ({ info: { version } }) => + (typeof version === 'string' ? version : version.version) === + (moduleParam as { version: string }).version + ) } - // Get the proper module version - foundModule = filteredModules.find( - ({ info: { version } }) => - (typeof version === 'string' ? version : version.version) === - (moduleParam as { version: string }).version - ) - - const foundConfig = await moduleConfig.compute(env) + // Maybe we found latest already so let's use it + const version = foundModule?.info.version as { version: string } + const foundConfig = await moduleConfig.compute({ + ...env, + ...{ args: { version: version.version, ...args } }, + }) return ( foundModule && From 540f2381e6d3a2584c1b2bd031c5c3c575f65c07 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:14:47 +0200 Subject: [PATCH 22/29] openapi update --- static/openapi.json | 82 +++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/static/openapi.json b/static/openapi.json index 75c1db2c..41d129f8 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -38,41 +38,7 @@ "contract" ], "summary": "account > accountId", - "description": "`account/accountId`", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "success" - } - } - } - }, - "/{chainId}/contract/{address}/account/accountTxs": { - "get": { - "tags": [ - "contract" - ], - "summary": "account > accountTxs", - "description": "`account/accountTxs`", + "description": "Get accountId of the account", "parameters": [ { "name": "chainId", @@ -106,7 +72,7 @@ "contract" ], "summary": "account > info", - "description": "`account/info`", + "description": "Get the account info", "parameters": [ { "name": "chainId", @@ -140,7 +106,7 @@ "contract" ], "summary": "account > moduleInfos", - "description": "`account/moduleInfos`", + "description": "Get module infos that are installed on this account", "parameters": [ { "name": "chainId", @@ -174,7 +140,7 @@ "contract" ], "summary": "account > owner", - "description": "`account/owner`", + "description": "Get the owner of the account", "parameters": [ { "name": "chainId", @@ -208,7 +174,7 @@ "contract" ], "summary": "account > subAccountIds", - "description": "`account/subAccountIds`", + "description": "Get sub-accounts owned by this account", "parameters": [ { "name": "chainId", @@ -242,7 +208,7 @@ "contract" ], "summary": "account > suspensionStatus", - "description": "`account/suspensionStatus`", + "description": "Get suspension status of the account", "parameters": [ { "name": "chainId", @@ -276,7 +242,7 @@ "contract" ], "summary": "account > whitelistedModules", - "description": "`account/whitelistedModules`", + "description": "Get a list of whitelisted modules", "parameters": [ { "name": "chainId", @@ -10997,7 +10963,7 @@ "contract" ], "summary": "registry > module", - "description": "Module info", + "description": "Module details", "parameters": [ { "name": "chainId", @@ -11016,11 +10982,41 @@ "schema": { "type": "string" } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": false, + "schema": { + "type": "string" + }, + "in": "query" } ], "responses": { "200": { "description": "success" + }, + "400": { + "description": "missing required arguments" } } } @@ -11031,7 +11027,7 @@ "contract" ], "summary": "registry > moduleConfig", - "description": "Configuration of the module installation huh", + "description": "Configuration of the module installation", "parameters": [ { "name": "chainId", From c5b9648cc5e0689a1efdac29f48396003097605f Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:18:00 +0200 Subject: [PATCH 23/29] dodged transformers --- .../transformers/abstract/account.ts | 16 ---------------- src/transformers/transformers/abstract/index.ts | 3 --- src/transformers/transformers/index.ts | 2 -- 3 files changed, 21 deletions(-) delete mode 100644 src/transformers/transformers/abstract/account.ts delete mode 100644 src/transformers/transformers/abstract/index.ts diff --git a/src/transformers/transformers/abstract/account.ts b/src/transformers/transformers/abstract/account.ts deleted file mode 100644 index 1099a94c..00000000 --- a/src/transformers/transformers/abstract/account.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { makeTransformer, makeTransformerForMap } from '@/transformers/utils' - -const CODE_IDS_KEYS = ['abstract-account'] - -const AccountStorageKeys = { - SUSPENSION_STATUS: 'aa', - INFO: 'ab', - ACCOUNT_MODULES: 'ac', - DEPENDENTS: 'ad', - SUB_ACCOUNTS: 'ae', - WHITELISTED_MODULES: 'af', - ACCOUNT_ID: 'ag', - OWNER: 'ownership', -} - -export default [] diff --git a/src/transformers/transformers/abstract/index.ts b/src/transformers/transformers/abstract/index.ts deleted file mode 100644 index f340c476..00000000 --- a/src/transformers/transformers/abstract/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import account from './account' - -export default [...account] diff --git a/src/transformers/transformers/index.ts b/src/transformers/transformers/index.ts index f4e8584c..2c5a2f76 100644 --- a/src/transformers/transformers/index.ts +++ b/src/transformers/transformers/index.ts @@ -8,7 +8,6 @@ import { TransformerMaker, } from '@/types' -import abstract from './abstract' import common from './common' import dao from './dao' import delegation from './delegation' @@ -43,7 +42,6 @@ export const getProcessedTransformers = ( ...staking, ...valence, ...voting, - ...abstract, // Makers. ...transformerMakers.map((maker) => maker(config)), From a24de9ca1591be66c833c2a039db63d9e85d9764 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 04:19:41 +0200 Subject: [PATCH 24/29] cleanup --- src/transformers/utils.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/transformers/utils.ts b/src/transformers/utils.ts index 8b86701c..f0ff7993 100644 --- a/src/transformers/utils.ts +++ b/src/transformers/utils.ts @@ -28,23 +28,6 @@ export const makeTransformer = ( } } -export const makeAddressTransformer = ( - contractAddresses: string[], - name: string, - keyOrKeys?: string | string[] -): Transformer => { - const dbKeys = [keyOrKeys || name].flat().map((key) => dbKeyForKeys(key)) - - return { - filter: { - contractAddresses, - matches: (event) => dbKeys.includes(event.key), - }, - name, - getValue: defaultGetValue, - } -} - interface TransformerForMapOptions { /** * Override the default name generation. The map prefix is automatically From 06fce90eb37900e5436b107d3fcadb3dd053195b Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 22 Nov 2024 14:19:53 +0200 Subject: [PATCH 25/29] rename api path --- config.json.example | 1 - .../formulas/contract/abstract/index.ts | 4 +- static/openapi.json | 420 +++++++++--------- 3 files changed, 212 insertions(+), 213 deletions(-) diff --git a/config.json.example b/config.json.example index 2d5a7a39..1c0ce1e2 100644 --- a/config.json.example +++ b/config.json.example @@ -37,7 +37,6 @@ "polytone-note": [], "polytone-voice": [], "valence-account": [], - "abstract:account": [7693], }, "daoDaoBase": "https://testnet.daodao.zone", "discordNotifierApiKey": "key", diff --git a/src/formulas/formulas/contract/abstract/index.ts b/src/formulas/formulas/contract/abstract/index.ts index fd19b39d..4f093f70 100644 --- a/src/formulas/formulas/contract/abstract/index.ts +++ b/src/formulas/formulas/contract/abstract/index.ts @@ -1,2 +1,2 @@ -export * as account from './account' -export * as registry from './registry' +export * as abstractAccount from './account' +export * as abstractRegistry from './registry' diff --git a/static/openapi.json b/static/openapi.json index 41d129f8..aa75a637 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -32,12 +32,12 @@ } ], "paths": { - "/{chainId}/contract/{address}/account/accountId": { + "/{chainId}/contract/{address}/abstractAccount/accountId": { "get": { "tags": [ "contract" ], - "summary": "account > accountId", + "summary": "abstractAccount > accountId", "description": "Get accountId of the account", "parameters": [ { @@ -66,12 +66,12 @@ } } }, - "/{chainId}/contract/{address}/account/info": { + "/{chainId}/contract/{address}/abstractAccount/info": { "get": { "tags": [ "contract" ], - "summary": "account > info", + "summary": "abstractAccount > info", "description": "Get the account info", "parameters": [ { @@ -100,12 +100,12 @@ } } }, - "/{chainId}/contract/{address}/account/moduleInfos": { + "/{chainId}/contract/{address}/abstractAccount/moduleInfos": { "get": { "tags": [ "contract" ], - "summary": "account > moduleInfos", + "summary": "abstractAccount > moduleInfos", "description": "Get module infos that are installed on this account", "parameters": [ { @@ -134,12 +134,12 @@ } } }, - "/{chainId}/contract/{address}/account/owner": { + "/{chainId}/contract/{address}/abstractAccount/owner": { "get": { "tags": [ "contract" ], - "summary": "account > owner", + "summary": "abstractAccount > owner", "description": "Get the owner of the account", "parameters": [ { @@ -168,12 +168,12 @@ } } }, - "/{chainId}/contract/{address}/account/subAccountIds": { + "/{chainId}/contract/{address}/abstractAccount/subAccountIds": { "get": { "tags": [ "contract" ], - "summary": "account > subAccountIds", + "summary": "abstractAccount > subAccountIds", "description": "Get sub-accounts owned by this account", "parameters": [ { @@ -202,12 +202,12 @@ } } }, - "/{chainId}/contract/{address}/account/suspensionStatus": { + "/{chainId}/contract/{address}/abstractAccount/suspensionStatus": { "get": { "tags": [ "contract" ], - "summary": "account > suspensionStatus", + "summary": "abstractAccount > suspensionStatus", "description": "Get suspension status of the account", "parameters": [ { @@ -236,12 +236,12 @@ } } }, - "/{chainId}/contract/{address}/account/whitelistedModules": { + "/{chainId}/contract/{address}/abstractAccount/whitelistedModules": { "get": { "tags": [ "contract" ], - "summary": "account > whitelistedModules", + "summary": "abstractAccount > whitelistedModules", "description": "Get a list of whitelisted modules", "parameters": [ { @@ -270,6 +270,202 @@ } } }, + "/{chainId}/contract/{address}/abstractRegistry/listLocalAccounts": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > listLocalAccounts", + "description": "Lists local accounts on chain", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/abstractRegistry/listRegisteredModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > listRegisteredModules", + "description": "Lists registered modules in registry", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "success" + } + } + } + }, + "/{chainId}/contract/{address}/abstractRegistry/module": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > module", + "description": "Module details", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": false, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, + "/{chainId}/contract/{address}/abstractRegistry/moduleConfig": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractRegistry > moduleConfig", + "description": "Configuration of the module installation", + "parameters": [ + { + "name": "chainId", + "in": "path", + "description": "chain ID", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "address", + "in": "path", + "description": "contract address", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "description": "name of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "namespace", + "description": "namespace of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + }, + { + "name": "version", + "description": "semver version of the module", + "required": true, + "schema": { + "type": "string" + }, + "in": "query" + } + ], + "responses": { + "200": { + "description": "success" + }, + "400": { + "description": "missing required arguments" + } + } + } + }, "/{chainId}/contract/{address}/cw1Whitelist/adminList": { "get": { "tags": [ @@ -10889,202 +11085,6 @@ } } }, - "/{chainId}/contract/{address}/registry/listLocalAccounts": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > listLocalAccounts", - "description": "Lists local accounts on chain", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "success" - } - } - } - }, - "/{chainId}/contract/{address}/registry/listRegisteredModules": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > listRegisteredModules", - "description": "Lists registered modules in registry", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "success" - } - } - } - }, - "/{chainId}/contract/{address}/registry/module": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > module", - "description": "Module details", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "description": "name of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "namespace", - "description": "namespace of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "version", - "description": "semver version of the module", - "required": false, - "schema": { - "type": "string" - }, - "in": "query" - } - ], - "responses": { - "200": { - "description": "success" - }, - "400": { - "description": "missing required arguments" - } - } - } - }, - "/{chainId}/contract/{address}/registry/moduleConfig": { - "get": { - "tags": [ - "contract" - ], - "summary": "registry > moduleConfig", - "description": "Configuration of the module installation", - "parameters": [ - { - "name": "chainId", - "in": "path", - "description": "chain ID", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "address", - "in": "path", - "description": "contract address", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "description": "name of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "namespace", - "description": "namespace of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - }, - { - "name": "version", - "description": "semver version of the module", - "required": true, - "schema": { - "type": "string" - }, - "in": "query" - } - ], - "responses": { - "200": { - "description": "success" - }, - "400": { - "description": "missing required arguments" - } - } - } - }, "/{chainId}/contract/{address}/valence/account/admin": { "get": { "tags": [ From f74043d8edb0c0a0f556e834a26128418509d9e9 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Fri, 20 Dec 2024 18:27:12 -0500 Subject: [PATCH 26/29] optimized abstractAccount/accountsOwnedBy query --- .../formulas/account/abstractAccount.ts | 57 ++++++++----------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/src/formulas/formulas/account/abstractAccount.ts b/src/formulas/formulas/account/abstractAccount.ts index f5b3b706..07126636 100644 --- a/src/formulas/formulas/account/abstractAccount.ts +++ b/src/formulas/formulas/account/abstractAccount.ts @@ -1,4 +1,7 @@ +import { Op } from 'sequelize' + import { AccountFormula } from '@/types' + import { AccountTypes } from '../contract/abstract/types' /** @@ -35,48 +38,34 @@ export const accountsOwnedBy: AccountFormula< getCodeIdsForKeys, } = env - const monarchyOwned = - ( - await getTransformationMatches( - undefined, - 'owner', - { - monarchy: { - monarch: address, - }, - } satisfies AccountTypes.GovernanceDetailsForString, - key ? getCodeIdsForKeys(key) : undefined - ) - )?.map(({ contractAddress }) => contractAddress) || [] - - const subAccountOwned = - ( - await getTransformationMatches( - undefined, - 'owner', - { - sub_account: { - account: address, - }, - } satisfies AccountTypes.GovernanceDetailsForString, - key ? getCodeIdsForKeys(key) : undefined - ) - )?.map(({ contractAddress }) => contractAddress) || [] - - const abstractAccountOwned = + const owned = ( await getTransformationMatches( undefined, 'owner', { - abstract_account: { - address: address, - }, - } satisfies AccountTypes.GovernanceDetailsForString, + [Op.or]: [ + { + monarchy: { + monarch: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + { + sub_account: { + account: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + { + abstract_account: { + address: address, + }, + } satisfies AccountTypes.GovernanceDetailsForString, + ], + }, key ? getCodeIdsForKeys(key) : undefined ) )?.map(({ contractAddress }) => contractAddress) || [] - return monarchyOwned.concat(subAccountOwned, abstractAccountOwned) + return owned }, } From c567d2b0f1abb96badd096862f3c76cda71a0f22 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Fri, 20 Dec 2024 18:45:07 -0500 Subject: [PATCH 27/29] cleaned up abstract stuff --- .../{abstractAccount.ts => abstract.ts} | 0 src/formulas/formulas/account/index.ts | 2 +- .../formulas/contract/abstract/account.ts | 78 +++++++------------ .../formulas/contract/abstract/index.ts | 4 +- 4 files changed, 33 insertions(+), 51 deletions(-) rename src/formulas/formulas/account/{abstractAccount.ts => abstract.ts} (100%) diff --git a/src/formulas/formulas/account/abstractAccount.ts b/src/formulas/formulas/account/abstract.ts similarity index 100% rename from src/formulas/formulas/account/abstractAccount.ts rename to src/formulas/formulas/account/abstract.ts diff --git a/src/formulas/formulas/account/index.ts b/src/formulas/formulas/account/index.ts index 934fe8ab..df72113d 100644 --- a/src/formulas/formulas/account/index.ts +++ b/src/formulas/formulas/account/index.ts @@ -1,3 +1,4 @@ +export * as abstract from './abstract' export * as bank from './bank' export * as contract from './contract' export * as daos from './daos' @@ -8,4 +9,3 @@ export * as tokens from './tokens' export * as valence from './valence' export * as vesting from './vesting' export * as veto from './veto' -export * as abstractAccount from './abstractAccount' diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts index 2bcf882a..d7481250 100644 --- a/src/formulas/formulas/contract/abstract/account.ts +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -1,6 +1,6 @@ -import { loadConfig } from '@/config' import { ContractFormula } from '@/types' +import { makeSimpleContractFormula } from '../../utils' import * as Common from '../common' import { AccountTypes } from './types' import { Addr, GovernanceDetailsForString } from './types/account' @@ -16,69 +16,51 @@ const AccountStorageKeys = { OWNER: 'ownership', } -export const owner: ContractFormula = { +export const owner = makeSimpleContractFormula< + { owner: GovernanceDetailsForString }, + GovernanceDetailsForString | null +>({ docs: { description: 'Get the owner of the account', }, - compute: async ({ contractAddress, get }) => { - return ( - ( - await get( - contractAddress, - AccountStorageKeys.OWNER - ) - )?.owner ?? undefined - ) - }, -} + transformation: AccountStorageKeys.OWNER, + fallbackKeys: [AccountStorageKeys.OWNER], + transform: (data) => data.owner, + fallback: null, +}) -export const accountId: ContractFormula = { - docs: { - description: 'Get accountId of the account', - }, - compute: async ({ contractAddress, get }) => { - return await get( - contractAddress, - AccountStorageKeys.ACCOUNT_ID - ) - }, -} +export const accountId = + makeSimpleContractFormula({ + docs: { + description: 'Get accountId of the account', + }, + key: AccountStorageKeys.ACCOUNT_ID, + fallback: null, + }) -export const suspensionStatus: ContractFormula = { +export const suspensionStatus = makeSimpleContractFormula({ docs: { description: 'Get suspension status of the account', }, - compute: async ({ contractAddress, get }) => { - return await get( - contractAddress, - AccountStorageKeys.SUSPENSION_STATUS - ) - }, -} + key: AccountStorageKeys.SUSPENSION_STATUS, + fallback: null, +}) -export const info: ContractFormula = { +export const info = makeSimpleContractFormula({ docs: { description: 'Get the account info', }, - compute: async ({ contractAddress, get }) => { - return await get( - contractAddress, - AccountStorageKeys.INFO - ) - }, -} + key: AccountStorageKeys.INFO, + fallback: null, +}) -export const whitelistedModules: ContractFormula | undefined> = { +export const whitelistedModules = makeSimpleContractFormula({ docs: { description: 'Get a list of whitelisted modules', }, - compute: async ({ contractAddress, get }) => { - return await get>( - contractAddress, - AccountStorageKeys.WHITELISTED_MODULES - ) - }, -} + key: AccountStorageKeys.WHITELISTED_MODULES, + fallback: null, +}) export const subAccountIds: ContractFormula = { docs: { diff --git a/src/formulas/formulas/contract/abstract/index.ts b/src/formulas/formulas/contract/abstract/index.ts index 4f093f70..fd19b39d 100644 --- a/src/formulas/formulas/contract/abstract/index.ts +++ b/src/formulas/formulas/contract/abstract/index.ts @@ -1,2 +1,2 @@ -export * as abstractAccount from './account' -export * as abstractRegistry from './registry' +export * as account from './account' +export * as registry from './registry' From 62d346349dacf4b1a69e73b782a12b7b717a89fd Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Fri, 20 Dec 2024 18:46:13 -0500 Subject: [PATCH 28/29] formatted --- config.json.example | 2 +- .../contract/abstract/types/account.ts | 883 ++++++++++-------- .../contract/abstract/types/registry.ts | 433 +++++---- 3 files changed, 722 insertions(+), 596 deletions(-) diff --git a/config.json.example b/config.json.example index 1c0ce1e2..0c22bd87 100644 --- a/config.json.example +++ b/config.json.example @@ -36,7 +36,7 @@ "cw4-group": [178], "polytone-note": [], "polytone-voice": [], - "valence-account": [], + "valence-account": [] }, "daoDaoBase": "https://testnet.daodao.zone", "discordNotifierApiKey": "key", diff --git a/src/formulas/formulas/contract/abstract/types/account.ts b/src/formulas/formulas/contract/abstract/types/account.ts index a74ef553..497187d8 100644 --- a/src/formulas/formulas/contract/abstract/types/account.ts +++ b/src/formulas/formulas/contract/abstract/types/account.ts @@ -1,444 +1,525 @@ /** -* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. -* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, -* and run the @cosmwasm/ts-codegen generate command to regenerate this file. -*/ + * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ -export type AccountTrace = "local" | { - remote: TruncatedChainId[]; -}; -export type TruncatedChainId = string; -export type AddAuthenticator = { - Secp256K1: { - id: number; - pubkey: Binary; - signature: Binary; - }; -} | { - Ed25519: { - id: number; - pubkey: Binary; - signature: Binary; - }; -} | { - EthWallet: { - address: string; - id: number; - signature: Binary; - }; -} | { - Jwt: { - aud: string; - id: number; - sub: string; - token: Binary; - }; -} | { - Secp256R1: { - id: number; - pubkey: Binary; - signature: Binary; - }; -} | { - Passkey: { - credential: Binary; - id: number; - url: string; - }; -}; -export type Binary = string; -export type Namespace = string; -export type ModuleVersion = "latest" | { - version: string; -}; -export type GovernanceDetailsForString = { - monarchy: { - monarch: string; - }; -} | { - sub_account: { - account: string; - }; -} | { - external: { - governance_address: string; - governance_type: string; - }; -} | { - n_f_t: { - collection_addr: string; - token_id: string; - }; -} | { - abstract_account: { - address: Addr; - }; -} | { - renounced: {}; -}; -export type Addr = string; +export type AccountTrace = + | 'local' + | { + remote: TruncatedChainId[] + } +export type TruncatedChainId = string +export type AddAuthenticator = + | { + Secp256K1: { + id: number + pubkey: Binary + signature: Binary + } + } + | { + Ed25519: { + id: number + pubkey: Binary + signature: Binary + } + } + | { + EthWallet: { + address: string + id: number + signature: Binary + } + } + | { + Jwt: { + aud: string + id: number + sub: string + token: Binary + } + } + | { + Secp256R1: { + id: number + pubkey: Binary + signature: Binary + } + } + | { + Passkey: { + credential: Binary + id: number + url: string + } + } +export type Binary = string +export type Namespace = string +export type ModuleVersion = + | 'latest' + | { + version: string + } +export type GovernanceDetailsForString = + | { + monarchy: { + monarch: string + } + } + | { + sub_account: { + account: string + } + } + | { + external: { + governance_address: string + governance_type: string + } + } + | { + n_f_t: { + collection_addr: string + token_id: string + } + } + | { + abstract_account: { + address: Addr + } + } + | { + renounced: {} + } +export type Addr = string export interface InstantiateMsg { - account_id?: AccountId | null; - authenticator?: AddAuthenticator | null; - description?: string | null; - install_modules?: ModuleInstallConfig[]; - link?: string | null; - name?: string | null; - namespace?: string | null; - owner: GovernanceDetailsForString; + account_id?: AccountId | null + authenticator?: AddAuthenticator | null + description?: string | null + install_modules?: ModuleInstallConfig[] + link?: string | null + name?: string | null + namespace?: string | null + owner: GovernanceDetailsForString } export interface AccountId { - seq: number; - trace: AccountTrace; + seq: number + trace: AccountTrace } export interface ModuleInstallConfig { - init_msg?: Binary | null; - module: ModuleInfo; + init_msg?: Binary | null + module: ModuleInfo } export interface ModuleInfo { - name: string; - namespace: Namespace; - version: ModuleVersion; + name: string + namespace: Namespace + version: ModuleVersion } -export type ExecuteMsg = { - execute: { - msgs: CosmosMsgForEmpty[]; - }; -} | { - execute_with_data: { - msg: CosmosMsgForEmpty; - }; -} | { - execute_on_module: { - exec_msg: Binary; - funds: Coin[]; - module_id: string; - }; -} | { - admin_execute: { - addr: string; - msg: Binary; - }; -} | { - admin_execute_on_module: { - module_id: string; - msg: Binary; - }; -} | { - ica_action: { - action_query_msg: Binary; - }; -} | { - update_internal_config: InternalConfigAction; -} | { - install_modules: { - modules: ModuleInstallConfig[]; - }; -} | { - uninstall_module: { - module_id: string; - }; -} | { - upgrade: { - modules: [ModuleInfo, Binary | null][]; - }; -} | { - create_sub_account: { - account_id?: number | null; - description?: string | null; - install_modules: ModuleInstallConfig[]; - link?: string | null; - name?: string | null; - namespace?: string | null; - }; -} | { - update_info: { - description?: string | null; - link?: string | null; - name?: string | null; - }; -} | { - update_status: { - is_suspended?: boolean | null; - }; -} | { - update_sub_account: UpdateSubAccountAction; -} | { - update_ownership: GovAction; -} | { - add_auth_method: { - add_authenticator: AddAuthenticator; - }; -} | { - remove_auth_method: { - id: number; - }; -}; -export type CosmosMsgForEmpty = { - bank: BankMsg; -} | { - custom: Empty; -} | { - staking: StakingMsg; -} | { - distribution: DistributionMsg; -} | { - stargate: { - type_url: string; - value: Binary; - }; -} | { - any: AnyMsg; -} | { - ibc: IbcMsg; -} | { - wasm: WasmMsg; -} | { - gov: GovMsg; -}; -export type BankMsg = { - send: { - amount: Coin[]; - to_address: string; - }; -} | { - burn: { - amount: Coin[]; - }; -}; -export type Uint128 = string; -export type StakingMsg = { - delegate: { - amount: Coin; - validator: string; - }; -} | { - undelegate: { - amount: Coin; - validator: string; - }; -} | { - redelegate: { - amount: Coin; - dst_validator: string; - src_validator: string; - }; -}; -export type DistributionMsg = { - set_withdraw_address: { - address: string; - }; -} | { - withdraw_delegator_reward: { - validator: string; - }; -} | { - fund_community_pool: { - amount: Coin[]; - }; -}; -export type IbcMsg = { - transfer: { - amount: Coin; - channel_id: string; - memo?: string | null; - timeout: IbcTimeout; - to_address: string; - }; -} | { - send_packet: { - channel_id: string; - data: Binary; - timeout: IbcTimeout; - }; -} | { - close_channel: { - channel_id: string; - }; -}; -export type Timestamp = Uint64; -export type Uint64 = string; -export type WasmMsg = { - execute: { - contract_addr: string; - funds: Coin[]; - msg: Binary; - }; -} | { - instantiate: { - admin?: string | null; - code_id: number; - funds: Coin[]; - label: string; - msg: Binary; - }; -} | { - instantiate2: { - admin?: string | null; - code_id: number; - funds: Coin[]; - label: string; - msg: Binary; - salt: Binary; - }; -} | { - migrate: { - contract_addr: string; - msg: Binary; - new_code_id: number; - }; -} | { - update_admin: { - admin: string; - contract_addr: string; - }; -} | { - clear_admin: { - contract_addr: string; - }; -}; -export type GovMsg = { - vote: { - option: VoteOption; - proposal_id: number; - }; -} | { - vote_weighted: { - options: WeightedVoteOption[]; - proposal_id: number; - }; -}; -export type VoteOption = "yes" | "no" | "abstain" | "no_with_veto"; -export type Decimal = string; -export type InternalConfigAction = { - update_module_addresses: { - to_add: [string, string][]; - to_remove: string[]; - }; -} | { - update_whitelist: { - to_add: string[]; - to_remove: string[]; - }; -}; -export type UpdateSubAccountAction = { - unregister_sub_account: { - id: number; - }; -} | { - register_sub_account: { - id: number; - }; -}; -export type GovAction = { - transfer_ownership: { - expiry?: Expiration | null; - new_owner: GovernanceDetailsForString; - }; -} | "accept_ownership" | "renounce_ownership"; -export type Expiration = { - at_height: number; -} | { - at_time: Timestamp; -} | { - never: {}; -}; +export type ExecuteMsg = + | { + execute: { + msgs: CosmosMsgForEmpty[] + } + } + | { + execute_with_data: { + msg: CosmosMsgForEmpty + } + } + | { + execute_on_module: { + exec_msg: Binary + funds: Coin[] + module_id: string + } + } + | { + admin_execute: { + addr: string + msg: Binary + } + } + | { + admin_execute_on_module: { + module_id: string + msg: Binary + } + } + | { + ica_action: { + action_query_msg: Binary + } + } + | { + update_internal_config: InternalConfigAction + } + | { + install_modules: { + modules: ModuleInstallConfig[] + } + } + | { + uninstall_module: { + module_id: string + } + } + | { + upgrade: { + modules: [ModuleInfo, Binary | null][] + } + } + | { + create_sub_account: { + account_id?: number | null + description?: string | null + install_modules: ModuleInstallConfig[] + link?: string | null + name?: string | null + namespace?: string | null + } + } + | { + update_info: { + description?: string | null + link?: string | null + name?: string | null + } + } + | { + update_status: { + is_suspended?: boolean | null + } + } + | { + update_sub_account: UpdateSubAccountAction + } + | { + update_ownership: GovAction + } + | { + add_auth_method: { + add_authenticator: AddAuthenticator + } + } + | { + remove_auth_method: { + id: number + } + } +export type CosmosMsgForEmpty = + | { + bank: BankMsg + } + | { + custom: Empty + } + | { + staking: StakingMsg + } + | { + distribution: DistributionMsg + } + | { + stargate: { + type_url: string + value: Binary + } + } + | { + any: AnyMsg + } + | { + ibc: IbcMsg + } + | { + wasm: WasmMsg + } + | { + gov: GovMsg + } +export type BankMsg = + | { + send: { + amount: Coin[] + to_address: string + } + } + | { + burn: { + amount: Coin[] + } + } +export type Uint128 = string +export type StakingMsg = + | { + delegate: { + amount: Coin + validator: string + } + } + | { + undelegate: { + amount: Coin + validator: string + } + } + | { + redelegate: { + amount: Coin + dst_validator: string + src_validator: string + } + } +export type DistributionMsg = + | { + set_withdraw_address: { + address: string + } + } + | { + withdraw_delegator_reward: { + validator: string + } + } + | { + fund_community_pool: { + amount: Coin[] + } + } +export type IbcMsg = + | { + transfer: { + amount: Coin + channel_id: string + memo?: string | null + timeout: IbcTimeout + to_address: string + } + } + | { + send_packet: { + channel_id: string + data: Binary + timeout: IbcTimeout + } + } + | { + close_channel: { + channel_id: string + } + } +export type Timestamp = Uint64 +export type Uint64 = string +export type WasmMsg = + | { + execute: { + contract_addr: string + funds: Coin[] + msg: Binary + } + } + | { + instantiate: { + admin?: string | null + code_id: number + funds: Coin[] + label: string + msg: Binary + } + } + | { + instantiate2: { + admin?: string | null + code_id: number + funds: Coin[] + label: string + msg: Binary + salt: Binary + } + } + | { + migrate: { + contract_addr: string + msg: Binary + new_code_id: number + } + } + | { + update_admin: { + admin: string + contract_addr: string + } + } + | { + clear_admin: { + contract_addr: string + } + } +export type GovMsg = + | { + vote: { + option: VoteOption + proposal_id: number + } + } + | { + vote_weighted: { + options: WeightedVoteOption[] + proposal_id: number + } + } +export type VoteOption = 'yes' | 'no' | 'abstain' | 'no_with_veto' +export type Decimal = string +export type InternalConfigAction = + | { + update_module_addresses: { + to_add: [string, string][] + to_remove: string[] + } + } + | { + update_whitelist: { + to_add: string[] + to_remove: string[] + } + } +export type UpdateSubAccountAction = + | { + unregister_sub_account: { + id: number + } + } + | { + register_sub_account: { + id: number + } + } +export type GovAction = + | { + transfer_ownership: { + expiry?: Expiration | null + new_owner: GovernanceDetailsForString + } + } + | 'accept_ownership' + | 'renounce_ownership' +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } export interface Coin { - amount: Uint128; - denom: string; + amount: Uint128 + denom: string } export interface Empty {} export interface AnyMsg { - type_url: string; - value: Binary; + type_url: string + value: Binary } export interface IbcTimeout { - block?: IbcTimeoutBlock | null; - timestamp?: Timestamp | null; + block?: IbcTimeoutBlock | null + timestamp?: Timestamp | null } export interface IbcTimeoutBlock { - height: number; - revision: number; + height: number + revision: number } export interface WeightedVoteOption { - option: VoteOption; - weight: Decimal; + option: VoteOption + weight: Decimal } -export type QueryMsg = { - config: {}; -} | { - module_versions: { - ids: string[]; - }; -} | { - module_addresses: { - ids: string[]; - }; -} | { - module_infos: { - limit?: number | null; - start_after?: string | null; - }; -} | { - info: {}; -} | { - sub_account_ids: { - limit?: number | null; - start_after?: number | null; - }; -} | { - top_level_owner: {}; -} | { - ownership: {}; -} | { - authenticator_by_i_d: { - id: number; - }; -} | { - authenticator_i_ds: {}; -}; +export type QueryMsg = + | { + config: {} + } + | { + module_versions: { + ids: string[] + } + } + | { + module_addresses: { + ids: string[] + } + } + | { + module_infos: { + limit?: number | null + start_after?: string | null + } + } + | { + info: {} + } + | { + sub_account_ids: { + limit?: number | null + start_after?: number | null + } + } + | { + top_level_owner: {} + } + | { + ownership: {} + } + | { + authenticator_by_i_d: { + id: number + } + } + | { + authenticator_i_ds: {} + } export interface MigrateMsg {} export interface ConfigResponse { - account_id: AccountId; - is_suspended: boolean; - module_factory_address: Addr; - registry_address: Addr; - whitelisted_addresses: Addr[]; + account_id: AccountId + is_suspended: boolean + module_factory_address: Addr + registry_address: Addr + whitelisted_addresses: Addr[] } export interface InfoResponse { - info: AccountInfo; + info: AccountInfo } export interface AccountInfo { - description?: string | null; - link?: string | null; - name?: string | null; + description?: string | null + link?: string | null + name?: string | null } export interface ModuleAddressesResponse { - modules: [string, Addr][]; + modules: [string, Addr][] } export interface ModuleInfosResponse { - module_infos: AccountModuleInfo[]; + module_infos: AccountModuleInfo[] } export interface AccountModuleInfo { - address: Addr; - id: string; - version: ContractVersion; + address: Addr + id: string + version: ContractVersion } export interface ContractVersion { - contract: string; - version: string; + contract: string + version: string } export interface ModuleVersionsResponse { - versions: ContractVersion[]; + versions: ContractVersion[] } export interface OwnershipForString { - owner: GovernanceDetailsForString; - pending_expiry?: Expiration | null; - pending_owner?: GovernanceDetailsForString | null; + owner: GovernanceDetailsForString + pending_expiry?: Expiration | null + pending_owner?: GovernanceDetailsForString | null } export interface SubAccountIdsResponse { - sub_accounts: number[]; + sub_accounts: number[] } export interface TopLevelOwnerResponse { - address: Addr; -} \ No newline at end of file + address: Addr +} diff --git a/src/formulas/formulas/contract/abstract/types/registry.ts b/src/formulas/formulas/contract/abstract/types/registry.ts index cf698ab7..1218704e 100644 --- a/src/formulas/formulas/contract/abstract/types/registry.ts +++ b/src/formulas/formulas/contract/abstract/types/registry.ts @@ -1,228 +1,273 @@ /** -* This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. -* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, -* and run the @cosmwasm/ts-codegen generate command to regenerate this file. -*/ + * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + */ -export type Uint128 = string; +export type Uint128 = string export interface InstantiateMsg { - admin: string; - namespace_registration_fee?: Coin | null; - security_disabled?: boolean | null; + admin: string + namespace_registration_fee?: Coin | null + security_disabled?: boolean | null } export interface Coin { - amount: Uint128; - denom: string; -} -export type ExecuteMsg = { - remove_module: { - module: ModuleInfo; - }; -} | { - yank_module: { - module: ModuleInfo; - }; -} | { - propose_modules: { - modules: [ModuleInfo, ModuleReference][]; - }; -} | { - update_module_configuration: { - module_name: string; - namespace: Namespace; - update_module: UpdateModule; - }; -} | { - approve_or_reject_modules: { - approves: ModuleInfo[]; - rejects: ModuleInfo[]; - }; -} | { - claim_namespace: { - account_id: AccountId; - namespace: string; - }; -} | { - forgo_namespace: { - namespaces: string[]; - }; -} | { - add_account: { - creator: string; - namespace?: string | null; - }; -} | { - update_config: { - namespace_registration_fee?: ClearableForCoin | null; - security_disabled?: boolean | null; - }; -} | { - update_ownership: Action; -}; -export type Namespace = string; -export type ModuleVersion = "latest" | { - version: string; -}; -export type ModuleReference = { - account: number; -} | { - native: Addr; -} | { - adapter: Addr; -} | { - app: number; -} | { - standalone: number; -} | { - service: Addr; -}; -export type Addr = string; -export type UpdateModule = { - default: { - metadata: string; - }; -} | { - versioned: { - instantiation_funds?: Coin[] | null; - metadata?: string | null; - monetization?: Monetization | null; - version: string; - }; -}; -export type Monetization = "none" | { - install_fee: FixedFee; -}; -export type AccountTrace = "local" | { - remote: TruncatedChainId[]; -}; -export type TruncatedChainId = string; -export type ClearableForCoin = "clear" | { - set: Coin; -}; -export type Action = { - transfer_ownership: { - expiry?: Expiration | null; - new_owner: string; - }; -} | "accept_ownership" | "renounce_ownership"; -export type Expiration = { - at_height: number; -} | { - at_time: Timestamp; -} | { - never: {}; -}; -export type Timestamp = Uint64; -export type Uint64 = string; + amount: Uint128 + denom: string +} +export type ExecuteMsg = + | { + remove_module: { + module: ModuleInfo + } + } + | { + yank_module: { + module: ModuleInfo + } + } + | { + propose_modules: { + modules: [ModuleInfo, ModuleReference][] + } + } + | { + update_module_configuration: { + module_name: string + namespace: Namespace + update_module: UpdateModule + } + } + | { + approve_or_reject_modules: { + approves: ModuleInfo[] + rejects: ModuleInfo[] + } + } + | { + claim_namespace: { + account_id: AccountId + namespace: string + } + } + | { + forgo_namespace: { + namespaces: string[] + } + } + | { + add_account: { + creator: string + namespace?: string | null + } + } + | { + update_config: { + namespace_registration_fee?: ClearableForCoin | null + security_disabled?: boolean | null + } + } + | { + update_ownership: Action + } +export type Namespace = string +export type ModuleVersion = + | 'latest' + | { + version: string + } +export type ModuleReference = + | { + account: number + } + | { + native: Addr + } + | { + adapter: Addr + } + | { + app: number + } + | { + standalone: number + } + | { + service: Addr + } +export type Addr = string +export type UpdateModule = + | { + default: { + metadata: string + } + } + | { + versioned: { + instantiation_funds?: Coin[] | null + metadata?: string | null + monetization?: Monetization | null + version: string + } + } +export type Monetization = + | 'none' + | { + install_fee: FixedFee + } +export type AccountTrace = + | 'local' + | { + remote: TruncatedChainId[] + } +export type TruncatedChainId = string +export type ClearableForCoin = + | 'clear' + | { + set: Coin + } +export type Action = + | { + transfer_ownership: { + expiry?: Expiration | null + new_owner: string + } + } + | 'accept_ownership' + | 'renounce_ownership' +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type Timestamp = Uint64 +export type Uint64 = string export interface ModuleInfo { - name: string; - namespace: Namespace; - version: ModuleVersion; + name: string + namespace: Namespace + version: ModuleVersion } export interface FixedFee { - fee: Coin; + fee: Coin } export interface AccountId { - seq: number; - trace: AccountTrace; -} -export type QueryMsg = { - accounts: { - account_ids: AccountId[]; - }; -} | { - modules: { - infos: ModuleInfo[]; - }; -} | { - namespaces: { - accounts: AccountId[]; - }; -} | { - namespace: { - namespace: Namespace; - }; -} | { - config: {}; -} | { - account_list: { - limit?: number | null; - start_after?: AccountId | null; - }; -} | { - module_list: { - filter?: ModuleFilter | null; - limit?: number | null; - start_after?: ModuleInfo | null; - }; -} | { - namespace_list: { - limit?: number | null; - start_after?: string | null; - }; -} | { - ownership: {}; -}; -export type ModuleStatus = "registered" | "pending" | "yanked"; + seq: number + trace: AccountTrace +} +export type QueryMsg = + | { + accounts: { + account_ids: AccountId[] + } + } + | { + modules: { + infos: ModuleInfo[] + } + } + | { + namespaces: { + accounts: AccountId[] + } + } + | { + namespace: { + namespace: Namespace + } + } + | { + config: {} + } + | { + account_list: { + limit?: number | null + start_after?: AccountId | null + } + } + | { + module_list: { + filter?: ModuleFilter | null + limit?: number | null + start_after?: ModuleInfo | null + } + } + | { + namespace_list: { + limit?: number | null + start_after?: string | null + } + } + | { + ownership: {} + } +export type ModuleStatus = 'registered' | 'pending' | 'yanked' export interface ModuleFilter { - name?: string | null; - namespace?: string | null; - status?: ModuleStatus | null; - version?: string | null; -} -export type MigrateMsg = { - instantiate: InstantiateMsg; -} | { - migrate: {}; -}; -export type AccountForAddr = Addr; + name?: string | null + namespace?: string | null + status?: ModuleStatus | null + version?: string | null +} +export type MigrateMsg = + | { + instantiate: InstantiateMsg + } + | { + migrate: {} + } +export type AccountForAddr = Addr export interface AccountListResponse { - accounts: [AccountId, AccountForAddr][]; + accounts: [AccountId, AccountForAddr][] } export interface AccountsResponse { - accounts: AccountForAddr[]; + accounts: AccountForAddr[] } export interface ConfigResponse { - local_account_sequence: number; - namespace_registration_fee?: Coin | null; - security_disabled: boolean; + local_account_sequence: number + namespace_registration_fee?: Coin | null + security_disabled: boolean } export interface ModulesListResponse { - modules: ModuleResponse[]; + modules: ModuleResponse[] } export interface ModuleResponse { - config: ModuleConfiguration; - module: Module; + config: ModuleConfiguration + module: Module } export interface ModuleConfiguration { - instantiation_funds: Coin[]; - metadata?: string | null; - monetization: Monetization; + instantiation_funds: Coin[] + metadata?: string | null + monetization: Monetization } export interface Module { - info: ModuleInfo; - reference: ModuleReference; + info: ModuleInfo + reference: ModuleReference } export interface ModulesResponse { - modules: ModuleResponse[]; + modules: ModuleResponse[] } -export type NamespaceResponse = { - claimed: NamespaceInfo; -} | { - unclaimed: {}; -}; +export type NamespaceResponse = + | { + claimed: NamespaceInfo + } + | { + unclaimed: {} + } export interface NamespaceInfo { - account: AccountForAddr; - account_id: AccountId; + account: AccountForAddr + account_id: AccountId } export interface NamespaceListResponse { - namespaces: [Namespace, AccountId][]; + namespaces: [Namespace, AccountId][] } export interface NamespacesResponse { - namespaces: [Namespace, AccountId][]; + namespaces: [Namespace, AccountId][] } export interface OwnershipForString { - owner?: string | null; - pending_expiry?: Expiration | null; - pending_owner?: string | null; -} \ No newline at end of file + owner?: string | null + pending_expiry?: Expiration | null + pending_owner?: string | null +} From 5331d3a81b8d5217e58809d2328d831400a1af96 Mon Sep 17 00:00:00 2001 From: adairrr <32375605+adairrr@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:54:29 -0500 Subject: [PATCH 29/29] Update abstract types to 0.26 --- .../formulas/contract/abstract/types/account.ts | 5 +++-- .../formulas/contract/abstract/types/registry.ts | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/formulas/formulas/contract/abstract/types/account.ts b/src/formulas/formulas/contract/abstract/types/account.ts index 497187d8..50d1f76a 100644 --- a/src/formulas/formulas/contract/abstract/types/account.ts +++ b/src/formulas/formulas/contract/abstract/types/account.ts @@ -1,7 +1,7 @@ /** - * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. + * This file was automatically generated by @abstract-money/ts-codegen@0.37.0-beta-5. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + * and run the @abstract-money/ts-codegen generate command to regenerate this file. */ export type AccountTrace = @@ -96,6 +96,7 @@ export type Addr = string export interface InstantiateMsg { account_id?: AccountId | null authenticator?: AddAuthenticator | null + code_id: number description?: string | null install_modules?: ModuleInstallConfig[] link?: string | null diff --git a/src/formulas/formulas/contract/abstract/types/registry.ts b/src/formulas/formulas/contract/abstract/types/registry.ts index 1218704e..f0c5efc0 100644 --- a/src/formulas/formulas/contract/abstract/types/registry.ts +++ b/src/formulas/formulas/contract/abstract/types/registry.ts @@ -1,14 +1,14 @@ /** - * This file was automatically generated by @cosmwasm/ts-codegen@1.11.1. + * This file was automatically generated by @abstract-money/ts-codegen@0.37.0-beta-5. * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, - * and run the @cosmwasm/ts-codegen generate command to regenerate this file. + * and run the @abstract-money/ts-codegen generate command to regenerate this file. */ export type Uint128 = string export interface InstantiateMsg { admin: string namespace_registration_fee?: Coin | null - security_disabled?: boolean | null + security_enabled?: boolean | null } export interface Coin { amount: Uint128 @@ -63,7 +63,7 @@ export type ExecuteMsg = | { update_config: { namespace_registration_fee?: ClearableForCoin | null - security_disabled?: boolean | null + security_enabled?: boolean | null } } | { @@ -228,7 +228,7 @@ export interface AccountsResponse { export interface ConfigResponse { local_account_sequence: number namespace_registration_fee?: Coin | null - security_disabled: boolean + security_enabled: boolean } export interface ModulesListResponse { modules: ModuleResponse[]