From e00141de3d06e0b307f50f8ac458e16085ed2f37 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 09:27:02 +0200 Subject: [PATCH 01/27] fix : avalancheFuji to avalancheFujiTestnet for hardhat network --- deployments/{avalancheFuji => avalancheFujiTestnet}/.chainId | 0 .../{avalancheFuji => avalancheFujiTestnet}/AppRegistry.json | 0 .../DatasetRegistry.json | 0 .../ENSIntegrationDelegate.json | 0 .../{avalancheFuji => avalancheFujiTestnet}/ENSRegistry.json | 0 .../{avalancheFuji => avalancheFujiTestnet}/ERC1538Proxy.json | 0 .../ERC1538QueryDelegate.json | 0 .../ERC1538UpdateDelegate.json | 0 .../{avalancheFuji => avalancheFujiTestnet}/FIFSRegistrar.json | 0 .../IexecAccessorsABILegacyDelegate.json | 0 .../IexecAccessorsDelegate.json | 0 .../IexecCategoryManagerDelegate.json | 0 .../IexecERC20Delegate.json | 0 .../IexecEscrowTokenDelegate.json | 0 .../IexecLibOrders_v5.json | 0 .../IexecMaintenanceDelegate.json | 0 .../IexecMaintenanceExtraDelegate.json | 0 .../IexecOrderManagementDelegate.json | 0 .../IexecPoco1Delegate.json | 0 .../IexecPoco2Delegate.json | 0 .../IexecPocoAccessorsDelegate.json | 0 .../IexecPocoBoostAccessorsDelegate.json | 0 .../IexecPocoBoostDelegate.json | 0 .../IexecRelayDelegate.json | 0 .../{avalancheFuji => avalancheFujiTestnet}/PublicResolver.json | 0 deployments/{avalancheFuji => avalancheFujiTestnet}/RLC.json | 0 .../ReverseRegistrar.json | 0 .../WorkerpoolRegistry.json | 0 package.json | 2 +- 29 files changed, 1 insertion(+), 1 deletion(-) rename deployments/{avalancheFuji => avalancheFujiTestnet}/.chainId (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/AppRegistry.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/DatasetRegistry.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/ENSIntegrationDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/ENSRegistry.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/ERC1538Proxy.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/ERC1538QueryDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/ERC1538UpdateDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/FIFSRegistrar.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecAccessorsABILegacyDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecAccessorsDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecCategoryManagerDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecERC20Delegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecEscrowTokenDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecLibOrders_v5.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecMaintenanceDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecMaintenanceExtraDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecOrderManagementDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecPoco1Delegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecPoco2Delegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecPocoAccessorsDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecPocoBoostAccessorsDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecPocoBoostDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/IexecRelayDelegate.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/PublicResolver.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/RLC.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/ReverseRegistrar.json (100%) rename deployments/{avalancheFuji => avalancheFujiTestnet}/WorkerpoolRegistry.json (100%) diff --git a/deployments/avalancheFuji/.chainId b/deployments/avalancheFujiTestnet/.chainId similarity index 100% rename from deployments/avalancheFuji/.chainId rename to deployments/avalancheFujiTestnet/.chainId diff --git a/deployments/avalancheFuji/AppRegistry.json b/deployments/avalancheFujiTestnet/AppRegistry.json similarity index 100% rename from deployments/avalancheFuji/AppRegistry.json rename to deployments/avalancheFujiTestnet/AppRegistry.json diff --git a/deployments/avalancheFuji/DatasetRegistry.json b/deployments/avalancheFujiTestnet/DatasetRegistry.json similarity index 100% rename from deployments/avalancheFuji/DatasetRegistry.json rename to deployments/avalancheFujiTestnet/DatasetRegistry.json diff --git a/deployments/avalancheFuji/ENSIntegrationDelegate.json b/deployments/avalancheFujiTestnet/ENSIntegrationDelegate.json similarity index 100% rename from deployments/avalancheFuji/ENSIntegrationDelegate.json rename to deployments/avalancheFujiTestnet/ENSIntegrationDelegate.json diff --git a/deployments/avalancheFuji/ENSRegistry.json b/deployments/avalancheFujiTestnet/ENSRegistry.json similarity index 100% rename from deployments/avalancheFuji/ENSRegistry.json rename to deployments/avalancheFujiTestnet/ENSRegistry.json diff --git a/deployments/avalancheFuji/ERC1538Proxy.json b/deployments/avalancheFujiTestnet/ERC1538Proxy.json similarity index 100% rename from deployments/avalancheFuji/ERC1538Proxy.json rename to deployments/avalancheFujiTestnet/ERC1538Proxy.json diff --git a/deployments/avalancheFuji/ERC1538QueryDelegate.json b/deployments/avalancheFujiTestnet/ERC1538QueryDelegate.json similarity index 100% rename from deployments/avalancheFuji/ERC1538QueryDelegate.json rename to deployments/avalancheFujiTestnet/ERC1538QueryDelegate.json diff --git a/deployments/avalancheFuji/ERC1538UpdateDelegate.json b/deployments/avalancheFujiTestnet/ERC1538UpdateDelegate.json similarity index 100% rename from deployments/avalancheFuji/ERC1538UpdateDelegate.json rename to deployments/avalancheFujiTestnet/ERC1538UpdateDelegate.json diff --git a/deployments/avalancheFuji/FIFSRegistrar.json b/deployments/avalancheFujiTestnet/FIFSRegistrar.json similarity index 100% rename from deployments/avalancheFuji/FIFSRegistrar.json rename to deployments/avalancheFujiTestnet/FIFSRegistrar.json diff --git a/deployments/avalancheFuji/IexecAccessorsABILegacyDelegate.json b/deployments/avalancheFujiTestnet/IexecAccessorsABILegacyDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecAccessorsABILegacyDelegate.json rename to deployments/avalancheFujiTestnet/IexecAccessorsABILegacyDelegate.json diff --git a/deployments/avalancheFuji/IexecAccessorsDelegate.json b/deployments/avalancheFujiTestnet/IexecAccessorsDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecAccessorsDelegate.json rename to deployments/avalancheFujiTestnet/IexecAccessorsDelegate.json diff --git a/deployments/avalancheFuji/IexecCategoryManagerDelegate.json b/deployments/avalancheFujiTestnet/IexecCategoryManagerDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecCategoryManagerDelegate.json rename to deployments/avalancheFujiTestnet/IexecCategoryManagerDelegate.json diff --git a/deployments/avalancheFuji/IexecERC20Delegate.json b/deployments/avalancheFujiTestnet/IexecERC20Delegate.json similarity index 100% rename from deployments/avalancheFuji/IexecERC20Delegate.json rename to deployments/avalancheFujiTestnet/IexecERC20Delegate.json diff --git a/deployments/avalancheFuji/IexecEscrowTokenDelegate.json b/deployments/avalancheFujiTestnet/IexecEscrowTokenDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecEscrowTokenDelegate.json rename to deployments/avalancheFujiTestnet/IexecEscrowTokenDelegate.json diff --git a/deployments/avalancheFuji/IexecLibOrders_v5.json b/deployments/avalancheFujiTestnet/IexecLibOrders_v5.json similarity index 100% rename from deployments/avalancheFuji/IexecLibOrders_v5.json rename to deployments/avalancheFujiTestnet/IexecLibOrders_v5.json diff --git a/deployments/avalancheFuji/IexecMaintenanceDelegate.json b/deployments/avalancheFujiTestnet/IexecMaintenanceDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecMaintenanceDelegate.json rename to deployments/avalancheFujiTestnet/IexecMaintenanceDelegate.json diff --git a/deployments/avalancheFuji/IexecMaintenanceExtraDelegate.json b/deployments/avalancheFujiTestnet/IexecMaintenanceExtraDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecMaintenanceExtraDelegate.json rename to deployments/avalancheFujiTestnet/IexecMaintenanceExtraDelegate.json diff --git a/deployments/avalancheFuji/IexecOrderManagementDelegate.json b/deployments/avalancheFujiTestnet/IexecOrderManagementDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecOrderManagementDelegate.json rename to deployments/avalancheFujiTestnet/IexecOrderManagementDelegate.json diff --git a/deployments/avalancheFuji/IexecPoco1Delegate.json b/deployments/avalancheFujiTestnet/IexecPoco1Delegate.json similarity index 100% rename from deployments/avalancheFuji/IexecPoco1Delegate.json rename to deployments/avalancheFujiTestnet/IexecPoco1Delegate.json diff --git a/deployments/avalancheFuji/IexecPoco2Delegate.json b/deployments/avalancheFujiTestnet/IexecPoco2Delegate.json similarity index 100% rename from deployments/avalancheFuji/IexecPoco2Delegate.json rename to deployments/avalancheFujiTestnet/IexecPoco2Delegate.json diff --git a/deployments/avalancheFuji/IexecPocoAccessorsDelegate.json b/deployments/avalancheFujiTestnet/IexecPocoAccessorsDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecPocoAccessorsDelegate.json rename to deployments/avalancheFujiTestnet/IexecPocoAccessorsDelegate.json diff --git a/deployments/avalancheFuji/IexecPocoBoostAccessorsDelegate.json b/deployments/avalancheFujiTestnet/IexecPocoBoostAccessorsDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecPocoBoostAccessorsDelegate.json rename to deployments/avalancheFujiTestnet/IexecPocoBoostAccessorsDelegate.json diff --git a/deployments/avalancheFuji/IexecPocoBoostDelegate.json b/deployments/avalancheFujiTestnet/IexecPocoBoostDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecPocoBoostDelegate.json rename to deployments/avalancheFujiTestnet/IexecPocoBoostDelegate.json diff --git a/deployments/avalancheFuji/IexecRelayDelegate.json b/deployments/avalancheFujiTestnet/IexecRelayDelegate.json similarity index 100% rename from deployments/avalancheFuji/IexecRelayDelegate.json rename to deployments/avalancheFujiTestnet/IexecRelayDelegate.json diff --git a/deployments/avalancheFuji/PublicResolver.json b/deployments/avalancheFujiTestnet/PublicResolver.json similarity index 100% rename from deployments/avalancheFuji/PublicResolver.json rename to deployments/avalancheFujiTestnet/PublicResolver.json diff --git a/deployments/avalancheFuji/RLC.json b/deployments/avalancheFujiTestnet/RLC.json similarity index 100% rename from deployments/avalancheFuji/RLC.json rename to deployments/avalancheFujiTestnet/RLC.json diff --git a/deployments/avalancheFuji/ReverseRegistrar.json b/deployments/avalancheFujiTestnet/ReverseRegistrar.json similarity index 100% rename from deployments/avalancheFuji/ReverseRegistrar.json rename to deployments/avalancheFujiTestnet/ReverseRegistrar.json diff --git a/deployments/avalancheFuji/WorkerpoolRegistry.json b/deployments/avalancheFujiTestnet/WorkerpoolRegistry.json similarity index 100% rename from deployments/avalancheFuji/WorkerpoolRegistry.json rename to deployments/avalancheFujiTestnet/WorkerpoolRegistry.json diff --git a/package.json b/package.json index b73f4442e..10bb7d647 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "clean": "rm -rf deployments/hardhat", "test": "npm run clean && REPORT_GAS=true npx hardhat test", "test:arbitrumSepolia": "npm run clean && ARBITRUM_SEPOLIA_FORK=true npx hardhat test", - "test:avalancheFuji": "npm run clean && FUJI_FORK=true npx hardhat test", + "test:avalancheFujiTestnet": "npm run clean && FUJI_FORK=true npx hardhat test", "test:native": "npm run clean && TEST__IS_NATIVE_CHAIN=true npx hardhat test test/byContract/IexecEscrow/IexecEscrowNative.test.ts", "coverage": "npx hardhat coverage", "verify": "npx hardhat verify", From 5ef06ce136db5a7a1c4e062296ab217602c27da2 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 09:31:06 +0200 Subject: [PATCH 02/27] fix: rename avalancheFuji to avalancheFujiTestnet and update related configurations --- hardhat.config.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index 32aa0b125..92c7b62cd 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -175,10 +175,10 @@ const config: HardhatUserConfig = { }, }, // Add Fuji as a network - avalancheFuji: { + avalancheFujiTestnet: { url: process.env.FUJI_RPC_URL || 'https://api.avax-test.network/ext/bc/C/rpc', accounts: [ - process.env.DEV_PRIVATE_KEY || + process.env.PRIVATE_KEY || '0x0000000000000000000000000000000000000000000000000000000000000000', ], ...fujiBaseConfig, @@ -187,7 +187,7 @@ const config: HardhatUserConfig = { arbitrumSepolia: { url: process.env.ARBITRUM_SEPOLIA_RPC_URL || 'https://sepolia-rollup.arbitrum.io/rpc', accounts: [ - process.env.DEV_PRIVATE_KEY || + process.env.PRIVATE_KEY || '0x0000000000000000000000000000000000000000000000000000000000000000', ], ...arbitrumSepoliaBaseConfig, @@ -204,7 +204,7 @@ const config: HardhatUserConfig = { chainId: 134, url: 'https://bellecour.iex.ec', accounts: [ - process.env.PROD_PRIVATE_KEY || + process.env.PRIVATE_KEY || '0x0000000000000000000000000000000000000000000000000000000000000000', ], ...bellecourBaseConfig, @@ -219,7 +219,7 @@ const config: HardhatUserConfig = { etherscan: { apiKey: { mainnet: process.env.ETHERSCAN_API_KEY || '', - avalancheFuji: 'nothing', // a non-empty string is needed by the plugin. + avalancheFujiTestnet: 'nothing', // a non-empty string is needed by the plugin. arbitrumSepolia: process.env.ARBISCAN_API_KEY || '', viviani: 'nothing', // a non-empty string is needed by the plugin. bellecour: 'nothing', // a non-empty string is needed by the plugin. @@ -243,6 +243,9 @@ const config: HardhatUserConfig = { }, ], }, + sourcify: { + enabled: true, + }, typechain: { outDir: 'typechain', }, @@ -316,7 +319,7 @@ task('test').setAction(async (taskArgs: any, hre, runSuper) => { networkName = 'arbitrumSepolia'; deploymentsCopied = await copyDeployments(networkName); } else if (process.env.FUJI_FORK === 'true') { - networkName = 'avalancheFuji'; + networkName = 'avalancheFujiTestnet'; deploymentsCopied = await copyDeployments(networkName); } await runSuper(taskArgs); From 619063556bde444ed9aa53b05b2886e2b5897e00 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 11:13:33 +0200 Subject: [PATCH 03/27] fix: include bytecode and args in deployment saving process --- scripts/boost/0_deploy-modules.ts | 1 + utils/deploy-tools.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/boost/0_deploy-modules.ts b/scripts/boost/0_deploy-modules.ts index d8b3df8cc..5be989281 100644 --- a/scripts/boost/0_deploy-modules.ts +++ b/scripts/boost/0_deploy-modules.ts @@ -42,6 +42,7 @@ const genericFactoryAddress = require('@amxx/factory/deployments/GenericFactory. await deployments.save(module.name, { abi: [], address: moduleAddress, + bytecode: module.bytecode, }); } })(); diff --git a/utils/deploy-tools.ts b/utils/deploy-tools.ts index 379969e83..761bbd0a0 100644 --- a/utils/deploy-tools.ts +++ b/utils/deploy-tools.ts @@ -19,15 +19,19 @@ export async function deploy( constructorArgs?: any[], opts?: { quiet: boolean }, ) { + const args = constructorArgs ?? []; const contractInstance = await contractFactory .connect(deployer) - .deploy(...(constructorArgs ?? [])) + .deploy(...args) .then((x) => x.waitForDeployment()); const contractName = getBaseNameFromContractFactory(contractFactory); const contractAddress = await contractInstance.getAddress(); await deployments.save(contractName, { abi: (contractFactory as any).constructor.abi, address: contractAddress, + args: args, + bytecode: contractFactory.bytecode, + deployedBytecode: (await contractFactory.getDeployTransaction(...args)).data, }); if (!opts || (opts && !opts.quiet)) { console.log(`${contractName}: ${contractAddress}`); From df8c19d8f32618bf5c2f0de2c14c57b938af599f Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 11:33:51 +0200 Subject: [PATCH 04/27] fix: update verification script path and enhance error handling --- scripts/sponsoring/README.md | 2 +- scripts/sponsoring/verify.ts | 22 ------------------ scripts/verify.ts | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 23 deletions(-) delete mode 100644 scripts/sponsoring/verify.ts create mode 100644 scripts/verify.ts diff --git a/scripts/sponsoring/README.md b/scripts/sponsoring/README.md index b8faf6760..311676691 100644 --- a/scripts/sponsoring/README.md +++ b/scripts/sponsoring/README.md @@ -51,7 +51,7 @@ npx hardhat --network bellecour etherscan-verify ``` and embedded `hardhat-verify` plugin of `hardhat` (v2.22.12): ``` -npx hardhat run ./scripts/sponsoring/verify.ts --network bellecour +npx hardhat run ./scripts/verify.ts --network bellecour ``` by previously modifiying the `.json` file produced by: ``` diff --git a/scripts/sponsoring/verify.ts b/scripts/sponsoring/verify.ts deleted file mode 100644 index 3fa7c209d..000000000 --- a/scripts/sponsoring/verify.ts +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH -// SPDX-License-Identifier: Apache-2.0 - -import fs from 'fs'; -import hre, { deployments } from 'hardhat'; -import path from 'path'; - -(async () => { - const jsonExtension = '.json'; - const contractNames = fs - .readdirSync(path.resolve(__dirname, `../../deployments/${hre.network.name}`)) - .filter((file) => file.endsWith(jsonExtension)) - .map((filePath) => filePath.replace(jsonExtension, '')); - console.log(`Contracts to verify: ${contractNames}`); - for (const contractName of contractNames) { - console.log(`Verifying ${contractName}..`); - const address = (await deployments.get(contractName)).address; - await hre.run('verify:verify', { - address, - }); - } -})(); diff --git a/scripts/verify.ts b/scripts/verify.ts new file mode 100644 index 000000000..f3b0bd6c4 --- /dev/null +++ b/scripts/verify.ts @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2024-2025 IEXEC BLOCKCHAIN TECH +// SPDX-License-Identifier: Apache-2.0 + +import fs from 'fs'; +import hre, { deployments } from 'hardhat'; +import path from 'path'; + +(async () => { + const jsonExtension = '.json'; + const contractNames = fs + .readdirSync(path.resolve(__dirname, `../deployments/${hre.network.name}`)) + .filter((file) => file.endsWith(jsonExtension)) + .map((filePath) => filePath.replace(jsonExtension, '')); + + console.log(`Contracts to verify: ${contractNames}`); + + for (const contractName of contractNames) { + try { + console.log(`Verifying ${contractName}..`); + const deployment = await deployments.get(contractName); + const address = deployment.address; + const constructorArguments = deployment.args || []; + await hre.run('verify:verify', { + address, + constructorArguments, + }); + + console.log(`${contractName} verified successfully`); + } catch (error: any) { + console.error(`Error verifying ${contractName}:`, error.message || error); + if ( + typeof error.message === 'string' && + error.message.includes('has') && + error.message.includes('parameters but') && + error.message.includes('arguments were provided') + ) { + console.error( + `${contractName} requires constructor arguments. Please add them to the deployment artifact.`, + ); + } + } + } +})(); From 7fef22fe99f2b971e685985dc87c75b35ee4b801 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 12:08:44 +0200 Subject: [PATCH 05/27] feat: add deployment workflow and update config script for new networks --- .github/workflows/deploy-smart-contracts.yml | 102 +++++++++++++++++++ scripts/tools/update-config.js | 54 ++++++++++ 2 files changed, 156 insertions(+) create mode 100644 .github/workflows/deploy-smart-contracts.yml create mode 100644 scripts/tools/update-config.js diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml new file mode 100644 index 000000000..343b619d0 --- /dev/null +++ b/.github/workflows/deploy-smart-contracts.yml @@ -0,0 +1,102 @@ +name: Deploy PoCo Contracts +on: + workflow_dispatch: + inputs: + network: + description: 'Target Network' + required: true + type: choice + options: + - hardhat + - avalancheFujiTestnet + - arbitrumSepolia + - bellecour + environment: + description: 'Deployment Environment' + required: true + type: choice + options: + - develop + - production + default: 'develop' + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: write # Required for saving deployment + environment: ${{ inputs.environment }} # Use the selected environment + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Nodejs + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' # Cache dependencies + + - name: Install dependencies + run: npm ci + + - name: Run tests + if: inputs.environment != 'production' + run: | + if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then + npm run test:arbitrumSepolia + elif [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then + npm run test:fuji + else + npm run test + fi + + - name: Deploy contracts + env: + PRIVATE_KEY: ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }} + FUJI_RPC_URL: ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }} + ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }} + BELLECOUR_RPC_URL: ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }} + run: | + echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment" + npm run deploy -- --network ${{ inputs.network }} + + - name: Update config.json with ERC1538Proxy address + run: | + if [ -f "deployments/${{ inputs.network }}/ERC1538Proxy.json" ]; then + PROXY_ADDRESS=$(jq -r '.address' deployments/${{ inputs.network }}/ERC1538Proxy.json) + # Verify we have an address before updating + if [ -n "$PROXY_ADDRESS" ] && [ "$PROXY_ADDRESS" != "null" ]; then + echo "Found ERC1538Proxy address: $PROXY_ADDRESS" + # Update config.json using our script + node scripts/update-config.js "${{ inputs.network }}" "ERC1538Proxy" "$PROXY_ADDRESS" + else + echo "Failed to extract a valid ERC1538Proxy address" + fi + else + echo "ERC1538Proxy deployment file not found. Skipping config update." + fi + + - name: Save deployment artifacts and updated config + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})" + file_pattern: 'deployments/${{ inputs.network }}/* config/config.json' + commit_user_name: "GitHub Actions Bot" + commit_user_email: "github-actions[bot]@users.noreply.github.com" + commit_author: "GitHub Actions Bot " + + - name: Verify contracts + if: inputs.network != 'hardhat' + env: + PRIVATE_KEY: ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }} + FUJI_RPC_URL: ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }} + ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }} + BELLECOUR_RPC_URL: ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }} + ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} + ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} + SNOWTRACE_API_KEY: ${{ secrets.SNOWTRACE_API_KEY }} + run: | + # Add a delay to allow block explorers to index the contracts + echo "Waiting for contracts to be indexed..." + sleep 60 + npx hardhat run ./scripts/verify.ts --network ${{ inputs.network }} diff --git a/scripts/tools/update-config.js b/scripts/tools/update-config.js new file mode 100644 index 000000000..838395661 --- /dev/null +++ b/scripts/tools/update-config.js @@ -0,0 +1,54 @@ +import fs from "fs"; +import path from "path"; + +// Map network names to chain IDs +const NETWORK_TO_CHAIN_ID = { + hardhat: "31337", + avalancheFujiTestnet: "43113", + arbitrumSepolia: "421614", + bellecour: "134" +}; + +// Get arguments from command line +const [networkName, contractKey, contractAddress] = process.argv.slice(2); + +if (!networkName || !contractKey || !contractAddress) { + console.error("Usage: node update-config.js
"); + process.exit(1); +} + +const chainId = NETWORK_TO_CHAIN_ID[networkName]; +if (!chainId) { + console.error(`Unknown network: ${networkName}`); + process.exit(1); +} + +// Read config file +const configPath = path.resolve("config/config.json"); +const config = JSON.parse(fs.readFileSync(configPath, "utf8")); + +// Ensure the chain structure exists +if (!config.chains) { + config.chains = {}; +} + +if (!config.chains[chainId]) { + config.chains[chainId] = { + v5: {} + }; +} + +if (!config.chains[chainId].v5) { + config.chains[chainId].v5 = {}; +} + +// Update the contract address +const previousValue = config.chains[chainId].v5[contractKey] || "null"; +config.chains[chainId].v5[contractKey] = contractAddress; + +// Write the updated config back to file +fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + +console.log(`Updated ${chainId}.v5.${contractKey}:`); +console.log(`Previous: ${previousValue}`); +console.log(`New: ${contractAddress}`); From adf39e522bc49867ea45b9e57b3a17df5e0fde7a Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 14:25:25 +0200 Subject: [PATCH 06/27] docs: enhance deployment instructions and add GitHub Actions workflow details --- README.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3221d8a7d..d2febb966 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# iExec PoCo Smart Contracts + [![codecov](https://codecov.io/github/iExecBlockchainComputing/PoCo/graph/badge.svg)](https://codecov.io/github/iExecBlockchainComputing/PoCo) # Introduction @@ -117,23 +119,69 @@ npm run test ## Deploy -You can deploy the smart contracts according to the [deploy/0_deploy.ts](./deploy/0_deploy.ts) content. This will automatically save some addresses of the deployed artifacts to the `./build` folder. +The iExec PoCo contracts support automated deployment through both command-line interface and GitHub Actions workflows. + +### Command Line Deployment + +You can deploy the smart contracts according to the [deploy/0_deploy.ts](./deploy/0_deploy.ts) content. This will automatically save some addresses of the deployed artifacts to the `./deployments` folder. -To do so: +To deploy using the CLI: -1. Make sure you followed the "Configure a deployment" section; -2. Enter your targeted blockchain parameters in `hardhat.config.ts` configuration file; +1. Make sure you followed the "Configure a deployment" section above +2. Enter your targeted blockchain parameters in `hardhat.config.ts` 3. Run the deployment using: + ``` npx hardhat deploy --network ``` -Example of "complex" deployment: +Example with custom salt: ``` SALT=0x0000000000000000000000000000000000000000000000000000000000000001 npx hardhat deploy --network hardhat ``` +### GitHub Actions Deployment + +For production deployments, we use GitHub Actions to automate the process with enhanced security. The workflow allows deploying to different networks with different environment configurations (development or production). + +To deploy using GitHub Actions: + +1. Navigate to the Actions tab in your GitHub repository +2. Select the "Deploy PoCo Contracts" workflow +3. Click "Run workflow" +4. Choose the target network from the dropdown +5. Select the deployment environment (develop or production) +6. Start the workflow + +The workflow will: +1. Run tests for the target network (only in development environment) +2. Deploy the contracts using the appropriate environment keys +3. Update the `config.json` file with the deployed contract addresses +4. Commit the deployment artifacts and updated configuration back to the repository +5. Wait for the contracts to be indexed by the block explorer +6. Verify the contracts on the blockchain explorer + +## Contract Verification + +After deploying contracts, you can verify them on block explorers to make their source code publicly available. + +### Manual Verification + +To manually verify contracts: + +``` +npx hardhat run ./scripts/verify.ts --network +``` + +This script automatically reads all deployed contract addresses and their constructor arguments from the deployment artifacts and verifies them on the relevant block explorer. + +### Automated Verification via GitHub Actions + +The GitHub Actions workflow automatically handles contract verification after deployment. It waits 60 seconds for the contracts to be indexed by the block explorer before attempting verification. + +The verification process uses the same script (`./scripts/verify.ts`) that reads deployment artifacts to verify each contract with its correct constructor arguments. + ## Formatting Format a specific file or files in a directory: From bad70928e50361906c600810048d5c754305cc0e Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 14:35:15 +0200 Subject: [PATCH 07/27] add entry to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac3486ea9..79ed2c7d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - [x] `IexecPoco2Delegate.sol` ### Features +- Add gitub action workflow for deployment (#218) - Fix new testnets chain name (#217) - Deploy on new testnet chains using CreateX factory (#216) - Add CreateX factory for new chain deployment (#215) From cb0e5a0a08480cf8ce2eccc94a581b76d6f883d3 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 14:56:40 +0200 Subject: [PATCH 08/27] fix: add condition to skip config update and artifact saving for hardhat network --- .github/workflows/deploy-smart-contracts.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 343b619d0..9259d5786 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -61,6 +61,7 @@ jobs: npm run deploy -- --network ${{ inputs.network }} - name: Update config.json with ERC1538Proxy address + if: inputs.network != 'hardhat' run: | if [ -f "deployments/${{ inputs.network }}/ERC1538Proxy.json" ]; then PROXY_ADDRESS=$(jq -r '.address' deployments/${{ inputs.network }}/ERC1538Proxy.json) @@ -77,6 +78,7 @@ jobs: fi - name: Save deployment artifacts and updated config + if: inputs.network != 'hardhat' uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})" From 1897a09ee291d1e78584c7e1b90a322f2ccd5150 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 15:57:51 +0200 Subject: [PATCH 09/27] refactor: simplify environment variable handling in deployment workflow --- .github/workflows/deploy-smart-contracts.yml | 77 ++++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 9259d5786..59d882547 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -3,42 +3,42 @@ on: workflow_dispatch: inputs: network: - description: 'Target Network' + description: 'Network' required: true type: choice options: - hardhat - - avalancheFujiTestnet + - avalancheFujiTestnet - arbitrumSepolia - bellecour environment: - description: 'Deployment Environment' + description: 'Environment' required: true type: choice options: - - develop - - production + - develop + - production default: 'develop' jobs: deploy: runs-on: ubuntu-latest permissions: - contents: write # Required for saving deployment - environment: ${{ inputs.environment }} # Use the selected environment + contents: write # Required for saving deployment + environment: ${{ inputs.environment }} # Use the selected environment steps: - name: Checkout uses: actions/checkout@v4 - + - name: Set up Nodejs uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' # Cache dependencies - + - name: Install dependencies run: npm ci - + - name: Run tests if: inputs.environment != 'production' run: | @@ -49,17 +49,33 @@ jobs: else npm run test fi - + + - name: Set environment variables + id: set-env + run: | + if [ "${{ inputs.environment }}" == "production" ]; then + echo "PRIVATE_KEY=${{ secrets.PROD_PRIVATE_KEY }}" >> $GITHUB_ENV + else + echo "PRIVATE_KEY=${{ secrets. DEV_PRIVATE_KEY }}" >> $GITHUB_ENV + fi + + if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then + echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV + fi + + if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then + echo "ARBITRUM_SEPOLIA_RPC_URL=${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}" >> $GITHUB_ENV + fi + + if [ "${{ inputs.network }}" == "bellecour" ]; then + echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV + fi + - name: Deploy contracts - env: - PRIVATE_KEY: ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }} - FUJI_RPC_URL: ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }} - ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }} - BELLECOUR_RPC_URL: ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }} run: | echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment" npm run deploy -- --network ${{ inputs.network }} - + - name: Update config.json with ERC1538Proxy address if: inputs.network != 'hardhat' run: | @@ -76,27 +92,26 @@ jobs: else echo "ERC1538Proxy deployment file not found. Skipping config update." fi - + - name: Save deployment artifacts and updated config if: inputs.network != 'hardhat' uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})" + commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})' file_pattern: 'deployments/${{ inputs.network }}/* config/config.json' - commit_user_name: "GitHub Actions Bot" - commit_user_email: "github-actions[bot]@users.noreply.github.com" - commit_author: "GitHub Actions Bot " - + commit_user_name: 'GitHub Actions Bot' + commit_user_email: 'github-actions[bot]@users.noreply.github.com' + commit_author: 'GitHub Actions Bot ' + + - name: Set verification environment variables + if: inputs.network != 'hardhat' + run: | + echo "ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}" >> $GITHUB_ENV + echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV + echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV + - name: Verify contracts if: inputs.network != 'hardhat' - env: - PRIVATE_KEY: ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }} - FUJI_RPC_URL: ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }} - ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }} - BELLECOUR_RPC_URL: ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }} - ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} - ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} - SNOWTRACE_API_KEY: ${{ secrets.SNOWTRACE_API_KEY }} run: | # Add a delay to allow block explorers to index the contracts echo "Waiting for contracts to be indexed..." From 988984183d20a5d2b3f84cc23e0bb3d71093255d Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Fri, 25 Apr 2025 16:31:42 +0200 Subject: [PATCH 10/27] fix: set default network option to 'hardhat' in deployment workflow --- .github/workflows/deploy-smart-contracts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 59d882547..a3a8e65df 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -11,6 +11,7 @@ on: - avalancheFujiTestnet - arbitrumSepolia - bellecour + default: 'hardhat' environment: description: 'Environment' required: true From dffaef7b697154eded445646cc8dc9038583f5d0 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 5 May 2025 13:44:58 +0200 Subject: [PATCH 11/27] fix: update environment options name --- .github/workflows/deploy-smart-contracts.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index a3a8e65df..d0e725cd4 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -17,9 +17,9 @@ on: required: true type: choice options: - - develop - - production - default: 'develop' + - testnets + - mainnets + default: 'testnets' jobs: deploy: @@ -41,7 +41,7 @@ jobs: run: npm ci - name: Run tests - if: inputs.environment != 'production' + if: inputs.environment != 'mainnets' run: | if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then npm run test:arbitrumSepolia @@ -54,11 +54,7 @@ jobs: - name: Set environment variables id: set-env run: | - if [ "${{ inputs.environment }}" == "production" ]; then - echo "PRIVATE_KEY=${{ secrets.PROD_PRIVATE_KEY }}" >> $GITHUB_ENV - else - echo "PRIVATE_KEY=${{ secrets. DEV_PRIVATE_KEY }}" >> $GITHUB_ENV - fi + echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV From fa2a482b7b42ce7b05d10a01adbb635a1fb1506d Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 5 May 2025 13:56:14 +0200 Subject: [PATCH 12/27] refactor(ci): combine environment variables steps in deploy workflow --- .github/workflows/deploy-smart-contracts.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index d0e725cd4..45a3cea11 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -55,7 +55,6 @@ jobs: id: set-env run: | echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV - if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV fi @@ -67,6 +66,11 @@ jobs: if [ "${{ inputs.network }}" == "bellecour" ]; then echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV fi + if [ "${{ inputs.network }}" != "hardhat" ]; then + echo "ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}" >> $GITHUB_ENV + echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV + echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV + fi - name: Deploy contracts run: | @@ -100,13 +104,6 @@ jobs: commit_user_email: 'github-actions[bot]@users.noreply.github.com' commit_author: 'GitHub Actions Bot ' - - name: Set verification environment variables - if: inputs.network != 'hardhat' - run: | - echo "ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}" >> $GITHUB_ENV - echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV - echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV - - name: Verify contracts if: inputs.network != 'hardhat' run: | From 6343461f23731d9dd903e9c55845c63f86294f7a Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 5 May 2025 16:24:30 +0200 Subject: [PATCH 13/27] feat(deploy): integrate contract verification into deployment process --- .github/workflows/deploy-smart-contracts.yml | 8 -------- deploy/0_deploy.ts | 9 ++++++++- scripts/verify.ts | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 45a3cea11..b4e258ebd 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -103,11 +103,3 @@ jobs: commit_user_name: 'GitHub Actions Bot' commit_user_email: 'github-actions[bot]@users.noreply.github.com' commit_author: 'GitHub Actions Bot ' - - - name: Verify contracts - if: inputs.network != 'hardhat' - run: | - # Add a delay to allow block explorers to index the contracts - echo "Waiting for contracts to be indexed..." - sleep 60 - npx hardhat run ./scripts/verify.ts --network ${{ inputs.network }} diff --git a/deploy/0_deploy.ts b/deploy/0_deploy.ts index f3ba03857..92b30c7e9 100644 --- a/deploy/0_deploy.ts +++ b/deploy/0_deploy.ts @@ -53,7 +53,8 @@ import { linkContractToProxy } from '../utils/proxy-tools'; */ export default async function deploy() { console.log('Deploying PoCo..'); - const chainId = (await ethers.provider.getNetwork()).chainId; + const network = await ethers.provider.getNetwork(); + const chainId = network.chainId; const [owner] = await ethers.getSigners(); const deploymentOptions = config.getChainConfigOrDefault(chainId); const factoryDeployer = new FactoryDeployer(owner, chainId); @@ -209,6 +210,12 @@ export default async function deploy() { for (let i = 0; i < Number(catCountAfter); i++) { console.log(`Category ${i}: ${await iexecAccessorsInstance.viewCategory(i)}`); } + + if (network.name !== 'hardhat' && network.name !== 'localhost') { + console.log('Waiting for block explorer to index the contracts...'); + await new Promise((resolve) => setTimeout(resolve, 60000)); + await import('../scripts/verify').then((module) => module.default()); + } } async function getOrDeployRlc(token: string, owner: SignerWithAddress) { diff --git a/scripts/verify.ts b/scripts/verify.ts index f3b0bd6c4..0758a45c7 100644 --- a/scripts/verify.ts +++ b/scripts/verify.ts @@ -5,7 +5,7 @@ import fs from 'fs'; import hre, { deployments } from 'hardhat'; import path from 'path'; -(async () => { +async function verify() { const jsonExtension = '.json'; const contractNames = fs .readdirSync(path.resolve(__dirname, `../deployments/${hre.network.name}`)) @@ -40,4 +40,15 @@ import path from 'path'; } } } -})(); +} + +if (require.main === module) { + verify() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); +} + +export default verify; From 7d39f189d32a847c54577ffe91f7ab3d2e61dd00 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 5 May 2025 16:30:52 +0200 Subject: [PATCH 14/27] refactor(docs): remove redundant GitHub Actions deployment and verification sections from README --- README.md | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/README.md b/README.md index d2febb966..039405fe7 100644 --- a/README.md +++ b/README.md @@ -141,30 +141,6 @@ Example with custom salt: SALT=0x0000000000000000000000000000000000000000000000000000000000000001 npx hardhat deploy --network hardhat ``` -### GitHub Actions Deployment - -For production deployments, we use GitHub Actions to automate the process with enhanced security. The workflow allows deploying to different networks with different environment configurations (development or production). - -To deploy using GitHub Actions: - -1. Navigate to the Actions tab in your GitHub repository -2. Select the "Deploy PoCo Contracts" workflow -3. Click "Run workflow" -4. Choose the target network from the dropdown -5. Select the deployment environment (develop or production) -6. Start the workflow - -The workflow will: -1. Run tests for the target network (only in development environment) -2. Deploy the contracts using the appropriate environment keys -3. Update the `config.json` file with the deployed contract addresses -4. Commit the deployment artifacts and updated configuration back to the repository -5. Wait for the contracts to be indexed by the block explorer -6. Verify the contracts on the blockchain explorer - -## Contract Verification - -After deploying contracts, you can verify them on block explorers to make their source code publicly available. ### Manual Verification @@ -176,11 +152,6 @@ npx hardhat run ./scripts/verify.ts --network This script automatically reads all deployed contract addresses and their constructor arguments from the deployment artifacts and verifies them on the relevant block explorer. -### Automated Verification via GitHub Actions - -The GitHub Actions workflow automatically handles contract verification after deployment. It waits 60 seconds for the contracts to be indexed by the block explorer before attempting verification. - -The verification process uses the same script (`./scripts/verify.ts`) that reads deployment artifacts to verify each contract with its correct constructor arguments. ## Formatting From 03e35cf82a799d760e0218dcea1a0e384995d9e1 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 5 May 2025 16:40:12 +0200 Subject: [PATCH 15/27] fix(ci): skip tests for mainnets environment in deployment workflow --- .github/workflows/deploy-smart-contracts.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index b4e258ebd..0bfbc0e60 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -41,7 +41,6 @@ jobs: run: npm ci - name: Run tests - if: inputs.environment != 'mainnets' run: | if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then npm run test:arbitrumSepolia From 2118ea95ba2b26c40bed4f28dc729fa9bed5f20c Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 5 May 2025 16:42:36 +0200 Subject: [PATCH 16/27] feat(ci): add validation for Bellecour mainnet deployments to ensure they are made from the main branch --- .github/workflows/deploy-smart-contracts.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 0bfbc0e60..fa1484b3b 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -22,7 +22,22 @@ on: default: 'testnets' jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Validate mainnet deployment conditions + run: | + if [[ "${{ inputs.environment }}" == "mainnets" && "${{ inputs.network }}" == "bellecour" && "${{ github.ref }}" != "refs/heads/main" ]]; then + echo "::error::Bellecour mainnet deployments must be made from the main branch. Current branch: ${GITHUB_REF#refs/heads/}" + exit 1 + fi + + echo "Deployment validation passed!" deploy: + needs: validate runs-on: ubuntu-latest permissions: contents: write # Required for saving deployment From 562aeae7508d125cc756e01d07350155bfa202e1 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 6 May 2025 10:56:46 +0200 Subject: [PATCH 17/27] fix(ci): update validation for Bellecour mainnet deployments to require main branch --- .github/workflows/deploy-smart-contracts.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index fa1484b3b..c1d1087aa 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -30,7 +30,8 @@ jobs: - name: Validate mainnet deployment conditions run: | - if [[ "${{ inputs.environment }}" == "mainnets" && "${{ inputs.network }}" == "bellecour" && "${{ github.ref }}" != "refs/heads/main" ]]; then + #TODO remove this when we have other mainnets + if [[ "${{ inputs.environment }}" == "mainnets" && !("${{ inputs.network }}" == "bellecour" && "${{ github.ref }}" == "refs/heads/main") ]]; then echo "::error::Bellecour mainnet deployments must be made from the main branch. Current branch: ${GITHUB_REF#refs/heads/}" exit 1 fi From ba5cb6ed9287634b3eb696c84f1786f38ee169cc Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 6 May 2025 10:59:17 +0200 Subject: [PATCH 18/27] feat(ci): add API key environment variables for Avalanche Fuji and Arbitrum Sepolia networks --- .github/workflows/deploy-smart-contracts.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index c1d1087aa..2b8382326 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -72,20 +72,17 @@ jobs: echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV + echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV fi if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then echo "ARBITRUM_SEPOLIA_RPC_URL=${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}" >> $GITHUB_ENV + echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV fi if [ "${{ inputs.network }}" == "bellecour" ]; then echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV fi - if [ "${{ inputs.network }}" != "hardhat" ]; then - echo "ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}" >> $GITHUB_ENV - echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV - echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV - fi - name: Deploy contracts run: | From 14cf5eb3e012ec0aea8feaba17f79d659066087c Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 6 May 2025 11:11:36 +0200 Subject: [PATCH 19/27] refactor(scripts): simplify update-config.js by removing unused parameters and improving error handling --- .github/workflows/deploy-smart-contracts.yml | 15 +---- scripts/tools/update-config.js | 59 ++++++++++++-------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 2b8382326..a80c99e50 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -91,20 +91,7 @@ jobs: - name: Update config.json with ERC1538Proxy address if: inputs.network != 'hardhat' - run: | - if [ -f "deployments/${{ inputs.network }}/ERC1538Proxy.json" ]; then - PROXY_ADDRESS=$(jq -r '.address' deployments/${{ inputs.network }}/ERC1538Proxy.json) - # Verify we have an address before updating - if [ -n "$PROXY_ADDRESS" ] && [ "$PROXY_ADDRESS" != "null" ]; then - echo "Found ERC1538Proxy address: $PROXY_ADDRESS" - # Update config.json using our script - node scripts/update-config.js "${{ inputs.network }}" "ERC1538Proxy" "$PROXY_ADDRESS" - else - echo "Failed to extract a valid ERC1538Proxy address" - fi - else - echo "ERC1538Proxy deployment file not found. Skipping config update." - fi + run: node scripts/tool/update-config.js "${{ inputs.network }}" - name: Save deployment artifacts and updated config if: inputs.network != 'hardhat' diff --git a/scripts/tools/update-config.js b/scripts/tools/update-config.js index 838395661..bfb3c2d41 100644 --- a/scripts/tools/update-config.js +++ b/scripts/tools/update-config.js @@ -1,49 +1,64 @@ -import fs from "fs"; -import path from "path"; +import fs from 'fs'; +import path from 'path'; // Map network names to chain IDs const NETWORK_TO_CHAIN_ID = { - hardhat: "31337", - avalancheFujiTestnet: "43113", - arbitrumSepolia: "421614", - bellecour: "134" + hardhat: '31337', + avalancheFujiTestnet: '43113', + arbitrumSepolia: '421614', + bellecour: '134', }; -// Get arguments from command line -const [networkName, contractKey, contractAddress] = process.argv.slice(2); +const [networkName] = process.argv.slice(2); -if (!networkName || !contractKey || !contractAddress) { - console.error("Usage: node update-config.js
"); - process.exit(1); +if (!networkName) { + console.error('Usage: node update-config.js '); + process.exit(1); } const chainId = NETWORK_TO_CHAIN_ID[networkName]; if (!chainId) { - console.error(`Unknown network: ${networkName}`); - process.exit(1); + console.error(`Unknown network: ${networkName}`); + process.exit(1); } +const deploymentPath = path.resolve(`deployments/${networkName}/ERC1538Proxy.json`); +if (!fs.existsSync(deploymentPath)) { + console.error(`ERC1538Proxy deployment file not found for network: ${networkName}`); + process.exit(1); +} + +const deployment = JSON.parse(fs.readFileSync(deploymentPath, 'utf8')); +const contractAddress = deployment.address; + +if (!contractAddress || contractAddress === 'null') { + console.error(`Failed to extract a valid ERC1538Proxy address from deployment file`); + process.exit(1); +} + +console.log(`Found ERC1538Proxy address: ${contractAddress}`); + // Read config file -const configPath = path.resolve("config/config.json"); -const config = JSON.parse(fs.readFileSync(configPath, "utf8")); +const configPath = path.resolve('config/config.json'); +const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); // Ensure the chain structure exists if (!config.chains) { - config.chains = {}; + config.chains = {}; } if (!config.chains[chainId]) { - config.chains[chainId] = { - v5: {} - }; + config.chains[chainId] = { + v5: {}, + }; } if (!config.chains[chainId].v5) { - config.chains[chainId].v5 = {}; + config.chains[chainId].v5 = {}; } -// Update the contract address -const previousValue = config.chains[chainId].v5[contractKey] || "null"; +const contractKey = 'ERC1538Proxy'; +const previousValue = config.chains[chainId].v5[contractKey] || 'null'; config.chains[chainId].v5[contractKey] = contractAddress; // Write the updated config back to file From 948bafa464e3ed52b7bc6c54a2aec4395447ee2f Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 6 May 2025 11:34:33 +0200 Subject: [PATCH 20/27] fix(scripts): update update-config.js to use Hardhat for network chain ID retrieval and improve error handling --- .github/workflows/deploy-smart-contracts.yml | 2 +- scripts/tools/update-config.js | 107 +++++++++---------- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index a80c99e50..7c22b9cc5 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -91,7 +91,7 @@ jobs: - name: Update config.json with ERC1538Proxy address if: inputs.network != 'hardhat' - run: node scripts/tool/update-config.js "${{ inputs.network }}" + run: npx hardhat run scripts/tool/update-config.js --network ${{ inputs.network }} -- ${{ inputs.network }} - name: Save deployment artifacts and updated config if: inputs.network != 'hardhat' diff --git a/scripts/tools/update-config.js b/scripts/tools/update-config.js index bfb3c2d41..92e83fa59 100644 --- a/scripts/tools/update-config.js +++ b/scripts/tools/update-config.js @@ -1,69 +1,68 @@ import fs from 'fs'; +import hre from 'hardhat'; import path from 'path'; -// Map network names to chain IDs -const NETWORK_TO_CHAIN_ID = { - hardhat: '31337', - avalancheFujiTestnet: '43113', - arbitrumSepolia: '421614', - bellecour: '134', -}; +async function main() { + const [networkName] = process.argv.slice(2); -const [networkName] = process.argv.slice(2); + if (!networkName) { + console.error('Usage: node update-config.js '); + process.exit(1); + } -if (!networkName) { - console.error('Usage: node update-config.js '); - process.exit(1); -} - -const chainId = NETWORK_TO_CHAIN_ID[networkName]; -if (!chainId) { - console.error(`Unknown network: ${networkName}`); - process.exit(1); -} - -const deploymentPath = path.resolve(`deployments/${networkName}/ERC1538Proxy.json`); -if (!fs.existsSync(deploymentPath)) { - console.error(`ERC1538Proxy deployment file not found for network: ${networkName}`); - process.exit(1); -} + let chainId; + try { + chainId = (await hre.ethers.provider.getNetwork()).chainId.toString(); + } catch (error) { + console.error(`Failed to get chain ID for network ${networkName}:`, error.message); + process.exit(1); + } -const deployment = JSON.parse(fs.readFileSync(deploymentPath, 'utf8')); -const contractAddress = deployment.address; + const deploymentPath = path.resolve(`deployments/${networkName}/ERC1538Proxy.json`); + if (!fs.existsSync(deploymentPath)) { + console.error(`ERC1538Proxy deployment file not found for network: ${networkName}`); + process.exit(1); + } -if (!contractAddress || contractAddress === 'null') { - console.error(`Failed to extract a valid ERC1538Proxy address from deployment file`); - process.exit(1); -} + const deployment = JSON.parse(fs.readFileSync(deploymentPath, 'utf8')); + const contractAddress = deployment.address; -console.log(`Found ERC1538Proxy address: ${contractAddress}`); + if (!contractAddress || contractAddress === 'null') { + console.error(`Failed to extract a valid ERC1538Proxy address from deployment file`); + process.exit(1); + } -// Read config file -const configPath = path.resolve('config/config.json'); -const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); + console.log(`Found ERC1538Proxy address: ${contractAddress}`); + const configPath = path.resolve('config/config.json'); + const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); -// Ensure the chain structure exists -if (!config.chains) { - config.chains = {}; -} + if (!config.chains) { + config.chains = {}; + } -if (!config.chains[chainId]) { - config.chains[chainId] = { - v5: {}, - }; -} + if (!config.chains[chainId]) { + config.chains[chainId] = { + v5: {}, + }; + } -if (!config.chains[chainId].v5) { - config.chains[chainId].v5 = {}; -} + if (!config.chains[chainId].v5) { + config.chains[chainId].v5 = {}; + } -const contractKey = 'ERC1538Proxy'; -const previousValue = config.chains[chainId].v5[contractKey] || 'null'; -config.chains[chainId].v5[contractKey] = contractAddress; + const contractKey = 'ERC1538Proxy'; + const previousValue = config.chains[chainId].v5[contractKey] || 'null'; + config.chains[chainId].v5[contractKey] = contractAddress; -// Write the updated config back to file -fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); -console.log(`Updated ${chainId}.v5.${contractKey}:`); -console.log(`Previous: ${previousValue}`); -console.log(`New: ${contractAddress}`); + console.log(`Updated ${chainId}.v5.${contractKey}:`); + console.log(`Previous: ${previousValue}`); + console.log(`New: ${contractAddress}`); +} +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error('Error in update-config script:', error); + process.exit(1); + }); From 40ed84c8faf4e39407dca622eb38f1c593b2b88b Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 6 May 2025 14:03:30 +0200 Subject: [PATCH 21/27] fix(scripts): import config in update-config.js and refactor local configuration handling --- scripts/tools/update-config.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/scripts/tools/update-config.js b/scripts/tools/update-config.js index 92e83fa59..9835160f2 100644 --- a/scripts/tools/update-config.js +++ b/scripts/tools/update-config.js @@ -1,6 +1,7 @@ import fs from 'fs'; import hre from 'hardhat'; import path from 'path'; +import config from '../utils/config'; async function main() { const [networkName] = process.argv.slice(2); @@ -33,15 +34,21 @@ async function main() { } console.log(`Found ERC1538Proxy address: ${contractAddress}`); - const configPath = path.resolve('config/config.json'); - const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); - - if (!config.chains) { - config.chains = {}; + const localconfig = config; + if (!localconfig.chains) { + localconfig.chains = {}; } - if (!config.chains[chainId]) { - config.chains[chainId] = { + if (!localconfig.chains[chainId]) { + localconfig.chains[chainId] = { + _comment: `Chain ${chainId} (${networkName})`, + asset: 'Native', // Default value, update as needed + v3: { + Hub: null, + AppRegistry: null, + DatasetRegistry: null, + WorkerpoolRegistry: null, + }, v5: {}, }; } @@ -52,14 +59,16 @@ async function main() { const contractKey = 'ERC1538Proxy'; const previousValue = config.chains[chainId].v5[contractKey] || 'null'; - config.chains[chainId].v5[contractKey] = contractAddress; + localconfig.chains[chainId].v5[contractKey] = contractAddress; - fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + const configPath = path.resolve('config/config.json'); + fs.writeFileSync(configPath, JSON.stringify(localconfig, null, 2)); console.log(`Updated ${chainId}.v5.${contractKey}:`); console.log(`Previous: ${previousValue}`); console.log(`New: ${contractAddress}`); } + main() .then(() => process.exit(0)) .catch((error) => { From 1999911e99320eb7feec6e5b0173f60f342dce4b Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 12 May 2025 15:43:25 +0200 Subject: [PATCH 22/27] fix(scripts): remove redundant networkName argument from update-config.js and retrieve it directly from hre.network --- .github/workflows/deploy-smart-contracts.yml | 2 +- scripts/tools/update-config.js | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 7c22b9cc5..6348aaeae 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -91,7 +91,7 @@ jobs: - name: Update config.json with ERC1538Proxy address if: inputs.network != 'hardhat' - run: npx hardhat run scripts/tool/update-config.js --network ${{ inputs.network }} -- ${{ inputs.network }} + run: npx hardhat run scripts/tools/update-config.js --network ${{ inputs.network }} - name: Save deployment artifacts and updated config if: inputs.network != 'hardhat' diff --git a/scripts/tools/update-config.js b/scripts/tools/update-config.js index 9835160f2..4957d6337 100644 --- a/scripts/tools/update-config.js +++ b/scripts/tools/update-config.js @@ -4,16 +4,11 @@ import path from 'path'; import config from '../utils/config'; async function main() { - const [networkName] = process.argv.slice(2); - - if (!networkName) { - console.error('Usage: node update-config.js '); - process.exit(1); - } - let chainId; + let networkName; try { chainId = (await hre.ethers.provider.getNetwork()).chainId.toString(); + networkName = hre.network.name; } catch (error) { console.error(`Failed to get chain ID for network ${networkName}:`, error.message); process.exit(1); From b348f0c736a7e032f79c103f34bf3eaca61bd463 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 12 May 2025 17:34:25 +0200 Subject: [PATCH 23/27] feat(scripts): implement update-config.ts to manage ERC1538Proxy deployment configuration and improve error handling --- .../{update-config.js => update-config.ts} | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) rename scripts/tools/{update-config.js => update-config.ts} (65%) diff --git a/scripts/tools/update-config.js b/scripts/tools/update-config.ts similarity index 65% rename from scripts/tools/update-config.js rename to scripts/tools/update-config.ts index 4957d6337..0591d6bcf 100644 --- a/scripts/tools/update-config.js +++ b/scripts/tools/update-config.ts @@ -1,18 +1,18 @@ -import fs from 'fs'; -import hre from 'hardhat'; -import path from 'path'; -import config from '../utils/config'; +import * as fs from 'fs'; +import { ethers } from 'hardhat'; +import * as path from 'path'; +import config from '../../utils/config'; -async function main() { - let chainId; - let networkName; - try { - chainId = (await hre.ethers.provider.getNetwork()).chainId.toString(); - networkName = hre.network.name; - } catch (error) { - console.error(`Failed to get chain ID for network ${networkName}:`, error.message); - process.exit(1); - } +// Get the absolute path to the config file +const configPath = path.resolve('config/config.json'); + +async function main(): Promise { + // Get network info from ethers + const network = await ethers.provider.getNetwork(); + const networkName = network.name; + const chainId = network.chainId.toString(); + + console.log(`Working with network: ${networkName} (Chain ID: ${chainId})`); const deploymentPath = path.resolve(`deployments/${networkName}/ERC1538Proxy.json`); if (!fs.existsSync(deploymentPath)) { @@ -29,7 +29,11 @@ async function main() { } console.log(`Found ERC1538Proxy address: ${contractAddress}`); + + // Read the config file directly const localconfig = config; + + // Ensure the chain structure exists if (!localconfig.chains) { localconfig.chains = {}; } @@ -48,15 +52,15 @@ async function main() { }; } - if (!config.chains[chainId].v5) { - config.chains[chainId].v5 = {}; + if (!localconfig.chains[chainId].v5) { + localconfig.chains[chainId].v5 = {}; } const contractKey = 'ERC1538Proxy'; - const previousValue = config.chains[chainId].v5[contractKey] || 'null'; + const previousValue = localconfig.chains[chainId].v5[contractKey] || 'null'; localconfig.chains[chainId].v5[contractKey] = contractAddress; - const configPath = path.resolve('config/config.json'); + // Write the updated config back to file fs.writeFileSync(configPath, JSON.stringify(localconfig, null, 2)); console.log(`Updated ${chainId}.v5.${contractKey}:`); @@ -64,6 +68,7 @@ async function main() { console.log(`New: ${contractAddress}`); } +// Execute the main function and handle any errors main() .then(() => process.exit(0)) .catch((error) => { From 83098d27b71566fc5ff30a4753d8c2fcdf1486a1 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 12 May 2025 17:38:41 +0200 Subject: [PATCH 24/27] fix(scripts): update update-config.ts to use deployments.get for ERC1538Proxy and change asset default to 'Token' --- scripts/tools/update-config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tools/update-config.ts b/scripts/tools/update-config.ts index 0591d6bcf..e26bb3d3a 100644 --- a/scripts/tools/update-config.ts +++ b/scripts/tools/update-config.ts @@ -1,5 +1,5 @@ import * as fs from 'fs'; -import { ethers } from 'hardhat'; +import { deployments, ethers } from 'hardhat'; import * as path from 'path'; import config from '../../utils/config'; @@ -20,7 +20,7 @@ async function main(): Promise { process.exit(1); } - const deployment = JSON.parse(fs.readFileSync(deploymentPath, 'utf8')); + const deployment = await deployments.get('ERC1538Proxy'); const contractAddress = deployment.address; if (!contractAddress || contractAddress === 'null') { @@ -41,7 +41,7 @@ async function main(): Promise { if (!localconfig.chains[chainId]) { localconfig.chains[chainId] = { _comment: `Chain ${chainId} (${networkName})`, - asset: 'Native', // Default value, update as needed + asset: 'Token', // Default value, update as needed v3: { Hub: null, AppRegistry: null, From 94e4045b01ac69cc8b93fa36b6c02debeba9db84 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 12 May 2025 17:41:31 +0200 Subject: [PATCH 25/27] fix(scripts): update deploy workflow to use update-config.ts and remove redundant comment in update-config.ts --- .github/workflows/deploy-smart-contracts.yml | 2 +- scripts/tools/update-config.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/deploy-smart-contracts.yml b/.github/workflows/deploy-smart-contracts.yml index 6348aaeae..71f4d22e5 100644 --- a/.github/workflows/deploy-smart-contracts.yml +++ b/.github/workflows/deploy-smart-contracts.yml @@ -91,7 +91,7 @@ jobs: - name: Update config.json with ERC1538Proxy address if: inputs.network != 'hardhat' - run: npx hardhat run scripts/tools/update-config.js --network ${{ inputs.network }} + run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }} - name: Save deployment artifacts and updated config if: inputs.network != 'hardhat' diff --git a/scripts/tools/update-config.ts b/scripts/tools/update-config.ts index e26bb3d3a..ddc2d5b6f 100644 --- a/scripts/tools/update-config.ts +++ b/scripts/tools/update-config.ts @@ -29,8 +29,6 @@ async function main(): Promise { } console.log(`Found ERC1538Proxy address: ${contractAddress}`); - - // Read the config file directly const localconfig = config; // Ensure the chain structure exists From 01ee9cf8803b6f50ac0bf40294259c54917d7bff Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Mon, 12 May 2025 17:49:08 +0200 Subject: [PATCH 26/27] fix(scripts): correct variable name from localconfig to localConfig in update-config.ts --- scripts/tools/update-config.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/tools/update-config.ts b/scripts/tools/update-config.ts index ddc2d5b6f..7f4155cbf 100644 --- a/scripts/tools/update-config.ts +++ b/scripts/tools/update-config.ts @@ -29,15 +29,15 @@ async function main(): Promise { } console.log(`Found ERC1538Proxy address: ${contractAddress}`); - const localconfig = config; + const localConfig = config; // Ensure the chain structure exists - if (!localconfig.chains) { - localconfig.chains = {}; + if (!localConfig.chains) { + localConfig.chains = {}; } - if (!localconfig.chains[chainId]) { - localconfig.chains[chainId] = { + if (!localConfig.chains[chainId]) { + localConfig.chains[chainId] = { _comment: `Chain ${chainId} (${networkName})`, asset: 'Token', // Default value, update as needed v3: { @@ -50,16 +50,16 @@ async function main(): Promise { }; } - if (!localconfig.chains[chainId].v5) { - localconfig.chains[chainId].v5 = {}; + if (!localConfig.chains[chainId].v5) { + localConfig.chains[chainId].v5 = {}; } const contractKey = 'ERC1538Proxy'; - const previousValue = localconfig.chains[chainId].v5[contractKey] || 'null'; - localconfig.chains[chainId].v5[contractKey] = contractAddress; + const previousValue = localConfig.chains[chainId].v5[contractKey] || 'null'; + localConfig.chains[chainId].v5[contractKey] = contractAddress; // Write the updated config back to file - fs.writeFileSync(configPath, JSON.stringify(localconfig, null, 2)); + fs.writeFileSync(configPath, JSON.stringify(localConfig, null, 2)); console.log(`Updated ${chainId}.v5.${contractKey}:`); console.log(`Previous: ${previousValue}`); From c520fa326a2df995a760fe1e486577c9ccba7784 Mon Sep 17 00:00:00 2001 From: gfournieriExec Date: Tue, 13 May 2025 09:15:31 +0200 Subject: [PATCH 27/27] fix(scripts): remove redundant deployment file check for ERC1538Proxy in update-config.ts --- scripts/tools/update-config.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/tools/update-config.ts b/scripts/tools/update-config.ts index 7f4155cbf..0b0094ce6 100644 --- a/scripts/tools/update-config.ts +++ b/scripts/tools/update-config.ts @@ -13,13 +13,6 @@ async function main(): Promise { const chainId = network.chainId.toString(); console.log(`Working with network: ${networkName} (Chain ID: ${chainId})`); - - const deploymentPath = path.resolve(`deployments/${networkName}/ERC1538Proxy.json`); - if (!fs.existsSync(deploymentPath)) { - console.error(`ERC1538Proxy deployment file not found for network: ${networkName}`); - process.exit(1); - } - const deployment = await deployments.get('ERC1538Proxy'); const contractAddress = deployment.address;