From 8539e8c315e2bb75ea0f2f4147753b91920180e0 Mon Sep 17 00:00:00 2001 From: Rodion Chachura Date: Thu, 14 Sep 2023 14:22:47 +0400 Subject: [PATCH 1/3] update: use enterprise facade for dao & proposal indexers --- indexers/enterprise/package.json | 6 +- .../enterprise/src/collectors/events/index.ts | 4 +- .../enterprise/src/indexers/daos/Indexer.ts | 8 +- .../enterprise/src/indexers/daos/types.ts | 8 +- .../src/indexers/proposals/Indexer.ts | 19 +- .../proposals/getProposalFromContract.ts | 29 +- .../src/indexers/proposals/types.ts | 10 +- .../{enterprise.ts => enterprise_facade.ts} | 866 ++++++++---------- .../src/types/contracts/enterprise_factory.ts | 203 ++-- .../enterprise/src/types/contracts/index.ts | 2 +- indexers/enterprise/src/utils/Environment.ts | 12 +- .../shared/utils/daoContractAddressRecord.ts | 14 + indexers/shared/utils/getContractAddress.ts | 35 - indexers/shared/utils/index.ts | 26 +- 14 files changed, 595 insertions(+), 647 deletions(-) rename indexers/enterprise/src/types/contracts/{enterprise.ts => enterprise_facade.ts} (64%) create mode 100644 indexers/shared/utils/daoContractAddressRecord.ts delete mode 100644 indexers/shared/utils/getContractAddress.ts diff --git a/indexers/enterprise/package.json b/indexers/enterprise/package.json index da1f9e9b..78f18088 100644 --- a/indexers/enterprise/package.json +++ b/indexers/enterprise/package.json @@ -34,9 +34,9 @@ }, "generate-types": { "contracts": [ - "enterprise", - "enterprise-factory" + "enterprise-factory", + "enterprise-facade" ], "output": "src/types/contracts" } -} +} \ No newline at end of file diff --git a/indexers/enterprise/src/collectors/events/index.ts b/indexers/enterprise/src/collectors/events/index.ts index 1978b803..a26cc848 100644 --- a/indexers/enterprise/src/collectors/events/index.ts +++ b/indexers/enterprise/src/collectors/events/index.ts @@ -3,10 +3,12 @@ import { EventCollector } from '@apps-shared/indexers/collectors'; import { EventStoreTableInitializer, StateTableInitializer } from '@apps-shared/indexers/initializers'; import { Runner } from '@apps-shared/indexers/indexers'; import { + NetworkName, createDynamoDBClient, createEventStore, createLCDClient, createState, + daoContractAddressRecord, fetchAll, } from '@apps-shared/indexers/utils'; import { BlockListener } from '@apps-shared/indexers/services/block-listener'; @@ -23,7 +25,7 @@ const state = createState('collector:enterprise-events'); const genesis = Environment.getGenesis(); -const enterpriseFactoryAddress = Environment.getContractAddress('enterprise-factory'); +const enterpriseFactoryAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-factory']; class EnterpriseEventCollector implements Runnable { private enterpriseAddresses: string[] = []; diff --git a/indexers/enterprise/src/indexers/daos/Indexer.ts b/indexers/enterprise/src/indexers/daos/Indexer.ts index 52089071..6fb2f668 100644 --- a/indexers/enterprise/src/indexers/daos/Indexer.ts +++ b/indexers/enterprise/src/indexers/daos/Indexer.ts @@ -2,17 +2,19 @@ import { EventIndexer, IndexFnOptions } from 'indexers/EventIndexer'; import { LCDClient } from '@terra-money/feather.js'; import { DaoEntity } from './types'; import { TableNames, DAOS_PK_NAME, DAOS_SK_NAME } from 'initializers'; -import { batch, createLCDClient } from '@apps-shared/indexers/utils'; +import { NetworkName, batch, createLCDClient, daoContractAddressRecord } from '@apps-shared/indexers/utils'; import { KeySelector } from '@apps-shared/indexers/services/persistence'; import { fetchByHeight } from '@apps-shared/indexers/services/event-store'; import { EnterpriseEventPK, ExecuteProposalEvent, InstantiateDaoEvent } from 'types/events'; -import { enterprise } from 'types/contracts'; import Big from 'big.js'; +import { enterprise_facade } from 'types/contracts'; export const PK: KeySelector = (data) => data.address; export const SK = 'dao'; +const enterpriseFacadeAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-facade']; + export class Indexer extends EventIndexer { constructor() { super({ @@ -45,7 +47,7 @@ export class Indexer extends EventIndexer { }; private fetchDAO = async (lcd: LCDClient, address: string): Promise => { - const response = await lcd.wasm.contractQuery(address, { dao_info: {} }); + const response = await lcd.wasm.contractQuery(address, { dao_info: {} }); const created = 'creation_date' in response ? Math.trunc(Big(response.creation_date).div(1000000).toNumber()) : 0; return { diff --git a/indexers/enterprise/src/indexers/daos/types.ts b/indexers/enterprise/src/indexers/daos/types.ts index 56b446ba..5b33d2e9 100644 --- a/indexers/enterprise/src/indexers/daos/types.ts +++ b/indexers/enterprise/src/indexers/daos/types.ts @@ -1,9 +1,9 @@ -import { enterprise } from 'types/contracts'; +import { enterprise_facade } from 'types/contracts'; export type DaoEntity = { _type: string; address: string; - type: enterprise.DaoType; + type: enterprise_facade.DaoType; name: string; description?: string; lowerCaseName: string; @@ -12,7 +12,7 @@ export type DaoEntity = { enterpriseFactoryContract: string; created: number; codeVersionId: string; - council: enterprise.DaoCouncil; + council: enterprise_facade.DaoCouncil; socials: { discord_username?: string; github_username?: string; @@ -23,7 +23,7 @@ export type DaoEntity = { quorum: number; threshold: number; vetoThreshold: number; - unlockingPeriod: enterprise.Duration; + unlockingPeriod: enterprise_facade.Duration; voteDuration: number; minimumDeposit?: string; }; diff --git a/indexers/enterprise/src/indexers/proposals/Indexer.ts b/indexers/enterprise/src/indexers/proposals/Indexer.ts index 2e1f53ae..3e7ad4a3 100644 --- a/indexers/enterprise/src/indexers/proposals/Indexer.ts +++ b/indexers/enterprise/src/indexers/proposals/Indexer.ts @@ -1,17 +1,19 @@ import { EventIndexer, IndexFnOptions } from 'indexers/EventIndexer'; import { Entity, ProposalKey } from './types'; import { TableNames, DAOS_PK_NAME, DAOS_SK_NAME } from 'initializers'; -import { batch, createLCDClient } from '@apps-shared/indexers/utils'; +import { NetworkName, batch, createLCDClient, daoContractAddressRecord } from '@apps-shared/indexers/utils'; import { KeySelector } from '@apps-shared/indexers/services/persistence'; import { fetchByHeight } from '@apps-shared/indexers/services/event-store'; import { DaoEvents, EnterpriseEventPK } from 'types/events'; -import { enterprise } from 'types/contracts'; import { getProposalFromContract } from './getProposalFromContract'; +import { enterprise_facade } from 'types/contracts'; export const PK: KeySelector = (data) => data.daoAddress; export const SK: KeySelector = (data) => `proposal:${data.id}`; +const enterpriseFacadeAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-facade']; + export class Indexer extends EventIndexer { constructor() { super({ @@ -71,11 +73,18 @@ export class Indexer extends EventIndexer { daoAddresses.map(async (daoAddress) => { try { this.logger.info(`Getting proposals for ${daoAddress} DAO.`); - const { proposals } = await lcd.wasm.contractQuery(daoAddress, { + const query: enterprise_facade.QueryMsg = { proposals: { - filter: 'in_progress', + contract: daoAddress, + params: { + filter: 'in_progress', + }, }, - }); + }; + const { proposals } = await lcd.wasm.contractQuery( + enterpriseFacadeAddress, + query + ); proposals.forEach(({ proposal }) => { const key: ProposalKey = { daoAddress, id: proposal.id }; if (!proposalsKeys.some((k) => k.daoAddress === key.daoAddress && k.id === key.id)) { diff --git a/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts b/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts index 9f4f5d13..0551b2bc 100644 --- a/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts +++ b/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts @@ -1,24 +1,31 @@ -import { createLCDClient, Logger } from "@apps-shared/indexers/utils"; -import { enterprise } from "types/contracts"; +import { createLCDClient, daoContractAddressRecord, Logger, NetworkName } from '@apps-shared/indexers/utils'; import Big from 'big.js'; -import { Entity } from "./types"; +import { Entity } from './types'; +import { enterprise_facade } from 'types/contracts'; interface GetProposalParams { - daoAddress: string - id: number - logger: Logger + daoAddress: string; + id: number; + logger: Logger; } +const enterpriseFacadeAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-facade']; + export const getProposalFromContract = async ({ daoAddress, id, logger }: GetProposalParams): Promise => { const lcd = createLCDClient(); logger.info(`Fetching proposal with id ${id} for ${daoAddress} DAO.`); - const response = await lcd.wasm.contractQuery(daoAddress, { + const msg: enterprise_facade.QueryMsg = { proposal: { - proposal_id: id, + contract: daoAddress, + params: { + proposal_id: id, + }, }, - }); + }; + + const response = await lcd.wasm.contractQuery(enterpriseFacadeAddress, msg); logger.info(`Received proposal response: ${response}.`); @@ -50,6 +57,6 @@ export const getProposalFromContract = async ({ daoAddress, id, logger }: GetPro vetoVotes, totalVotes: response.total_votes_available, type: response.proposal.proposal_type, - proposer: response.proposal.proposer + proposer: response.proposal.proposer, }; -} \ No newline at end of file +}; diff --git a/indexers/enterprise/src/indexers/proposals/types.ts b/indexers/enterprise/src/indexers/proposals/types.ts index acf177dd..0d204ae2 100644 --- a/indexers/enterprise/src/indexers/proposals/types.ts +++ b/indexers/enterprise/src/indexers/proposals/types.ts @@ -1,4 +1,4 @@ -import { enterprise } from 'types/contracts'; +import { enterprise_facade } from 'types/contracts'; export type Entity = { _type: string; @@ -9,15 +9,15 @@ export type Entity = { started_at: number; title: string; description: string; - expires: enterprise.Expiration; - status: enterprise.ProposalStatus; - proposalActions: enterprise.ProposalAction[]; + expires: enterprise_facade.Expiration; + status: enterprise_facade.ProposalStatus; + proposalActions: enterprise_facade.ProposalAction[]; yesVotes: string; noVotes: string; abstainVotes: string; vetoVotes: string; totalVotes: string; - type: enterprise.ProposalType; + type: enterprise_facade.ProposalType; proposer?: string; }; diff --git a/indexers/enterprise/src/types/contracts/enterprise.ts b/indexers/enterprise/src/types/contracts/enterprise_facade.ts similarity index 64% rename from indexers/enterprise/src/types/contracts/enterprise.ts rename to indexers/enterprise/src/types/contracts/enterprise_facade.ts index d170c61b..8f81ce61 100644 --- a/indexers/enterprise/src/types/contracts/enterprise.ts +++ b/indexers/enterprise/src/types/contracts/enterprise_facade.ts @@ -1,5 +1,9 @@ -export module enterprise { -export type Uint128 = string +export module enterprise_facade { +export type Addr = string +export interface AdapterResponse { + msg: string; + target_contract: Addr; +} export type AssetInfoBaseFor_Addr = | { native: string; @@ -14,20 +18,6 @@ export type AssetInfoBaseFor_Addr = */ cw1155: [Addr, string]; } -export type Addr = string -export interface AssetTreasuryResponse { - assets: AssetBaseFor_Addr[]; -} -export interface AssetBaseFor_Addr { - /** - * Specifies the asset's amount - */ - amount: Uint128; - /** - * Specifies the asset's type (CW20 or native) - */ - info: AssetInfoBaseFor_Addr; -} export interface AssetWhitelistResponse { assets: AssetInfoBaseFor_Addr[]; } @@ -38,6 +28,7 @@ export type ClaimAsset = | { cw721: Cw721ClaimAsset; } +export type Uint128 = string export type ReleaseAt = | { timestamp: Timestamp; @@ -60,12 +51,147 @@ export interface Cw20ClaimAsset { export interface Cw721ClaimAsset { tokens: string[]; } -export type Cw20HookMsg = +export type ProposalActionType = + | "update_metadata" + | "update_gov_config" + | "update_council" + | "update_asset_whitelist" + | "update_nft_whitelist" + | "request_funding_from_dao" + | "upgrade_dao" + | "execute_msgs" + | "modify_multisig_membership" + | "distribute_funds" + | "update_minimum_weight_for_rewards" + | "add_attestation" + | "remove_attestation" + | "deploy_cross_chain_treasury" +export type Decimal = string +export type DaoType = "denom" | "token" | "nft" | "multisig" +export type Duration = + | { + height: number; + } + | { + time: number; + } +export type Logo = + | "none" + | { + url: string; + } +export interface DaoInfoResponse { + creation_date: Timestamp; + dao_code_version: Uint64; + dao_council?: DaoCouncil | null; + dao_membership_contract: Addr; + dao_type: DaoType; + enterprise_factory_contract: Addr; + funds_distributor_contract: Addr; + gov_config: DaoGovConfig; + metadata: DaoMetadata; +} +export interface DaoCouncil { + allowed_proposal_action_types: ProposalActionType[]; + members: Addr[]; + quorum: Decimal; + threshold: Decimal; +} +export interface DaoGovConfig { + /** + * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. + */ + allow_early_proposal_execution: boolean; + /** + * Optional minimum amount of DAO's governance unit to be required to create a deposit. + */ + minimum_deposit?: Uint128 | null; + /** + * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires + */ + quorum: Decimal; + /** + * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win + */ + threshold: Decimal; + /** + * Duration that has to pass for unstaked membership tokens to be claimable + */ + unlocking_period: Duration; + /** + * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. + */ + veto_threshold?: Decimal | null; + /** + * Duration of proposals before they end, expressed in seconds + */ + vote_duration: number; +} +export interface DaoMetadata { + description?: string | null; + logo: Logo; + name: string; + socials: DaoSocialData; +} +export interface DaoSocialData { + discord_username?: string | null; + github_username?: string | null; + telegram_username?: string | null; + twitter_username?: string | null; +} +export type ExecuteMsg = { + execute_proposal: { + contract: Addr; + msg: ExecuteProposalMsg; + }; +} +export interface ExecuteProposalMsg { + proposal_id: number; +} +export interface InstantiateMsg {} +export interface MemberInfoResponse { + voting_power: Decimal; +} +export interface MemberVoteResponse { + vote?: Vote | null; +} +export interface Vote { + /** + * Number of votes on the outcome. + */ + amount: number; + /** + * The outcome, 0-indexed. + */ + outcome: number; + /** + * Unique identifier for the poll. + */ + poll_id: number; + /** + * Voter address. + */ + voter: Addr; +} +export interface MultisigMembersResponse { + members: MultisigMember[]; +} +export interface MultisigMember { + address: string; + weight: Uint128; +} +export interface NftWhitelistResponse { + nfts: Addr[]; +} +export type Expiration = | { - stake: {}; + at_height: number; + } + | { + at_time: Timestamp; } | { - create_proposal: CreateProposalMsg; + never: {}; } export type ProposalAction = | { @@ -78,10 +204,10 @@ export type ProposalAction = update_council: UpdateCouncilMsg; } | { - update_asset_whitelist: UpdateAssetWhitelistMsg; + update_asset_whitelist: UpdateAssetWhitelistProposalActionMsg; } | { - update_nft_whitelist: UpdateNftWhitelistMsg; + update_nft_whitelist: UpdateNftWhitelistProposalActionMsg; } | { request_funding_from_dao: RequestFundingFromDaoMsg; @@ -98,6 +224,18 @@ export type ProposalAction = | { distribute_funds: DistributeFundsMsg; } + | { + update_minimum_weight_for_rewards: UpdateMinimumWeightForRewardsMsg; + } + | { + add_attestation: AddAttestationMsg; + } + | { + remove_attestation: {}; + } + | { + deploy_cross_chain_treasury: DeployCrossChainTreasuryMsg; + } export type ModifyValueFor_Nullable_String = | "no_change" | { @@ -108,11 +246,6 @@ export type ModifyValueFor_Logo = | { change: Logo; } -export type Logo = - | "none" - | { - url: string; - } export type ModifyValueFor_String = | "no_change" | { @@ -133,19 +266,11 @@ export type ModifyValueFor_Decimal = | { change: Decimal; } -export type Decimal = string export type ModifyValueFor_Duration = | "no_change" | { change: Duration; } -export type Duration = - | { - height: number; - } - | { - time: number; - } export type ModifyValueFor_Nullable_Decimal = | "no_change" | { @@ -156,30 +281,41 @@ export type ModifyValueFor_Uint64 = | { change: Uint64; } -export type ProposalActionType = - | "update_metadata" - | "update_gov_config" - | "update_council" - | "update_asset_whitelist" - | "update_nft_whitelist" - | "request_funding_from_dao" - | "upgrade_dao" - | "execute_msgs" - | "modify_multisig_membership" - | "distribute_funds" +export type AssetInfoBaseFor_String = + | { + native: string; + } + | { + cw20: string; + } + | { + /** + * @minItems 2 + * @maxItems 2 + */ + cw1155: [string, string]; + } export type Binary = string -export interface CreateProposalMsg { - /** - * Optional description text of the proposal - */ - description?: string | null; +export type ProposalType = "general" | "council" +export type ProposalStatus = "in_progress" | "passed" | "rejected" | "executed" +export interface ProposalResponse { + proposal: Proposal; + proposal_status: ProposalStatus; /** - * Actions to be executed, in order, if the proposal passes + * Total vote-count (value) for each outcome (key). */ + results: [number, Uint128][]; + total_votes_available: Uint128; +} +export interface Proposal { + description: string; + expires: Expiration; + id: number; proposal_actions: ProposalAction[]; - /** - * Title of the proposal - */ + proposal_type: ProposalType; + proposer: Addr; + started_at: Timestamp; + status: ProposalStatus; title: string; } export interface UpdateMetadataMsg { @@ -221,33 +357,75 @@ export interface DaoCouncilSpec { */ threshold: Decimal; } -export interface UpdateAssetWhitelistMsg { +export interface UpdateAssetWhitelistProposalActionMsg { /** * New assets to add to the whitelist. Will ignore assets that are already whitelisted. */ - add: AssetInfoBaseFor_Addr[]; + add: AssetInfoBaseFor_String[]; + remote_treasury_target?: RemoteTreasuryTarget | null; /** * Assets to remove from the whitelist. Will ignore assets that are not already whitelisted. */ - remove: AssetInfoBaseFor_Addr[]; + remove: AssetInfoBaseFor_String[]; +} +export interface RemoteTreasuryTarget { + /** + * Spec for the cross-chain message to send. Treasury address will be determined using chain-id given in the spec. + */ + cross_chain_msg_spec: CrossChainMsgSpec; +} +export interface CrossChainMsgSpec { + chain_id: string; + dest_ibc_channel: string; + dest_ibc_port: string; + src_ibc_channel: string; + src_ibc_port: string; + /** + * Optional timeout for the cross-chain messages. Formatted in nanoseconds. + */ + timeout_nanos?: number | null; + /** + * uluna IBC denom on the remote chain. Currently, can be calculated as 'ibc/' + uppercase(sha256('{port}/{channel}/uluna')) + */ + uluna_denom: string; } -export interface UpdateNftWhitelistMsg { +export interface UpdateNftWhitelistProposalActionMsg { /** * New NFTs to add to the whitelist. Will ignore NFTs that are already whitelisted. */ - add: Addr[]; + add: string[]; + remote_treasury_target?: RemoteTreasuryTarget | null; /** * NFTs to remove from the whitelist. Will ignore NFTs that are not already whitelisted. */ - remove: Addr[]; + remove: string[]; } export interface RequestFundingFromDaoMsg { - assets: AssetBaseFor_Addr[]; + assets: AssetBaseFor_String[]; recipient: string; + remote_treasury_target?: RemoteTreasuryTarget | null; +} +export interface AssetBaseFor_String { + /** + * Specifies the asset's amount + */ + amount: Uint128; + /** + * Specifies the asset's type (CW20 or native) + */ + info: AssetInfoBaseFor_String; } export interface UpgradeDaoMsg { + /** + * Expects a map of (version, migrate msg for that version). E.g. { "1.0.2": { }, "2.0.0": { } } + */ migrate_msg: Binary; - new_dao_code_id: number; + new_version: Version; +} +export interface Version { + major: number; + minor: number; + patch: number; } export interface ExecuteMsgsMsg { action_type: string; @@ -257,476 +435,179 @@ export interface ModifyMultisigMembershipMsg { /** * Members to be edited. Can contain existing members, in which case their new weight will be the one specified in this message. This effectively allows removing of members (by setting their weight to 0). */ - edit_members: MultisigMember[]; + edit_members: UserWeight[]; } -export interface MultisigMember { - address: string; +export interface UserWeight { + user: string; weight: Uint128; } export interface DistributeFundsMsg { - funds: AssetBaseFor_Addr[]; + funds: AssetBaseFor_String[]; } -export type Cw721HookMsg = { - stake: {}; -} -export type DaoType = "token" | "nft" | "multisig" -export interface DaoInfoResponse { - creation_date: Timestamp; - dao_code_version: Uint64; - dao_council?: DaoCouncil | null; - dao_membership_contract: Addr; - dao_type: DaoType; - enterprise_factory_contract: Addr; - funds_distributor_contract: Addr; - gov_config: DaoGovConfig; - metadata: DaoMetadata; +export interface UpdateMinimumWeightForRewardsMsg { + minimum_weight_for_rewards: Uint128; } -export interface DaoCouncil { - allowed_proposal_action_types: ProposalActionType[]; - members: Addr[]; - quorum: Decimal; - threshold: Decimal; +export interface AddAttestationMsg { + attestation_text: string; } -export interface DaoGovConfig { +export interface DeployCrossChainTreasuryMsg { + asset_whitelist?: AssetInfoBaseFor_String[] | null; /** - * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. + * Proxy contract serving globally for the given chain, with no specific permission model. */ - allow_early_proposal_execution: boolean; + chain_global_proxy: string; + cross_chain_msg_spec: CrossChainMsgSpec; + enterprise_treasury_code_id: number; + ics_proxy_code_id: number; + nft_whitelist?: string[] | null; +} +export interface ProposalStatusResponse { + expires: Expiration; /** - * Optional minimum amount of DAO's governance unit to be required to create a deposit. + * Total vote-count (value) for each outcome (key). */ - minimum_deposit?: Uint128 | null; - /** - * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires - */ - quorum: Decimal; - /** - * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win - */ - threshold: Decimal; - /** - * Duration that has to pass for unstaked membership tokens to be claimable - */ - unlocking_period: Duration; - /** - * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. - */ - veto_threshold?: Decimal | null; - /** - * Duration of proposals before they end, expressed in seconds - */ - vote_duration: number; -} -export interface DaoMetadata { - description?: string | null; - logo: Logo; - name: string; - socials: DaoSocialData; -} -export interface DaoSocialData { - discord_username?: string | null; - github_username?: string | null; - telegram_username?: string | null; - twitter_username?: string | null; -} -export type ExecuteMsg = - | { - create_proposal: CreateProposalMsg; - } - | { - create_council_proposal: CreateProposalMsg; - } - | { - cast_vote: CastVoteMsg; - } - | { - cast_council_vote: CastVoteMsg; - } - | { - execute_proposal: ExecuteProposalMsg; - } - | { - unstake: UnstakeMsg; - } - | { - claim: {}; - } - | { - receive: Cw20ReceiveMsg; - } - | { - receive_nft: ReceiveNftMsg; - } -export type VoteOutcome = "yes" | "no" | "abstain" | "veto" -export type UnstakeMsg = - | { - cw20: UnstakeCw20Msg; - } - | { - cw721: UnstakeCw721Msg; - } -export interface CastVoteMsg { - outcome: VoteOutcome; - proposal_id: number; -} -export interface ExecuteProposalMsg { - proposal_id: number; -} -export interface UnstakeCw20Msg { - amount: Uint128; -} -export interface UnstakeCw721Msg { - tokens: string[]; + results: [number, Uint128][]; + status: ProposalStatus; } -export interface Cw20ReceiveMsg { - amount: Uint128; - msg: Binary; - sender: string; +export interface ProposalVotesResponse { + votes: Vote[]; } -export interface ReceiveNftMsg { - edition?: Uint64 | null; - msg: Binary; - sender: string; - token_id: string; +export interface ProposalsResponse { + proposals: ProposalResponse[]; } -export type DaoMembershipInfo = - | { - new: NewDaoMembershipMsg; - } - | { - existing: ExistingDaoMembershipMsg; - } -export type NewMembershipInfo = - | { - new_token: NewTokenMembershipInfo; - } - | { - new_nft: NewNftMembershipInfo; - } +export type QueryMsg = | { - new_multisig: NewMultisigMembershipInfo; + dao_info: { + contract: Addr; + }; } -export interface InstantiateMsg { - /** - * Assets that are allowed to show in DAO's treasury - */ - asset_whitelist?: AssetInfoBaseFor_Addr[] | null; - /** - * Optional council structure that can manage certain aspects of the DAO - */ - dao_council?: DaoCouncilSpec | null; - dao_gov_config: DaoGovConfig; - dao_membership_info: DaoMembershipInfo; - dao_metadata: DaoMetadata; - /** - * Address of enterprise-factory contract that is creating this DAO - */ - enterprise_factory_contract: string; - enterprise_governance_code_id: number; - funds_distributor_code_id: number; - /** - * NFTs (CW721) that are allowed to show in DAO's treasury - */ - nft_whitelist?: Addr[] | null; -} -export interface NewDaoMembershipMsg { - membership_contract_code_id: number; - membership_info: NewMembershipInfo; -} -export interface NewTokenMembershipInfo { - /** - * Optional amount of tokens to be minted to the DAO's address - */ - initial_dao_balance?: Uint128 | null; - initial_token_balances: Cw20Coin[]; - token_decimals: number; - token_marketing?: TokenMarketingInfo | null; - token_mint?: MinterResponse | null; - token_name: string; - token_symbol: string; -} -export interface Cw20Coin { - address: string; - amount: Uint128; -} -export interface TokenMarketingInfo { - description?: string | null; - logo_url?: string | null; - marketing_owner?: string | null; - project?: string | null; -} -export interface MinterResponse { - /** - * cap is a hard cap on total supply that can be achieved by minting. Note that this refers to total_supply. If None, there is unlimited cap. - */ - cap?: Uint128 | null; - minter: string; -} -export interface NewNftMembershipInfo { - minter?: string | null; - nft_name: string; - nft_symbol: string; -} -export interface NewMultisigMembershipInfo { - multisig_members: MultisigMember[]; -} -export interface ExistingDaoMembershipMsg { - dao_type: DaoType; - membership_contract_addr: string; -} -export interface MemberInfoResponse { - voting_power: Decimal; -} -export interface MemberVoteResponse { - vote?: Vote | null; -} -export interface Vote { - /** - * Number of votes on the outcome. - */ - amount: number; - /** - * The outcome, 0-indexed. - */ - outcome: number; - /** - * Unique identifier for the poll. - */ - poll_id: number; - /** - * Voter address. - */ - voter: Addr; -} -export interface MigrateMsg {} -export interface MultisigMembersResponse { - members: MultisigMember[]; -} -export interface NftTreasuryResponse { - nfts: NftCollection[]; -} -export interface NftCollection { - nft_address: Addr; - token_ids: string[]; -} -export interface NftWhitelistResponse { - nfts: Addr[]; -} -export type PollStatus = | { - in_progress: { - ends_at: Timestamp; + member_info: { + contract: Addr; + msg: QueryMemberInfoMsg; }; } | { - passed: { - count: Uint128; - outcome: number; + list_multisig_members: { + contract: Addr; + msg: ListMultisigMembersMsg; }; } | { - rejected: { - reason: PollRejectionReason; + asset_whitelist: { + contract: Addr; + params: AssetWhitelistParams; }; } -export type PollRejectionReason = - | ( - | "quorum_not_reached" - | "threshold_not_reached" - | "quorum_and_threshold_not_reached" - | "is_rejecting_outcome" - | "is_veto_outcome" - ) | { - /** - * @minItems 3 - * @maxItems 3 - */ - outcome_draw: [number, number, Uint128]; - } -export interface PollStatusResponse { - /** - * Poll end time. - */ - ends_at: Timestamp; - /** - * Total vote-count (value) for each outcome (key). - */ - results: [number, Uint128][]; - /** - * Status of the poll. - */ - status: PollStatus; -} -export interface PollVoterResponse { - /** - * The voter's vote on the specific poll. - */ - vote?: Vote | null; -} -export interface PollVotersResponse { - /** - * All votes on the specific poll. - */ - votes: Vote[]; -} -export type VotingScheme = "coin_voting" -export interface PollsResponse { - /** - * The polls. - */ - polls: Poll[]; -} -export interface Poll { - /** - * Poll deposit amount. - */ - deposit_amount: number; - /** - * User-defined description for the poll. - */ - description: string; - /** - * End-time of poll. - */ - ends_at: Timestamp; - /** - * Unique identifier for the poll. - */ - id: number; - /** - * User-defined label for the poll. - */ - label: string; - /** - * Proposer address. - */ - proposer: Addr; - /** - * Quorum to be reached for the poll to be valid. Calculated as (total votes) / (total available votes). - */ - quorum: Decimal; - /** - * Total vote-count (value) for each outcome (key). - */ - results: [number, Uint128][]; - /** - * Voting scheme of the poll, e.g. "CoinVoting". - */ - scheme: VotingScheme; - /** - * Start-time of poll. - */ - started_at: Timestamp; - /** - * Status of the poll. - */ - status: PollStatus; - /** - * Threshold ratio for a vote option to be the winning one. Calculated as (votes for certain option) / (total available votes - abstaining votes). - */ - threshold: Decimal; - /** - * Optional separate threshold ratio for a veto option to be the winning one. Calculated as (veto votes) / (total available votes - abstaining votes). If None, regular threshold will be used for veto option. - */ - veto_threshold?: Decimal | null; -} -export type Expiration = - | { - at_height: number; + nft_whitelist: { + contract: Addr; + params: NftWhitelistParams; + }; } | { - at_time: Timestamp; + proposal: { + contract: Addr; + params: ProposalParams; + }; } | { - never: {}; + proposals: { + contract: Addr; + params: ProposalsParams; + }; } -export type ProposalType = "general" | "council" -export type ProposalStatus = "in_progress" | "passed" | "rejected" | "executed" -export interface ProposalResponse { - proposal: Proposal; - proposal_status: ProposalStatus; - /** - * Total vote-count (value) for each outcome (key). - */ - results: [number, Uint128][]; - total_votes_available: Uint128; -} -export interface Proposal { - description: string; - expires: Expiration; - id: number; - proposal_actions: ProposalAction[]; - proposal_type: ProposalType; - proposer: Addr; - started_at: Timestamp; - status: ProposalStatus; - title: string; -} -export interface ProposalStatusResponse { - expires: Expiration; - /** - * Total vote-count (value) for each outcome (key). - */ - results: [number, Uint128][]; - status: ProposalStatus; -} -export interface ProposalVotesResponse { - votes: Vote[]; -} -export interface ProposalsResponse { - proposals: ProposalResponse[]; -} -export type QueryMsg = | { - dao_info: {}; + proposal_status: { + contract: Addr; + params: ProposalStatusParams; + }; } | { - member_info: QueryMemberInfoMsg; + member_vote: { + contract: Addr; + params: MemberVoteParams; + }; } | { - list_multisig_members: ListMultisigMembersMsg; + proposal_votes: { + contract: Addr; + params: ProposalVotesParams; + }; } | { - asset_whitelist: {}; + user_stake: { + contract: Addr; + params: UserStakeParams; + }; } | { - nft_whitelist: {}; + total_staked_amount: { + contract: Addr; + }; } | { - proposal: ProposalParams; + staked_nfts: { + contract: Addr; + params: StakedNftsParams; + }; } | { - proposals: ProposalsParams; + claims: { + contract: Addr; + params: ClaimsParams; + }; } | { - proposal_status: ProposalStatusParams; + releasable_claims: { + contract: Addr; + params: ClaimsParams; + }; } | { - member_vote: MemberVoteParams; + create_proposal_adapted: { + contract: Addr; + params: CreateProposalMsg; + }; } | { - proposal_votes: ProposalVotesParams; + create_council_proposal_adapted: { + contract: Addr; + params: CreateProposalMsg; + }; } | { - user_stake: UserStakeParams; + cast_vote: { + contract: Addr; + params: CastVoteMsg; + }; } | { - total_staked_amount: {}; + cast_council_vote: { + contract: Addr; + params: CastVoteMsg; + }; } | { - claims: ClaimsParams; + unstake: { + contract: Addr; + params: UnstakeMsg; + }; } | { - releasable_claims: ClaimsParams; + claim: { + contract: Addr; + }; } +export type ProposalStatusFilter = "in_progress" | "passed" | "rejected" +export type VoteOutcome = "yes" | "no" | "abstain" | "veto" +export type UnstakeMsg = | { - cw20_treasury: {}; + cw20: UnstakeCw20Msg; } | { - nft_treasury: {}; + cw721: UnstakeCw721Msg; } -export type ProposalStatusFilter = "in_progress" | "passed" | "rejected" export interface QueryMemberInfoMsg { member_address: string; } @@ -734,6 +615,14 @@ export interface ListMultisigMembersMsg { limit?: number | null; start_after?: string | null; } +export interface AssetWhitelistParams { + limit?: number | null; + start_after?: AssetInfoBaseFor_String | null; +} +export interface NftWhitelistParams { + limit?: number | null; + start_after?: string | null; +} export interface ProposalParams { proposal_id: number; } @@ -761,16 +650,52 @@ export interface ProposalVotesParams { start_after?: string | null; } export interface UserStakeParams { + limit?: number | null; + start_after?: string | null; user: string; } +export interface StakedNftsParams { + limit?: number | null; + start_after?: string | null; +} export interface ClaimsParams { owner: string; } +export interface CreateProposalMsg { + /** + * Optional description text of the proposal + */ + description?: string | null; + /** + * Actions to be executed, in order, if the proposal passes + */ + proposal_actions: ProposalAction[]; + /** + * Title of the proposal + */ + title: string; +} +export interface CastVoteMsg { + outcome: VoteOutcome; + proposal_id: number; +} +export interface UnstakeCw20Msg { + amount: Uint128; +} +export interface UnstakeCw721Msg { + tokens: string[]; +} +export interface StakedNftsResponse { + nfts: string[]; +} export interface TotalStakedAmountResponse { total_staked_amount: Uint128; } export type UserStake = | "none" + | { + denom: DenomUserStake; + } | { token: TokenUserStake; } @@ -780,6 +705,9 @@ export type UserStake = export interface UserStakeResponse { user_stake: UserStake; } +export interface DenomUserStake { + amount: Uint128; +} export interface TokenUserStake { amount: Uint128; } diff --git a/indexers/enterprise/src/types/contracts/enterprise_factory.ts b/indexers/enterprise/src/types/contracts/enterprise_factory.ts index 5d8846f6..9bbdee0a 100644 --- a/indexers/enterprise/src/types/contracts/enterprise_factory.ts +++ b/indexers/enterprise/src/types/contracts/enterprise_factory.ts @@ -3,41 +3,39 @@ export type Addr = string export interface AllDaosResponse { daos: Addr[]; } -export type AssetInfoBaseFor_Addr = - | { - native: string; - } - | { - cw20: Addr; - } - | { - /** - * @minItems 2 - * @maxItems 2 - */ - cw1155: [Addr, string]; - } -export interface AssetWhitelistResponse { - assets: AssetInfoBaseFor_Addr[]; -} export interface ConfigResponse { config: Config; } export interface Config { cw20_code_id: number; - cw3_fixed_multisig_code_id: number; cw721_code_id: number; - enterprise_code_id: number; - enterprise_governance_code_id: number; - funds_distributor_code_id: number; + enterprise_versioning: Addr; } export type Uint64 = string export interface EnterpriseCodeIdsResponse { code_ids: Uint64[]; } -export type ExecuteMsg = { - create_dao: CreateDaoMsg; -} +export type ExecuteMsg = + | { + create_dao: CreateDaoMsg; + } + | { + finalize_dao_creation: {}; + } +export type AssetInfoBaseFor_String = + | { + native: string; + } + | { + cw20: string; + } + | { + /** + * @minItems 2 + * @maxItems 2 + */ + cw1155: [string, string]; + } export type ProposalActionType = | "update_metadata" | "update_gov_config" @@ -49,33 +47,41 @@ export type ProposalActionType = | "execute_msgs" | "modify_multisig_membership" | "distribute_funds" + | "update_minimum_weight_for_rewards" + | "add_attestation" + | "remove_attestation" + | "deploy_cross_chain_treasury" export type Decimal = string -export type Uint128 = string -export type Duration = +export type CreateDaoMembershipMsg = | { - height: number; + new_denom: NewDenomMembershipMsg; } | { - time: number; + import_cw20: ImportCw20MembershipMsg; } -export type CreateDaoMembershipMsg = | { - new_membership: NewMembershipInfo; + new_cw20: NewCw20MembershipMsg; } | { - existing_membership: ExistingDaoMembershipMsg; + import_cw721: ImportCw721MembershipMsg; } -export type NewMembershipInfo = | { - new_token: NewTokenMembershipInfo; + new_cw721: NewCw721MembershipMsg; } | { - new_nft: NewNftMembershipInfo; + import_cw3: ImportCw3MembershipMsg; } | { - new_multisig: NewMultisigMembershipInfo; + new_multisig: NewMultisigMembershipMsg; + } +export type Duration = + | { + height: number; } -export type DaoType = "token" | "nft" | "multisig" + | { + time: number; + } +export type Uint128 = string export type Logo = | "none" | { @@ -85,18 +91,26 @@ export interface CreateDaoMsg { /** * assets that are allowed to show in DAO's treasury */ - asset_whitelist?: AssetInfoBaseFor_Addr[] | null; + asset_whitelist?: AssetInfoBaseFor_String[] | null; + /** + * Optional text that users will have to attest to before being able to participate in DAO's governance and certain other functions. + */ + attestation_text?: string | null; /** * Optional council structure that can manage certain aspects of the DAO */ dao_council?: DaoCouncilSpec | null; - dao_gov_config: DaoGovConfig; dao_membership: CreateDaoMembershipMsg; dao_metadata: DaoMetadata; + gov_config: GovConfig; + /** + * Minimum weight that a user should have in order to qualify for rewards. E.g. a value of 3 here means that a user in token or NFT DAO needs at least 3 staked DAO assets, or a weight of 3 in multisig DAO, to be eligible for rewards. + */ + minimum_weight_for_rewards?: Uint128 | null; /** * NFTs that are allowed to show in DAO's treasury */ - nft_whitelist?: Addr[] | null; + nft_whitelist?: string[] | null; } export interface DaoCouncilSpec { /** @@ -116,37 +130,21 @@ export interface DaoCouncilSpec { */ threshold: Decimal; } -export interface DaoGovConfig { - /** - * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. - */ - allow_early_proposal_execution: boolean; - /** - * Optional minimum amount of DAO's governance unit to be required to create a deposit. - */ - minimum_deposit?: Uint128 | null; - /** - * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires - */ - quorum: Decimal; - /** - * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win - */ - threshold: Decimal; - /** - * Duration that has to pass for unstaked membership tokens to be claimable - */ +export interface NewDenomMembershipMsg { + denom: string; unlocking_period: Duration; +} +export interface ImportCw20MembershipMsg { /** - * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. + * Address of the CW20 token to import */ - veto_threshold?: Decimal | null; + cw20_contract: string; /** - * Duration of proposals before they end, expressed in seconds + * Duration after which unstaked tokens can be claimed */ - vote_duration: number; + unlocking_period: Duration; } -export interface NewTokenMembershipInfo { +export interface NewCw20MembershipMsg { /** * Optional amount of tokens to be minted to the DAO's address */ @@ -157,6 +155,7 @@ export interface NewTokenMembershipInfo { token_mint?: MinterResponse | null; token_name: string; token_symbol: string; + unlocking_period: Duration; } export interface Cw20Coin { address: string; @@ -175,21 +174,34 @@ export interface MinterResponse { cap?: Uint128 | null; minter: string; } -export interface NewNftMembershipInfo { +export interface ImportCw721MembershipMsg { + /** + * Address of the CW721 contract to import + */ + cw721_contract: string; + /** + * Duration after which unstaked items can be claimed + */ + unlocking_period: Duration; +} +export interface NewCw721MembershipMsg { minter?: string | null; nft_name: string; nft_symbol: string; + unlocking_period: Duration; } -export interface NewMultisigMembershipInfo { - multisig_members: MultisigMember[]; +export interface ImportCw3MembershipMsg { + /** + * Address of the CW3 contract to import + */ + cw3_contract: string; } -export interface MultisigMember { - address: string; - weight: Uint128; +export interface NewMultisigMembershipMsg { + multisig_members: UserWeight[]; } -export interface ExistingDaoMembershipMsg { - dao_type: DaoType; - membership_contract_addr: string; +export interface UserWeight { + user: string; + weight: Uint128; } export interface DaoMetadata { description?: string | null; @@ -203,32 +215,49 @@ export interface DaoSocialData { telegram_username?: string | null; twitter_username?: string | null; } +export interface GovConfig { + /** + * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. + */ + allow_early_proposal_execution: boolean; + /** + * Optional minimum amount of DAO's governance unit to be required to create a deposit. + */ + minimum_deposit?: Uint128 | null; + /** + * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires + */ + quorum: Decimal; + /** + * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win + */ + threshold: Decimal; + /** + * Duration that has to pass for unstaked membership tokens to be claimable + */ + unlocking_period: Duration; + /** + * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. + */ + veto_threshold?: Decimal | null; + /** + * Duration of proposals before they end, expressed in seconds + */ + vote_duration: number; +} export interface InstantiateMsg { config: Config; - global_asset_whitelist?: AssetInfoBaseFor_Addr[] | null; - global_nft_whitelist?: Addr[] | null; } export interface IsEnterpriseCodeIdResponse { is_enterprise_code_id: boolean; } export interface MigrateMsg { - new_enterprise_code_id: number; - new_enterprise_governance_code_id: number; - new_funds_distributor_code_id: number; -} -export interface NftWhitelistResponse { - nfts: Addr[]; + enterprise_versioning_addr: string; } export type QueryMsg = | { config: {}; } - | { - global_asset_whitelist: {}; - } - | { - global_nft_whitelist: {}; - } | { all_daos: QueryAllDaosMsg; } diff --git a/indexers/enterprise/src/types/contracts/index.ts b/indexers/enterprise/src/types/contracts/index.ts index 7c001795..365fa49c 100644 --- a/indexers/enterprise/src/types/contracts/index.ts +++ b/indexers/enterprise/src/types/contracts/index.ts @@ -1,3 +1,3 @@ -export * from './enterprise' +export * from './enterprise_facade' export * from './enterprise_factory' \ No newline at end of file diff --git a/indexers/enterprise/src/utils/Environment.ts b/indexers/enterprise/src/utils/Environment.ts index 520508fd..e2c62caf 100644 --- a/indexers/enterprise/src/utils/Environment.ts +++ b/indexers/enterprise/src/utils/Environment.ts @@ -1,9 +1,5 @@ -import dotenv from "dotenv"; -import { - ContractAddresses, - getContractAddress, -} from "@apps-shared/indexers/utils"; -import { Epoch } from "@apps-shared/indexers/types"; +import dotenv from 'dotenv'; +import { Epoch } from '@apps-shared/indexers/types'; dotenv.config(); @@ -18,8 +14,4 @@ export class Environment { timestamp: +process.env.GENESIS_TIMESTAMP, }; }; - - static getContractAddress(contract: keyof ContractAddresses) { - return getContractAddress(process.env.NETWORK, contract); - } } diff --git a/indexers/shared/utils/daoContractAddressRecord.ts b/indexers/shared/utils/daoContractAddressRecord.ts new file mode 100644 index 00000000..bbdd50e9 --- /dev/null +++ b/indexers/shared/utils/daoContractAddressRecord.ts @@ -0,0 +1,14 @@ +export type NetworkName = 'mainnet' | 'testnet'; + +export type DaoContract = 'enterprise-factory' | 'enterprise-facade'; + +export const daoContractAddressRecord: Record> = { + 'enterprise-factory': { + mainnet: 'terra1y2dwydnnnctdwwmvs23ct60fj626t66qk53cae2gc55k3ce92jmqldj0sf', + testnet: 'terra1vwfllxsuvkyhfztv7yenv0wjra2ue7zu6arc3esmwcckenpq566sxch3wk', + }, + 'enterprise-facade': { + mainnet: '', + testnet: 'terra1jyy4r09tgn55ysa5r0fmz20k9q9akjh7r6jrhc4vftdakfaly0sqe7ewyj', + }, +}; diff --git a/indexers/shared/utils/getContractAddress.ts b/indexers/shared/utils/getContractAddress.ts deleted file mode 100644 index 244b221e..00000000 --- a/indexers/shared/utils/getContractAddress.ts +++ /dev/null @@ -1,35 +0,0 @@ -import contracts from '../../../refs.json'; - -type NetworkName = 'mainnet' | 'testnet' | 'localterra'; - -interface ContractDefinition { - codeId: string; - address: string; -} - -export interface ContractAddresses { - 'fountain-streams': ContractDefinition; - 'story-manager': ContractDefinition; - 'story-root-dao': ContractDefinition; - 'story-protocol-token': ContractDefinition; - 'prediction-markets': ContractDefinition; - 'enterprise-factory': ContractDefinition; - enterprise: ContractDefinition; - 'proxy-wallet-core': ContractDefinition; - 'improv-hub': ContractDefinition; - 'warp-controller': ContractDefinition; -} - -export const CONTRACT_ADDRESSES = contracts as unknown as Record, Partial>; - -export const getContractAddress = (network: string, contract: keyof ContractAddresses): string | undefined => { - const networkName = network as NetworkName; - - if (CONTRACT_ADDRESSES[networkName]) { - const definition = CONTRACT_ADDRESSES[networkName][contract]; - if (definition !== undefined) { - return definition.address; - } - } - return undefined; -}; diff --git a/indexers/shared/utils/index.ts b/indexers/shared/utils/index.ts index a02a4a77..a2c604c8 100644 --- a/indexers/shared/utils/index.ts +++ b/indexers/shared/utils/index.ts @@ -1,13 +1,13 @@ -export * from "./Logger"; -export * from "./sleep"; -export * from "./getContractAddress"; -export * from "./batch"; -export * from "./createDynamoDBClient"; -export * from "./createPersistence"; -export * from "./createEventStore"; -export * from "./createLCDClient"; -export * from "./createState"; -export * from "./makeTableName"; -export * from "./tableNameExists"; -export * from "./fetchAll"; -export * from "./deserializeEntity"; +export * from './Logger'; +export * from './sleep'; +export * from './batch'; +export * from './createDynamoDBClient'; +export * from './createPersistence'; +export * from './createEventStore'; +export * from './createLCDClient'; +export * from './createState'; +export * from './makeTableName'; +export * from './tableNameExists'; +export * from './fetchAll'; +export * from './deserializeEntity'; +export * from './daoContractAddressRecord'; From 4d418ccf1e81ed8f66665136aa26820d31644823 Mon Sep 17 00:00:00 2001 From: Rodion Chachura Date: Thu, 28 Sep 2023 11:44:46 +0400 Subject: [PATCH 2/3] update: types --- indexers/enterprise/package.json | 7 - .../enterprise/src/collectors/events/index.ts | 2 +- .../enterprise/src/indexers/daos/Indexer.ts | 12 +- .../enterprise/src/indexers/daos/types.ts | 8 +- .../src/indexers/proposals/Indexer.ts | 11 +- .../proposals/getProposalFromContract.ts | 8 +- .../src/indexers/proposals/types.ts | 10 +- .../src/types/contracts/enterprise_facade.ts | 717 ---------------- .../enterprise/src/types/contracts/index.ts | 3 - .../enterprise/src/types/enterprise_facade.ts | 789 ++++++++++++++++++ .../{contracts => }/enterprise_factory.ts | 215 +++-- .../src/types/enterprise_versioning.ts | 62 ++ .../enterprise/src/types/funds_distributor.ts | 102 +++ .../shared/utils/daoContractAddressRecord.ts | 10 +- 14 files changed, 1092 insertions(+), 864 deletions(-) delete mode 100644 indexers/enterprise/src/types/contracts/enterprise_facade.ts delete mode 100644 indexers/enterprise/src/types/contracts/index.ts create mode 100644 indexers/enterprise/src/types/enterprise_facade.ts rename indexers/enterprise/src/types/{contracts => }/enterprise_factory.ts (58%) create mode 100644 indexers/enterprise/src/types/enterprise_versioning.ts create mode 100644 indexers/enterprise/src/types/funds_distributor.ts diff --git a/indexers/enterprise/package.json b/indexers/enterprise/package.json index 78f18088..6f2c3530 100644 --- a/indexers/enterprise/package.json +++ b/indexers/enterprise/package.json @@ -31,12 +31,5 @@ "esbuild": "^0.14.54", "ts-node": "^10.9.1", "tsconfig-paths": "^4.1.0" - }, - "generate-types": { - "contracts": [ - "enterprise-factory", - "enterprise-facade" - ], - "output": "src/types/contracts" } } \ No newline at end of file diff --git a/indexers/enterprise/src/collectors/events/index.ts b/indexers/enterprise/src/collectors/events/index.ts index a26cc848..2a1646dc 100644 --- a/indexers/enterprise/src/collectors/events/index.ts +++ b/indexers/enterprise/src/collectors/events/index.ts @@ -25,7 +25,7 @@ const state = createState('collector:enterprise-events'); const genesis = Environment.getGenesis(); -const enterpriseFactoryAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-factory']; +const enterpriseFactoryAddress = daoContractAddressRecord['enterprise-factory'][process.env.NETWORK as NetworkName]; class EnterpriseEventCollector implements Runnable { private enterpriseAddresses: string[] = []; diff --git a/indexers/enterprise/src/indexers/daos/Indexer.ts b/indexers/enterprise/src/indexers/daos/Indexer.ts index 6fb2f668..4cdf53af 100644 --- a/indexers/enterprise/src/indexers/daos/Indexer.ts +++ b/indexers/enterprise/src/indexers/daos/Indexer.ts @@ -7,13 +7,13 @@ import { KeySelector } from '@apps-shared/indexers/services/persistence'; import { fetchByHeight } from '@apps-shared/indexers/services/event-store'; import { EnterpriseEventPK, ExecuteProposalEvent, InstantiateDaoEvent } from 'types/events'; import Big from 'big.js'; -import { enterprise_facade } from 'types/contracts'; +import { DaoInfoResponse, QueryMsg } from 'types/enterprise_facade'; export const PK: KeySelector = (data) => data.address; export const SK = 'dao'; -const enterpriseFacadeAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-facade']; +const enterpriseFacadeAddress = daoContractAddressRecord['enterprise-facade'][process.env.NETWORK as NetworkName]; export class Indexer extends EventIndexer { constructor() { @@ -47,7 +47,13 @@ export class Indexer extends EventIndexer { }; private fetchDAO = async (lcd: LCDClient, address: string): Promise => { - const response = await lcd.wasm.contractQuery(address, { dao_info: {} }); + const msg: QueryMsg = { + dao_info: { + contract: address, + }, + }; + + const response = await lcd.wasm.contractQuery(enterpriseFacadeAddress, msg); const created = 'creation_date' in response ? Math.trunc(Big(response.creation_date).div(1000000).toNumber()) : 0; return { diff --git a/indexers/enterprise/src/indexers/daos/types.ts b/indexers/enterprise/src/indexers/daos/types.ts index 5b33d2e9..75c5fa1c 100644 --- a/indexers/enterprise/src/indexers/daos/types.ts +++ b/indexers/enterprise/src/indexers/daos/types.ts @@ -1,9 +1,9 @@ -import { enterprise_facade } from 'types/contracts'; +import { DaoType, DaoCouncil, Duration } from 'types/enterprise_facade'; export type DaoEntity = { _type: string; address: string; - type: enterprise_facade.DaoType; + type: DaoType; name: string; description?: string; lowerCaseName: string; @@ -12,7 +12,7 @@ export type DaoEntity = { enterpriseFactoryContract: string; created: number; codeVersionId: string; - council: enterprise_facade.DaoCouncil; + council: DaoCouncil; socials: { discord_username?: string; github_username?: string; @@ -23,7 +23,7 @@ export type DaoEntity = { quorum: number; threshold: number; vetoThreshold: number; - unlockingPeriod: enterprise_facade.Duration; + unlockingPeriod: Duration; voteDuration: number; minimumDeposit?: string; }; diff --git a/indexers/enterprise/src/indexers/proposals/Indexer.ts b/indexers/enterprise/src/indexers/proposals/Indexer.ts index 3e7ad4a3..ddaa59c2 100644 --- a/indexers/enterprise/src/indexers/proposals/Indexer.ts +++ b/indexers/enterprise/src/indexers/proposals/Indexer.ts @@ -6,13 +6,13 @@ import { KeySelector } from '@apps-shared/indexers/services/persistence'; import { fetchByHeight } from '@apps-shared/indexers/services/event-store'; import { DaoEvents, EnterpriseEventPK } from 'types/events'; import { getProposalFromContract } from './getProposalFromContract'; -import { enterprise_facade } from 'types/contracts'; +import { QueryMsg, ProposalsResponse } from 'types/enterprise_facade'; export const PK: KeySelector = (data) => data.daoAddress; export const SK: KeySelector = (data) => `proposal:${data.id}`; -const enterpriseFacadeAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-facade']; +const enterpriseFacadeAddress = daoContractAddressRecord['enterprise-facade'][process.env.NETWORK as NetworkName]; export class Indexer extends EventIndexer { constructor() { @@ -73,7 +73,7 @@ export class Indexer extends EventIndexer { daoAddresses.map(async (daoAddress) => { try { this.logger.info(`Getting proposals for ${daoAddress} DAO.`); - const query: enterprise_facade.QueryMsg = { + const query: QueryMsg = { proposals: { contract: daoAddress, params: { @@ -81,10 +81,7 @@ export class Indexer extends EventIndexer { }, }, }; - const { proposals } = await lcd.wasm.contractQuery( - enterpriseFacadeAddress, - query - ); + const { proposals } = await lcd.wasm.contractQuery(enterpriseFacadeAddress, query); proposals.forEach(({ proposal }) => { const key: ProposalKey = { daoAddress, id: proposal.id }; if (!proposalsKeys.some((k) => k.daoAddress === key.daoAddress && k.id === key.id)) { diff --git a/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts b/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts index 0551b2bc..2803c443 100644 --- a/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts +++ b/indexers/enterprise/src/indexers/proposals/getProposalFromContract.ts @@ -1,7 +1,7 @@ import { createLCDClient, daoContractAddressRecord, Logger, NetworkName } from '@apps-shared/indexers/utils'; import Big from 'big.js'; import { Entity } from './types'; -import { enterprise_facade } from 'types/contracts'; +import { QueryMsg, ProposalResponse } from 'types/enterprise_facade'; interface GetProposalParams { daoAddress: string; @@ -9,14 +9,14 @@ interface GetProposalParams { logger: Logger; } -const enterpriseFacadeAddress = daoContractAddressRecord[process.env.NETWORK as NetworkName]['enterprise-facade']; +const enterpriseFacadeAddress = daoContractAddressRecord['enterprise-facade'][process.env.NETWORK as NetworkName]; export const getProposalFromContract = async ({ daoAddress, id, logger }: GetProposalParams): Promise => { const lcd = createLCDClient(); logger.info(`Fetching proposal with id ${id} for ${daoAddress} DAO.`); - const msg: enterprise_facade.QueryMsg = { + const msg: QueryMsg = { proposal: { contract: daoAddress, params: { @@ -25,7 +25,7 @@ export const getProposalFromContract = async ({ daoAddress, id, logger }: GetPro }, }; - const response = await lcd.wasm.contractQuery(enterpriseFacadeAddress, msg); + const response = await lcd.wasm.contractQuery(enterpriseFacadeAddress, msg); logger.info(`Received proposal response: ${response}.`); diff --git a/indexers/enterprise/src/indexers/proposals/types.ts b/indexers/enterprise/src/indexers/proposals/types.ts index 0d204ae2..d56b4a6c 100644 --- a/indexers/enterprise/src/indexers/proposals/types.ts +++ b/indexers/enterprise/src/indexers/proposals/types.ts @@ -1,4 +1,4 @@ -import { enterprise_facade } from 'types/contracts'; +import { Expiration, ProposalStatus, ProposalAction, ProposalType } from 'types/enterprise_facade'; export type Entity = { _type: string; @@ -9,15 +9,15 @@ export type Entity = { started_at: number; title: string; description: string; - expires: enterprise_facade.Expiration; - status: enterprise_facade.ProposalStatus; - proposalActions: enterprise_facade.ProposalAction[]; + expires: Expiration; + status: ProposalStatus; + proposalActions: ProposalAction[]; yesVotes: string; noVotes: string; abstainVotes: string; vetoVotes: string; totalVotes: string; - type: enterprise_facade.ProposalType; + type: ProposalType; proposer?: string; }; diff --git a/indexers/enterprise/src/types/contracts/enterprise_facade.ts b/indexers/enterprise/src/types/contracts/enterprise_facade.ts deleted file mode 100644 index 8f81ce61..00000000 --- a/indexers/enterprise/src/types/contracts/enterprise_facade.ts +++ /dev/null @@ -1,717 +0,0 @@ -export module enterprise_facade { -export type Addr = string -export interface AdapterResponse { - msg: string; - target_contract: Addr; -} -export type AssetInfoBaseFor_Addr = - | { - native: string; - } - | { - cw20: Addr; - } - | { - /** - * @minItems 2 - * @maxItems 2 - */ - cw1155: [Addr, string]; - } -export interface AssetWhitelistResponse { - assets: AssetInfoBaseFor_Addr[]; -} -export type ClaimAsset = - | { - cw20: Cw20ClaimAsset; - } - | { - cw721: Cw721ClaimAsset; - } -export type Uint128 = string -export type ReleaseAt = - | { - timestamp: Timestamp; - } - | { - height: Uint64; - } -export type Timestamp = Uint64 -export type Uint64 = string -export interface ClaimsResponse { - claims: Claim[]; -} -export interface Claim { - asset: ClaimAsset; - release_at: ReleaseAt; -} -export interface Cw20ClaimAsset { - amount: Uint128; -} -export interface Cw721ClaimAsset { - tokens: string[]; -} -export type ProposalActionType = - | "update_metadata" - | "update_gov_config" - | "update_council" - | "update_asset_whitelist" - | "update_nft_whitelist" - | "request_funding_from_dao" - | "upgrade_dao" - | "execute_msgs" - | "modify_multisig_membership" - | "distribute_funds" - | "update_minimum_weight_for_rewards" - | "add_attestation" - | "remove_attestation" - | "deploy_cross_chain_treasury" -export type Decimal = string -export type DaoType = "denom" | "token" | "nft" | "multisig" -export type Duration = - | { - height: number; - } - | { - time: number; - } -export type Logo = - | "none" - | { - url: string; - } -export interface DaoInfoResponse { - creation_date: Timestamp; - dao_code_version: Uint64; - dao_council?: DaoCouncil | null; - dao_membership_contract: Addr; - dao_type: DaoType; - enterprise_factory_contract: Addr; - funds_distributor_contract: Addr; - gov_config: DaoGovConfig; - metadata: DaoMetadata; -} -export interface DaoCouncil { - allowed_proposal_action_types: ProposalActionType[]; - members: Addr[]; - quorum: Decimal; - threshold: Decimal; -} -export interface DaoGovConfig { - /** - * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. - */ - allow_early_proposal_execution: boolean; - /** - * Optional minimum amount of DAO's governance unit to be required to create a deposit. - */ - minimum_deposit?: Uint128 | null; - /** - * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires - */ - quorum: Decimal; - /** - * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win - */ - threshold: Decimal; - /** - * Duration that has to pass for unstaked membership tokens to be claimable - */ - unlocking_period: Duration; - /** - * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. - */ - veto_threshold?: Decimal | null; - /** - * Duration of proposals before they end, expressed in seconds - */ - vote_duration: number; -} -export interface DaoMetadata { - description?: string | null; - logo: Logo; - name: string; - socials: DaoSocialData; -} -export interface DaoSocialData { - discord_username?: string | null; - github_username?: string | null; - telegram_username?: string | null; - twitter_username?: string | null; -} -export type ExecuteMsg = { - execute_proposal: { - contract: Addr; - msg: ExecuteProposalMsg; - }; -} -export interface ExecuteProposalMsg { - proposal_id: number; -} -export interface InstantiateMsg {} -export interface MemberInfoResponse { - voting_power: Decimal; -} -export interface MemberVoteResponse { - vote?: Vote | null; -} -export interface Vote { - /** - * Number of votes on the outcome. - */ - amount: number; - /** - * The outcome, 0-indexed. - */ - outcome: number; - /** - * Unique identifier for the poll. - */ - poll_id: number; - /** - * Voter address. - */ - voter: Addr; -} -export interface MultisigMembersResponse { - members: MultisigMember[]; -} -export interface MultisigMember { - address: string; - weight: Uint128; -} -export interface NftWhitelistResponse { - nfts: Addr[]; -} -export type Expiration = - | { - at_height: number; - } - | { - at_time: Timestamp; - } - | { - never: {}; - } -export type ProposalAction = - | { - update_metadata: UpdateMetadataMsg; - } - | { - update_gov_config: UpdateGovConfigMsg; - } - | { - update_council: UpdateCouncilMsg; - } - | { - update_asset_whitelist: UpdateAssetWhitelistProposalActionMsg; - } - | { - update_nft_whitelist: UpdateNftWhitelistProposalActionMsg; - } - | { - request_funding_from_dao: RequestFundingFromDaoMsg; - } - | { - upgrade_dao: UpgradeDaoMsg; - } - | { - execute_msgs: ExecuteMsgsMsg; - } - | { - modify_multisig_membership: ModifyMultisigMembershipMsg; - } - | { - distribute_funds: DistributeFundsMsg; - } - | { - update_minimum_weight_for_rewards: UpdateMinimumWeightForRewardsMsg; - } - | { - add_attestation: AddAttestationMsg; - } - | { - remove_attestation: {}; - } - | { - deploy_cross_chain_treasury: DeployCrossChainTreasuryMsg; - } -export type ModifyValueFor_Nullable_String = - | "no_change" - | { - change: string | null; - } -export type ModifyValueFor_Logo = - | "no_change" - | { - change: Logo; - } -export type ModifyValueFor_String = - | "no_change" - | { - change: string; - } -export type ModifyValueFor_Boolean = - | "no_change" - | { - change: boolean; - } -export type ModifyValueFor_Nullable_Uint128 = - | "no_change" - | { - change: Uint128 | null; - } -export type ModifyValueFor_Decimal = - | "no_change" - | { - change: Decimal; - } -export type ModifyValueFor_Duration = - | "no_change" - | { - change: Duration; - } -export type ModifyValueFor_Nullable_Decimal = - | "no_change" - | { - change: Decimal | null; - } -export type ModifyValueFor_Uint64 = - | "no_change" - | { - change: Uint64; - } -export type AssetInfoBaseFor_String = - | { - native: string; - } - | { - cw20: string; - } - | { - /** - * @minItems 2 - * @maxItems 2 - */ - cw1155: [string, string]; - } -export type Binary = string -export type ProposalType = "general" | "council" -export type ProposalStatus = "in_progress" | "passed" | "rejected" | "executed" -export interface ProposalResponse { - proposal: Proposal; - proposal_status: ProposalStatus; - /** - * Total vote-count (value) for each outcome (key). - */ - results: [number, Uint128][]; - total_votes_available: Uint128; -} -export interface Proposal { - description: string; - expires: Expiration; - id: number; - proposal_actions: ProposalAction[]; - proposal_type: ProposalType; - proposer: Addr; - started_at: Timestamp; - status: ProposalStatus; - title: string; -} -export interface UpdateMetadataMsg { - description: ModifyValueFor_Nullable_String; - discord_username: ModifyValueFor_Nullable_String; - github_username: ModifyValueFor_Nullable_String; - logo: ModifyValueFor_Logo; - name: ModifyValueFor_String; - telegram_username: ModifyValueFor_Nullable_String; - twitter_username: ModifyValueFor_Nullable_String; -} -export interface UpdateGovConfigMsg { - allow_early_proposal_execution: ModifyValueFor_Boolean; - minimum_deposit: ModifyValueFor_Nullable_Uint128; - quorum: ModifyValueFor_Decimal; - threshold: ModifyValueFor_Decimal; - unlocking_period: ModifyValueFor_Duration; - veto_threshold: ModifyValueFor_Nullable_Decimal; - voting_duration: ModifyValueFor_Uint64; -} -export interface UpdateCouncilMsg { - dao_council?: DaoCouncilSpec | null; -} -export interface DaoCouncilSpec { - /** - * Proposal action types allowed in proposals that are voted on by the council. Effectively defines what types of actions council can propose and vote on. If None, will default to a predefined set of actions. - */ - allowed_proposal_action_types?: ProposalActionType[] | null; - /** - * Addresses of council members. Each member has equal voting power. - */ - members: string[]; - /** - * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires - */ - quorum: Decimal; - /** - * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win - */ - threshold: Decimal; -} -export interface UpdateAssetWhitelistProposalActionMsg { - /** - * New assets to add to the whitelist. Will ignore assets that are already whitelisted. - */ - add: AssetInfoBaseFor_String[]; - remote_treasury_target?: RemoteTreasuryTarget | null; - /** - * Assets to remove from the whitelist. Will ignore assets that are not already whitelisted. - */ - remove: AssetInfoBaseFor_String[]; -} -export interface RemoteTreasuryTarget { - /** - * Spec for the cross-chain message to send. Treasury address will be determined using chain-id given in the spec. - */ - cross_chain_msg_spec: CrossChainMsgSpec; -} -export interface CrossChainMsgSpec { - chain_id: string; - dest_ibc_channel: string; - dest_ibc_port: string; - src_ibc_channel: string; - src_ibc_port: string; - /** - * Optional timeout for the cross-chain messages. Formatted in nanoseconds. - */ - timeout_nanos?: number | null; - /** - * uluna IBC denom on the remote chain. Currently, can be calculated as 'ibc/' + uppercase(sha256('{port}/{channel}/uluna')) - */ - uluna_denom: string; -} -export interface UpdateNftWhitelistProposalActionMsg { - /** - * New NFTs to add to the whitelist. Will ignore NFTs that are already whitelisted. - */ - add: string[]; - remote_treasury_target?: RemoteTreasuryTarget | null; - /** - * NFTs to remove from the whitelist. Will ignore NFTs that are not already whitelisted. - */ - remove: string[]; -} -export interface RequestFundingFromDaoMsg { - assets: AssetBaseFor_String[]; - recipient: string; - remote_treasury_target?: RemoteTreasuryTarget | null; -} -export interface AssetBaseFor_String { - /** - * Specifies the asset's amount - */ - amount: Uint128; - /** - * Specifies the asset's type (CW20 or native) - */ - info: AssetInfoBaseFor_String; -} -export interface UpgradeDaoMsg { - /** - * Expects a map of (version, migrate msg for that version). E.g. { "1.0.2": { }, "2.0.0": { } } - */ - migrate_msg: Binary; - new_version: Version; -} -export interface Version { - major: number; - minor: number; - patch: number; -} -export interface ExecuteMsgsMsg { - action_type: string; - msgs: string[]; -} -export interface ModifyMultisigMembershipMsg { - /** - * Members to be edited. Can contain existing members, in which case their new weight will be the one specified in this message. This effectively allows removing of members (by setting their weight to 0). - */ - edit_members: UserWeight[]; -} -export interface UserWeight { - user: string; - weight: Uint128; -} -export interface DistributeFundsMsg { - funds: AssetBaseFor_String[]; -} -export interface UpdateMinimumWeightForRewardsMsg { - minimum_weight_for_rewards: Uint128; -} -export interface AddAttestationMsg { - attestation_text: string; -} -export interface DeployCrossChainTreasuryMsg { - asset_whitelist?: AssetInfoBaseFor_String[] | null; - /** - * Proxy contract serving globally for the given chain, with no specific permission model. - */ - chain_global_proxy: string; - cross_chain_msg_spec: CrossChainMsgSpec; - enterprise_treasury_code_id: number; - ics_proxy_code_id: number; - nft_whitelist?: string[] | null; -} -export interface ProposalStatusResponse { - expires: Expiration; - /** - * Total vote-count (value) for each outcome (key). - */ - results: [number, Uint128][]; - status: ProposalStatus; -} -export interface ProposalVotesResponse { - votes: Vote[]; -} -export interface ProposalsResponse { - proposals: ProposalResponse[]; -} -export type QueryMsg = - | { - dao_info: { - contract: Addr; - }; - } - | { - member_info: { - contract: Addr; - msg: QueryMemberInfoMsg; - }; - } - | { - list_multisig_members: { - contract: Addr; - msg: ListMultisigMembersMsg; - }; - } - | { - asset_whitelist: { - contract: Addr; - params: AssetWhitelistParams; - }; - } - | { - nft_whitelist: { - contract: Addr; - params: NftWhitelistParams; - }; - } - | { - proposal: { - contract: Addr; - params: ProposalParams; - }; - } - | { - proposals: { - contract: Addr; - params: ProposalsParams; - }; - } - | { - proposal_status: { - contract: Addr; - params: ProposalStatusParams; - }; - } - | { - member_vote: { - contract: Addr; - params: MemberVoteParams; - }; - } - | { - proposal_votes: { - contract: Addr; - params: ProposalVotesParams; - }; - } - | { - user_stake: { - contract: Addr; - params: UserStakeParams; - }; - } - | { - total_staked_amount: { - contract: Addr; - }; - } - | { - staked_nfts: { - contract: Addr; - params: StakedNftsParams; - }; - } - | { - claims: { - contract: Addr; - params: ClaimsParams; - }; - } - | { - releasable_claims: { - contract: Addr; - params: ClaimsParams; - }; - } - | { - create_proposal_adapted: { - contract: Addr; - params: CreateProposalMsg; - }; - } - | { - create_council_proposal_adapted: { - contract: Addr; - params: CreateProposalMsg; - }; - } - | { - cast_vote: { - contract: Addr; - params: CastVoteMsg; - }; - } - | { - cast_council_vote: { - contract: Addr; - params: CastVoteMsg; - }; - } - | { - unstake: { - contract: Addr; - params: UnstakeMsg; - }; - } - | { - claim: { - contract: Addr; - }; - } -export type ProposalStatusFilter = "in_progress" | "passed" | "rejected" -export type VoteOutcome = "yes" | "no" | "abstain" | "veto" -export type UnstakeMsg = - | { - cw20: UnstakeCw20Msg; - } - | { - cw721: UnstakeCw721Msg; - } -export interface QueryMemberInfoMsg { - member_address: string; -} -export interface ListMultisigMembersMsg { - limit?: number | null; - start_after?: string | null; -} -export interface AssetWhitelistParams { - limit?: number | null; - start_after?: AssetInfoBaseFor_String | null; -} -export interface NftWhitelistParams { - limit?: number | null; - start_after?: string | null; -} -export interface ProposalParams { - proposal_id: number; -} -export interface ProposalsParams { - /** - * Optional proposal status to filter for. - */ - filter?: ProposalStatusFilter | null; - limit?: number | null; - start_after?: number | null; -} -export interface ProposalStatusParams { - proposal_id: number; -} -export interface MemberVoteParams { - member: string; - proposal_id: number; -} -export interface ProposalVotesParams { - limit?: number | null; - proposal_id: number; - /** - * Optional pagination data, will return votes after the given voter address - */ - start_after?: string | null; -} -export interface UserStakeParams { - limit?: number | null; - start_after?: string | null; - user: string; -} -export interface StakedNftsParams { - limit?: number | null; - start_after?: string | null; -} -export interface ClaimsParams { - owner: string; -} -export interface CreateProposalMsg { - /** - * Optional description text of the proposal - */ - description?: string | null; - /** - * Actions to be executed, in order, if the proposal passes - */ - proposal_actions: ProposalAction[]; - /** - * Title of the proposal - */ - title: string; -} -export interface CastVoteMsg { - outcome: VoteOutcome; - proposal_id: number; -} -export interface UnstakeCw20Msg { - amount: Uint128; -} -export interface UnstakeCw721Msg { - tokens: string[]; -} -export interface StakedNftsResponse { - nfts: string[]; -} -export interface TotalStakedAmountResponse { - total_staked_amount: Uint128; -} -export type UserStake = - | "none" - | { - denom: DenomUserStake; - } - | { - token: TokenUserStake; - } - | { - nft: NftUserStake; - } -export interface UserStakeResponse { - user_stake: UserStake; -} -export interface DenomUserStake { - amount: Uint128; -} -export interface TokenUserStake { - amount: Uint128; -} -export interface NftUserStake { - amount: Uint128; - tokens: string[]; -} } \ No newline at end of file diff --git a/indexers/enterprise/src/types/contracts/index.ts b/indexers/enterprise/src/types/contracts/index.ts deleted file mode 100644 index 365fa49c..00000000 --- a/indexers/enterprise/src/types/contracts/index.ts +++ /dev/null @@ -1,3 +0,0 @@ - -export * from './enterprise_facade' -export * from './enterprise_factory' \ No newline at end of file diff --git a/indexers/enterprise/src/types/enterprise_facade.ts b/indexers/enterprise/src/types/enterprise_facade.ts new file mode 100644 index 00000000..0aa29386 --- /dev/null +++ b/indexers/enterprise/src/types/enterprise_facade.ts @@ -0,0 +1,789 @@ +export type Uint128 = string +export type Addr = string +export interface AdapterResponse { + msgs: AdaptedMsg[] +} +export interface AdaptedMsg { + funds: Coin[] + msg: string + target_contract: Addr +} +export interface Coin { + amount: Uint128 + denom: string +} +export type AssetInfoBaseFor_Addr = + | { + native: string + } + | { + cw20: Addr + } + | { + /** + * @minItems 2 + * @maxItems 2 + */ + cw1155: [Addr, string] + } +export interface AssetWhitelistResponse { + assets: AssetInfoBaseFor_Addr[] +} +export type ClaimAsset = + | { + cw20: Cw20ClaimAsset + } + | { + cw721: Cw721ClaimAsset + } +export type ReleaseAt = + | { + timestamp: Timestamp + } + | { + height: Uint64 + } +export type Timestamp = Uint64 +export type Uint64 = string +export interface ClaimsResponse { + claims: Claim[] +} +export interface Claim { + asset: ClaimAsset + release_at: ReleaseAt +} +export interface Cw20ClaimAsset { + amount: Uint128 +} +export interface Cw721ClaimAsset { + tokens: string[] +} +export type ProposalActionType = + | 'update_metadata' + | 'update_gov_config' + | 'update_council' + | 'update_asset_whitelist' + | 'update_nft_whitelist' + | 'request_funding_from_dao' + | 'upgrade_dao' + | 'execute_msgs' + | 'modify_multisig_membership' + | 'distribute_funds' + | 'update_minimum_weight_for_rewards' + | 'add_attestation' + | 'remove_attestation' + | 'deploy_cross_chain_treasury' +export type Decimal = string +export type DaoType = 'denom' | 'token' | 'nft' | 'multisig' +export type Duration = + | { + height: number + } + | { + time: number + } +export type Logo = + | 'none' + | { + url: string + } +export interface DaoInfoResponse { + creation_date: Timestamp + dao_code_version: Uint64 + dao_council?: DaoCouncil | null + dao_membership_contract: Addr + dao_type: DaoType + enterprise_factory_contract: Addr + funds_distributor_contract: Addr + gov_config: GovConfigV5 + metadata: DaoMetadata +} +export interface DaoCouncil { + allowed_proposal_action_types: ProposalActionType[] + members: Addr[] + quorum: Decimal + threshold: Decimal +} +export interface GovConfigV5 { + /** + * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. + */ + allow_early_proposal_execution: boolean + /** + * Optional minimum amount of DAO's governance unit to be required to create a deposit. + */ + minimum_deposit?: Uint128 | null + /** + * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires + */ + quorum: Decimal + /** + * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win + */ + threshold: Decimal + /** + * Duration that has to pass for unstaked membership tokens to be claimable + */ + unlocking_period: Duration + /** + * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. + */ + veto_threshold?: Decimal | null + /** + * Duration of proposals before they end, expressed in seconds + */ + vote_duration: number +} +export interface DaoMetadata { + description?: string | null + logo: Logo + name: string + socials: DaoSocialData +} +export interface DaoSocialData { + discord_username?: string | null + github_username?: string | null + telegram_username?: string | null + twitter_username?: string | null +} +export type ExecuteMsg = { + execute_proposal: { + contract: Addr + msg: ExecuteProposalMsg + } +} +export interface ExecuteProposalMsg { + proposal_id: number +} +export interface InstantiateMsg {} +export interface MemberInfoResponse { + voting_power: Decimal +} +export interface MemberVoteResponse { + vote?: Vote | null +} +export interface Vote { + /** + * Number of votes on the outcome. + */ + amount: number + /** + * The outcome, 0-indexed. + */ + outcome: number + /** + * Unique identifier for the poll. + */ + poll_id: number + /** + * Voter address. + */ + voter: Addr +} +export interface MultisigMembersResponse { + members: MultisigMember[] +} +export interface MultisigMember { + address: string + weight: Uint128 +} +export interface NftWhitelistResponse { + nfts: Addr[] +} +export type Expiration = + | { + at_height: number + } + | { + at_time: Timestamp + } + | { + never: {} + } +export type ProposalAction = + | { + update_metadata: UpdateMetadataMsg + } + | { + update_gov_config: UpdateGovConfigMsg + } + | { + update_council: UpdateCouncilMsg + } + | { + update_asset_whitelist: UpdateAssetWhitelistProposalActionMsg + } + | { + update_nft_whitelist: UpdateNftWhitelistProposalActionMsg + } + | { + request_funding_from_dao: RequestFundingFromDaoMsg + } + | { + upgrade_dao: UpgradeDaoMsg + } + | { + execute_msgs: ExecuteMsgsMsg + } + | { + modify_multisig_membership: ModifyMultisigMembershipMsg + } + | { + distribute_funds: DistributeFundsMsg + } + | { + update_minimum_weight_for_rewards: UpdateMinimumWeightForRewardsMsg + } + | { + add_attestation: AddAttestationMsg + } + | { + remove_attestation: {} + } + | { + deploy_cross_chain_treasury: DeployCrossChainTreasuryMsg + } +export type ModifyValueFor_Nullable_String = + | 'no_change' + | { + change: string | null + } +export type ModifyValueFor_Logo = + | 'no_change' + | { + change: Logo + } +export type ModifyValueFor_String = + | 'no_change' + | { + change: string + } +export type ModifyValueFor_Boolean = + | 'no_change' + | { + change: boolean + } +export type ModifyValueFor_Nullable_Uint128 = + | 'no_change' + | { + change: Uint128 | null + } +export type ModifyValueFor_Decimal = + | 'no_change' + | { + change: Decimal + } +export type ModifyValueFor_Duration = + | 'no_change' + | { + change: Duration + } +export type ModifyValueFor_Nullable_Decimal = + | 'no_change' + | { + change: Decimal | null + } +export type ModifyValueFor_Uint64 = + | 'no_change' + | { + change: Uint64 + } +export type AssetInfoBaseFor_String = + | { + native: string + } + | { + cw20: string + } + | { + /** + * @minItems 2 + * @maxItems 2 + */ + cw1155: [string, string] + } +export type Binary = string +export type ProposalType = 'general' | 'council' +export type ProposalStatus = 'in_progress' | 'passed' | 'rejected' | 'executed' +export interface ProposalResponse { + proposal: Proposal + proposal_status: ProposalStatus + /** + * Total vote-count (value) for each outcome (key). + */ + results: [number, Uint128][] + total_votes_available: Uint128 +} +export interface Proposal { + description: string + expires: Expiration + id: number + proposal_actions: ProposalAction[] + proposal_type: ProposalType + proposer: Addr + started_at: Timestamp + status: ProposalStatus + title: string +} +export interface UpdateMetadataMsg { + description: ModifyValueFor_Nullable_String + discord_username: ModifyValueFor_Nullable_String + github_username: ModifyValueFor_Nullable_String + logo: ModifyValueFor_Logo + name: ModifyValueFor_String + telegram_username: ModifyValueFor_Nullable_String + twitter_username: ModifyValueFor_Nullable_String +} +export interface UpdateGovConfigMsg { + allow_early_proposal_execution: ModifyValueFor_Boolean + minimum_deposit: ModifyValueFor_Nullable_Uint128 + quorum: ModifyValueFor_Decimal + threshold: ModifyValueFor_Decimal + unlocking_period: ModifyValueFor_Duration + veto_threshold: ModifyValueFor_Nullable_Decimal + voting_duration: ModifyValueFor_Uint64 +} +export interface UpdateCouncilMsg { + dao_council?: DaoCouncilSpec | null +} +export interface DaoCouncilSpec { + /** + * Proposal action types allowed in proposals that are voted on by the council. Effectively defines what types of actions council can propose and vote on. If None, will default to a predefined set of actions. + */ + allowed_proposal_action_types?: ProposalActionType[] | null + /** + * Addresses of council members. Each member has equal voting power. + */ + members: string[] + /** + * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires + */ + quorum: Decimal + /** + * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win + */ + threshold: Decimal +} +export interface UpdateAssetWhitelistProposalActionMsg { + /** + * New assets to add to the whitelist. Will ignore assets that are already whitelisted. + */ + add: AssetInfoBaseFor_String[] + remote_treasury_target?: RemoteTreasuryTarget | null + /** + * Assets to remove from the whitelist. Will ignore assets that are not already whitelisted. + */ + remove: AssetInfoBaseFor_String[] +} +export interface RemoteTreasuryTarget { + /** + * Spec for the cross-chain message to send. Treasury address will be determined using chain-id given in the spec. + */ + cross_chain_msg_spec: CrossChainMsgSpec +} +export interface CrossChainMsgSpec { + chain_id: string + dest_ibc_channel: string + dest_ibc_port: string + src_ibc_channel: string + src_ibc_port: string + /** + * Optional timeout for the cross-chain messages. Formatted in nanoseconds. + */ + timeout_nanos?: number | null + /** + * uluna IBC denom on the remote chain. Currently, can be calculated as 'ibc/' + uppercase(sha256('{port}/{channel}/uluna')) + */ + uluna_denom: string +} +export interface UpdateNftWhitelistProposalActionMsg { + /** + * New NFTs to add to the whitelist. Will ignore NFTs that are already whitelisted. + */ + add: string[] + remote_treasury_target?: RemoteTreasuryTarget | null + /** + * NFTs to remove from the whitelist. Will ignore NFTs that are not already whitelisted. + */ + remove: string[] +} +export interface RequestFundingFromDaoMsg { + assets: AssetBaseFor_String[] + recipient: string + remote_treasury_target?: RemoteTreasuryTarget | null +} +export interface AssetBaseFor_String { + /** + * Specifies the asset's amount + */ + amount: Uint128 + /** + * Specifies the asset's type (CW20 or native) + */ + info: AssetInfoBaseFor_String +} +export interface UpgradeDaoMsg { + migrate_msg: Binary + /** + * Expects an array of (version, migrate msg for that version). E.g. [ { "version": { "major": 2, "minor": 0, "patch": 0 }, "migrate_msg": }, { "version": { "major": 2, "minor": 1, "patch": 3 }, "migrate_msg": } ] + */ + migrate_msgs: VersionMigrateMsg[] + new_version: Version +} +export interface VersionMigrateMsg { + migrate_msg: string + version: Version +} +export interface Version { + major: number + minor: number + patch: number +} +export interface ExecuteMsgsMsg { + action_type: string + msgs: string[] +} +export interface ModifyMultisigMembershipMsg { + /** + * Members to be edited. Can contain existing members, in which case their new weight will be the one specified in this message. This effectively allows removing of members (by setting their weight to 0). + */ + edit_members: UserWeight[] +} +export interface UserWeight { + user: string + weight: Uint128 +} +export interface DistributeFundsMsg { + funds: AssetBaseFor_String[] +} +export interface UpdateMinimumWeightForRewardsMsg { + minimum_weight_for_rewards: Uint128 +} +export interface AddAttestationMsg { + attestation_text: string +} +export interface DeployCrossChainTreasuryMsg { + asset_whitelist?: AssetInfoBaseFor_String[] | null + /** + * Proxy contract serving globally for the given chain, with no specific permission model. + */ + chain_global_proxy: string + cross_chain_msg_spec: CrossChainMsgSpec + enterprise_treasury_code_id: number + ics_proxy_code_id: number + nft_whitelist?: string[] | null +} +export interface ProposalStatusResponse { + expires: Expiration + /** + * Total vote-count (value) for each outcome (key). + */ + results: [number, Uint128][] + status: ProposalStatus +} +export interface ProposalVotesResponse { + votes: Vote[] +} +export interface ProposalsResponse { + proposals: ProposalResponse[] +} +export type QueryMsg = + | { + dao_info: { + contract: Addr + } + } + | { + member_info: { + contract: Addr + msg: QueryMemberInfoMsg + } + } + | { + list_multisig_members: { + contract: Addr + msg: ListMultisigMembersMsg + } + } + | { + asset_whitelist: { + contract: Addr + params: AssetWhitelistParams + } + } + | { + nft_whitelist: { + contract: Addr + params: NftWhitelistParams + } + } + | { + proposal: { + contract: Addr + params: ProposalParams + } + } + | { + proposals: { + contract: Addr + params: ProposalsParams + } + } + | { + proposal_status: { + contract: Addr + params: ProposalStatusParams + } + } + | { + member_vote: { + contract: Addr + params: MemberVoteParams + } + } + | { + proposal_votes: { + contract: Addr + params: ProposalVotesParams + } + } + | { + user_stake: { + contract: Addr + params: UserStakeParams + } + } + | { + total_staked_amount: { + contract: Addr + } + } + | { + staked_nfts: { + contract: Addr + params: StakedNftsParams + } + } + | { + claims: { + contract: Addr + params: ClaimsParams + } + } + | { + releasable_claims: { + contract: Addr + params: ClaimsParams + } + } + | { + create_proposal_adapted: { + contract: Addr + params: CreateProposalMsg + } + } + | { + create_proposal_with_denom_deposit_adapted: { + contract: Addr + params: CreateProposalWithDenomDepositMsg + } + } + | { + create_proposal_with_token_deposit_adapted: { + contract: Addr + params: CreateProposalWithTokenDepositMsg + } + } + | { + create_proposal_with_nft_deposit_adapted: { + contract: Addr + params: CreateProposalWithNftDepositMsg + } + } + | { + create_council_proposal_adapted: { + contract: Addr + params: CreateProposalMsg + } + } + | { + cast_vote_adapted: { + contract: Addr + params: CastVoteMsg + } + } + | { + cast_council_vote_adapted: { + contract: Addr + params: CastVoteMsg + } + } + | { + stake_adapted: { + contract: Addr + params: StakeMsg + } + } + | { + unstake_adapted: { + contract: Addr + params: UnstakeMsg + } + } + | { + claim_adapted: { + contract: Addr + } + } +export type ProposalStatusFilter = 'in_progress' | 'passed' | 'rejected' +export type VoteOutcome = 'yes' | 'no' | 'abstain' | 'veto' +export type StakeMsg = + | { + cw20: StakeCw20Msg + } + | { + cw721: StakeCw721Msg + } + | { + denom: StakeDenomMsg + } +export type UnstakeMsg = + | { + cw20: UnstakeCw20Msg + } + | { + cw721: UnstakeCw721Msg + } +export interface QueryMemberInfoMsg { + member_address: string +} +export interface ListMultisigMembersMsg { + limit?: number | null + start_after?: string | null +} +export interface AssetWhitelistParams { + limit?: number | null + start_after?: AssetInfoBaseFor_String | null +} +export interface NftWhitelistParams { + limit?: number | null + start_after?: string | null +} +export interface ProposalParams { + proposal_id: number +} +export interface ProposalsParams { + /** + * Optional proposal status to filter for. + */ + filter?: ProposalStatusFilter | null + limit?: number | null + start_after?: number | null +} +export interface ProposalStatusParams { + proposal_id: number +} +export interface MemberVoteParams { + member: string + proposal_id: number +} +export interface ProposalVotesParams { + limit?: number | null + proposal_id: number + /** + * Optional pagination data, will return votes after the given voter address + */ + start_after?: string | null +} +export interface UserStakeParams { + limit?: number | null + start_after?: string | null + user: string +} +export interface StakedNftsParams { + limit?: number | null + start_after?: string | null +} +export interface ClaimsParams { + owner: string +} +export interface CreateProposalMsg { + /** + * Optional description text of the proposal + */ + description?: string | null + /** + * Actions to be executed, in order, if the proposal passes + */ + proposal_actions: ProposalAction[] + /** + * Title of the proposal + */ + title: string +} +export interface CreateProposalWithDenomDepositMsg { + create_proposal_msg: CreateProposalMsg + deposit_amount: Uint128 +} +export interface CreateProposalWithTokenDepositMsg { + create_proposal_msg: CreateProposalMsg + deposit_amount: Uint128 +} +export interface CreateProposalWithNftDepositMsg { + create_proposal_msg: CreateProposalMsg + /** + * Tokens that the user wants to deposit to create the proposal. These tokens are expected to be owned by the user or approved for them, otherwise this fails. governance-controller expects to have an approval for those tokens. + */ + deposit_tokens: string[] +} +export interface CastVoteMsg { + outcome: VoteOutcome + proposal_id: number +} +export interface StakeCw20Msg { + amount: Uint128 + user: string +} +export interface StakeCw721Msg { + tokens: string[] + user: string +} +export interface StakeDenomMsg { + amount: Uint128 +} +export interface UnstakeCw20Msg { + amount: Uint128 +} +export interface UnstakeCw721Msg { + tokens: string[] +} +export interface StakedNftsResponse { + nfts: string[] +} +export interface TotalStakedAmountResponse { + total_staked_amount: Uint128 +} +export type UserStake = + | 'none' + | { + denom: DenomUserStake + } + | { + token: TokenUserStake + } + | { + nft: NftUserStake + } +export interface UserStakeResponse { + user_stake: UserStake +} +export interface DenomUserStake { + amount: Uint128 +} +export interface TokenUserStake { + amount: Uint128 +} +export interface NftUserStake { + amount: Uint128 + tokens: string[] +} diff --git a/indexers/enterprise/src/types/contracts/enterprise_factory.ts b/indexers/enterprise/src/types/enterprise_factory.ts similarity index 58% rename from indexers/enterprise/src/types/contracts/enterprise_factory.ts rename to indexers/enterprise/src/types/enterprise_factory.ts index 9bbdee0a..a23720ce 100644 --- a/indexers/enterprise/src/types/contracts/enterprise_factory.ts +++ b/indexers/enterprise/src/types/enterprise_factory.ts @@ -1,280 +1,275 @@ -export module enterprise_factory { export type Addr = string export interface AllDaosResponse { - daos: Addr[]; + daos: Addr[] } export interface ConfigResponse { - config: Config; + config: Config } export interface Config { - cw20_code_id: number; - cw721_code_id: number; - enterprise_versioning: Addr; + cw20_code_id: number + cw721_code_id: number + enterprise_versioning: Addr } export type Uint64 = string export interface EnterpriseCodeIdsResponse { - code_ids: Uint64[]; + code_ids: Uint64[] } export type ExecuteMsg = | { - create_dao: CreateDaoMsg; + create_dao: CreateDaoMsg } | { - finalize_dao_creation: {}; + finalize_dao_creation: {} } export type AssetInfoBaseFor_String = | { - native: string; + native: string } | { - cw20: string; + cw20: string } | { /** * @minItems 2 * @maxItems 2 */ - cw1155: [string, string]; + cw1155: [string, string] } export type ProposalActionType = - | "update_metadata" - | "update_gov_config" - | "update_council" - | "update_asset_whitelist" - | "update_nft_whitelist" - | "request_funding_from_dao" - | "upgrade_dao" - | "execute_msgs" - | "modify_multisig_membership" - | "distribute_funds" - | "update_minimum_weight_for_rewards" - | "add_attestation" - | "remove_attestation" - | "deploy_cross_chain_treasury" + | 'update_metadata' + | 'update_gov_config' + | 'update_council' + | 'update_asset_whitelist' + | 'update_nft_whitelist' + | 'request_funding_from_dao' + | 'upgrade_dao' + | 'execute_msgs' + | 'modify_multisig_membership' + | 'distribute_funds' + | 'update_minimum_weight_for_rewards' + | 'add_attestation' + | 'remove_attestation' + | 'deploy_cross_chain_treasury' export type Decimal = string export type CreateDaoMembershipMsg = | { - new_denom: NewDenomMembershipMsg; + new_denom: NewDenomMembershipMsg } | { - import_cw20: ImportCw20MembershipMsg; + import_cw20: ImportCw20MembershipMsg } | { - new_cw20: NewCw20MembershipMsg; + new_cw20: NewCw20MembershipMsg } | { - import_cw721: ImportCw721MembershipMsg; + import_cw721: ImportCw721MembershipMsg } | { - new_cw721: NewCw721MembershipMsg; + new_cw721: NewCw721MembershipMsg } | { - import_cw3: ImportCw3MembershipMsg; + import_cw3: ImportCw3MembershipMsg } | { - new_multisig: NewMultisigMembershipMsg; + new_multisig: NewMultisigMembershipMsg } export type Duration = | { - height: number; + height: number } | { - time: number; + time: number } export type Uint128 = string export type Logo = - | "none" + | 'none' | { - url: string; + url: string } export interface CreateDaoMsg { /** * assets that are allowed to show in DAO's treasury */ - asset_whitelist?: AssetInfoBaseFor_String[] | null; + asset_whitelist?: AssetInfoBaseFor_String[] | null /** * Optional text that users will have to attest to before being able to participate in DAO's governance and certain other functions. */ - attestation_text?: string | null; + attestation_text?: string | null /** * Optional council structure that can manage certain aspects of the DAO */ - dao_council?: DaoCouncilSpec | null; - dao_membership: CreateDaoMembershipMsg; - dao_metadata: DaoMetadata; - gov_config: GovConfig; + dao_council?: DaoCouncilSpec | null + dao_membership: CreateDaoMembershipMsg + dao_metadata: DaoMetadata + gov_config: GovConfig /** * Minimum weight that a user should have in order to qualify for rewards. E.g. a value of 3 here means that a user in token or NFT DAO needs at least 3 staked DAO assets, or a weight of 3 in multisig DAO, to be eligible for rewards. */ - minimum_weight_for_rewards?: Uint128 | null; + minimum_weight_for_rewards?: Uint128 | null /** * NFTs that are allowed to show in DAO's treasury */ - nft_whitelist?: string[] | null; + nft_whitelist?: string[] | null } export interface DaoCouncilSpec { /** * Proposal action types allowed in proposals that are voted on by the council. Effectively defines what types of actions council can propose and vote on. If None, will default to a predefined set of actions. */ - allowed_proposal_action_types?: ProposalActionType[] | null; + allowed_proposal_action_types?: ProposalActionType[] | null /** * Addresses of council members. Each member has equal voting power. */ - members: string[]; + members: string[] /** * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires */ - quorum: Decimal; + quorum: Decimal /** * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win */ - threshold: Decimal; + threshold: Decimal } export interface NewDenomMembershipMsg { - denom: string; - unlocking_period: Duration; + denom: string + unlocking_period: Duration } export interface ImportCw20MembershipMsg { /** * Address of the CW20 token to import */ - cw20_contract: string; + cw20_contract: string /** * Duration after which unstaked tokens can be claimed */ - unlocking_period: Duration; + unlocking_period: Duration } export interface NewCw20MembershipMsg { /** * Optional amount of tokens to be minted to the DAO's address */ - initial_dao_balance?: Uint128 | null; - initial_token_balances: Cw20Coin[]; - token_decimals: number; - token_marketing?: TokenMarketingInfo | null; - token_mint?: MinterResponse | null; - token_name: string; - token_symbol: string; - unlocking_period: Duration; + initial_dao_balance?: Uint128 | null + initial_token_balances: Cw20Coin[] + token_decimals: number + token_marketing?: TokenMarketingInfo | null + token_mint?: MinterResponse | null + token_name: string + token_symbol: string + unlocking_period: Duration } export interface Cw20Coin { - address: string; - amount: Uint128; + address: string + amount: Uint128 } export interface TokenMarketingInfo { - description?: string | null; - logo_url?: string | null; - marketing_owner?: string | null; - project?: string | null; + description?: string | null + logo_url?: string | null + marketing_owner?: string | null + project?: string | null } export interface MinterResponse { /** * cap is a hard cap on total supply that can be achieved by minting. Note that this refers to total_supply. If None, there is unlimited cap. */ - cap?: Uint128 | null; - minter: string; + cap?: Uint128 | null + minter: string } export interface ImportCw721MembershipMsg { /** * Address of the CW721 contract to import */ - cw721_contract: string; + cw721_contract: string /** * Duration after which unstaked items can be claimed */ - unlocking_period: Duration; + unlocking_period: Duration } export interface NewCw721MembershipMsg { - minter?: string | null; - nft_name: string; - nft_symbol: string; - unlocking_period: Duration; + minter?: string | null + nft_name: string + nft_symbol: string + unlocking_period: Duration } export interface ImportCw3MembershipMsg { /** * Address of the CW3 contract to import */ - cw3_contract: string; + cw3_contract: string } export interface NewMultisigMembershipMsg { - multisig_members: UserWeight[]; + multisig_members: UserWeight[] } export interface UserWeight { - user: string; - weight: Uint128; + user: string + weight: Uint128 } export interface DaoMetadata { - description?: string | null; - logo: Logo; - name: string; - socials: DaoSocialData; + description?: string | null + logo: Logo + name: string + socials: DaoSocialData } export interface DaoSocialData { - discord_username?: string | null; - github_username?: string | null; - telegram_username?: string | null; - twitter_username?: string | null; + discord_username?: string | null + github_username?: string | null + telegram_username?: string | null + twitter_username?: string | null } export interface GovConfig { /** * If set to true, this will allow DAOs to execute proposals that have reached quorum and threshold, even before their voting period ends. */ - allow_early_proposal_execution: boolean; + allow_early_proposal_execution: boolean /** * Optional minimum amount of DAO's governance unit to be required to create a deposit. */ - minimum_deposit?: Uint128 | null; + minimum_deposit?: Uint128 | null /** * Portion of total available votes cast in a proposal to consider it valid e.g. quorum of 30% means that 30% of all available votes have to be cast in the proposal, otherwise it fails automatically when it expires */ - quorum: Decimal; + quorum: Decimal /** * Portion of votes assigned to a single option from all the votes cast in the given proposal required to determine the 'winning' option e.g. 51% threshold means that an option has to have at least 51% of the cast votes to win */ - threshold: Decimal; - /** - * Duration that has to pass for unstaked membership tokens to be claimable - */ - unlocking_period: Duration; + threshold: Decimal /** * Portion of votes assigned to veto option from all the votes cast in the given proposal required to veto the proposal. If None, will default to the threshold set for all proposal options. */ - veto_threshold?: Decimal | null; + veto_threshold?: Decimal | null /** * Duration of proposals before they end, expressed in seconds */ - vote_duration: number; + vote_duration: number } export interface InstantiateMsg { - config: Config; + config: Config } export interface IsEnterpriseCodeIdResponse { - is_enterprise_code_id: boolean; + is_enterprise_code_id: boolean } export interface MigrateMsg { - enterprise_versioning_addr: string; + enterprise_versioning_addr: string } export type QueryMsg = | { - config: {}; + config: {} } | { - all_daos: QueryAllDaosMsg; + all_daos: QueryAllDaosMsg } | { - enterprise_code_ids: EnterpriseCodeIdsMsg; + enterprise_code_ids: EnterpriseCodeIdsMsg } | { - is_enterprise_code_id: IsEnterpriseCodeIdMsg; + is_enterprise_code_id: IsEnterpriseCodeIdMsg } export interface QueryAllDaosMsg { - limit?: number | null; - start_after?: Uint64 | null; + limit?: number | null + start_after?: Uint64 | null } export interface EnterpriseCodeIdsMsg { - limit?: number | null; - start_after?: Uint64 | null; + limit?: number | null + start_after?: Uint64 | null } export interface IsEnterpriseCodeIdMsg { - code_id: Uint64; -} } \ No newline at end of file + code_id: Uint64 +} diff --git a/indexers/enterprise/src/types/enterprise_versioning.ts b/indexers/enterprise/src/types/enterprise_versioning.ts new file mode 100644 index 00000000..2a1d5b90 --- /dev/null +++ b/indexers/enterprise/src/types/enterprise_versioning.ts @@ -0,0 +1,62 @@ +export type Addr = string +export interface AdminResponse { + admin: Addr +} +export type ExecuteMsg = { + add_version: AddVersionMsg +} +export interface AddVersionMsg { + version: VersionInfo +} +export interface VersionInfo { + attestation_code_id: number + /** + * Changelog items from the previous version + */ + changelog: string[] + denom_staking_membership_code_id: number + enterprise_code_id: number + enterprise_governance_code_id: number + enterprise_governance_controller_code_id: number + enterprise_treasury_code_id: number + funds_distributor_code_id: number + multisig_membership_code_id: number + nft_staking_membership_code_id: number + token_staking_membership_code_id: number + version: Version +} +export interface Version { + major: number + minor: number + patch: number +} +export interface InstantiateMsg { + admin: string +} +export interface MigrateMsg {} +export type QueryMsg = + | { + admin: {} + } + | { + version: VersionParams + } + | { + versions: VersionsParams + } + | { + latest_version: {} + } +export interface VersionParams { + version: Version +} +export interface VersionsParams { + limit?: number | null + start_after?: Version | null +} +export interface VersionResponse { + version: VersionInfo +} +export interface VersionsResponse { + versions: VersionInfo[] +} diff --git a/indexers/enterprise/src/types/funds_distributor.ts b/indexers/enterprise/src/types/funds_distributor.ts new file mode 100644 index 00000000..b14d663b --- /dev/null +++ b/indexers/enterprise/src/types/funds_distributor.ts @@ -0,0 +1,102 @@ +export type Cw20HookMsg = { + distribute: {} +} +export type ExecuteMsg = + | { + update_user_weights: UpdateUserWeightsMsg + } + | { + update_minimum_eligible_weight: UpdateMinimumEligibleWeightMsg + } + | { + distribute_native: {} + } + | { + claim_rewards: ClaimRewardsMsg + } + | { + receive: Cw20ReceiveMsg + } +export type Uint128 = string +export type Binary = string +export interface UpdateUserWeightsMsg { + /** + * New weights that the users have, after the change + */ + new_user_weights: UserWeight[] +} +export interface UserWeight { + user: string + weight: Uint128 +} +export interface UpdateMinimumEligibleWeightMsg { + /** + * New minimum weight that the user must have to be eligible for rewards distributions + */ + minimum_eligible_weight: Uint128 +} +export interface ClaimRewardsMsg { + /** + * CW20 asset rewards to be claimed, should be addresses of CW20 tokens + */ + cw20_assets: string[] + /** + * Native denominations to be claimed + */ + native_denoms: string[] + user: string +} +export interface Cw20ReceiveMsg { + amount: Uint128 + msg: Binary + sender: string +} +export interface InstantiateMsg { + admin: string + enterprise_contract: string + initial_weights: UserWeight[] + /** + * Optional minimum weight that the user must have to be eligible for rewards distributions + */ + minimum_eligible_weight?: Uint128 | null +} +export interface MigrateMsg { + new_admin: string + new_enterprise_contract: string +} +export interface MinimumEligibleWeightResponse { + minimum_eligible_weight: Uint128 +} +export type QueryMsg = + | { + user_rewards: UserRewardsParams + } + | { + minimum_eligible_weight: {} + } +export interface UserRewardsParams { + /** + * Addresses of CW20 tokens to be queried for rewards + */ + cw20_assets: string[] + /** + * Native denominations to be queried for rewards + */ + native_denoms: string[] + user: string +} +export interface UserRewardsResponse { + cw20_rewards: Cw20Reward[] + native_rewards: NativeReward[] +} +export interface Cw20Reward { + amount: Uint128 + /** + * Address of the CW20 token + */ + asset: string +} +export interface NativeReward { + amount: Uint128 + denom: string +} diff --git a/indexers/shared/utils/daoContractAddressRecord.ts b/indexers/shared/utils/daoContractAddressRecord.ts index bbdd50e9..8f283d9e 100644 --- a/indexers/shared/utils/daoContractAddressRecord.ts +++ b/indexers/shared/utils/daoContractAddressRecord.ts @@ -1,14 +1,18 @@ export type NetworkName = 'mainnet' | 'testnet'; -export type DaoContract = 'enterprise-factory' | 'enterprise-facade'; +export type DaoContract = 'enterprise-factory' | 'enterprise-facade' | 'enterprise-versioning'; export const daoContractAddressRecord: Record> = { 'enterprise-factory': { mainnet: 'terra1y2dwydnnnctdwwmvs23ct60fj626t66qk53cae2gc55k3ce92jmqldj0sf', - testnet: 'terra1vwfllxsuvkyhfztv7yenv0wjra2ue7zu6arc3esmwcckenpq566sxch3wk', + testnet: 'terra1rafjglr2gl7l66dmjmvc2r2lct57dpdfzvjfpdxjy5mk5gfk38mssegvy9', }, 'enterprise-facade': { mainnet: '', - testnet: 'terra1jyy4r09tgn55ysa5r0fmz20k9q9akjh7r6jrhc4vftdakfaly0sqe7ewyj', + testnet: 'terra1xjnxvwrk8vj4ju6rclgy5sm47a0ll8lux54jdjyhntzgwycmeuyq5wvvm5', + }, + 'enterprise-versioning': { + mainnet: '', + testnet: 'terra1ye4hfjvpehz6u9m25nhvsgj0q9d2yqjswxkay9tdgmu6mujau5kqz9e7zz', }, }; From f38997e25a5ee4d9144459e4f5e817082a4fa642 Mon Sep 17 00:00:00 2001 From: Rodion Chachura Date: Thu, 5 Oct 2023 11:39:45 +0400 Subject: [PATCH 3/3] update: addresses --- indexers/shared/utils/daoContractAddressRecord.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indexers/shared/utils/daoContractAddressRecord.ts b/indexers/shared/utils/daoContractAddressRecord.ts index 8f283d9e..99b1087d 100644 --- a/indexers/shared/utils/daoContractAddressRecord.ts +++ b/indexers/shared/utils/daoContractAddressRecord.ts @@ -5,11 +5,11 @@ export type DaoContract = 'enterprise-factory' | 'enterprise-facade' | 'enterpri export const daoContractAddressRecord: Record> = { 'enterprise-factory': { mainnet: 'terra1y2dwydnnnctdwwmvs23ct60fj626t66qk53cae2gc55k3ce92jmqldj0sf', - testnet: 'terra1rafjglr2gl7l66dmjmvc2r2lct57dpdfzvjfpdxjy5mk5gfk38mssegvy9', + testnet: 'terra16vhaar9vhysnr8y5qrs20gecactkc6cxdehzzf487rh60eqst25q3wk77r', }, 'enterprise-facade': { mainnet: '', - testnet: 'terra1xjnxvwrk8vj4ju6rclgy5sm47a0ll8lux54jdjyhntzgwycmeuyq5wvvm5', + testnet: 'terra1v5tw0fq7hdnjh2pg7xxxnm98n2mk56h0qnc3zk68s9s7t74yja0s3wgurm', }, 'enterprise-versioning': { mainnet: '',