diff --git a/modules/client-common/CHANGELOG.md b/modules/client-common/CHANGELOG.md index 93b061fd4..62b4a39e1 100644 --- a/modules/client-common/CHANGELOG.md +++ b/modules/client-common/CHANGELOG.md @@ -19,6 +19,27 @@ TEMPLATE: ## [UPCOMING] +### Added + +- `getDefaultIpfsNodes` function to get the default IPFS nodes for a network +- `getDefaultGraphNodes` function to get the default Graph nodes for a network + +### Changed + +- Removed `LIVE_CONTRACTS` and used `contracts` from `@aragon/osx-commons-configs` instead +- Removed address getters and changed them for a generic `getAddress` function +- `ContextParams` keys for contract addresses now are the contract names: + - `daoFactoryAddress` -> `DaoFactory` + - `multisigRepoAddress` -> `MultisigRepoProxy` + - `tokenVotingRepoAddress` -> `TokenVotingRepoProxy` + - etc... +- Removed `IPFS_NODES` and `GRAPH_NODES` and used `getDefaultIpfsNodes` and `getDefaultGraphNodes` instead +- Removed `ADDITIONAL_NETWORKS` +- `SupportedNetworks` and `SupportedVersions` now are exported from `@aragon/osx-commons-configs` +- + +## [1.14.1] + ### Fixed - Typo in `LIVE_CONTRACTS` for mainnet diff --git a/modules/client-common/package.json b/modules/client-common/package.json index 0489b7616..eff08219e 100644 --- a/modules/client-common/package.json +++ b/modules/client-common/package.json @@ -1,7 +1,7 @@ { "name": "@aragon/sdk-client-common", "author": "Aragon Association", - "version": "1.14.1", + "version": "1.15.0", "license": "MIT", "main": "dist/index.js", "module": "dist/sdk-client-common.esm.js", @@ -58,6 +58,7 @@ "typescript": "^5.2.2" }, "dependencies": { + "@aragon/osx-commons-configs": "^0.2.0", "@aragon/osx-ethers": "^1.3.1", "@aragon/osx-ethers-v1.0.0": "npm:@aragon/osx-ethers@1.2.1", "@aragon/sdk-ipfs": "^1.1.0", diff --git a/modules/client-common/src/constants.ts b/modules/client-common/src/constants.ts index 3a60066b8..bf647ba40 100644 --- a/modules/client-common/src/constants.ts +++ b/modules/client-common/src/constants.ts @@ -1,8 +1,4 @@ -import { activeContractsList } from "@aragon/osx-ethers"; -import { activeContractsList as activeContractsListV1_0_0 } from "@aragon/osx-ethers-v1.0.0"; -import { ProposalMetadata, SupportedNetwork, SupportedVersion } from "./types"; -import { NetworkDeployment } from "./internal"; -import { Network } from "@ethersproject/networks"; +import { ProposalMetadata } from "./types"; import { keccak256 } from "@ethersproject/keccak256"; import { toUtf8Bytes } from "@ethersproject/strings"; @@ -10,37 +6,6 @@ import { toUtf8Bytes } from "@ethersproject/strings"; * many fetch requests that could take a long time */ export const MULTI_FETCH_TIMEOUT = 7 * 1000; -type GraphqlNetworks = - | "mainnet" - | "goerli" - | "polygon" - | "mumbai" - | "baseGoerli" - | "baseMainnet" - | "baseSepolia" - | "local" - | "sepolia" - | "arbitrum" - | "arbitrumSepolia" - | "arbitrumGoerli"; - -const SupportedNetworksToGraphqlNetworks: { - [K in SupportedNetwork]: GraphqlNetworks; -} = { - [SupportedNetwork.MAINNET]: "mainnet", - [SupportedNetwork.GOERLI]: "goerli", - [SupportedNetwork.POLYGON]: "polygon", - [SupportedNetwork.MUMBAI]: "mumbai", - [SupportedNetwork.BASE_GOERLI]: "baseGoerli", - [SupportedNetwork.BASE_SEPOLIA]: "baseSepolia", - [SupportedNetwork.BASE]: "baseMainnet", - [SupportedNetwork.LOCAL]: "local", - [SupportedNetwork.SEPOLIA]: "sepolia", - [SupportedNetwork.ARBITRUM]: "arbitrum", - [SupportedNetwork.ARBITRUM_GOERLI]: "arbitrumGoerli", - [SupportedNetwork.ARBITRUM_SEPOLIA]: "arbitrumSepolia", -}; - export const UNSUPPORTED_PROPOSAL_METADATA_LINK: ProposalMetadata = { title: "(unsupported metadata link)", summary: "(the link to the metadata is not supported)", @@ -60,44 +25,7 @@ export const UNAVAILABLE_PROPOSAL_METADATA: ProposalMetadata = { resources: [], }; -const getGraphqlNode = (network: SupportedNetwork): string => { - return `https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-${ - SupportedNetworksToGraphqlNetworks[network] - }/version/v1.4.0/api`; -}; - -export const GRAPHQL_NODES: { [K in SupportedNetwork]: { url: string }[] } = { - [SupportedNetwork.MAINNET]: [{ - url: getGraphqlNode(SupportedNetwork.MAINNET), - }], - [SupportedNetwork.GOERLI]: [{ url: getGraphqlNode(SupportedNetwork.GOERLI) }], - [SupportedNetwork.POLYGON]: [{ - url: getGraphqlNode(SupportedNetwork.POLYGON), - }], - [SupportedNetwork.MUMBAI]: [{ url: getGraphqlNode(SupportedNetwork.MUMBAI) }], - [SupportedNetwork.BASE]: [{ url: getGraphqlNode(SupportedNetwork.BASE) }], - [SupportedNetwork.BASE_GOERLI]: [{ - url: getGraphqlNode(SupportedNetwork.BASE_GOERLI), - }], - [SupportedNetwork.BASE_SEPOLIA]: [{ - url: getGraphqlNode(SupportedNetwork.BASE_SEPOLIA), - }], - [SupportedNetwork.LOCAL]: [{ url: getGraphqlNode(SupportedNetwork.LOCAL) }], - [SupportedNetwork.SEPOLIA]: [{ - url: getGraphqlNode(SupportedNetwork.SEPOLIA), - }], - [SupportedNetwork.ARBITRUM]: [{ - url: getGraphqlNode(SupportedNetwork.ARBITRUM), - }], - [SupportedNetwork.ARBITRUM_GOERLI]: [{ - url: getGraphqlNode(SupportedNetwork.ARBITRUM_GOERLI), - }], - [SupportedNetwork.ARBITRUM_SEPOLIA]: [{ - url: getGraphqlNode(SupportedNetwork.ARBITRUM_SEPOLIA), - }], -}; - -const IPFS_ENDPOINTS = { +export const IPFS_ENDPOINTS = { prod: [ { url: "https://prod.ipfs.aragon.network/api/v0", @@ -116,355 +44,6 @@ const IPFS_ENDPOINTS = { ], }; -export const IPFS_NODES: { - [K in SupportedNetwork]: { - url: string; - headers?: Record | undefined; - }[]; -} = { - [SupportedNetwork.MAINNET]: IPFS_ENDPOINTS.prod, - [SupportedNetwork.GOERLI]: IPFS_ENDPOINTS.test, - [SupportedNetwork.POLYGON]: IPFS_ENDPOINTS.prod, - [SupportedNetwork.MUMBAI]: IPFS_ENDPOINTS.test, - [SupportedNetwork.BASE]: IPFS_ENDPOINTS.prod, - [SupportedNetwork.BASE_GOERLI]: IPFS_ENDPOINTS.test, - [SupportedNetwork.BASE_SEPOLIA]: IPFS_ENDPOINTS.test, - [SupportedNetwork.LOCAL]: IPFS_ENDPOINTS.test, - [SupportedNetwork.SEPOLIA]: IPFS_ENDPOINTS.test, - [SupportedNetwork.ARBITRUM]: IPFS_ENDPOINTS.prod, - [SupportedNetwork.ARBITRUM_GOERLI]: IPFS_ENDPOINTS.test, - [SupportedNetwork.ARBITRUM_SEPOLIA]: IPFS_ENDPOINTS.test, -}; - -const EMPTY_DEPLOYMENT = { - daoFactoryAddress: "", - pluginSetupProcessorAddress: "", - multisigRepoAddress: "", - adminRepoAddress: "", - addresslistVotingRepoAddress: "", - tokenVotingRepoAddress: "", - multisigSetupAddress: "", - adminSetupAddress: "", - addresslistVotingSetupAddress: "", - tokenVotingSetupAddress: "", - ensRegistryAddress: "", -}; - -export const LIVE_CONTRACTS: { - [J in SupportedVersion]: { [K in SupportedNetwork]: NetworkDeployment }; -} = { - [SupportedVersion.V1_0_0]: { - [SupportedNetwork.MAINNET]: { - daoFactoryAddress: activeContractsListV1_0_0.mainnet.DAOFactory, - pluginSetupProcessorAddress: - activeContractsListV1_0_0.mainnet.PluginSetupProcessor, - multisigRepoAddress: activeContractsListV1_0_0.mainnet["multisig-repo"], - adminRepoAddress: activeContractsListV1_0_0.mainnet["admin-repo"], - addresslistVotingRepoAddress: - activeContractsListV1_0_0.mainnet["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsListV1_0_0.mainnet["token-voting-repo"], - multisigSetupAddress: activeContractsListV1_0_0.mainnet.MultisigSetup, - adminSetupAddress: activeContractsListV1_0_0.mainnet.AdminSetup, - addresslistVotingSetupAddress: - activeContractsListV1_0_0.mainnet.AddresslistVotingSetup, - tokenVotingSetupAddress: - activeContractsListV1_0_0.mainnet.TokenVotingSetup, - }, - [SupportedNetwork.GOERLI]: { - daoFactoryAddress: activeContractsListV1_0_0.goerli.DAOFactory, - pluginSetupProcessorAddress: - activeContractsListV1_0_0.goerli.PluginSetupProcessor, - multisigRepoAddress: activeContractsListV1_0_0.goerli["multisig-repo"], - adminRepoAddress: activeContractsListV1_0_0.goerli["admin-repo"], - addresslistVotingRepoAddress: - activeContractsListV1_0_0.goerli["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsListV1_0_0.goerli["token-voting-repo"], - multisigSetupAddress: activeContractsListV1_0_0.goerli.MultisigSetup, - adminSetupAddress: activeContractsListV1_0_0.goerli.AdminSetup, - addresslistVotingSetupAddress: - activeContractsListV1_0_0.goerli.AddresslistVotingSetup, - tokenVotingSetupAddress: - activeContractsListV1_0_0.goerli.TokenVotingSetup, - }, - [SupportedNetwork.POLYGON]: { - daoFactoryAddress: activeContractsListV1_0_0.polygon.DAOFactory, - pluginSetupProcessorAddress: - activeContractsListV1_0_0.polygon.PluginSetupProcessor, - multisigRepoAddress: activeContractsListV1_0_0.polygon["multisig-repo"], - adminRepoAddress: activeContractsListV1_0_0.polygon["admin-repo"], - addresslistVotingRepoAddress: - activeContractsListV1_0_0.polygon["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsListV1_0_0.polygon["token-voting-repo"], - multisigSetupAddress: activeContractsListV1_0_0.polygon.MultisigSetup, - adminSetupAddress: activeContractsListV1_0_0.polygon.AdminSetup, - addresslistVotingSetupAddress: - activeContractsListV1_0_0.polygon.AddresslistVotingSetup, - tokenVotingSetupAddress: - activeContractsListV1_0_0.polygon.TokenVotingSetup, - ensRegistryAddress: activeContractsListV1_0_0.polygon.ENSRegistry, - }, - [SupportedNetwork.MUMBAI]: { - daoFactoryAddress: activeContractsListV1_0_0.mumbai.DAOFactory, - pluginSetupProcessorAddress: - activeContractsListV1_0_0.mumbai.PluginSetupProcessor, - multisigRepoAddress: activeContractsListV1_0_0.mumbai["multisig-repo"], - adminRepoAddress: activeContractsListV1_0_0.mumbai["admin-repo"], - addresslistVotingRepoAddress: - activeContractsListV1_0_0.mumbai["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsListV1_0_0.mumbai["token-voting-repo"], - multisigSetupAddress: activeContractsListV1_0_0.mumbai.MultisigSetup, - adminSetupAddress: activeContractsListV1_0_0.mumbai.AdminSetup, - addresslistVotingSetupAddress: - activeContractsListV1_0_0.mumbai.AddresslistVotingSetup, - tokenVotingSetupAddress: - activeContractsListV1_0_0.mumbai.TokenVotingSetup, - ensRegistryAddress: activeContractsListV1_0_0.mumbai.ENSRegistry, - }, - [SupportedNetwork.BASE]: EMPTY_DEPLOYMENT, - [SupportedNetwork.BASE_GOERLI]: EMPTY_DEPLOYMENT, - [SupportedNetwork.BASE_SEPOLIA]: EMPTY_DEPLOYMENT, - [SupportedNetwork.LOCAL]: EMPTY_DEPLOYMENT, - [SupportedNetwork.SEPOLIA]: EMPTY_DEPLOYMENT, - [SupportedNetwork.ARBITRUM]: EMPTY_DEPLOYMENT, - [SupportedNetwork.ARBITRUM_GOERLI]: EMPTY_DEPLOYMENT, - [SupportedNetwork.ARBITRUM_SEPOLIA]: EMPTY_DEPLOYMENT, - }, - [SupportedVersion.V1_3_0]: { - [SupportedNetwork.MAINNET]: { - daoFactoryAddress: activeContractsList.mainnet.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.mainnet.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.mainnet["multisig-repo"], - adminRepoAddress: activeContractsList.mainnet["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.mainnet["address-list-voting-repo"], - tokenVotingRepoAddress: activeContractsList.mainnet["token-voting-repo"], - multisigSetupAddress: activeContractsList.mainnet.MultisigSetup, - adminSetupAddress: activeContractsList.mainnet.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.mainnet.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.mainnet.TokenVotingSetup, - }, - [SupportedNetwork.GOERLI]: { - daoFactoryAddress: activeContractsList.goerli.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.goerli.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.goerli["multisig-repo"], - adminRepoAddress: activeContractsList.goerli["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.goerli["address-list-voting-repo"], - tokenVotingRepoAddress: activeContractsList.goerli["token-voting-repo"], - multisigSetupAddress: activeContractsList.goerli.MultisigSetup, - adminSetupAddress: activeContractsList.goerli.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.goerli.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.goerli.TokenVotingSetup, - }, - [SupportedNetwork.POLYGON]: { - daoFactoryAddress: activeContractsList.polygon.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.polygon.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.polygon["multisig-repo"], - adminRepoAddress: activeContractsList.polygon["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.polygon["address-list-voting-repo"], - tokenVotingRepoAddress: activeContractsList.polygon["token-voting-repo"], - multisigSetupAddress: activeContractsList.polygon.MultisigSetup, - adminSetupAddress: activeContractsList.polygon.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.polygon.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.polygon.TokenVotingSetup, - ensRegistryAddress: activeContractsList.polygon.ENSRegistry, - }, - [SupportedNetwork.MUMBAI]: { - daoFactoryAddress: activeContractsList.mumbai.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.mumbai.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.mumbai["multisig-repo"], - adminRepoAddress: activeContractsList.mumbai["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.mumbai["address-list-voting-repo"], - tokenVotingRepoAddress: activeContractsList.mumbai["token-voting-repo"], - multisigSetupAddress: activeContractsList.mumbai.MultisigSetup, - adminSetupAddress: activeContractsList.mumbai.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.mumbai.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.mumbai.TokenVotingSetup, - ensRegistryAddress: activeContractsList.mumbai.ENSRegistry, - }, - [SupportedNetwork.BASE]: { - daoFactoryAddress: activeContractsList.baseMainnet.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.baseMainnet.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.baseMainnet["multisig-repo"], - adminRepoAddress: activeContractsList.baseMainnet["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.baseMainnet["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsList.baseMainnet["token-voting-repo"], - multisigSetupAddress: activeContractsList.baseMainnet.MultisigSetup, - adminSetupAddress: activeContractsList.baseMainnet.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.baseMainnet.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.baseMainnet.TokenVotingSetup, - ensRegistryAddress: activeContractsList.baseMainnet.ENSRegistry, - }, - [SupportedNetwork.BASE_GOERLI]: { - daoFactoryAddress: activeContractsList.baseGoerli.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.baseGoerli.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.baseGoerli["multisig-repo"], - adminRepoAddress: activeContractsList.baseGoerli["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.baseGoerli["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsList.baseGoerli["token-voting-repo"], - multisigSetupAddress: activeContractsList.baseGoerli.MultisigSetup, - adminSetupAddress: activeContractsList.baseGoerli.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.baseGoerli.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.baseGoerli.TokenVotingSetup, - ensRegistryAddress: activeContractsList.baseGoerli.ENSRegistry, - }, - [SupportedNetwork.BASE_SEPOLIA]: { - daoFactoryAddress: activeContractsList.baseSepolia.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.baseSepolia.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.baseSepolia["multisig-repo"], - adminRepoAddress: activeContractsList.baseSepolia["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.baseSepolia["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsList.baseSepolia["token-voting-repo"], - multisigSetupAddress: activeContractsList.baseSepolia.MultisigSetup, - adminSetupAddress: activeContractsList.baseSepolia.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.baseSepolia.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.baseSepolia.TokenVotingSetup, - ensRegistryAddress: activeContractsList.baseSepolia.ENSRegistry, - }, - [SupportedNetwork.LOCAL]: { - daoFactoryAddress: "", - pluginSetupProcessorAddress: "", - multisigRepoAddress: "", - adminRepoAddress: "", - addresslistVotingRepoAddress: "", - tokenVotingRepoAddress: "", - multisigSetupAddress: "", - adminSetupAddress: "", - addresslistVotingSetupAddress: "", - tokenVotingSetupAddress: "", - ensRegistryAddress: "", - }, - [SupportedNetwork.SEPOLIA]: { - daoFactoryAddress: activeContractsList.sepolia.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.sepolia.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.sepolia["multisig-repo"], - adminRepoAddress: activeContractsList.sepolia["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.sepolia["address-list-voting-repo"], - tokenVotingRepoAddress: activeContractsList.sepolia["token-voting-repo"], - multisigSetupAddress: activeContractsList.sepolia.MultisigSetup, - adminSetupAddress: activeContractsList.sepolia.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.sepolia.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.sepolia.TokenVotingSetup, - ensRegistryAddress: activeContractsList.sepolia.ENSRegistry, - }, - [SupportedNetwork.ARBITRUM]: { - daoFactoryAddress: activeContractsList.arbitrum.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.arbitrum.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.arbitrum["multisig-repo"], - adminRepoAddress: activeContractsList.arbitrum["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.arbitrum["address-list-voting-repo"], - tokenVotingRepoAddress: activeContractsList.arbitrum["token-voting-repo"], - multisigSetupAddress: activeContractsList.arbitrum.MultisigSetup, - adminSetupAddress: activeContractsList.arbitrum.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.arbitrum.AddresslistVotingSetup, - tokenVotingSetupAddress: activeContractsList.arbitrum.TokenVotingSetup, - ensRegistryAddress: activeContractsList.arbitrum.ENSRegistry, - }, - [SupportedNetwork.ARBITRUM_SEPOLIA]: { - daoFactoryAddress: activeContractsList.arbitrumSepolia.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.arbitrumSepolia.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.arbitrumSepolia["multisig-repo"], - adminRepoAddress: activeContractsList.arbitrumSepolia["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.arbitrumSepolia["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsList.arbitrumSepolia["token-voting-repo"], - multisigSetupAddress: activeContractsList.arbitrumSepolia.MultisigSetup, - adminSetupAddress: activeContractsList.arbitrumSepolia.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.arbitrumSepolia.AddresslistVotingSetup, - tokenVotingSetupAddress: - activeContractsList.arbitrumSepolia.TokenVotingSetup, - ensRegistryAddress: activeContractsList.arbitrumSepolia.ENSRegistry, - }, - [SupportedNetwork.ARBITRUM_GOERLI]: { - daoFactoryAddress: activeContractsList.arbitrumGoerli.DAOFactory, - pluginSetupProcessorAddress: - activeContractsList.arbitrumGoerli.PluginSetupProcessor, - multisigRepoAddress: activeContractsList.arbitrumGoerli["multisig-repo"], - adminRepoAddress: activeContractsList.arbitrumGoerli["admin-repo"], - addresslistVotingRepoAddress: - activeContractsList.arbitrumGoerli["address-list-voting-repo"], - tokenVotingRepoAddress: - activeContractsList.arbitrumGoerli["token-voting-repo"], - multisigSetupAddress: activeContractsList.arbitrumGoerli.MultisigSetup, - adminSetupAddress: activeContractsList.arbitrumGoerli.AdminSetup, - addresslistVotingSetupAddress: - activeContractsList.arbitrumGoerli.AddresslistVotingSetup, - tokenVotingSetupAddress: - activeContractsList.arbitrumGoerli.TokenVotingSetup, - ensRegistryAddress: activeContractsList.arbitrumGoerli.ENSRegistry, - }, - }, -}; -export const ADDITIONAL_NETWORKS: Network[] = [ - { - name: "baseGoerli", - chainId: 84531, - }, - { - name: "base", - chainId: 8453, - }, - { - name: "baseSepolia", - chainId: 84532, - }, - { - name: "arbitrum", - chainId: 42161, - }, - { - name: "arbitrumGoerli", - chainId: 421613, - }, - { - name: "arbitrumSepolia", - chainId: 421614, - }, - { - name: "sepolia", - chainId: 11155111, - }, - { - name: "local", - chainId: 31337, - }, -]; - const Permissions = { UPGRADE_PERMISSION: "UPGRADE_PERMISSION", UPGRADE_PLUGIN_PERMISSION: "UPGRADE_PLUGIN_PERMISSION", diff --git a/modules/client-common/src/context-core.ts b/modules/client-common/src/context-core.ts index a1bb621d0..3aaa008fe 100644 --- a/modules/client-common/src/context-core.ts +++ b/modules/client-common/src/context-core.ts @@ -3,48 +3,39 @@ import { Client as IpfsClient } from "@aragon/sdk-ipfs"; import { GraphQLClient } from "graphql-request"; import { isAddress } from "@ethersproject/address"; import { Signer } from "@ethersproject/abstract-signer"; +import { ContextParams, ContextState, OverriddenState } from "./types"; import { - ContextParams, - ContextState, - OverriddenState, - SupportedNetwork, - SupportedNetworksArray, - SupportedVersion, -} from "./types"; -import { GRAPHQL_NODES, IPFS_NODES, LIVE_CONTRACTS } from "./constants"; -import { getNetwork } from "./utils"; -import { DeployedAddressesArray } from "./internal"; + getDefaultGraphqlNodes, + getDefaultIpfsNodes, + getNetwork, +} from "./utils"; import { InvalidAddressError, InvalidGasEstimationFactorError, UnsupportedNetworkError, UnsupportedProtocolError, } from "./errors"; +import { + ContractNames, + getNetworkDeploymentForVersion, + getNetworkNameByAlias, + SupportedVersions, +} from "@aragon/osx-commons-configs"; const DEFAULT_GAS_FEE_ESTIMATION_FACTOR = 0.625; const supportedProtocols = ["https:"]; +const contractNames = Object.values(ContractNames); if (typeof process !== "undefined" && process?.env?.TESTING) { supportedProtocols.push("http:"); } export abstract class ContextCore { protected state: ContextState = {} as ContextState; - protected overriden: OverriddenState = { - daoFactoryAddress: false, - pluginSetupProcessorAddress: false, - multisigRepoAddress: false, - adminRepoAddress: false, - addresslistVotingRepoAddress: false, - tokenVotingRepoAddress: false, - multisigSetupAddress: false, - adminSetupAddress: false, - addresslistVotingSetupAddress: false, - tokenVotingSetupAddress: false, - ensRegistryAddress: false, - gasFeeEstimationFactor: false, - ipfsNodes: false, - graphqlNodes: false, - }; + + protected overriden: OverriddenState = contractNames.reduce( + (acc, key) => ({ ...acc, [key]: false }), + { ENSRegistry: false } as OverriddenState, + ); // INTERNAL CONTEXT STATE /** * @param {Object} params @@ -61,7 +52,7 @@ export abstract class ContextCore { if (contextParams.network) { this.state.network = ContextCore.resolveNetwork( contextParams.network, - contextParams.ensRegistryAddress, + contextParams.ENSRegistry, ); // once the network is resolved set default values this.setNetworkDefaults(); @@ -90,7 +81,7 @@ export abstract class ContextCore { this.overriden.ipfsNodes = true; } // Set all the available addresses - for (const address of DeployedAddressesArray) { + for (const address of contractNames) { if (contextParams[address]) { this.state[address] = contextParams[address]!; this.overriden[address] = true; @@ -107,35 +98,43 @@ export abstract class ContextCore { } private setNetworkDefaults() { - const networkName = this.network.name as SupportedNetwork; - if ( - !GRAPHQL_NODES[networkName]?.length || - !IPFS_NODES[networkName]?.length || - !LIVE_CONTRACTS[SupportedVersion.LATEST][networkName] - ) { - throw new UnsupportedNetworkError(networkName); + // check network + const networkName = getNetworkNameByAlias(this.network.name); + if (!networkName) { + throw new UnsupportedNetworkError(this.network.name); } - + // set graphql nodes if (!this.overriden.graphqlNodes) { this.state.graphql = ContextCore.resolveGraphql( - GRAPHQL_NODES[networkName], + getDefaultGraphqlNodes(networkName), ); } - + // set ipfs nodes if (!this.overriden.ipfsNodes) { - this.state.ipfs = ContextCore.resolveIpfs(IPFS_NODES[networkName]); + this.state.ipfs = ContextCore.resolveIpfs( + getDefaultIpfsNodes(networkName), + ); } - - for (const address of DeployedAddressesArray) { - if (!this.overriden[address]) { - let defaultAddress = - LIVE_CONTRACTS[SupportedVersion.LATEST][networkName][address]; + // set contract addresses + for (const contractName of contractNames) { + if (!this.overriden[contractName]) { + let contractAddress: string | undefined; + // get deployment + let deployment = getNetworkDeploymentForVersion( + networkName, + SupportedVersions.V1_3_0, + ); + // get address from deployment + if (deployment) { + contractAddress = deployment[contractName]?.address; + } // custom check for ensRegistryAddress - if (address === "ensRegistryAddress" && !defaultAddress) { - defaultAddress = this.network.ensAddress; + // set the ensRegistryAddress to the network.ensAddress + if (contractName === ContractNames.ENS_REGISTRY && !contractAddress) { + contractAddress = this.network.ensAddress; } - if (defaultAddress) { - this.state[address] = defaultAddress; + if (contractAddress) { + this.state[contractName] = contractAddress; } } } @@ -159,19 +158,6 @@ export abstract class ContextCore { get network() { return this.state.network; } - /** - * Getter for the Signer - * - * @var signer - * - * @returns {Signer} - * - * @public - */ - get ensRegistryAddress(): string | undefined { - return this.state.ensRegistryAddress; - } - /** * Getter for the Signer * @@ -198,109 +184,6 @@ export abstract class ContextCore { return this.state.web3Providers || []; } - /** - * Getter for daoFactoryAddress property - * - * @var daoFactoryAddress - * - * @returns {string} - * - * @public - */ - get daoFactoryAddress(): string { - return this.state.daoFactoryAddress; - } - - /** - * Getter for pluginSetupProcessorAddress property - * @var pluginSetupProcessorAddress - * @returns {string} - * @public - */ - get pluginSetupProcessorAddress(): string { - return this.state.pluginSetupProcessorAddress; - } - /** - * Getter for multisigRepoAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get multisigRepoAddress(): string { - return this.state.multisigRepoAddress; - } - /** - * Getter for adminRepoAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get adminRepoAddress(): string { - return this.state.adminRepoAddress; - } - /** - * Getter for addresslistVotingRepoAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get addresslistVotingRepoAddress(): string { - return this.state.addresslistVotingRepoAddress; - } - /** - * Getter for tokenVotingRepoAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get tokenVotingRepoAddress(): string { - return this.state.tokenVotingRepoAddress; - } - /** - * Getter for multisigSetupAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get multisigSetupAddress(): string { - return this.state.multisigSetupAddress; - } - /** - * Getter for adminSetupAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get adminSetupAddress(): string { - return this.state.adminSetupAddress; - } - /** - * Getter for addresslistVotingSetupAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get addresslistVotingSetupAddress(): string { - return this.state.addresslistVotingSetupAddress; - } - /** - * Getter for tokenVotingSetupAddress property - * - * @readonly - * @type {string} - * @memberof ContextCore - */ - get tokenVotingSetupAddress(): string { - return this.state.tokenVotingSetupAddress; - } - /** * Getter for the gas fee reducer used in estimations * @@ -342,17 +225,16 @@ export abstract class ContextCore { return this.state.graphql; } + public getAddress(contractName: ContractNames): string { + return this.state[contractName]; + } + // INTERNAL HELPERS private static resolveNetwork( networkish: Networkish, ensRegistryAddress?: string, ): Network { const network = getNetwork(networkish); - const networkName = network.name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { - throw new UnsupportedNetworkError(networkName); - } - if (ensRegistryAddress) { if (!isAddress(ensRegistryAddress)) { throw new InvalidAddressError(); @@ -360,15 +242,6 @@ export abstract class ContextCore { network.ensAddress = ensRegistryAddress; } } - - if (!network.ensAddress) { - const ensAddress = - LIVE_CONTRACTS[SupportedVersion.LATEST][networkName].ensRegistryAddress; - if (!ensAddress) { - throw new UnsupportedNetworkError(networkName); - } - network.ensAddress = ensAddress; - } return network; } diff --git a/modules/client-common/src/errors.ts b/modules/client-common/src/errors.ts index 2ad8ad2f5..05a4ba60d 100644 --- a/modules/client-common/src/errors.ts +++ b/modules/client-common/src/errors.ts @@ -381,3 +381,17 @@ export class InvalidPermissionOperationType extends SdkError { super("Invalid permission operation", cause); } } + +export class ContractNotDeployedError extends SdkError { + constructor( + contractName: string, + version: string, + network: string, + cause?: any, + ) { + super( + `Contract "${contractName}" version "${version}" is not deployed on network "${network}"`, + cause, + ); + } +} diff --git a/modules/client-common/src/internal/interfaces.ts b/modules/client-common/src/internal/interfaces.ts index e145a2b47..376b5f1fd 100644 --- a/modules/client-common/src/internal/interfaces.ts +++ b/modules/client-common/src/internal/interfaces.ts @@ -5,15 +5,15 @@ import { Contract, ContractInterface } from "@ethersproject/contracts"; import { JsonRpcProvider } from "@ethersproject/providers"; import { Client as IpfsClient, PinResponse } from "@aragon/sdk-ipfs"; import { GraphQLClient } from "graphql-request"; -import { GasFeeEstimation, SupportedNetwork } from "../types"; -import { DeployedAddresses } from "./types"; +import { GasFeeEstimation } from "../types"; +import { ContractNames, SupportedNetworks } from "@aragon/osx-commons-configs"; export interface IClientWeb3Core { shiftProvider: () => void; getSigner: () => Signer; getConnectedSigner: () => Signer; getProvider: () => JsonRpcProvider; - getNetworkName: () => SupportedNetwork; + getNetworkName: () => SupportedNetworks; getMaxFeePerGas: () => Promise; isUp: () => Promise; ensureOnline: () => Promise; @@ -21,7 +21,7 @@ export interface IClientWeb3Core { address: string, abi: ContractInterface, ) => Contract & T; - getAddress: (addressName: DeployedAddresses) => string; + getAddress: (addressName: ContractNames) => string; getApproximateGasFee: (estimatedFee: bigint) => Promise; } export interface IClientIpfsCore { diff --git a/modules/client-common/src/internal/modules/web3.ts b/modules/client-common/src/internal/modules/web3.ts index faa23d035..ba8907cad 100644 --- a/modules/client-common/src/internal/modules/web3.ts +++ b/modules/client-common/src/internal/modules/web3.ts @@ -4,12 +4,7 @@ import { Contract, ContractInterface } from "@ethersproject/contracts"; import { Signer } from "@ethersproject/abstract-signer"; import { IClientWeb3Core } from "../interfaces"; import { Context } from "../../context"; -import { - GasFeeEstimation, - SupportedNetwork, - SupportedNetworksArray, -} from "../../types"; -import { DeployedAddresses } from "../types"; +import { GasFeeEstimation } from "../../types"; import { CannotEstimateGasError, InvalidAddressError, @@ -19,6 +14,11 @@ import { NoSignerError, UnsupportedNetworkError, } from "../../errors"; +import { + ContractNames, + getNetworkByAlias, + SupportedNetworks, +} from "@aragon/osx-commons-configs"; export class Web3Module implements IClientWeb3Core { private static readonly PRECISION_FACTOR_BASE = 1000; private providerIdx: number = -1; @@ -56,12 +56,12 @@ export class Web3Module implements IClientWeb3Core { } /** Returns the currently active network */ - public getNetworkName(): SupportedNetwork { - const networkName = this.context.network.name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { - throw new UnsupportedNetworkError(networkName); + public getNetworkName(): SupportedNetworks { + const network = getNetworkByAlias(this.context.network.name); + if (!network) { + throw new UnsupportedNetworkError(this.context.network.name); } - return networkName; + return network.name; } /** Returns a signer connected to the current network provider */ @@ -139,8 +139,8 @@ export class Web3Module implements IClientWeb3Core { } /** FRAMEWORK ADDRESSES */ - public getAddress(addressName: DeployedAddresses): string { - const address = this.context[addressName]; + public getAddress(addressName: ContractNames): string { + const address = this.context.getAddress(addressName); if (!address || !isAddress(address)) { throw new InvalidAddressError(); } diff --git a/modules/client-common/src/internal/types.ts b/modules/client-common/src/internal/types.ts index 99c36b10c..6a10bf957 100644 --- a/modules/client-common/src/internal/types.ts +++ b/modules/client-common/src/internal/types.ts @@ -2,37 +2,11 @@ import { Signer } from "@ethersproject/abstract-signer"; import { JsonRpcProvider, Network, Networkish } from "@ethersproject/providers"; import { Client as IpfsClient } from "@aragon/sdk-ipfs"; import { GraphQLClient } from "graphql-request"; - -// Create a readonly string array from the keys of NetworkDeployment -export const DeployedAddressesArray = [ - "daoFactoryAddress", - "pluginSetupProcessorAddress", - "multisigRepoAddress", - "adminRepoAddress", - "addresslistVotingRepoAddress", - "tokenVotingRepoAddress", - "multisigSetupAddress", - "adminSetupAddress", - "addresslistVotingSetupAddress", - "tokenVotingSetupAddress", - "ensRegistryAddress", -] as const; -// export the type from the readonly string array -export type DeployedAddresses = typeof DeployedAddressesArray[number]; -// Override helper type -type Override = Omit & U; -export type NetworkDeployment = Override< - { - [address in DeployedAddresses]: string; - }, - { ensRegistryAddress?: string } ->; -// Context input parameters +import { ContractNames } from "@aragon/osx-commons-configs"; export type Web3ContextParams = - /** If any contract is not provided it will use the default from LIVE_CONTRACTS in the provided network */ & { - [address in DeployedAddresses]?: string; + [index in ContractNames]?: string; } & { /** Defaults to mainnet */ @@ -53,12 +27,9 @@ export type GraphQLContextParams = { }; export type Web3ContextState = - & Override< - { - [address in DeployedAddresses]: string; - }, - { ensRegistryAddress?: string } - > + & { + [index in ContractNames]: string; + } & { network: Network; signer: Signer; diff --git a/modules/client-common/src/types.ts b/modules/client-common/src/types.ts index 244effe1f..96d9f504c 100644 --- a/modules/client-common/src/types.ts +++ b/modules/client-common/src/types.ts @@ -1,5 +1,5 @@ +import { ContractNames } from "@aragon/osx-commons-configs"; import { - DeployedAddresses, GraphQLContextParams, GraphQLContextState, IpfsContextParams, @@ -20,7 +20,7 @@ export type ContextState = export type OverriddenState = & { - [key in DeployedAddresses]: boolean; + [key in ContractNames]: boolean; } & { gasFeeEstimationFactor: boolean; @@ -28,23 +28,6 @@ export type OverriddenState = graphqlNodes: boolean; }; -export enum SupportedNetwork { - MAINNET = "homestead", - GOERLI = "goerli", - POLYGON = "matic", - MUMBAI = "maticmum", - BASE = "base", - BASE_GOERLI = "baseGoerli", - BASE_SEPOLIA = "baseSepolia", - LOCAL = "local", - SEPOLIA = "sepolia", - ARBITRUM = "arbitrum", - ARBITRUM_GOERLI = "arbitrumGoerli", - ARBITRUM_SEPOLIA = "arbitrumSepolia", -} - -export const SupportedNetworksArray = Object.values(SupportedNetwork); - /** * Contains the payload passed to the global DAO factory so that * plugins can be initialized @@ -276,11 +259,6 @@ export type ApplyUpdateParams = ApplyUpdateParamsBase & { export type DecodedApplyUpdateParams = ApplyUpdateParamsBase & { helpersHash: string; }; -export enum SupportedVersion { - V1_0_0 = "1.0.0", - V1_3_0 = "1.3.0", - LATEST = "1.3.0", -} export type IsMemberParams = { address: string; pluginAddress: string; diff --git a/modules/client-common/src/utils.ts b/modules/client-common/src/utils.ts index b82e9c915..2625eb0a9 100644 --- a/modules/client-common/src/utils.ts +++ b/modules/client-common/src/utils.ts @@ -1,4 +1,8 @@ -import { FunctionFragment, Interface } from "@ethersproject/abi"; +import { + defaultAbiCoder, + FunctionFragment, + Interface, +} from "@ethersproject/abi"; import { id } from "@ethersproject/hash"; import { getNetwork as ethersGetNetwork, @@ -15,8 +19,6 @@ import { PrepareUpdateParams, PrepareUpdateStep, PrepareUpdateStepValue, - SupportedNetwork, - SupportedVersion, } from "./types"; import { IClientGraphQLCore, @@ -28,8 +30,7 @@ import { PluginSetupProcessor, PluginSetupProcessor__factory, } from "@aragon/osx-ethers"; -import { ADDITIONAL_NETWORKS, LIVE_CONTRACTS } from "./constants"; -import { defaultAbiCoder } from "@ethersproject/abi"; +import { IPFS_ENDPOINTS } from "./constants"; import { isAddress } from "@ethersproject/address"; import { Network } from "@ethersproject/networks"; import { QueryIPlugin } from "./internal/graphql-queries"; @@ -43,6 +44,18 @@ import { UnsupportedNetworkError, } from "./errors"; import { Zero } from "@ethersproject/constants"; +import { + ContractNames, + getNetworkAlias, + getNetworkByChainId, + getNetworkByNameOrAlias, + getNetworkDeploymentForVersion, + NetworkConfig, + networks, + SupportedAliases, + SupportedNetworks, + SupportedVersions, +} from "@aragon/osx-commons-configs"; /** * Finds a log in a receipt given the event name @@ -134,7 +147,11 @@ export async function prepareGenericInstallationEstimation( if (!isAddress(params.pluginRepo)) { throw new InvalidAddressError(); } - const networkName = (await provider.getNetwork()).name as SupportedNetwork; + const ethers5NetworkName = (await provider.getNetwork()).name; + const networkName = getNetworkByNameOrAlias(ethers5NetworkName)?.name; + if (!networkName) { + throw new UnsupportedNetworkError(ethers5NetworkName); + } let version = params.version; // if version is not specified install latest version if (!version) { @@ -155,9 +172,15 @@ export async function prepareGenericInstallationEstimation( installationParams, ); // connect to psp contract + const deployment = getNetworkDeploymentForVersion( + networkName, + SupportedVersions.V1_3_0, + ); + if (!deployment) { + throw new UnsupportedNetworkError(networkName); + } const pspContract = PluginSetupProcessor__factory.connect( - LIVE_CONTRACTS[SupportedVersion.LATEST][networkName] - .pluginSetupProcessorAddress, + deployment[ContractNames.PLUGIN_SETUP_PROCESSOR].address, provider, ); @@ -404,30 +427,67 @@ export async function* prepareGenericUpdate( * @return {Network} */ export function getNetwork(networkish: Networkish): Network { - let network: Network | undefined; - for (const nw of ADDITIONAL_NETWORKS) { - switch (typeof networkish) { - case "string": - if (networkish === nw.name) { - network = nw; - } - break; - case "number": - if (networkish === nw.chainId) { - network = nw; - } - break; - case "object": - if (networkish.name === nw.name && networkish.chainId === nw.chainId) { - network = nw; - } - break; - default: - throw new UnsupportedNetworkError(networkish); - } - } - if (!network) { + let network: Network | null = null; + try { network = ethersGetNetwork(networkish); + } catch {} + try { + network = aragonGetNetwork(networkish); + } catch {} + if (!network) { + throw new UnsupportedNetworkError(networkish.toString()); + } + return network; +} + +/** + * When ethers 5 does not support the network return a Network object + * using our osx-commons-configs as a source of truth + * + * @private + * @param {Networkish} networkish + * @return {*} {Network} + */ +function aragonGetNetwork(networkish: Networkish): Network | null { + let aragonNetwork: NetworkConfig | null = null; + let network: Network | null = null; + switch (typeof networkish) { + case "string": + case "number": { + if (typeof networkish === "number") { + aragonNetwork = getNetworkByChainId(networkish); + } else { + aragonNetwork = getNetworkByNameOrAlias(networkish); + } + if (!aragonNetwork) { + throw new UnsupportedNetworkError(networkish.toString()); + } + const ethers5Alias = getNetworkAlias( + SupportedAliases.ETHERS_5, + aragonNetwork.name, + ); + const networkDeployment = getNetworkDeploymentForVersion( + aragonNetwork.name, + SupportedVersions.V1_3_0, + ); + if (!networkDeployment) { + throw new UnsupportedNetworkError(aragonNetwork.name); + } + const ensRegistryAddress = networkDeployment.ENSRegistry?.address; + network = { + name: ethers5Alias || aragonNetwork.name, + chainId: aragonNetwork.chainId, + ensAddress: ensRegistryAddress, + }; + break; + } + case "object": + if (networkish.name && networkish.chainId) { + network = networkish; + } + break; + default: + throw new UnsupportedNetworkError(networkish); } return network; } @@ -447,3 +507,16 @@ export function getInterfaceId(iface: Interface): string { } return interfaceId.toHexString(); } + +export function getDefaultIpfsNodes(network: SupportedNetworks) { + return networks[network].isTestnet + ? IPFS_ENDPOINTS.test + : IPFS_ENDPOINTS.prod; +} + +export function getDefaultGraphqlNodes(network: SupportedNetworks) { + return [{ + url: + `https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/osx-${network}/version/v1.4.0/api`, + }]; +} diff --git a/modules/client-common/test/unit/client.test.ts b/modules/client-common/test/unit/client.test.ts index c4d62a6e8..10e62052f 100644 --- a/modules/client-common/test/unit/client.test.ts +++ b/modules/client-common/test/unit/client.test.ts @@ -12,6 +12,7 @@ import { TEST_WALLET_ADDRESS, web3endpoints, } from "../constants"; +import { SupportedNetworks } from "@aragon/osx-commons-configs"; class TestContext extends ContextCore { constructor(params?: Partial) { super(params); @@ -41,7 +42,7 @@ describe("Test an extended client", () => { expect(provider).toBeDefined(); const networkName = client.web3.getNetworkName(); - expect(networkName).toBe("homestead"); + expect(networkName).toBe(SupportedNetworks.MAINNET); const signer = client.web3.getConnectedSigner(); expect(signer).toBeDefined(); @@ -67,7 +68,7 @@ describe("Test an extended client", () => { expect(client.graphql).toBeDefined(); const networkName = client.web3.getNetworkName(); - expect(networkName).toBe("homestead"); + expect(networkName).toBe(SupportedNetworks.MAINNET); expect(() => client.web3.getProvider()).toThrowError(NoProviderError); expect(() => client.web3.getConnectedSigner()).toThrowError(NoSignerError); @@ -97,7 +98,7 @@ describe("Test an extended client", () => { expect(client.graphql).toBeDefined(); const networkName = client.web3.getNetworkName(); - expect(networkName).toBe("baseGoerli"); + expect(networkName).toBe(SupportedNetworks.BASE_GOERLI); const signer = client.web3.getConnectedSigner(); expect(signer).toBeDefined(); expect(await signer.getAddress()).toBe(TEST_WALLET_ADDRESS); diff --git a/modules/client-common/test/unit/context.test.ts b/modules/client-common/test/unit/context.test.ts index 244e761d3..34083bd3c 100644 --- a/modules/client-common/test/unit/context.test.ts +++ b/modules/client-common/test/unit/context.test.ts @@ -2,15 +2,18 @@ import { Wallet } from "@ethersproject/wallet"; import { ContextCore, ContextParams, - GRAPHQL_NODES, - IPFS_NODES, - LIVE_CONTRACTS, - SupportedVersion, + getDefaultGraphqlNodes, + getDefaultIpfsNodes, } from "../../src"; import { ADDRESS_ONE, TEST_WALLET, web3endpoints } from "../constants"; import { Client as IpfsClient } from "@aragon/sdk-ipfs"; import { JsonRpcProvider } from "@ethersproject/providers"; import { GraphQLClient } from "graphql-request"; +import { + ContractNames, + contracts, + SupportedNetworks, +} from "@aragon/osx-commons-configs"; class TestContext extends ContextCore { constructor(params?: Partial) { @@ -25,7 +28,7 @@ describe("Context instances", () => { contextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x1234", + DAOFactory: "0x1234", web3Providers: web3endpoints.working, gasFeeEstimationFactor: 0.1, graphqlNodes: [], @@ -37,14 +40,18 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(TestContext); expect(context.network.name).toBe("homestead"); expect(context.network.chainId).toBe(1); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].homestead.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.mainnet["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe(context.network.ensAddress); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(context.network.ensAddress); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(0); - expect(context.ipfs.length).toBe(IPFS_NODES.homestead.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.homestead.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.MAINNET).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.MAINNET).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -61,8 +68,10 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(TestContext); expect(context.network.name).toBe("homestead"); expect(context.network.chainId).toBe(1); - expect(context.daoFactoryAddress).toBe(contextParams.daoFactoryAddress); - expect(context.ensRegistryAddress).toBe(context.network.ensAddress); + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contextParams.DAOFactory, + ); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(context.network.ensAddress); expect(context.gasFeeEstimationFactor).toBe( contextParams.gasFeeEstimationFactor, ); @@ -81,7 +90,7 @@ describe("Context instances", () => { contextParams = { network: "goerli", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x2345", + DAOFactory: "0x2345", web3Providers: web3endpoints.working, gasFeeEstimationFactor: 0.1, ipfsNodes: [{ url: "https://localhost", headers: {} }], @@ -93,7 +102,7 @@ describe("Context instances", () => { expect(context.network.name).toEqual("goerli"); expect(context.network.chainId).toEqual(5); expect(context.signer).toBeInstanceOf(Wallet); - expect(context.daoFactoryAddress).toEqual("0x2345"); + expect(context.getAddress(ContractNames.DAO_FACTORY)).toEqual("0x2345"); context.web3Providers?.map((provider) => expect(provider).toBeInstanceOf(JsonRpcProvider) ); @@ -113,14 +122,18 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(TestContext); expect(context.network.name).toBe("goerli"); expect(context.network.chainId).toBe(5); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].goerli.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.goerli["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe(context.network.ensAddress); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(context.network.ensAddress); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); - expect(context.ipfs.length).toBe(IPFS_NODES.goerli.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.goerli.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.GOERLI).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.GOERLI).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -136,16 +149,20 @@ describe("Context instances", () => { }); expect(context.network.name).toBe("matic"); expect(context.network.chainId).toBe(137); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe( + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); - expect(context.ipfs.length).toBe(IPFS_NODES.matic.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.matic.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -165,16 +182,20 @@ describe("Context instances", () => { }); expect(context.network.name).toBe("matic"); expect(context.network.chainId).toBe(137); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe( + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); - expect(context.ipfs.length).toBe(IPFS_NODES.matic.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.matic.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -188,7 +209,7 @@ describe("Context instances", () => { it("Should Change the network and update all the parameters", () => { const context = new TestContext(); context.set({ - ensRegistryAddress: ADDRESS_ONE, + ENSRegistry: ADDRESS_ONE, graphqlNodes: [ { url: "https://example.com/1", @@ -208,13 +229,15 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(TestContext); expect(context.network.name).toBe("matic"); expect(context.network.chainId).toBe(137); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe(ADDRESS_ONE); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(ADDRESS_ONE); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(0); - expect(context.ipfs.length).toBe(IPFS_NODES.matic.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); expect(context.graphql.length).toBe(3); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); @@ -241,7 +264,7 @@ describe("Context instances", () => { }).toThrow(); }); it("Should create a context with the correct DAOFactory address from the core-contracts-package", () => { - contextParams.daoFactoryAddress = ""; + contextParams.DAOFactory = ""; contextParams.network = "matic"; contextParams.web3Providers = "https://polygon-rpc.com/"; const context = new TestContext(contextParams); @@ -253,15 +276,15 @@ describe("Context instances", () => { expect(nw.chainId).toEqual(137); expect(nw.name).toEqual("matic"); expect(nw.ensAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); }) ); - expect(context.daoFactoryAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toEqual( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toEqual( + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); }); it("Should create a context with baseGoerli as network and have the correct values", () => { @@ -273,11 +296,11 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(TestContext); expect(context.network.name).toBe("baseGoerli"); expect(context.network.chainId).toBe(84531); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].baseGoerli.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.baseGoerli["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].baseGoerli.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe( + contracts.baseGoerli["v1.3.0"]?.ENSRegistry?.address, ); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); @@ -288,8 +311,8 @@ describe("Context instances", () => { expect(nw.chainId).toEqual(84531); expect(nw.name).toEqual("baseGoerli"); expect(nw.ensAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].baseGoerli.ensRegistryAddress, - ); + contracts.baseGoerli["v1.3.0"]?.ENSRegistry?.address, + ); } }); }); diff --git a/modules/client-common/test/unit/encoding.test.ts b/modules/client-common/test/unit/encoding.test.ts index 096a5062e..709edc0cc 100644 --- a/modules/client-common/test/unit/encoding.test.ts +++ b/modules/client-common/test/unit/encoding.test.ts @@ -391,7 +391,7 @@ describe("Test encoding helper functions", () => { { in: "invalid_proposal", out: "", - error: InvalidProposalIdError + error: InvalidProposalIdError, }, { in: @@ -400,7 +400,7 @@ describe("Test encoding helper functions", () => { error: InvalidProposalIdError, }, ]; - + for (const entry of entries) { if (entry.error) { expect(() => getExtendedProposalId(entry.in)).toThrow(entry.error); @@ -438,7 +438,7 @@ describe("Test encoding helper functions", () => { error: "Invalid proposalId", }, ]; - + for (const entry of entries) { if (entry.error) { expect(() => getCompactProposalId(entry.in)).toThrow(entry.error); diff --git a/modules/client-common/test/unit/validation.test.ts b/modules/client-common/test/unit/validation.test.ts index b3c622dfd..154ec6fe4 100644 --- a/modules/client-common/test/unit/validation.test.ts +++ b/modules/client-common/test/unit/validation.test.ts @@ -96,7 +96,6 @@ describe("Test Validations", () => { { in: TEST_IPFS_URI_V1, out: true }, ]; for (const input of inputs) { - expect(isIpfsUri(input.in)).toBe(input.out); } }); diff --git a/modules/client/CHANGELOG.md b/modules/client/CHANGELOG.md index a55dd6ef1..5e72df9e8 100644 --- a/modules/client/CHANGELOG.md +++ b/modules/client/CHANGELOG.md @@ -18,6 +18,14 @@ TEMPLATE: --> ## [UPCOMING] +## [1.23.0] + +### Changed + +- Support for new version of `@aragon/osx-client-common` +- Removed `LIVE_CONTRACTS` and used `contracts` from `@aragon/osx-commons-configs` instead + +## [1.22.1] ### Fixed - Typo in `LIVE_CONTRACTS` for mainnet diff --git a/modules/client/examples/01-client/01-create-dao.ts b/modules/client/examples/01-client/01-create-dao.ts index 21cd87ff7..81eb9ba9c 100644 --- a/modules/client/examples/01-client/01-create-dao.ts +++ b/modules/client/examples/01-client/01-create-dao.ts @@ -36,6 +36,7 @@ const metadata: DaoMetadata = { // Through pinning the metadata in IPFS, we can get the IPFS URI. You can read more about it here: https://docs.ipfs.tech/how-to/pin-files/ const metadataUri = await client.methods.pinMetadata(metadata); + // You need at least one plugin in order to create a DAO. In this example, we'll use the TokenVoting plugin, but feel free to install whichever one best suites your needs. You can find resources on how to do this in the plugin sections. // These would be the plugin params if you need to mint a new token for the DAO to enable TokenVoting. const tokenVotingPluginInstallParams: TokenVotingPluginInstall = { diff --git a/modules/client/examples/02-multisig-client/02-create-proposal.ts b/modules/client/examples/02-multisig-client/02-create-proposal.ts index e87c87652..eb5f7d16b 100644 --- a/modules/client/examples/02-multisig-client/02-create-proposal.ts +++ b/modules/client/examples/02-multisig-client/02-create-proposal.ts @@ -47,6 +47,9 @@ const metadataUri: string = await multisigClient.methods.pinMetadata( const proposalParams: CreateMultisigProposalParams = { pluginAddress: "0x1234567890123456789012345678901234567890", metadataUri, + // Boolean array indicating the actions that can and cannot fail + // when the proposal is executed. + failSafeActions: [], actions: [], // optional - if left as an empty array, no action will be set for the proposal. the action needs to be encoded and will be executed once a proposal passes. }; diff --git a/modules/client/package.json b/modules/client/package.json index 0ec7e649c..9fe0badd4 100644 --- a/modules/client/package.json +++ b/modules/client/package.json @@ -1,7 +1,7 @@ { "name": "@aragon/sdk-client", "author": "Aragon Association", - "version": "1.22.1", + "version": "1.23.0", "license": "MIT", "main": "dist/index.js", "module": "dist/sdk-client.esm.js", @@ -67,8 +67,9 @@ "typescript": "^5.2.2" }, "dependencies": { + "@aragon/osx-commons-configs": "^0.2.0", "@aragon/osx-ethers": "1.3.0", - "@aragon/sdk-client-common": "^1.14.1", + "@aragon/sdk-client-common": "^1.15.0", "@aragon/sdk-ipfs": "^1.1.0", "@ethersproject/abstract-signer": "^5.5.0", "@ethersproject/bignumber": "^5.6.0", @@ -87,4 +88,4 @@ "testEnvironment": "./test-environment.ts", "testTimeout": 120000 } -} \ No newline at end of file +} diff --git a/modules/client/src/addresslistVoting/internal/client/encoding.ts b/modules/client/src/addresslistVoting/internal/client/encoding.ts index d0c24691c..dc8cbf960 100644 --- a/modules/client/src/addresslistVoting/internal/client/encoding.ts +++ b/modules/client/src/addresslistVoting/internal/client/encoding.ts @@ -16,14 +16,15 @@ import { getNetwork, hexToBytes, InvalidAddressError, - LIVE_CONTRACTS, PluginInstallItem, - SupportedNetwork, - SupportedNetworksArray, - SupportedVersion, UnsupportedNetworkError, } from "@aragon/sdk-client-common"; import { INSTALLATION_ABI } from "../constants"; +import { + contracts, + getNetworkNameByAlias, + SupportedVersions, +} from "@aragon/osx-commons-configs"; /** * Encoding module for the SDK AddressList Client @@ -43,8 +44,9 @@ export class AddresslistVotingClientEncoding extends ClientCore params: AddresslistVotingPluginInstall, network: Networkish, ): PluginInstallItem { - const networkName = getNetwork(network).name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { + const networkName = getNetwork(network).name; + const aragonNetwork = getNetworkNameByAlias(networkName); + if (!aragonNetwork) { throw new UnsupportedNetworkError(networkName); } const hexBytes = defaultAbiCoder.encode( @@ -54,10 +56,14 @@ export class AddresslistVotingClientEncoding extends ClientCore params.addresses, ], ); + const repoAddress = contracts[aragonNetwork][SupportedVersions.V1_3_0] + ?.AddresslistVotingRepoProxy.address; + if (!repoAddress) { + throw new Error("AddresslistVotingRepoProxy address not found"); + } return { - id: LIVE_CONTRACTS[SupportedVersion.LATEST][networkName] - .addresslistVotingRepoAddress, + id: repoAddress, data: hexToBytes(hexBytes), }; } diff --git a/modules/client/src/addresslistVoting/internal/client/estimation.ts b/modules/client/src/addresslistVoting/internal/client/estimation.ts index 371bf3fcc..8dbf0fe2d 100644 --- a/modules/client/src/addresslistVoting/internal/client/estimation.ts +++ b/modules/client/src/addresslistVoting/internal/client/estimation.ts @@ -9,11 +9,12 @@ import { ClientCore, decodeProposalId, GasFeeEstimation, + prepareGenericUpdateEstimation, SizeMismatchError, + boolArrayToBitmap, } from "@aragon/sdk-client-common"; import { AddresslistVotingPluginPrepareUpdateParams } from "../../types"; -import { prepareGenericUpdateEstimation } from "@aragon/sdk-client-common"; -import { boolArrayToBitmap } from "@aragon/sdk-client-common"; +import { ContractNames } from "@aragon/osx-commons-configs"; /** * Estimation module the SDK Address List Client @@ -128,9 +129,11 @@ export class AddresslistVotingClientEstimation extends ClientCore return await prepareGenericUpdateEstimation(this.web3, this.graphql, { ...params, pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, + ), + pluginRepo: this.web3.getAddress( + ContractNames.ADDRESSLIST_VOTING_REPO_PROXY, ), - pluginRepo: this.web3.getAddress("addresslistVotingRepoAddress"), }); } } diff --git a/modules/client/src/addresslistVoting/internal/client/methods.ts b/modules/client/src/addresslistVoting/internal/client/methods.ts index 45264a252..c6611d230 100644 --- a/modules/client/src/addresslistVoting/internal/client/methods.ts +++ b/modules/client/src/addresslistVoting/internal/client/methods.ts @@ -51,6 +51,7 @@ import { EMPTY_PROPOSAL_METADATA_LINK, encodeProposalId, findLog, + getExtendedProposalId, InvalidAddressError, InvalidAddressOrEnsError, InvalidCidError, @@ -71,14 +72,12 @@ import { resolveIpfsCid, SizeMismatchError, SortDirection, - SupportedNetwork, - SupportedNetworksArray, UNAVAILABLE_PROPOSAL_METADATA, UNSUPPORTED_PROPOSAL_METADATA_LINK, UnsupportedNetworkError, } from "@aragon/sdk-client-common"; import { INSTALLATION_ABI, UPDATE_ABI } from "../constants"; -import { getExtendedProposalId } from "@aragon/sdk-client-common"; +import { ContractNames, getNetworkByAlias } from "@aragon/osx-commons-configs"; /** * Methods module the SDK Address List Client @@ -253,13 +252,15 @@ export class AddresslistVotingClientMethods extends ClientCore params: AddresslistVotingPluginPrepareInstallationParams, ): AsyncGenerator { const network = await this.web3.getProvider().getNetwork(); - const networkName = network.name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { - throw new UnsupportedNetworkError(networkName); + const aragonNetwork = getNetworkByAlias(network.name); + if (!aragonNetwork) { + throw new UnsupportedNetworkError(network.name); } yield* prepareGenericInstallation(this.web3, { daoAddressOrEns: params.daoAddressOrEns, - pluginRepo: this.web3.getAddress("addresslistVotingRepoAddress"), + pluginRepo: this.web3.getAddress( + ContractNames.ADDRESSLIST_VOTING_REPO_PROXY, + ), version: params.versionTag, installationAbi: INSTALLATION_ABI, installationParams: [ @@ -267,7 +268,7 @@ export class AddresslistVotingClientMethods extends ClientCore params.settings.addresses, ], pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } @@ -283,11 +284,13 @@ export class AddresslistVotingClientMethods extends ClientCore ): AsyncGenerator { yield* prepareGenericUpdate(this.web3, this.graphql, { ...params, - pluginRepo: this.web3.getAddress("addresslistVotingRepoAddress"), + pluginRepo: this.web3.getAddress( + ContractNames.ADDRESSLIST_VOTING_REPO_PROXY, + ), updateAbi: UPDATE_ABI[params.newVersion.build] || params.updateAbi || [], pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } diff --git a/modules/client/src/addresslistVoting/internal/utils.ts b/modules/client/src/addresslistVoting/internal/utils.ts index 251fc39a0..b47218659 100644 --- a/modules/client/src/addresslistVoting/internal/utils.ts +++ b/modules/client/src/addresslistVoting/internal/utils.ts @@ -177,16 +177,16 @@ export function computeProposalStatus( return ProposalStatus.PENDING; } // The proposal is not executed and the start date is in the past. - // Accordingly, we check if the proposal reached enough approval + // Accordingly, we check if the proposal reached enough approval // (i.e., that the supportThreshold and minParticipation criteria are both met). - // If the approvalReached = true and the vote has ended (end date is in the past) it has succeeded. + // If approvalReached is true and the vote has ended (end date is in the past), it has succeeded. // This applies to normal mode and vote replacement mode. if (proposal.approvalReached && endDate <= now) { return ProposalStatus.SUCCEEDED; } - // In early exeuction mode, we calculate if subsequent voting can change the result of the vote. + // In early exeuction mode, we calculate if subsequent voting can change the result of the vote. // If not, the proposal is early executable and is therefore succeeded as well. - if(proposal.earlyExecutable){ + if (proposal.earlyExecutable) { return ProposalStatus.SUCCEEDED; } // The proposal is not executed and the start date is in the past @@ -197,7 +197,7 @@ export function computeProposalStatus( return ProposalStatus.ACTIVE; } // If none of the other conditions are met the status becomes DEFEATED - return ProposalStatus.DEFEATED + return ProposalStatus.DEFEATED; } export function computeProposalStatusFilter(status: ProposalStatus) { diff --git a/modules/client/src/internal/client/encoding.ts b/modules/client/src/internal/client/encoding.ts index 9644d8251..44b0c9ec9 100644 --- a/modules/client/src/internal/client/encoding.ts +++ b/modules/client/src/internal/client/encoding.ts @@ -59,6 +59,7 @@ import { WithdrawEthSchema, } from "../schemas"; import { string } from "yup"; +import { ContractNames } from "@aragon/osx-commons-configs"; /** * Encoding module the SDK Generic Client @@ -83,7 +84,9 @@ export class ClientEncoding extends ClientCore implements IClientEncoding { daoAddress, args, ]); - const pspAddress = this.web3.getAddress("pluginSetupProcessorAddress"); + const pspAddress = this.web3.getAddress( + ContractNames.PLUGIN_SETUP_PROCESSOR, + ); // Grant ROOT_PERMISION in the DAO to the PSP const grantAction = this.grantAction(daoAddress, { where: daoAddress, @@ -120,7 +123,9 @@ export class ClientEncoding extends ClientCore implements IClientEncoding { daoAddress, args, ]); - const pspAddress = this.web3.getAddress("pluginSetupProcessorAddress"); + const pspAddress = this.web3.getAddress( + ContractNames.PLUGIN_SETUP_PROCESSOR, + ); // Grant ROOT_PERMISION in the DAO to the PSP const grantAction = this.grantAction(daoAddress, { where: daoAddress, @@ -163,8 +168,10 @@ export class ClientEncoding extends ClientCore implements IClientEncoding { daoAddress, args, ]); - const pspAddress = this.web3.getAddress("pluginSetupProcessorAddress"); - + const pspAddress = this.web3.getAddress( + ContractNames.PLUGIN_SETUP_PROCESSOR, + ); + // Grant UPGRADE_PLUGIN_PERMISSION in the plugin to the PSP const grantUpgradeAction = this.grantAction(daoAddress, { where: params.pluginAddress, @@ -625,7 +632,7 @@ export class ClientEncoding extends ClientCore implements IClientEncoding { ); const { daoFactoryAddress } = params; const daoFactory = DAOFactory__factory.connect( - daoFactoryAddress || this.web3.getAddress("daoFactoryAddress"), + daoFactoryAddress ?? this.web3.getAddress(ContractNames.DAO_FACTORY), this.web3.getProvider(), ); const implementation = await daoFactory.daoBase(); diff --git a/modules/client/src/internal/client/estimation.ts b/modules/client/src/internal/client/estimation.ts index d966fbd16..9bdbcb184 100644 --- a/modules/client/src/internal/client/estimation.ts +++ b/modules/client/src/internal/client/estimation.ts @@ -42,6 +42,7 @@ import { DepositEthSchema, SetAllowanceSchema, } from "../schemas"; +import { ContractNames } from "@aragon/osx-commons-configs"; /** * Estimation module the SDK Generic Client @@ -65,7 +66,7 @@ export class ClientEstimation extends ClientCore implements IClientEstimation { const provider = this.web3.getProvider(); const daoInstance = DAOFactory__factory.connect( - this.web3.getAddress("daoFactoryAddress"), + this.web3.getAddress(ContractNames.DAO_FACTORY), provider, ); const pluginInstallationData: DAOFactory.PluginSettingsStruct[] = []; @@ -187,7 +188,7 @@ export class ClientEstimation extends ClientCore implements IClientEstimation { return await prepareGenericUpdateEstimation(this.web3, this.graphql, { ...params, pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } diff --git a/modules/client/src/internal/client/methods.ts b/modules/client/src/internal/client/methods.ts index 538de7042..e494fa45c 100644 --- a/modules/client/src/internal/client/methods.ts +++ b/modules/client/src/internal/client/methods.ts @@ -122,7 +122,6 @@ import { InvalidAddressOrEnsError, InvalidCidError, IpfsPinError, - LIVE_CONTRACTS, MissingExecPermissionError, MULTI_FETCH_TIMEOUT, MultiTargetPermission, @@ -144,7 +143,6 @@ import { promiseWithTimeout, resolveIpfsCid, SortDirection, - SupportedVersion, TokenType, UpdateAllowanceError, } from "@aragon/sdk-client-common"; @@ -161,6 +159,11 @@ import { PluginPreparationQuerySchema, PluginQuerySchema, } from "../schemas"; +import { + ContractNames, + contracts, + SupportedVersions, +} from "@aragon/osx-commons-configs"; /** * Methods module the SDK Generic Client @@ -173,7 +176,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { yield* prepareGenericInstallation(this.web3, { ...params, pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } @@ -191,7 +194,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { const signer = this.web3.getConnectedSigner(); const daoFactoryInstance = DAOFactory__factory.connect( - this.web3.getAddress("daoFactoryAddress"), + this.web3.getAddress(ContractNames.DAO_FACTORY), signer, ); @@ -615,7 +618,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { ); // connect to psp contract const pspContract = PluginSetupProcessor__factory.connect( - this.web3.getAddress("pluginSetupProcessorAddress"), + this.web3.getAddress(ContractNames.PLUGIN_SETUP_PROCESSOR), signer, ); const tx = await pspContract.prepareUninstallation( @@ -683,7 +686,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { { ...params, pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }, ); @@ -1203,7 +1206,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { return validateUpdatePluginProposalActions( daoActions, iproposal.dao.id, - this.web3.getAddress("pluginSetupProcessorAddress"), + this.web3.getAddress(ContractNames.PLUGIN_SETUP_PROCESSOR), this.graphql, this.ipfs, ); @@ -1219,7 +1222,7 @@ export class ClientMethods extends ClientCore implements IClientMethods { */ public async isDaoUpdateProposalValid( proposalId: string, - version?: SupportedVersion, + version?: SupportedVersions, ): Promise { // omit input validation because we are receiving the proposal id @@ -1255,12 +1258,11 @@ export class ClientMethods extends ClientCore implements IClientMethods { }; } // get implementation address, use latest version as default - let daoFactoryAddress = this.web3.getAddress("daoFactoryAddress"); + let daoFactoryAddress = this.web3.getAddress(ContractNames.DAO_FACTORY); if (version) { // if version is specified get the dao factory address from the live contracts - daoFactoryAddress = LIVE_CONTRACTS[version][ - this.web3.getNetworkName() - ].daoFactoryAddress; + daoFactoryAddress = + contracts[this.web3.getNetworkName()][version]!.DAOFactory.address; } return validateUpdateDaoProposalActions( diff --git a/modules/client/src/internal/graphql-queries/plugin.ts b/modules/client/src/internal/graphql-queries/plugin.ts index e18b9d680..62ef6fb9d 100644 --- a/modules/client/src/internal/graphql-queries/plugin.ts +++ b/modules/client/src/internal/graphql-queries/plugin.ts @@ -102,4 +102,4 @@ export const QueryPluginInstallations = gql` pluginInstallations(where: $where) { id } - }` + }`; diff --git a/modules/client/src/internal/interfaces.ts b/modules/client/src/internal/interfaces.ts index d47aa19cc..fb9943242 100644 --- a/modules/client/src/internal/interfaces.ts +++ b/modules/client/src/internal/interfaces.ts @@ -15,7 +15,6 @@ import { PrepareUninstallationStepValue, PrepareUpdateParams, PrepareUpdateStepValue, - SupportedVersion, } from "@aragon/sdk-client-common"; import { AssetBalance, @@ -52,6 +51,7 @@ import { UpgradeToAndCallParams, WithdrawParams, } from "../types"; +import { SupportedVersions } from "@aragon/osx-commons-configs"; /** Defines the shape of the general purpose Client class */ export interface IClientMethods { @@ -111,7 +111,7 @@ export interface IClientMethods { isDaoUpdateProposalValid: ( proposalId: string, - version?: SupportedVersion, + version?: SupportedVersions, ) => Promise; getDaoImplementation: ( diff --git a/modules/client/src/internal/utils.ts b/modules/client/src/internal/utils.ts index 4c21ceb41..6aae0f62f 100644 --- a/modules/client/src/internal/utils.ts +++ b/modules/client/src/internal/utils.ts @@ -932,7 +932,7 @@ export async function validateGrantUpgradePluginPermissionAction( .INVALID_GRANT_UPGRADE_PLUGIN_PERMISSION_TO_ADDRESS, ); } - + // The permission should be granted to the PSP if (decodedPermission.who !== pspAddress) { causes.push( @@ -1213,10 +1213,11 @@ export async function validateApplyUpdateFunction( type W = { pluginPreparations: SubgraphPluginUpdatePreparation[] }; const { pluginPreparations } = await graphql.request({ query: QueryPluginPreparations, - params: { where: { + params: { + where: { preparedSetupId: preparedSetupId.toLowerCase(), - pluginAddress: decodedParams.pluginAddress.toLowerCase() - } + pluginAddress: decodedParams.pluginAddress.toLowerCase(), + }, }, name: "pluginPreparations", }); @@ -1243,7 +1244,7 @@ export async function validateApplyUpdateFunction( const metadataUri = build.metadata; // fetch the metadata - const metadataCid = new MultiUri(metadataUri).ipfsCid + const metadataCid = new MultiUri(metadataUri).ipfsCid; const metadata = await ipfs.fetchString(metadataCid!); const metadataJson = JSON.parse(metadata); // Due to an human error the build metadata on the plugins @@ -1254,10 +1255,12 @@ export async function validateApplyUpdateFunction( // old metadata fields // Original PR: https://github.com/aragon/osx/pull/375 // Fix PR: https://github.com/aragon/osx/pull/481 - let updateAbi = [] - updateAbi = metadataJson?.pluginSetup?.prepareUpdate?.[plugin.appliedVersion?.build!]?.inputs + let updateAbi = []; + updateAbi = metadataJson?.pluginSetup?.prepareUpdate + ?.[plugin.appliedVersion?.build!]?.inputs; if (!updateAbi) { - updateAbi = metadataJson?.pluginSetup?.prepareInstallation?.prepareUpdate?.[plugin.appliedVersion?.build!]?.inputs + updateAbi = metadataJson?.pluginSetup?.prepareInstallation?.prepareUpdate + ?.[plugin.appliedVersion?.build!]?.inputs; } // get the update abi for the specified build if (updateAbi) { diff --git a/modules/client/src/multisig/internal/client/encoding.ts b/modules/client/src/multisig/internal/client/encoding.ts index 08ef6a48f..97464cf16 100644 --- a/modules/client/src/multisig/internal/client/encoding.ts +++ b/modules/client/src/multisig/internal/client/encoding.ts @@ -18,14 +18,15 @@ import { getNetwork, hexToBytes, InvalidAddressError, - LIVE_CONTRACTS, PluginInstallItem, - SupportedNetwork, - SupportedNetworksArray, - SupportedVersion, UnsupportedNetworkError, } from "@aragon/sdk-client-common"; import { INSTALLATION_ABI } from "../constants"; +import { + contracts, + getNetworkNameByAlias, + SupportedVersions, +} from "@aragon/osx-commons-configs"; /** * Encoding module for the SDK Multisig Client @@ -46,8 +47,9 @@ export class MultisigClientEncoding extends ClientCore params: MultisigPluginInstallParams, network: Networkish, ): PluginInstallItem { - const networkName = getNetwork(network).name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { + const networkName = getNetwork(network).name; + const aragonNetwork = getNetworkNameByAlias(networkName); + if (!aragonNetwork) { throw new UnsupportedNetworkError(networkName); } const hexBytes = defaultAbiCoder.encode( @@ -60,9 +62,16 @@ export class MultisigClientEncoding extends ClientCore ], ], ); + const repoAddress = + contracts[aragonNetwork][SupportedVersions.V1_3_0]?.MultisigRepoProxy + .address; + if (!repoAddress) { + throw new Error("AddresslistVotingRepoProxy address not found"); + } return { - id: LIVE_CONTRACTS[SupportedVersion.LATEST][networkName] - .multisigRepoAddress, + // this case will return "" when the version 1.3.0 of the contracts is not deployed + // in the specified network + id: repoAddress, data: hexToBytes(hexBytes), }; } diff --git a/modules/client/src/multisig/internal/client/estimation.ts b/modules/client/src/multisig/internal/client/estimation.ts index 102f5a988..5d4216d7e 100644 --- a/modules/client/src/multisig/internal/client/estimation.ts +++ b/modules/client/src/multisig/internal/client/estimation.ts @@ -14,6 +14,7 @@ import { prepareGenericUpdateEstimation, SizeMismatchError, } from "@aragon/sdk-client-common"; +import { ContractNames } from "@aragon/osx-commons-configs"; /** * Estimation module the SDK Address List Client */ @@ -124,9 +125,9 @@ export class MultisigClientEstimation extends ClientCore return await prepareGenericUpdateEstimation(this.web3, this.graphql, { ...params, pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), - pluginRepo: this.web3.getAddress("multisigRepoAddress"), + pluginRepo: this.web3.getAddress(ContractNames.MULTISIG_REPO_PROXY), }); } } diff --git a/modules/client/src/multisig/internal/client/methods.ts b/modules/client/src/multisig/internal/client/methods.ts index 385ec8e4e..3b7f3d122 100644 --- a/modules/client/src/multisig/internal/client/methods.ts +++ b/modules/client/src/multisig/internal/client/methods.ts @@ -69,13 +69,15 @@ import { resolveIpfsCid, SizeMismatchError, SortDirection, - SupportedNetwork, - SupportedNetworksArray, UNAVAILABLE_PROPOSAL_METADATA, UNSUPPORTED_PROPOSAL_METADATA_LINK, UnsupportedNetworkError, } from "@aragon/sdk-client-common"; import { INSTALLATION_ABI, UPDATE_ABI } from "../constants"; +import { + ContractNames, + getNetworkNameByAlias, +} from "@aragon/osx-commons-configs"; /** * Methods module the SDK Address List Client @@ -249,15 +251,16 @@ export class MultisigClientMethods extends ClientCore params: MultisigPluginPrepareInstallationParams, ): AsyncGenerator { const network = await this.web3.getProvider().getNetwork(); - const networkName = network.name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { + const networkName = network.name; + const aragonNetwork = getNetworkNameByAlias(networkName); + if (!aragonNetwork) { throw new UnsupportedNetworkError(networkName); } // TODO // Check params with yup yield* prepareGenericInstallation(this.web3, { daoAddressOrEns: params.daoAddressOrEns, - pluginRepo: this.web3.getAddress("multisigRepoAddress"), + pluginRepo: this.web3.getAddress(ContractNames.MULTISIG_REPO_PROXY), version: params.versionTag, installationAbi: INSTALLATION_ABI, installationParams: [ @@ -268,7 +271,7 @@ export class MultisigClientMethods extends ClientCore ], ], pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } @@ -284,11 +287,11 @@ export class MultisigClientMethods extends ClientCore ): AsyncGenerator { yield* prepareGenericUpdate(this.web3, this.graphql, { ...params, - pluginRepo: this.web3.getAddress("multisigRepoAddress"), + pluginRepo: this.web3.getAddress(ContractNames.MULTISIG_REPO_PROXY), updateAbi: UPDATE_ABI[params.newVersion.build] || params.updateAbi || [], pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } diff --git a/modules/client/src/tokenVoting/internal/client/encoding.ts b/modules/client/src/tokenVoting/internal/client/encoding.ts index efd61b2c6..c3945ad33 100644 --- a/modules/client/src/tokenVoting/internal/client/encoding.ts +++ b/modules/client/src/tokenVoting/internal/client/encoding.ts @@ -19,14 +19,15 @@ import { getNetwork, hexToBytes, InvalidAddressError, - LIVE_CONTRACTS, PluginInstallItem, - SupportedNetwork, - SupportedNetworksArray, - SupportedVersion, UnsupportedNetworkError, } from "@aragon/sdk-client-common"; import { INSTALLATION_ABI } from "../constants"; +import { + contracts, + getNetworkNameByAlias, + SupportedVersions, +} from "@aragon/osx-commons-configs"; /** * Encoding module the SDK TokenVoting Client @@ -46,8 +47,9 @@ export class TokenVotingClientEncoding extends ClientCore params: TokenVotingPluginInstall, network: Networkish, ): PluginInstallItem { - const networkName = getNetwork(network).name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { + const networkName = getNetwork(network).name; + const aragonNetwork = getNetworkNameByAlias(networkName); + if (!aragonNetwork) { throw new UnsupportedNetworkError(networkName); } const args = tokenVotingInitParamsToContract(params); @@ -55,9 +57,15 @@ export class TokenVotingClientEncoding extends ClientCore getNamedTypesFromMetadata(INSTALLATION_ABI), args, ); + + const repoAddress = + contracts[aragonNetwork][SupportedVersions.V1_3_0]?.TokenVotingRepoProxy + .address; + if (!repoAddress) { + throw new Error(); + } return { - id: LIVE_CONTRACTS[SupportedVersion.LATEST][networkName] - .tokenVotingRepoAddress, + id: repoAddress, data: hexToBytes(hexBytes), }; } diff --git a/modules/client/src/tokenVoting/internal/client/estimation.ts b/modules/client/src/tokenVoting/internal/client/estimation.ts index f655ee615..295f6044a 100644 --- a/modules/client/src/tokenVoting/internal/client/estimation.ts +++ b/modules/client/src/tokenVoting/internal/client/estimation.ts @@ -20,6 +20,7 @@ import { prepareGenericUpdateEstimation, SizeMismatchError, } from "@aragon/sdk-client-common"; +import { ContractNames } from "@aragon/osx-commons-configs"; /** * Estimation module the SDK TokenVoting Client */ @@ -170,9 +171,9 @@ export class TokenVotingClientEstimation extends ClientCore return await prepareGenericUpdateEstimation(this.web3, this.graphql, { ...params, pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), - pluginRepo: this.web3.getAddress("tokenVotingRepoAddress"), + pluginRepo: this.web3.getAddress(ContractNames.TOKEN_VOTING_REPO_PROXY), }); } } diff --git a/modules/client/src/tokenVoting/internal/client/methods.ts b/modules/client/src/tokenVoting/internal/client/methods.ts index 02a5c4ef5..b93a3dd9e 100644 --- a/modules/client/src/tokenVoting/internal/client/methods.ts +++ b/modules/client/src/tokenVoting/internal/client/methods.ts @@ -83,6 +83,8 @@ import { InvalidCidError, InvalidProposalIdError, IpfsPinError, + IsMemberParams, + IsMemberSchema, isProposalId, MULTI_FETCH_TIMEOUT, NoProviderError, @@ -97,8 +99,6 @@ import { resolveIpfsCid, SizeMismatchError, SortDirection, - SupportedNetwork, - SupportedNetworksArray, TokenType, UNAVAILABLE_PROPOSAL_METADATA, UNSUPPORTED_PROPOSAL_METADATA_LINK, @@ -113,8 +113,10 @@ import { import { abi as ERC165_ABI } from "@openzeppelin/contracts/build/contracts/ERC165.json"; import { Contract } from "@ethersproject/contracts"; import { AddressZero } from "@ethersproject/constants"; -import { IsMemberSchema } from "@aragon/sdk-client-common"; -import { IsMemberParams } from "@aragon/sdk-client-common"; +import { + ContractNames, + getNetworkNameByAlias, +} from "@aragon/osx-commons-configs"; /** * Methods module the SDK TokenVoting Client @@ -279,18 +281,19 @@ export class TokenVotingClientMethods extends ClientCore params: TokenVotingPluginPrepareInstallationParams, ): AsyncGenerator { const network = await this.web3.getProvider().getNetwork(); - const networkName = network.name as SupportedNetwork; - if (!SupportedNetworksArray.includes(networkName)) { + const networkName = network.name; + const aragonNetwork = getNetworkNameByAlias(networkName); + if (!aragonNetwork) { throw new UnsupportedNetworkError(networkName); } yield* prepareGenericInstallation(this.web3, { daoAddressOrEns: params.daoAddressOrEns, - pluginRepo: this.web3.getAddress("tokenVotingRepoAddress"), + pluginRepo: this.web3.getAddress(ContractNames.TOKEN_VOTING_REPO_PROXY), version: params.versionTag, installationAbi: INSTALLATION_ABI, installationParams: tokenVotingInitParamsToContract(params.settings), pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } @@ -306,11 +309,11 @@ export class TokenVotingClientMethods extends ClientCore ): AsyncGenerator { yield* prepareGenericUpdate(this.web3, this.graphql, { ...params, - pluginRepo: this.web3.getAddress("tokenVotingRepoAddress"), + pluginRepo: this.web3.getAddress(ContractNames.TOKEN_VOTING_REPO_PROXY), updateAbi: UPDATE_ABI[params.newVersion.build] || params.updateAbi || [], pluginSetupProcessorAddress: this.web3.getAddress( - "pluginSetupProcessorAddress", + ContractNames.PLUGIN_SETUP_PROCESSOR, ), }); } diff --git a/modules/client/src/tokenVoting/internal/utils.ts b/modules/client/src/tokenVoting/internal/utils.ts index 03459d427..dfa42552a 100644 --- a/modules/client/src/tokenVoting/internal/utils.ts +++ b/modules/client/src/tokenVoting/internal/utils.ts @@ -311,16 +311,16 @@ export function computeProposalStatus( return ProposalStatus.PENDING; } // The proposal is not executed and the start date is in the past. - // Accordingly, we check if the proposal reached enough approval + // Accordingly, we check if the proposal reached enough approval // (i.e., that the supportThreshold and minParticipation criteria are both met). - // If the approvalReached = true and the vote has ended (end date is in the past) it has succeeded. + // If approvalReached is true and the vote has ended (end date is in the past), it has succeeded. // This applies to normal mode and vote replacement mode. if (proposal.approvalReached && endDate <= now) { return ProposalStatus.SUCCEEDED; } - // In early exeuction mode, we calculate if subsequent voting can change the result of the vote. + // In early exeuction mode, we calculate if subsequent voting can change the result of the vote. // If not, the proposal is early executable and is therefore succeeded as well. - if(proposal.earlyExecutable){ + if (proposal.earlyExecutable) { return ProposalStatus.SUCCEEDED; } // The proposal is not executed and the start date is in the past @@ -331,7 +331,7 @@ export function computeProposalStatus( return ProposalStatus.ACTIVE; } // If none of the other conditions are met the status becomes DEFEATED - return ProposalStatus.DEFEATED + return ProposalStatus.DEFEATED; } export function computeProposalStatusFilter(status: ProposalStatus) { diff --git a/modules/client/test/integration/addresslistVoting-client/decoding.test.ts b/modules/client/test/integration/addresslistVoting-client/decoding.test.ts index ef1370a14..b7f7c78b5 100644 --- a/modules/client/test/integration/addresslistVoting-client/decoding.test.ts +++ b/modules/client/test/integration/addresslistVoting-client/decoding.test.ts @@ -8,7 +8,7 @@ import { ADDRESS_ONE, contextParamsLocalChain } from "../constants"; describe("Client Address List", () => { beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; }); describe("Action decoders", () => { it("Should decode the plugin settings from an update plugin settings action", async () => { diff --git a/modules/client/test/integration/addresslistVoting-client/encoding.test.ts b/modules/client/test/integration/addresslistVoting-client/encoding.test.ts index 6a5727920..804e5cc27 100644 --- a/modules/client/test/integration/addresslistVoting-client/encoding.test.ts +++ b/modules/client/test/integration/addresslistVoting-client/encoding.test.ts @@ -1,3 +1,8 @@ +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; import { AddresslistVotingClient, AddresslistVotingPluginInstall, @@ -12,7 +17,12 @@ import { describe("Client Address List", () => { beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; + contracts.local = { + [SupportedVersions.V1_3_0]: { + AddresslistVotingRepoProxy: { address: ADDRESS_ONE }, + } as NetworkDeployment, + }; }); describe("Action generators", () => { it("Should create an AddressList client and generate a install entry", async () => { diff --git a/modules/client/test/integration/addresslistVoting-client/estimation.test.ts b/modules/client/test/integration/addresslistVoting-client/estimation.test.ts index 65cda3500..4161e127a 100644 --- a/modules/client/test/integration/addresslistVoting-client/estimation.test.ts +++ b/modules/client/test/integration/addresslistVoting-client/estimation.test.ts @@ -9,6 +9,7 @@ import { VoteValues, } from "../../../src"; import { + ADDRESS_ONE, contextParamsLocalChain, SUBGRAPH_PLUGIN_INSTALLATION, } from "../constants"; @@ -16,6 +17,11 @@ import * as deployContracts from "../../helpers/deployContracts"; import { Context } from "@aragon/sdk-client-common"; import { buildAddressListVotingDAO } from "../../helpers/build-daos"; import { createAddresslistVotingPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Client Address List", () => { describe("Estimation module", () => { @@ -23,13 +29,17 @@ describe("Client Address List", () => { beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.addresslistVotingRepoAddress = + contextParamsLocalChain.AddresslistVotingRepoProxy = deployment.addresslistVotingRepo.address; - contextParamsLocalChain.ensRegistryAddress = - deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; + contracts.local = { + [SupportedVersions.V1_3_0]: { + AddresslistVotingRepoProxy: { address: ADDRESS_ONE }, + } as NetworkDeployment, + }; }); it("Should estimate the gas fees for creating a new proposal", async () => { diff --git a/modules/client/test/integration/addresslistVoting-client/methods.test.ts b/modules/client/test/integration/addresslistVoting-client/methods.test.ts index 3f3db587b..322e14dad 100644 --- a/modules/client/test/integration/addresslistVoting-client/methods.test.ts +++ b/modules/client/test/integration/addresslistVoting-client/methods.test.ts @@ -35,10 +35,7 @@ import { TEST_TX_HASH, TEST_WALLET_ADDRESS, } from "../constants"; -import { - mineBlock, - mineBlockWithTimeOffset, -} from "../../helpers/block-times"; +import { mineBlock, mineBlockWithTimeOffset } from "../../helpers/block-times"; import { buildAddressListVotingDAO } from "../../helpers/build-daos"; import { JsonRpcProvider } from "@ethersproject/providers"; import { @@ -65,6 +62,11 @@ import { } from "@aragon/sdk-client-common"; import { PluginRepo__factory } from "@aragon/osx-ethers"; import { createAddresslistVotingPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Client Address List", () => { let deployment: deployContracts.Deployment; @@ -73,26 +75,32 @@ describe("Client Address List", () => { beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.multisigRepoAddress = - deployment.multisigRepo.address; - contextParamsLocalChain.adminRepoAddress = ""; - contextParamsLocalChain.addresslistVotingRepoAddress = + contextParamsLocalChain.MultisigRepoProxy = deployment.multisigRepo.address; + contextParamsLocalChain.AdminRepoProxy = ""; + contextParamsLocalChain.AddresslistVotingRepoProxy = deployment.addresslistVotingRepo.address; - contextParamsLocalChain.tokenVotingRepoAddress = + contextParamsLocalChain.TokenVotingRepoProxy = deployment.tokenVotingRepo.address; - contextParamsLocalChain.multisigSetupAddress = + contextParamsLocalChain.MultisigSetup = deployment.multisigPluginSetup.address; - contextParamsLocalChain.adminSetupAddress = ""; - contextParamsLocalChain.addresslistVotingSetupAddress = + contextParamsLocalChain.AdminSetup = ""; + contextParamsLocalChain.AddresslistVotingSetup = deployment.addresslistVotingPluginSetup.address; - contextParamsLocalChain.tokenVotingSetupAddress = + contextParamsLocalChain.TokenVotingSetup = deployment.tokenVotingPluginSetup.address; - contextParamsLocalChain.ensRegistryAddress = deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; repoAddr = deployment.addresslistVotingRepo.address; + contracts.local = { + [SupportedVersions.V1_3_0]: { + AddresslistVotingRepoProxy: { + address: deployment.addresslistVotingRepo.address, + }, + } as NetworkDeployment, + }; if (Array.isArray(contextParamsLocalChain.web3Providers)) { provider = new JsonRpcProvider( contextParamsLocalChain.web3Providers[0] as string, diff --git a/modules/client/test/integration/client/decoding.test.ts b/modules/client/test/integration/client/decoding.test.ts index be924a5db..ef8bb590a 100644 --- a/modules/client/test/integration/client/decoding.test.ts +++ b/modules/client/test/integration/client/decoding.test.ts @@ -33,22 +33,31 @@ import { bytesToHex, Context, hexToBytes, - LIVE_CONTRACTS, PermissionIds, PermissionOperationType, Permissions, - SupportedVersion, TokenType, } from "@aragon/sdk-client-common"; +import { + contracts, + NetworkDeployment, + SupportedNetworks, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Client", () => { let deployment: deployContracts.Deployment; beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; - contextParamsLocalChain.pluginSetupProcessorAddress = ADDRESS_TWO; - LIVE_CONTRACTS[SupportedVersion.LATEST].local.daoFactoryAddress = - deployment.daoFactory.address; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; + contextParamsLocalChain.PluginSetupProcessor = ADDRESS_TWO; + contracts[SupportedNetworks.LOCAL] = { + [SupportedVersions.V1_3_0]: { + DAOFactory: { + address: deployment.daoFactory.address, + }, + } as NetworkDeployment, + }; }); describe("Action decoders", () => { it("Should decode an encoded grant action", () => { @@ -823,7 +832,7 @@ describe("Client", () => { it("Should decode an dao update action", async () => { const context = new Context(contextParamsLocalChain); const client = new Client(context); - const daoFactoryAddress = LIVE_CONTRACTS["1.3.0"].local.daoFactoryAddress; + const daoFactoryAddress = contracts.local["v1.3.0"]!.DAOFactory.address; const params: DaoUpdateParams = { previousVersion: [1, 0, 0], daoFactoryAddress, diff --git a/modules/client/test/integration/client/encoding.test.ts b/modules/client/test/integration/client/encoding.test.ts index 94dfebb44..ba15c78ab 100644 --- a/modules/client/test/integration/client/encoding.test.ts +++ b/modules/client/test/integration/client/encoding.test.ts @@ -43,9 +43,9 @@ describe("Client", () => { let deployment: deployContracts.Deployment; beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; - contextParamsLocalChain.pluginSetupProcessorAddress = ADDRESS_TWO; - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; + contextParamsLocalChain.PluginSetupProcessor = ADDRESS_TWO; + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; }); describe("Action generators", () => { it("Should create a client and generate a native withdraw action", async () => { @@ -601,8 +601,7 @@ describe("Client", () => { let hexString, argsDecoded, action; expect(actions.length).toBe(3); for (const [index, actionName] of expectedActions.entries()) { - - action = actions[index]; + action = actions[index]; expect(typeof action).toBe("object"); expect(action.data).toBeInstanceOf(Uint8Array); hexString = bytesToHex(action.data); @@ -618,7 +617,7 @@ describe("Client", () => { daoAddress, ); expect(argsDecoded[1]).toBe( - contextParamsLocalChain.pluginSetupProcessorAddress, + contextParamsLocalChain.PluginSetupProcessor, ); expect(argsDecoded[2]).toBe( keccak256(toUtf8Bytes(Permissions.UPGRADE_PLUGIN_PERMISSION)), @@ -700,7 +699,13 @@ describe("Client", () => { ); const pspInterface = PluginSetupProcessor__factory.createInterface(); const daoInterface = DAO__factory.createInterface(); - const expectedActions = ["grant", "grant", "applyUpdate", "revoke", "revoke"]; + const expectedActions = [ + "grant", + "grant", + "applyUpdate", + "revoke", + "revoke", + ]; let hexString, argsDecoded, action; expect(actions.length).toBe(5); for (const [index, actionName] of expectedActions.entries()) { @@ -720,7 +725,7 @@ describe("Client", () => { daoAddress, ); expect(argsDecoded[1]).toBe( - contextParamsLocalChain.pluginSetupProcessorAddress, + contextParamsLocalChain.PluginSetupProcessor, ); expect(argsDecoded[2]).toBe( keccak256(toUtf8Bytes(Permissions.ROOT_PERMISSION)), @@ -737,7 +742,7 @@ describe("Client", () => { pluginAddress, ); expect(argsDecoded[1]).toBe( - contextParamsLocalChain.pluginSetupProcessorAddress, + contextParamsLocalChain.PluginSetupProcessor, ); expect(argsDecoded[2]).toBe( keccak256(toUtf8Bytes(Permissions.UPGRADE_PLUGIN_PERMISSION)), diff --git a/modules/client/test/integration/client/estimation.test.ts b/modules/client/test/integration/client/estimation.test.ts index f2b171d5c..f02f259ec 100644 --- a/modules/client/test/integration/client/estimation.test.ts +++ b/modules/client/test/integration/client/estimation.test.ts @@ -20,19 +20,31 @@ import { deployErc1155 } from "../../helpers/deploy-erc1155"; import { deployErc721 } from "../../helpers/deploy-erc721"; import { buildMultisigDAO } from "../../helpers/build-daos"; import { createMultisigPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; let daoAddress = "0x1234567890123456789012345678901234567890"; describe("Client", () => { let deployment: deployContracts.Deployment; describe("Estimation module", () => { - beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.ensRegistryAddress = - deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; + contracts.local = { + [SupportedVersions.V1_3_0]: { + DAOFactory: { address: deployment.daoFactory.address }, + MultisigRepoProxy: { address: deployment.multisigRepo.address }, + AddresslistVotingRepoProxy: { + address: deployment.addresslistVotingRepo.address, + }, + } as NetworkDeployment, + }; }); it("Should estimate gas fees for creating a DAO", async () => { diff --git a/modules/client/test/integration/client/methods.test.ts b/modules/client/test/integration/client/methods.test.ts index 7ce0119c8..00feb7d34 100644 --- a/modules/client/test/integration/client/methods.test.ts +++ b/modules/client/test/integration/client/methods.test.ts @@ -75,13 +75,11 @@ import { bytesToHex, Context, DaoAction, - LIVE_CONTRACTS, Permissions, PrepareInstallationStep, PrepareUninstallationSteps, PrepareUpdateStep, SortDirection, - SupportedVersion, TokenType, } from "@aragon/sdk-client-common"; import { INSTALLATION_ABI } from "../../../src/multisig/internal/constants"; @@ -97,6 +95,12 @@ import { toPluginPermissionOperationType, toSubgraphActions, } from "../../../src/internal/utils"; +import { + ContractNames, + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Client", () => { let daoAddress: string; @@ -106,33 +110,41 @@ describe("Client", () => { let deploymentV1: deployV1Contracts.Deployment; describe("Methods Module tests", () => { - beforeAll(async () => { deployment = await deployContracts.deploy(); deploymentV1 = await deployV1Contracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.multisigRepoAddress = + contextParamsLocalChain.MultisigRepoProxy = deployment.multisigRepo.address; - contextParamsLocalChain.adminRepoAddress = ""; - contextParamsLocalChain.addresslistVotingRepoAddress = + contextParamsLocalChain.AddresslistVotingRepoProxy = deployment.addresslistVotingRepo.address; - contextParamsLocalChain.tokenVotingRepoAddress = + contextParamsLocalChain.TokenVotingRepoProxy = deployment.tokenVotingRepo.address; - contextParamsLocalChain.multisigSetupAddress = + contextParamsLocalChain.MultisigSetup = deployment.multisigPluginSetup.address; - contextParamsLocalChain.adminSetupAddress = ""; - contextParamsLocalChain.addresslistVotingSetupAddress = + contextParamsLocalChain.AddresslistVotingSetup = deployment.addresslistVotingPluginSetup.address; - contextParamsLocalChain.tokenVotingSetupAddress = + contextParamsLocalChain.TokenVotingSetup = deployment.tokenVotingPluginSetup.address; - contextParamsLocalChain.ensRegistryAddress = - deployment.ensRegistry.address; - LIVE_CONTRACTS[SupportedVersion.V1_0_0].local.daoFactoryAddress = - deploymentV1.daoFactory.address; - LIVE_CONTRACTS[SupportedVersion.LATEST].local.daoFactoryAddress = - deployment.daoFactory.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; + contracts.local = { + [SupportedVersions.V1_0_0]: { + DAOFactory: { address: deploymentV1.daoFactory.address }, + MultisigRepoProxy: { address: deploymentV1.multisigRepo.address }, + AddresslistVotingRepoProxy: { + address: deploymentV1.addresslistVotingRepo.address, + }, + } as NetworkDeployment, + [SupportedVersions.V1_3_0]: { + DAOFactory: { address: deployment.daoFactory.address }, + MultisigRepoProxy: { address: deployment.multisigRepo.address }, + AddresslistVotingRepoProxy: { + address: deployment.addresslistVotingRepo.address, + }, + } as NetworkDeployment, + }; const daoCreation = await deployContracts.createTokenVotingDAO( deployment, @@ -1145,8 +1157,7 @@ describe("Client", () => { params: TransferQueryParams, ctx: Context; beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = - deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; ctx = new Context(contextParamsLocalChain); params = { daoAddressOrEns: TEST_DAO_ADDRESS, @@ -2019,7 +2030,7 @@ describe("Client", () => { }); it("Should return true for a valid update", async () => { const implementationAddress = await client.methods.getDaoImplementation( - client.web3.getAddress("daoFactoryAddress"), + client.web3.getAddress(ContractNames.DAO_FACTORY), ); upgradeToAndCallAction = client.encoding.upgradeToAndCallAction( daoAddressV1, @@ -2049,7 +2060,7 @@ describe("Client", () => { }); it("Should PROPOSAL_NOT_FOUND when the proposal is null", async () => { const implementationAddress = await client.methods.getDaoImplementation( - client.web3.getAddress("daoFactoryAddress"), + client.web3.getAddress(ContractNames.DAO_FACTORY), ); upgradeToAndCallAction = client.encoding.upgradeToAndCallAction( daoAddressV1, diff --git a/modules/client/test/integration/constants.ts b/modules/client/test/integration/constants.ts index 089709fd0..95a28d4d0 100644 --- a/modules/client/test/integration/constants.ts +++ b/modules/client/test/integration/constants.ts @@ -1,5 +1,5 @@ // @ts-ignore Needed to get the global typing for hardhat -import * as jestenv from "jest-environment-hardhat" +import * as jestenv from "jest-environment-hardhat"; import { Wallet } from "@ethersproject/wallet"; import { PluginRepoBuildMetadata, @@ -97,7 +97,7 @@ export const TEST_NON_EXISTING_ADDRESS = export const contextParamsMainnet: ContextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x0123456789012345678901234567890123456789", + DAOFactory: "0x0123456789012345678901234567890123456789", web3Providers: web3endpoints.working, ipfsNodes: ipfsEndpoints.working, graphqlNodes: grapqhlEndpoints.working, @@ -106,7 +106,7 @@ export const contextParamsMainnet: ContextParams = { export const contextParamsLocalChain: ContextParams = { network: hardhat.hre.config.networks.hardhat.chainId, signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0xf8065dD2dAE72D4A8e74D8BB0c8252F3A9acE7f9", + DAOFactory: "0xf8065dD2dAE72D4A8e74D8BB0c8252F3A9acE7f9", web3Providers: [hardhat.url], ipfsNodes: ipfsEndpoints.working, graphqlNodes: grapqhlEndpoints.working, @@ -115,7 +115,7 @@ export const contextParamsLocalChain: ContextParams = { export const contextParamsFailing: ContextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x0123456789012345678901234567890123456789", + DAOFactory: "0x0123456789012345678901234567890123456789", web3Providers: web3endpoints.failing, ipfsNodes: ipfsEndpoints.failing, graphqlNodes: grapqhlEndpoints.failing, @@ -174,7 +174,7 @@ export const SUBGRAPH_PROPOSAL_BASE: SubgraphProposalBase = { export const contextParamsOkWithGraphqlTimeouts: ContextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x0123456789012345678901234567890123456789", + DAOFactory: "0x0123456789012345678901234567890123456789", web3Providers: web3endpoints.working, ipfsNodes: ipfsEndpoints.working, graphqlNodes: grapqhlEndpoints.timeout.concat(grapqhlEndpoints.working), diff --git a/modules/client/test/integration/core-modules/graphql.test.ts b/modules/client/test/integration/core-modules/graphql.test.ts index 781575243..1722ae2eb 100644 --- a/modules/client/test/integration/core-modules/graphql.test.ts +++ b/modules/client/test/integration/core-modules/graphql.test.ts @@ -22,7 +22,7 @@ const TEST_WALLET = const contextParamsMainnet: ContextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x0123456789012345678901234567890123456789", + DAOFactory: "0x0123456789012345678901234567890123456789", web3Providers: web3endpoints.working, ipfsNodes: [ { diff --git a/modules/client/test/integration/core-modules/ipfs.test.ts b/modules/client/test/integration/core-modules/ipfs.test.ts index e09d9a217..072debd6d 100644 --- a/modules/client/test/integration/core-modules/ipfs.test.ts +++ b/modules/client/test/integration/core-modules/ipfs.test.ts @@ -24,7 +24,7 @@ const TEST_WALLET = const contextParamsMainnet: ContextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x0123456789012345678901234567890123456789", + DAOFactory: `0x${'0123456789'.repeat(4)}`, web3Providers: web3endpoints.working, ipfsNodes: [ { diff --git a/modules/client/test/integration/multisig-client/decoding.test.ts b/modules/client/test/integration/multisig-client/decoding.test.ts index 77dbac77e..833f2cab1 100644 --- a/modules/client/test/integration/multisig-client/decoding.test.ts +++ b/modules/client/test/integration/multisig-client/decoding.test.ts @@ -10,7 +10,7 @@ import { ADDRESS_ONE, contextParamsLocalChain } from "../constants"; describe("Client Multisig", () => { beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; }); describe("Action decoders", () => { it("Should decode the members from an add members action", async () => { diff --git a/modules/client/test/integration/multisig-client/encoding.test.ts b/modules/client/test/integration/multisig-client/encoding.test.ts index 0e38acdc7..9384f84a6 100644 --- a/modules/client/test/integration/multisig-client/encoding.test.ts +++ b/modules/client/test/integration/multisig-client/encoding.test.ts @@ -1,3 +1,8 @@ +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; import { AddAddressesParams, MultisigClient, @@ -16,8 +21,13 @@ import { } from "@aragon/sdk-client-common"; describe("Client Multisig", () => { - beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; + beforeAll(async () => { + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; + contracts.local = { + [SupportedVersions.V1_3_0]: { + MultisigRepoProxy: { address: ADDRESS_ONE }, + } as NetworkDeployment, + }; }); describe("Action generators", () => { it("Should create an a Multisig install entry", async () => { diff --git a/modules/client/test/integration/multisig-client/estimation.test.ts b/modules/client/test/integration/multisig-client/estimation.test.ts index 9b57ae12c..4c5791d26 100644 --- a/modules/client/test/integration/multisig-client/estimation.test.ts +++ b/modules/client/test/integration/multisig-client/estimation.test.ts @@ -8,6 +8,7 @@ import { MultisigClient, } from "../../../src"; import { + ADDRESS_ONE, contextParamsLocalChain, SUBGRAPH_PLUGIN_INSTALLATION, TEST_WALLET_ADDRESS, @@ -16,6 +17,11 @@ import * as deployContracts from "../../helpers/deployContracts"; import { Context } from "@aragon/sdk-client-common"; import { buildMultisigDAO } from "../../helpers/build-daos"; import { createMultisigPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Client Multisig", () => { describe("Estimation module", () => { @@ -24,19 +30,23 @@ describe("Client Multisig", () => { beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.multisigRepoAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.MultisigRepoProxy = deployment.multisigRepo.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.ensRegistryAddress = - deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; const daoCreation = await deployContracts.createMultisigDAO( deployment, "test-multisig-dao", [TEST_WALLET_ADDRESS], ); pluginAddress = daoCreation.pluginAddrs[0]; + contracts.local = { + [SupportedVersions.V1_3_0]: { + MultisigRepoProxy: { address: ADDRESS_ONE }, + } as NetworkDeployment, + }; // advance to get past the voting checkpoint }); diff --git a/modules/client/test/integration/multisig-client/methods.test.ts b/modules/client/test/integration/multisig-client/methods.test.ts index cfc13ce6f..87e6af8e5 100644 --- a/modules/client/test/integration/multisig-client/methods.test.ts +++ b/modules/client/test/integration/multisig-client/methods.test.ts @@ -9,6 +9,7 @@ import { ApproveProposalStep, CanApproveParams, CreateMultisigProposalParams, + ExecuteProposalStep, MultisigClient, MultisigPluginPrepareInstallationParams, MultisigProposal, @@ -28,7 +29,6 @@ import { TEST_TX_HASH, TEST_WALLET_ADDRESS, } from "../constants"; -import { ExecuteProposalStep } from "../../../src"; import { buildMultisigDAO } from "../../helpers/build-daos"; import { mineBlock } from "../../helpers/block-times"; import { JsonRpcProvider } from "@ethersproject/providers"; @@ -55,6 +55,11 @@ import { } from "@aragon/sdk-client-common"; import { PluginRepo__factory } from "@aragon/osx-ethers"; import { createMultisigPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Client Multisig", () => { let deployment: deployContracts.Deployment; @@ -63,25 +68,29 @@ describe("Client Multisig", () => { beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.multisigRepoAddress = - deployment.multisigRepo.address; - contextParamsLocalChain.adminRepoAddress = ""; - contextParamsLocalChain.addresslistVotingRepoAddress = + contextParamsLocalChain.MultisigRepoProxy = deployment.multisigRepo.address; + contextParamsLocalChain.AdminRepoProxy = ""; + contextParamsLocalChain.AddresslistVotingRepoProxy = deployment.addresslistVotingRepo.address; - contextParamsLocalChain.tokenVotingRepoAddress = + contextParamsLocalChain.TokenVotingRepoProxy = deployment.tokenVotingRepo.address; - contextParamsLocalChain.multisigSetupAddress = + contextParamsLocalChain.MultisigSetup = deployment.multisigPluginSetup.address; - contextParamsLocalChain.adminSetupAddress = ""; - contextParamsLocalChain.addresslistVotingSetupAddress = + contextParamsLocalChain.AdminSetup = ""; + contextParamsLocalChain.AddresslistVotingSetup = deployment.addresslistVotingPluginSetup.address; - contextParamsLocalChain.tokenVotingSetupAddress = + contextParamsLocalChain.TokenVotingSetup = deployment.tokenVotingPluginSetup.address; - contextParamsLocalChain.ensRegistryAddress = deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; repoAddr = deployment.multisigRepo.address; + contracts.local = { + [SupportedVersions.V1_3_0]: { + MultisigRepoProxy: { address: deployment.multisigRepo.address }, + } as NetworkDeployment, + }; if (Array.isArray(contextParamsLocalChain.web3Providers)) { provider = new JsonRpcProvider( diff --git a/modules/client/test/integration/tokenVoting-client/decoding.test.ts b/modules/client/test/integration/tokenVoting-client/decoding.test.ts index ca1543517..eff4a30a7 100644 --- a/modules/client/test/integration/tokenVoting-client/decoding.test.ts +++ b/modules/client/test/integration/tokenVoting-client/decoding.test.ts @@ -6,11 +6,11 @@ import { } from "../../../src"; import { ADDRESS_ONE, contextParamsLocalChain } from "../constants"; -import { Context, bytesToHex } from "@aragon/sdk-client-common"; +import { bytesToHex, Context } from "@aragon/sdk-client-common"; describe("Token Voting Client", () => { beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; }); describe("Action decoders", () => { it("Should decode the plugin settings from an update plugin settings action", async () => { diff --git a/modules/client/test/integration/tokenVoting-client/encoding.test.ts b/modules/client/test/integration/tokenVoting-client/encoding.test.ts index d8bc6c251..6e3d1387e 100644 --- a/modules/client/test/integration/tokenVoting-client/encoding.test.ts +++ b/modules/client/test/integration/tokenVoting-client/encoding.test.ts @@ -1,3 +1,8 @@ +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; import { MintTokenParams, TokenVotingClient, @@ -10,7 +15,12 @@ import { Context, InvalidAddressError } from "@aragon/sdk-client-common"; describe("Token Voting Client", () => { beforeAll(() => { - contextParamsLocalChain.ensRegistryAddress = ADDRESS_ONE; + contextParamsLocalChain.ENSRegistry = ADDRESS_ONE; + contracts.local = { + [SupportedVersions.V1_3_0]: { + TokenVotingRepoProxy: { address: ADDRESS_ONE }, + } as NetworkDeployment, + }; }); describe("Encoding module", () => { it("Should create a TokenVoting client and generate a install entry", async () => { diff --git a/modules/client/test/integration/tokenVoting-client/estimation.test.ts b/modules/client/test/integration/tokenVoting-client/estimation.test.ts index 7f4466d22..4e972609d 100644 --- a/modules/client/test/integration/tokenVoting-client/estimation.test.ts +++ b/modules/client/test/integration/tokenVoting-client/estimation.test.ts @@ -19,19 +19,28 @@ import * as deployContracts from "../../helpers/deployContracts"; import { Context } from "@aragon/sdk-client-common"; import { buildTokenVotingDAO } from "../../helpers/build-daos"; import { createTokenVotingPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Token Voting Client", () => { describe("Estimation Module", () => { let deployment: deployContracts.Deployment; beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.tokenVotingRepoAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.TokenVotingRepoProxy = deployment.tokenVotingRepo.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.ensRegistryAddress = - deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; + contracts.local = { + [SupportedVersions.V1_3_0]: { + TokenVotingRepoProxy: { address: ADDRESS_ONE }, + } as NetworkDeployment, + }; }); it("Should estimate the gas fees for creating a new proposal", async () => { diff --git a/modules/client/test/integration/tokenVoting-client/methods.test.ts b/modules/client/test/integration/tokenVoting-client/methods.test.ts index 6002eb362..30fbe8b66 100644 --- a/modules/client/test/integration/tokenVoting-client/methods.test.ts +++ b/modules/client/test/integration/tokenVoting-client/methods.test.ts @@ -46,10 +46,7 @@ import { buildExistingTokenVotingDAO, buildTokenVotingDAO, } from "../../helpers/build-daos"; -import { - mineBlock, - mineBlockWithTimeOffset, -} from "../../helpers/block-times"; +import { mineBlock, mineBlockWithTimeOffset } from "../../helpers/block-times"; import { JsonRpcProvider } from "@ethersproject/providers"; import { QueryTokenVotingIsMember, @@ -91,6 +88,11 @@ import { TokenType, } from "@aragon/sdk-client-common"; import { createTokenVotingPluginBuild } from "../../helpers/create-plugin-build"; +import { + contracts, + NetworkDeployment, + SupportedVersions, +} from "@aragon/osx-commons-configs"; describe("Token Voting Client", () => { let deployment: deployContracts.Deployment; @@ -100,25 +102,29 @@ describe("Token Voting Client", () => { beforeAll(async () => { deployment = await deployContracts.deploy(); - contextParamsLocalChain.daoFactoryAddress = deployment.daoFactory.address; - contextParamsLocalChain.pluginSetupProcessorAddress = + contextParamsLocalChain.DAOFactory = deployment.daoFactory.address; + contextParamsLocalChain.PluginSetupProcessor = deployment.pluginSetupProcessor.address; - contextParamsLocalChain.multisigRepoAddress = - deployment.multisigRepo.address; - contextParamsLocalChain.adminRepoAddress = ""; - contextParamsLocalChain.addresslistVotingRepoAddress = + contextParamsLocalChain.MultisigRepoProxy = deployment.multisigRepo.address; + contextParamsLocalChain.AdminRepoProxy = ""; + contextParamsLocalChain.AddresslistVotingRepoProxy = deployment.addresslistVotingRepo.address; - contextParamsLocalChain.tokenVotingRepoAddress = + contextParamsLocalChain.TokenVotingRepoProxy = deployment.tokenVotingRepo.address; - contextParamsLocalChain.multisigSetupAddress = + contextParamsLocalChain.MultisigSetup = deployment.multisigPluginSetup.address; - contextParamsLocalChain.adminSetupAddress = ""; - contextParamsLocalChain.addresslistVotingSetupAddress = + contextParamsLocalChain.AdminSetup = ""; + contextParamsLocalChain.AddresslistVotingSetup = deployment.addresslistVotingPluginSetup.address; - contextParamsLocalChain.tokenVotingSetupAddress = + contextParamsLocalChain.TokenVotingSetup = deployment.tokenVotingPluginSetup.address; - contextParamsLocalChain.ensRegistryAddress = deployment.ensRegistry.address; + contextParamsLocalChain.ENSRegistry = deployment.ensRegistry.address; repoAddr = deployment.tokenVotingRepo.address; + contracts.local = { + [SupportedVersions.V1_3_0]: { + TokenVotingRepoProxy: { address: deployment.tokenVotingRepo.address }, + } as NetworkDeployment, + }; if (Array.isArray(contextParamsLocalChain.web3Providers)) { provider = new JsonRpcProvider( @@ -1316,7 +1322,9 @@ describe("Token Voting Client", () => { expect(action.value).toBe( BigInt(subgraphProposals[index].actions[actionIndex].value), ); - expect(action.to).toBe(subgraphProposals[index].actions[actionIndex].to); + expect(action.to).toBe( + subgraphProposals[index].actions[actionIndex].to, + ); expect(bytesToHex(action.data)).toBe( subgraphProposals[index].actions[actionIndex].data.toLowerCase(), ); diff --git a/modules/client/test/unit/client-common/utils.test.ts b/modules/client/test/unit/client-common/utils.test.ts index 107ddfdeb..88946a4fe 100644 --- a/modules/client/test/unit/client-common/utils.test.ts +++ b/modules/client/test/unit/client-common/utils.test.ts @@ -1,6 +1,4 @@ -import { - isFailingProposal, -} from "../../../src"; +import { isFailingProposal } from "../../../src"; import { Multisig__factory } from "@aragon/osx-ethers"; import { id } from "@ethersproject/hash"; import { DaoAction, hexToBytes } from "@aragon/sdk-client-common"; @@ -54,7 +52,6 @@ const UPGRADE_TO_ACTION = { ), }; - describe("Detect failing proposals", () => { it("isFailingProposal should return true because the proposal changes the min approvals and then updates the addresses", async () => { const actions: DaoAction[] = [ diff --git a/modules/client/test/unit/client/utils.test.ts b/modules/client/test/unit/client/utils.test.ts index b273650db..44881f920 100644 --- a/modules/client/test/unit/client/utils.test.ts +++ b/modules/client/test/unit/client/utils.test.ts @@ -27,9 +27,9 @@ import { TOKEN_VOTING_BUILD_METADATA, } from "../../integration/constants"; import { - startsWithDaoUpdateAction, containsPluginUpdateActionBlock, containsPluginUpdateActionBlockWithRootPermission, + startsWithDaoUpdateAction, validateApplyUpdateFunction, validateGrantRootPermissionAction, validateGrantUpgradePluginPermissionAction, @@ -48,7 +48,7 @@ import { SupportedPluginRepo } from "../../../src/internal/constants"; describe("Test client utils", () => { const pspAddress = ADDRESS_TWO; - const context = new Context({ pluginSetupProcessorAddress: pspAddress }); + const context = new Context({ PluginSetupProcessor: pspAddress }); const client = new Client(context); const pluginAddress = ADDRESS_ONE; const daoAddress = ADDRESS_THREE; @@ -634,11 +634,15 @@ describe("Test client utils", () => { }); describe("validateApplyUpdateFunction", () => { - function getApplyUpdateAction(daoAddress: string, applyUpdateParams: ApplyUpdateParams) { - const applyUpdateActions = client.encoding.applyUpdateAndPermissionsActionBlock( - daoAddress, - applyUpdateParams, - ); + function getApplyUpdateAction( + daoAddress: string, + applyUpdateParams: ApplyUpdateParams, + ) { + const applyUpdateActions = client.encoding + .applyUpdateAndPermissionsActionBlock( + daoAddress, + applyUpdateParams, + ); return applyUpdateActions[1]; } @@ -751,7 +755,7 @@ describe("Test client utils", () => { }; const action = getApplyUpdateAction(daoAddress, updatedApplyUpdateParams); mockedClient.request.mockResolvedValue({ - pluginRepo: subgraphPluginRepo, + pluginRepo: subgraphPluginRepo, dao: subgraphDao, pluginPreparations: [subgraphPluginPreparation], }); @@ -1066,17 +1070,19 @@ describe("Test client utils", () => { expect(result.proposalSettingsErrorCauses).toMatchObject([]); }); it("should return an empty for two groups of apply update", async () => { - const actionsGroupOne = client.encoding.applyUpdateAndPermissionsActionBlock( - daoAddress, - applyUpdateParams, - ); - const actionsGroupTwo = client.encoding.applyUpdateAndPermissionsActionBlock( - daoAddress, - { - ...applyUpdateParams, - permissions: [permission], - }, - ); + const actionsGroupOne = client.encoding + .applyUpdateAndPermissionsActionBlock( + daoAddress, + applyUpdateParams, + ); + const actionsGroupTwo = client.encoding + .applyUpdateAndPermissionsActionBlock( + daoAddress, + { + ...applyUpdateParams, + permissions: [permission], + }, + ); // setup mocks for (let i = 0; i < 3; i++) { mockedClient.request.mockResolvedValueOnce({ @@ -1111,7 +1117,7 @@ describe("Test client utils", () => { client.ipfs, ); expect(result.isValid).toEqual(true); - expect(result.actionErrorCauses).toMatchObject([[],[]]); + expect(result.actionErrorCauses).toMatchObject([[], []]); expect(result.proposalSettingsErrorCauses).toMatchObject([]); }); it("should return an INVALID_ACTIONS when the actions don't match the expected pattern", async () => { @@ -1130,7 +1136,9 @@ describe("Test client utils", () => { ); expect(result.isValid).toEqual(false); expect(result.actionErrorCauses).toMatchObject([]); - expect(result.proposalSettingsErrorCauses).toMatchObject([ProposalSettingsErrorCause.INVALID_ACTIONS]); + expect(result.proposalSettingsErrorCauses).toMatchObject([ + ProposalSettingsErrorCause.INVALID_ACTIONS, + ]); }); }); describe("validateUpdateDaoProposalActions", () => { @@ -1225,7 +1233,6 @@ describe("Test client utils", () => { DaoUpdateProposalInvalidityCause.NON_ZERO_CALL_VALUE, ]); expect(result.proposalSettingsErrorCauses).toMatchObject([]); - }); it("should return INVALID_UPGRADE_TO_IMPLEMENTATION_ADDRESS when the implementation address is not the correct one", () => { upgradeToAction = client.encoding.upgradeToAction( diff --git a/modules/client/test/unit/context.test.ts b/modules/client/test/unit/context.test.ts index 8d87767a2..7b3f7df60 100644 --- a/modules/client/test/unit/context.test.ts +++ b/modules/client/test/unit/context.test.ts @@ -6,11 +6,14 @@ import { ADDRESS_ONE } from "../integration/constants"; import { Context, ContextParams, - GRAPHQL_NODES, - IPFS_NODES, - LIVE_CONTRACTS, - SupportedVersion, + getDefaultGraphqlNodes, + getDefaultIpfsNodes, } from "@aragon/sdk-client-common"; +import { + ContractNames, + contracts, + SupportedNetworks, +} from "@aragon/osx-commons-configs"; const TEST_WALLET = "8d7d56a9efa4158d232edbeaae601021eb3477ad77b5f3c720601fd74e8e04bb"; @@ -29,7 +32,7 @@ describe("Context instances", () => { contextParams = { network: "mainnet", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x1234", + DAOFactory: "0x1234", web3Providers: web3endpoints.working, gasFeeEstimationFactor: 0.1, graphqlNodes: [], @@ -41,14 +44,18 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(Context); expect(context.network.name).toBe("homestead"); expect(context.network.chainId).toBe(1); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].homestead.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.mainnet["v1.3.0"]!.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe(context.network.ensAddress); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(context.network.ensAddress); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(0); - expect(context.ipfs.length).toBe(IPFS_NODES.homestead.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.homestead.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -65,8 +72,10 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(Context); expect(context.network.name).toBe("homestead"); expect(context.network.chainId).toBe(1); - expect(context.daoFactoryAddress).toBe(contextParams.daoFactoryAddress); - expect(context.ensRegistryAddress).toBe(context.network.ensAddress); + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contextParams.DAOFactory, + ); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(context.network.ensAddress); expect(context.gasFeeEstimationFactor).toBe( contextParams.gasFeeEstimationFactor, ); @@ -85,7 +94,7 @@ describe("Context instances", () => { contextParams = { network: "goerli", signer: new Wallet(TEST_WALLET), - daoFactoryAddress: "0x2345", + DAOFactory: "0x2345", web3Providers: web3endpoints.working, gasFeeEstimationFactor: 0.1, ipfsNodes: [{ url: "https://localhost", headers: {} }], @@ -97,7 +106,7 @@ describe("Context instances", () => { expect(context.network.name).toEqual("goerli"); expect(context.network.chainId).toEqual(5); expect(context.signer).toBeInstanceOf(Wallet); - expect(context.daoFactoryAddress).toEqual("0x2345"); + expect(context.getAddress(ContractNames.DAO_FACTORY)).toEqual("0x2345"); context.web3Providers?.map((provider) => expect(provider).toBeInstanceOf(JsonRpcProvider) ); @@ -117,14 +126,18 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(Context); expect(context.network.name).toBe("goerli"); expect(context.network.chainId).toBe(5); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].goerli.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.goerli["v1.3.0"]!.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe(context.network.ensAddress); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(context.network.ensAddress); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); - expect(context.ipfs.length).toBe(IPFS_NODES.goerli.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.goerli.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -140,16 +153,20 @@ describe("Context instances", () => { }); expect(context.network.name).toBe("matic"); expect(context.network.chainId).toBe(137); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.polygon["v1.3.0"]!.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe( + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); - expect(context.ipfs.length).toBe(IPFS_NODES.matic.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.matic.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -169,16 +186,20 @@ describe("Context instances", () => { }); expect(context.network.name).toBe("matic"); expect(context.network.chainId).toBe(137); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe( + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(1); - expect(context.ipfs.length).toBe(IPFS_NODES.matic.length); - expect(context.graphql.length).toBe(GRAPHQL_NODES.matic.length); + expect(context.ipfs.length).toBe( + getDefaultIpfsNodes(SupportedNetworks.POLYGON).length, + ); + expect(context.graphql.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); }); @@ -192,7 +213,7 @@ describe("Context instances", () => { it("Should Change the network and update all the parameters", () => { const context = new Context(); context.set({ - ensRegistryAddress: ADDRESS_ONE, + ENSRegistry: ADDRESS_ONE, graphqlNodes: [ { url: "https://example.com/1", @@ -212,13 +233,15 @@ describe("Context instances", () => { expect(context).toBeInstanceOf(Context); expect(context.network.name).toBe("matic"); expect(context.network.chainId).toBe(137); - expect(context.daoFactoryAddress).toBe( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toBe( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toBe(ADDRESS_ONE); + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toBe(ADDRESS_ONE); expect(context.gasFeeEstimationFactor).toBe(0.625); expect(context.web3Providers.length).toBe(0); - expect(context.ipfs.length).toBe(IPFS_NODES.matic.length); + expect(context.ipfs.length).toBe( + getDefaultGraphqlNodes(SupportedNetworks.POLYGON).length, + ); expect(context.graphql.length).toBe(3); context.web3Providers.map((provider) => { expect(provider).toBeInstanceOf(JsonRpcProvider); @@ -245,7 +268,7 @@ describe("Context instances", () => { }).toThrow(); }); it("Should create a context with the correct DAOFactory address from the core-contracts-package", () => { - contextParams.daoFactoryAddress = ""; + contextParams.DAOFactory = ""; contextParams.network = "matic"; const context = new Context(contextParams); @@ -255,14 +278,16 @@ describe("Context instances", () => { provider.getNetwork().then((nw) => { expect(nw.chainId).toEqual(137); expect(nw.name).toEqual("matic"); - expect(nw.ensAddress).toEqual(LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress); + expect(nw.ensAddress).toEqual( + contracts.polygon["v1.3.0"]?.DAOFactory.address, + ); }) ); - expect(context.daoFactoryAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.daoFactoryAddress, + expect(context.getAddress(ContractNames.DAO_FACTORY)).toEqual( + contracts.polygon["v1.3.0"]?.DAOFactory.address, ); - expect(context.ensRegistryAddress).toEqual( - LIVE_CONTRACTS[SupportedVersion.LATEST].matic.ensRegistryAddress, + expect(context.getAddress(ContractNames.ENS_REGISTRY)).toEqual( + contracts.polygon["v1.3.0"]?.ENSRegistry?.address, ); }); }); diff --git "a/modules/client/test/unit/tokenVoting-client\302\240 /utils.test.ts" "b/modules/client/test/unit/tokenVoting-client\302\240 /utils.test.ts" index 730b47c41..fd63664cd 100644 --- "a/modules/client/test/unit/tokenVoting-client\302\240 /utils.test.ts" +++ "b/modules/client/test/unit/tokenVoting-client\302\240 /utils.test.ts" @@ -1,6 +1,12 @@ import { ProposalStatus, TokenType } from "@aragon/sdk-client-common"; -import { SubgraphContractType, SubgraphTokenVotingProposal } from "../../../src/tokenVoting/internal/types"; -import { computeProposalStatus, parseToken } from "../../../src/tokenVoting/internal/utils"; +import { + SubgraphContractType, + SubgraphTokenVotingProposal, +} from "../../../src/tokenVoting/internal/types"; +import { + computeProposalStatus, + parseToken, +} from "../../../src/tokenVoting/internal/utils"; describe("tokenVoting-client utils", () => { describe("parseToken", () => { diff --git a/yarn.lock b/yarn.lock index 50d8bc07d..7a43bfa87 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,6 +15,13 @@ "@jridgewell/gen-mapping" "^0.1.0" "@jridgewell/trace-mapping" "^0.3.9" +"@aragon/osx-commons-configs@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.2.0.tgz#32f83596f4a2e9e48aef61cf560c1c5b4d32a049" + integrity sha512-wCFtgmuGCzs8L5mCxVCYQ6uEu69IrofS7q2w7E1Fjk7/nWuSmRUpgmif3ki9BQq1qpOvDu2P+u3UNLnIz8J82g== + dependencies: + tslib "^2.6.2" + "@aragon/osx-ethers-v1.0.0@npm:@aragon/osx-ethers@1.2.1", "osx-ethers-v1@npm:@aragon/osx-ethers@1.2.1": version "1.2.1" resolved "https://registry.yarnpkg.com/@aragon/osx-ethers/-/osx-ethers-1.2.1.tgz#a442048137153ed5a3ca4eff3f3927b45a5134b5"