From 0b9913046382f9fcce64be513d3cd6176c2acbd6 Mon Sep 17 00:00:00 2001 From: Interchain Adair <32375605+adairrr@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:13:27 -0500 Subject: [PATCH] Abstract Indexer Definitions (#12) --- .eslintignore | 1 + package-lock.json | 2 + package.json | 2 + src/formulas/formulas/account/abstract.ts | 71 +++ src/formulas/formulas/account/index.ts | 1 + .../formulas/contract/abstract/account.ts | 134 +++++ .../formulas/contract/abstract/index.ts | 2 + .../formulas/contract/abstract/registry.ts | 274 +++++++++ .../contract/abstract/types/account.ts | 526 ++++++++++++++++++ .../formulas/contract/abstract/types/index.ts | 2 + .../contract/abstract/types/registry.ts | 273 +++++++++ src/formulas/formulas/contract/index.ts | 1 + static/openapi.json | 483 ++++++++++++++++ 13 files changed, 1772 insertions(+) create mode 100644 src/formulas/formulas/account/abstract.ts create mode 100644 src/formulas/formulas/contract/abstract/account.ts create mode 100644 src/formulas/formulas/contract/abstract/index.ts create mode 100644 src/formulas/formulas/contract/abstract/registry.ts create mode 100644 src/formulas/formulas/contract/abstract/types/account.ts create mode 100644 src/formulas/formulas/contract/abstract/types/index.ts create mode 100644 src/formulas/formulas/contract/abstract/types/registry.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/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 6853990e..b07e5885 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,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", @@ -119,6 +120,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/account/abstract.ts b/src/formulas/formulas/account/abstract.ts new file mode 100644 index 00000000..07126636 --- /dev/null +++ b/src/formulas/formulas/account/abstract.ts @@ -0,0 +1,71 @@ +import { Op } from 'sequelize' + +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 owned = + ( + await getTransformationMatches( + undefined, + 'owner', + { + [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 owned + }, +} diff --git a/src/formulas/formulas/account/index.ts b/src/formulas/formulas/account/index.ts index 1690b43f..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' diff --git a/src/formulas/formulas/contract/abstract/account.ts b/src/formulas/formulas/contract/abstract/account.ts new file mode 100644 index 00000000..d7481250 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/account.ts @@ -0,0 +1,134 @@ +import { ContractFormula } from '@/types' + +import { makeSimpleContractFormula } from '../../utils' +import * as Common from '../common' +import { AccountTypes } from './types' +import { Addr, GovernanceDetailsForString } from './types/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 const owner = makeSimpleContractFormula< + { owner: GovernanceDetailsForString }, + GovernanceDetailsForString | null +>({ + docs: { + description: 'Get the owner of the account', + }, + transformation: AccountStorageKeys.OWNER, + fallbackKeys: [AccountStorageKeys.OWNER], + transform: (data) => data.owner, + fallback: null, +}) + +export const accountId = + makeSimpleContractFormula({ + docs: { + description: 'Get accountId of the account', + }, + key: AccountStorageKeys.ACCOUNT_ID, + fallback: null, + }) + +export const suspensionStatus = makeSimpleContractFormula({ + docs: { + description: 'Get suspension status of the account', + }, + key: AccountStorageKeys.SUSPENSION_STATUS, + fallback: null, +}) + +export const info = makeSimpleContractFormula({ + docs: { + description: 'Get the account info', + }, + key: AccountStorageKeys.INFO, + fallback: null, +}) + +export const whitelistedModules = makeSimpleContractFormula({ + docs: { + description: 'Get a list of whitelisted modules', + }, + key: AccountStorageKeys.WHITELISTED_MODULES, + fallback: null, +}) + +export const subAccountIds: ContractFormula = { + docs: { + description: 'Get sub-accounts owned by this account', + }, + compute: async ({ contractAddress, getMap }) => { + const subAccountsMap = + (await getMap( + contractAddress, + AccountStorageKeys.SUB_ACCOUNTS, + { + keyType: 'number', + } + )) ?? {} + + return Object.keys(subAccountsMap).map((seq) => ({ + trace: 'local', + seq: Number(seq), + })) + }, +} + +export const moduleInfos: ContractFormula< + Array< + Omit< + AccountTypes.ModuleInfosResponse['module_infos'][number], + 'version' + > & { version: string | undefined } + > +> = { + docs: { + description: 'Get module infos that are installed on this account', + }, + compute: async (env) => { + const { contractAddress, getMap } = env + + const moduleAddressesMap = + (await getMap( + contractAddress, + AccountStorageKeys.ACCOUNT_MODULES + )) ?? {} + + // 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({ + ...env, + contractAddress: address, + }) + + return { + id: contractInfo?.contract ?? moduleId, + address, + version: contractInfo?.version, + } + }) + ) + }, +} + +// 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/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/registry.ts b/src/formulas/formulas/contract/abstract/registry.ts new file mode 100644 index 00000000..b9427dd9 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/registry.ts @@ -0,0 +1,274 @@ +import semver from 'semver/preload' + +import { Module } from '@/formulas/formulas/contract/abstract/types/registry' +import { ContractFormula } from '@/types' +import { dbKeyForKeys, dbKeyToKeys } from '@/utils' + +import { RegistryTypes } from './types' + +const RegistryStorageKeys = { + CONFIG: 'cfg', + PENDING_MODULES: 'ca', + REGISTERED_MODULES: 'cb', + 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> = { + docs: { + description: 'Lists registered modules in registry', + }, + compute: async ({ contractAddress, getMap }) => { + const registeredModulesMap = + (await getMap( + contractAddress, + RegistryStorageKeys.REGISTERED_MODULES, + { keyType: 'raw' } + )) ?? {} + + return Object.entries(registeredModulesMap).map(([key, reference]) => { + const [namespace, name, version] = dbKeyToKeys(key, [ + false, + false, + false, + ]) as string[] + + const info: RegistryTypes.ModuleInfo = { + namespace, + name, + version: { version }, + } + return { + info, + reference, + } + }) + }, +} + +const moduleInfoToKey = ({ + namespace, + name, + version, +}: RegistryTypes.ModuleInfo | ModuleInfoParameter): string => { + const versionKey = version + ? typeof version === 'string' + ? version + : version.version + : 'latest' + return dbKeyForKeys(namespace, name, versionKey) +} + +const DEFAULT_MODULE_CONFIG: RegistryTypes.ModuleConfiguration = { + monetization: 'none', + instantiation_funds: [], +} + +type ModuleInfoParameter = Omit & { + version?: string +} + +export const moduleConfig: ContractFormula< + RegistryTypes.ModuleConfiguration | undefined, + ModuleInfoParameter +> = { + docs: { + description: 'Configuration of the module installation', + 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', + // We force version here + required: true, + schema: { + type: 'string', + }, + }, + ], + }, + compute: async ({ contractAddress, getMap, args }) => { + if (!args || !args.name || !args.namespace || !args.version) + return undefined + const moduleInfo: RegistryTypes.ModuleInfo = { + namespace: args.namespace, + name: args.name, + version: { version: args.version }, + } + + const versionedConfigMap = + (await getMap( + contractAddress, + RegistryStorageKeys.CONFIG, + { + keyType: 'raw', + } + )) ?? {} + + const moduleConfig = + versionedConfigMap[moduleInfoToKey(moduleInfo)] ?? DEFAULT_MODULE_CONFIG + + if (moduleConfig.metadata) { + return moduleConfig + } + + const defaultConfigMap = + (await getMap( + contractAddress, + RegistryStorageKeys.MODULE_DEFAULT_CONFIG, + { + keyType: 'raw', + } + )) ?? {} + + let moduleDefaultConfig = + defaultConfigMap[dbKeyForKeys(args.namespace, args.name)] + + return { + ...moduleConfig, + metadata: moduleDefaultConfig?.metadata, + } + }, +} + +export const module: ContractFormula< + RegistryTypes.ModuleResponse | undefined, + ModuleInfoParameter +> = { + docs: { + 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 + if (!args || !args.namespace || !args.name) return undefined + const moduleParam = args as ModuleInfoParameter + + const registeredModules = await listRegisteredModules.compute(env) + + const filteredModules = registeredModules.filter( + ({ info: { name, namespace } }) => { + return namespace === moduleParam.namespace && name === moduleParam.name + } + ) + + let foundModule: Module | 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] + } else { + // Get the proper module version + foundModule = filteredModules.find( + ({ info: { version } }) => + (typeof version === 'string' ? version : version.version) === + (moduleParam as { version: string }).version + ) + } + + // 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 && + foundConfig && { + module: foundModule, + config: foundConfig, + } + ) + }, +} + +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]) as [ + string, + number + ] + + const trace = + trace_raw === 'local' ? 'local' : { remote: trace_raw.split('>') } + return [ + { + seq: sequence, + trace, + }, + reference, + ] satisfies [RegistryTypes.AccountId, RegistryTypes.AccountForAddr] + } + ) + return { accounts } + }, + } 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..50d1f76a --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/account.ts @@ -0,0 +1,526 @@ +/** + * 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 @abstract-money/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 + code_id: number + 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 +} 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..50d51c84 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/index.ts @@ -0,0 +1,2 @@ +export * as AccountTypes from './account' +export * as RegistryTypes from './registry' 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..f0c5efc0 --- /dev/null +++ b/src/formulas/formulas/contract/abstract/types/registry.ts @@ -0,0 +1,273 @@ +/** + * 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 @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_enabled?: 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_enabled?: 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_enabled: 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 +} 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' diff --git a/static/openapi.json b/static/openapi.json index 15b9aa2d..0ccf4f68 100644 --- a/static/openapi.json +++ b/static/openapi.json @@ -26,9 +26,446 @@ "servers": [ { "url": "https://indexer.daodao.zone" + }, + { + "url": "http://localhost:3420" } ], "paths": { + "/{chainId}/contract/{address}/abstractAccount/accountId": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > accountId", + "description": "Get accountId of the account", + "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}/abstractAccount/info": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > info", + "description": "Get the 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}/abstractAccount/moduleInfos": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > moduleInfos", + "description": "Get module infos that are installed on this account", + "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}/abstractAccount/owner": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > owner", + "description": "Get the owner of the account", + "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}/abstractAccount/subAccountIds": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > subAccountIds", + "description": "Get sub-accounts owned by this account", + "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}/abstractAccount/suspensionStatus": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > suspensionStatus", + "description": "Get suspension status of the account", + "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}/abstractAccount/whitelistedModules": { + "get": { + "tags": [ + "contract" + ], + "summary": "abstractAccount > whitelistedModules", + "description": "Get a list of whitelisted modules", + "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/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": [ @@ -11101,6 +11538,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": [