diff --git a/.gitignore b/.gitignore index 405df69672..72616155bd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ cypress/screenshots /playwright-report/ /blob-report/ /playwright/.cache/ +/network-files .vscode .DS_Store diff --git a/docker/colony-cdapp-dev-env-orchestration.yaml b/docker/colony-cdapp-dev-env-orchestration.yaml index d70736b51c..19d914ceda 100644 --- a/docker/colony-cdapp-dev-env-orchestration.yaml +++ b/docker/colony-cdapp-dev-env-orchestration.yaml @@ -8,12 +8,12 @@ services: - 'amplify-mock-data:/mock-data' - '../amplify/backend/:/backend-repo' command: '/bin/bash -c "rm -rf /backend/* && rm -rf /mock-data/* && touch /backend/.initialized && touch /mock-data/.initialized && cp -r /backend-repo/* /backend/ && chown -R $(id -u node):$(id -g node) /backend && chown -R $(id -u node):$(id -g node) /mock-data"' - network-contracts: container_name: 'network' image: colony-cdapp-dev-env/network:latest volumes: - 'amplify-mock-data:/colonyCDapp/amplify/mock-data' + - '../network-files/:/colonyCDappBackend/colonyNetwork/artifacts' ports: - '8545:8545' - '3002:3002' @@ -25,7 +25,6 @@ services: depends_on: amplify-setup: condition: service_completed_successfully - reputation-monitor: container_name: 'monitor' image: colony-cdapp-dev-env/reputation-monitor:latest @@ -36,7 +35,6 @@ services: depends_on: network-contracts: condition: service_healthy - block-ingestor: container_name: 'ingestor' image: colony-cdapp-dev-env/block-ingestor:latest @@ -49,7 +47,6 @@ services: condition: service_healthy amplify: condition: service_healthy - amplify: container_name: 'amplify' image: colony-cdapp-dev-env/amplify:latest @@ -73,7 +70,6 @@ services: test: ['CMD', 'curl', '-f', 'http://localhost:9200'] interval: 5s retries: 1000 - auth-proxy: container_name: 'auth' image: colony-cdapp-dev-env/auth-proxy:latest @@ -82,7 +78,6 @@ services: depends_on: amplify: condition: service_healthy - network-files: container_name: 'network-files' image: colony-cdapp-dev-env/base:latest @@ -94,7 +89,6 @@ services: depends_on: network-contracts: condition: service_healthy - volumes: amplify-backend: amplify-mock-data: diff --git a/package-lock.json b/package-lock.json index 7e88d265f2..c926437b5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,10 +10,11 @@ "hasInstallScript": true, "dependencies": { "@apollo/client": "3.7.14", - "@colony/abis": "1.5.0", - "@colony/colony-js": "^7.2.0", - "@colony/events": "3.0.0", + "@colony/abis": "^1.6.0", + "@colony/colony-js": "^8.0.0-next.0", + "@colony/events": "^4.0.0-next.0", "@colony/redux-promise-listener": "^1.2.0", + "@colony/sdk": "^3.0.0-next.0", "@colony/unicode-confusables-noascii": "^0.1.2", "@hookform/resolvers": "^2.9.10", "@phosphor-icons/react": "^2.1.5", @@ -2725,22 +2726,22 @@ } }, "node_modules/@colony/abis": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colony/abis/-/abis-1.5.0.tgz", - "integrity": "sha512-j1gePuI/rog7IEsY2rNxqp1JI/ChDkTECh2id30kh0ubUApf3sfidDp08aFNQRSHILW1jPNvngtp7rSTV8zE5g==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colony/abis/-/abis-1.6.0.tgz", + "integrity": "sha512-A4rvNlDNr4TocEEtJWxvXt5K/E1GolGI/yd6hv2f7TcUwW6kvD1M6KW2EOXKIiAS3Txk4Jz5Tz/5LjSDg4eTqg==", "engines": { "node": "^16 || ^18 || ^20", "npm": "^8 || ^9 || ^10" } }, "node_modules/@colony/colony-js": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@colony/colony-js/-/colony-js-7.2.0.tgz", - "integrity": "sha512-vzXlYSoepHRnYIT2n8Ck9IV87vNPFRtUx2FAP834rVdCu4JwPPmNwKleH/7KBS9As92aaRYhlbzVDI9WQ+fgag==", + "version": "8.0.0-next.0", + "resolved": "https://registry.npmjs.org/@colony/colony-js/-/colony-js-8.0.0-next.0.tgz", + "integrity": "sha512-F46ElOrzhD/ktfYCQDf1ieNeBbIyWiDPd6cuHBjQ9yEU1iEo4pJfNt3J/57hZkwU+dY6wYqnU3NT7WCeu45u0A==", "dependencies": { - "@colony/core": "^2.3.0", - "@colony/events": "^3.0.0", - "@colony/tokens": "^0.3.0" + "@colony/core": "^3.0.0-next.0", + "@colony/events": "^4.0.0-next.0", + "@colony/tokens": "^1.0.0-next.0" }, "engines": { "node": "^16 || ^18 || ^20", @@ -2751,10 +2752,9 @@ } }, "node_modules/@colony/core": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/@colony/core/-/core-2.3.1.tgz", - "integrity": "sha512-TQzdFh+ayJdEh2lR04LyvyPEt1wEo0h/dukUTVY6lY9N8zpUvHZL4JCpyy//fUV1rlly+wQvxoRjcXzHYTguaw==", - "license": "GPL-3.0-only", + "version": "3.0.0-next.0", + "resolved": "https://registry.npmjs.org/@colony/core/-/core-3.0.0-next.0.tgz", + "integrity": "sha512-IfdFoRwmMJOW3Hj6jzn8hOiwA9UxRFiYrEVJpnykm0n/I6c+IPDGZ4lg2sWdimvRa+bJit4gNP39rH+Mj0cHLg==", "engines": { "node": "^16 || ^18 || ^20", "pnpm": "^8" @@ -2780,11 +2780,11 @@ } }, "node_modules/@colony/events": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@colony/events/-/events-3.0.0.tgz", - "integrity": "sha512-eFM51N75ZXHJ/E5HqAGZa/5btlEhD7Vw5bbkF91fHfF1tsb+TYrb1vVvCKmx2XihzuMRKm1v0iS7VPjFwoTADg==", + "version": "4.0.0-next.0", + "resolved": "https://registry.npmjs.org/@colony/events/-/events-4.0.0-next.0.tgz", + "integrity": "sha512-u89fmH6RlQWW8IeejfkZITsdptCm8zGx1a9qJ6F/p4ILY+EBnWdYkSdTZXITACU1r6sNSm4GkochTIjAy0R0ag==", "dependencies": { - "@colony/core": "^2.3.0", + "@colony/core": "^3.0.0-next.0", "fetch-retry": "^5.0.4", "typia": "^3.8.3" }, @@ -2805,10 +2805,29 @@ "redux": ">3.0.0" } }, + "node_modules/@colony/sdk": { + "version": "3.0.0-next.0", + "resolved": "https://registry.npmjs.org/@colony/sdk/-/sdk-3.0.0-next.0.tgz", + "integrity": "sha512-bQEC6AMqWA8WtxiqAV95ZS/weUNN7zOs26L7Qp65IscUAWVr0CWByh0IXrnGo6h+oYT4QYDiBan3yzDR0CTC9w==", + "dependencies": { + "@colony/core": "^3.0.0-next.0", + "@colony/events": "^4.0.0-next.0", + "@colony/tokens": "^1.0.0-next.0", + "@ethersproject/abstract-provider": "^5.7.0", + "abitype": "^1.0.6" + }, + "engines": { + "node": "^16 || ^18 || ^20", + "pnpm": "^8" + }, + "peerDependencies": { + "ethers": "^5.1.3" + } + }, "node_modules/@colony/tokens": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@colony/tokens/-/tokens-0.3.0.tgz", - "integrity": "sha512-7rftWSWCos4OYjt2JgdGN4gHccXvm7Un0Cv8op4mQHWTVvX/0Oek4k0VOaQQgHpu/3yoRjDrI7ciqFpafRnwCg==", + "version": "1.0.0-next.0", + "resolved": "https://registry.npmjs.org/@colony/tokens/-/tokens-1.0.0-next.0.tgz", + "integrity": "sha512-j5YBk4nOXwDpYd1LnRyGOLVcRgfvkBgb85TI2aXKLwjRhB2V9f4Jdsy5ooqr7R9cQivYeCvfnEs5euPiHAhgqg==", "engines": { "node": "^16 || ^18 || ^20", "pnpm": "^8" @@ -15674,6 +15693,26 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/abitype": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.6.tgz", + "integrity": "sha512-MMSqYh4+C/aVqI2RQaWqbvI4Kxo5cQV40WQ4QFtDnNzCkqChm8MuENhElmynZlO0qUy/ObkEUaXtKqYnx1Kp3A==", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3 >=3.22.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -16189,8 +16228,7 @@ "node_modules/array-timsort": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-timsort/-/array-timsort-1.0.3.tgz", - "integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==", - "license": "MIT" + "integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==" }, "node_modules/array-union": { "version": "2.1.0", @@ -19056,10 +19094,9 @@ } }, "node_modules/comment-json": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.3.tgz", - "integrity": "sha512-SsxdiOf064DWoZLH799Ata6u7iV658A11PlWtZATDlXPpKGJnbJZ5Z24ybixAi+LUUqJ/GKowAejtC5GFUG7Tw==", - "license": "MIT", + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.5.tgz", + "integrity": "sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==", "dependencies": { "array-timsort": "^1.0.3", "core-util-is": "^1.0.3", @@ -19074,8 +19111,7 @@ "node_modules/comment-json/node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "license": "MIT" + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "node_modules/comment-parser": { "version": "1.4.1", @@ -21103,7 +21139,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/drange/-/drange-1.1.1.tgz", "integrity": "sha512-pYxfDYpued//QpnLIm4Avk7rsNtAtQkUES2cwAYSvD/wd2pKD71gN2Ebj3e7klzXwjocvE8c5vx/1fxwpqmSxA==", - "license": "MIT", "engines": { "node": ">=4" } @@ -32449,7 +32484,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz", "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==", - "license": "MIT", "engines": { "node": ">=8" } @@ -51967,7 +52001,6 @@ "version": "3.8.9", "resolved": "https://registry.npmjs.org/typia/-/typia-3.8.9.tgz", "integrity": "sha512-yvQ67nhtzme+rnEUZfSOIgxBOHYrrQ3WBU1J4SrAhI3ntBhSelYwGiJkeaCvqchzK6O1RoIs3kCBS4XHIlp2NA==", - "license": "MIT", "dependencies": { "commander": "^10.0.0", "comment-json": "^4.2.3", @@ -51985,7 +52018,6 @@ "version": "10.0.1", "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "license": "MIT", "engines": { "node": ">=14" } @@ -51994,7 +52026,6 @@ "version": "0.5.3", "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", "integrity": "sha512-U+5l2KrcMNOUPYvazA3h5ekF80FHTUG+87SEAmHZmolh1M+i/WyTCxVzmi+tidIa1tM4BSe8g2Y/D3loWDjj+w==", - "license": "MIT", "dependencies": { "drange": "^1.0.2", "ret": "^0.2.0" @@ -52007,7 +52038,6 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==", - "license": "MIT", "engines": { "node": ">=4" } diff --git a/package.json b/package.json index 24043ba785..ac1d72f9c9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "postinstall": "if [ -z \"$SKIP_HOOKS\" ]; then ./scripts/lambda-functions-dependencies.sh && scripts/generate-amplify-local-config.sh; fi", "watch-amplify": "node scripts/watchAmplifyFiles", "forward-time": "node scripts/forward-time", - "playwright:install": "npx playwright install --with-deps", + "playwright:install": "npx playwright install --with-deps", "playwright:run": "playwright test", "playwright:watch": "playwright test --ui" }, @@ -149,10 +149,11 @@ }, "dependencies": { "@apollo/client": "3.7.14", - "@colony/abis": "1.5.0", - "@colony/colony-js": "^7.2.0", - "@colony/events": "3.0.0", + "@colony/abis": "^1.6.0", + "@colony/colony-js": "^8.0.0-next.0", + "@colony/events": "^4.0.0-next.0", "@colony/redux-promise-listener": "^1.2.0", + "@colony/sdk": "^3.0.0-next.0", "@colony/unicode-confusables-noascii": "^0.1.2", "@hookform/resolvers": "^2.9.10", "@phosphor-icons/react": "^2.1.5", diff --git a/src/context/ColonyManager.ts b/src/context/ColonyManager.ts index f2bf29af48..4b32d5e96c 100644 --- a/src/context/ColonyManager.ts +++ b/src/context/ColonyManager.ts @@ -11,9 +11,13 @@ import { type AnyColonyClient, type AnyMultisigPermissionsClient, } from '@colony/colony-js'; +import { type Abi, CustomContract } from '@colony/sdk'; +import { ContractConfig } from '@colony/sdk/dist/types/ContractConfig'; import { type Signer, type providers } from 'ethers'; +import { DEFAULT_NETWORK } from '~constants/index.ts'; import { type Address } from '~types/index.ts'; +import { ColonyJSNetworkMapping } from '~types/network.ts'; import { isAddress } from '~utils/web3/index.ts'; export default class ColonyManager { @@ -21,6 +25,8 @@ export default class ColonyManager { colonyClients: Map>; + customContracts: Map>; + extensionClients: Map>; tokenClients: Map>; @@ -38,6 +44,7 @@ export default class ColonyManager { this.extensionClients = new Map(); this.tokenClients = new Map(); this.tokenLockingClients = new Map(); + this.customContracts = new Map(); this.networkClient = networkClient; this.provider = networkClient.provider; this.signer = networkClient.signer; @@ -252,4 +259,34 @@ export default class ColonyManager { } return clientPromise; } + + /* + * Get a custom colony contract by address and ABI (using Colony SDK) + * + * @example + * ```ts + * import { abi as colonyNetworkAbi } from '../../network-files/contracts/colonyNetwork/ColonyNetwork.sol/ColonyNetwork.json'; + * const networkAddress = import.meta.env.NETWORK_CONTRACT_ADDRESS || ColonyNetworkAddress[DEFAULT_NETWORK]; + * const customColonyNetwork = colonyManager.getCustomContract(networkAddress, colonyNetworkAbi); + * ``` + */ + getCustomContract(address: string, abi: A): CustomContract { + const reputationOracleEndpoint = import.meta.env.REPUTATION_ORACLE_ENDPOINT + ? new URL(import.meta.env.REPUTATION_ORACLE_ENDPOINT) + : new URL(`/reputation`, window.location.origin); + + const metaTxBroadcasterEndpoint = `${import.meta.env.METATX_BROADCASTER_ENDPOINT}/broadcast`; + + const config = new ContractConfig(this.signer || this.provider, { + metaTxBroadcasterEndpoint, + network: ColonyJSNetworkMapping[DEFAULT_NETWORK], + reputationOracleEndpoint: reputationOracleEndpoint.toString(), + }); + + if (this.customContracts.has(address)) { + return this.customContracts.get(address) as CustomContract; + } + + return new CustomContract(address as `0x${string}`, abi, config); + } } diff --git a/src/redux/sagas/utils/getNetworkClient.ts b/src/redux/sagas/utils/getNetworkClient.ts index 211d8c29cb..80b797efb1 100644 --- a/src/redux/sagas/utils/getNetworkClient.ts +++ b/src/redux/sagas/utils/getNetworkClient.ts @@ -42,6 +42,7 @@ const getNetworkClient = async (signerOrProvider?: SignerOrProvider) => { return getColonyNetworkClient(ColonyJSNetwork.Custom, signer, { networkAddress, reputationOracleEndpoint: reputationOracleUrl.href, + disableVersionCheck: true, }); } @@ -58,6 +59,7 @@ const getNetworkClient = async (signerOrProvider?: SignerOrProvider) => { import.meta.env.NETWORK_CONTRACT_ADDRESS || ColonyNetworkAddress[network], reputationOracleEndpoint: reputationOracleUrl.href, + disableVersionCheck: true, }, ); };