From ea3d3bd07b38933417dd79b8990bb3d3fefaf2d9 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 14:12:26 +0700 Subject: [PATCH 01/48] chore: init test file --- package.json | 3 ++- sui/test/commands.test.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 sui/test/commands.test.js diff --git a/package.json b/package.json index d03692fc..77982981 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "lint": "eslint --fix '**/*.js'", - "prettier": "prettier --write '**/*.js' 'axelar-chains-config/info/*.json' 'package.json' 'evm/**/*.json' '.github/**/*.yaml'" + "prettier": "prettier --write '**/*.js' 'axelar-chains-config/info/*.json' 'package.json' 'evm/**/*.json' '.github/**/*.yaml'", + "test:sui": "mocha sui" }, "repository": { "type": "git", diff --git a/sui/test/commands.test.js b/sui/test/commands.test.js new file mode 100644 index 00000000..b051e403 --- /dev/null +++ b/sui/test/commands.test.js @@ -0,0 +1,9 @@ +describe('Test Sui Commands', () => { + describe('Deploy Contracts', () => {}); + + describe('Gas Service', () => {}); + + describe('GMP', () => {}); + + describe('Gateway', () => {}); +}); From 985e66d5f785a722f76a9a67fca0b95822962627 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 16:29:28 +0700 Subject: [PATCH 02/48] chore: rename evm test --- .github/workflows/test-evm.yaml | 140 ++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 .github/workflows/test-evm.yaml diff --git a/.github/workflows/test-evm.yaml b/.github/workflows/test-evm.yaml new file mode 100644 index 00000000..4a3a2119 --- /dev/null +++ b/.github/workflows/test-evm.yaml @@ -0,0 +1,140 @@ +name: Test Evm + +on: pull_request + +jobs: + test-evm: + runs-on: blacksmith-2vcpu-ubuntu-2204 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Node.js + uses: useblacksmith/setup-node@v5 + with: + node-version: 18.x + cache: 'npm' + + - name: Install + run: npm ci + + - name: Spin up Hardhat Network + run: npx hardhat node & + + - name: Prepare local.json + run: | + echo '{ + "chains": { + "test": { + "name": "Test", + "id": "test", + "axelarId": "test", + "chainId": 31337, + "rpc": "http://127.0.0.1:8545", + "tokenSymbol": "TEST", + "contracts": { + "AxelarGasService": { + "collector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + }, + "InterchainGovernance": { + "minimumTimeDelay": 3600 + }, + "AxelarServiceGovernance": { + "minimumTimeDelay": 3600, + "multisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + }, + "Multisig": { + "signers": [ + "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", + "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", + "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" + ], + "threshold": 2 + } + } + } + } + }' > ./axelar-chains-config/info/local.json + + # Create .env file with default hardhat private key that's prefunded + - name: Prepare .env + run: | + echo 'PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' >> .env + echo 'ENV=local' >> .env + echo 'CHAINS=test' >> .env + + - name: Display local.json + run: cat ./axelar-chains-config/info/local.json + + - name: Deploy ConstAddressDeployer + run: node evm/deploy-contract.js -c ConstAddressDeployer -m create -y + + - name: Deploy Create3Deployer + run: node evm/deploy-contract.js -c Create3Deployer -m create2 -y + + - name: Deploy AxelarAmplifierGateway + run: node evm/deploy-amplifier-gateway.js --deployMethod create3 -s "AxelarAmplifierGateway v5.8" --owner 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --domainSeparator 0x361b9fa2ae14de79d4b32164841b42ebc840b9d3ddb98cba1a45dc79a13214fc -y + + - name: Deploy AxelarGateway + run: node evm/deploy-gateway-v6.2.x.js --deployMethod create3 -s "AxelarGateway v6.2" --governance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --mintLimiter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -y + + - name: Call Method on Gateway + run: node evm/gateway.js --action callContract --destinationChain test2 -y + + - name: Deploy InterchainGovernance using create + run: node evm/deploy-contract.js -c InterchainGovernance -m create -y + + - name: Deploy InterchainGovernance using create2 + run: node evm/deploy-contract.js -c InterchainGovernance -m create2 -y + + - name: Deploy InterchainGovernance using create3 + run: node evm/deploy-contract.js -c InterchainGovernance -m create3 -y + + - name: Transfer gateway governance + run: node evm/gateway.js --action transferGovernance -y + + - name: Generate governance upgrade proposal + run: node evm/governance.js --targetContractName AxelarGateway --action upgrade --proposalAction schedule --date 2100-01-01T12:00:00 + + - name: Deploy AxelarServiceGovernance using create3 + run: node evm/deploy-contract.js -c AxelarServiceGovernance -m create3 -y + + - name: Deploy Multisig using create3 + run: node evm/deploy-contract.js -c Multisig -m create3 -y + + - name: Deploy Operators using create3 + run: node evm/deploy-contract.js -c Operators -m create3 -y + + - name: Deploy AxelarGasService using create2 + run: node evm/deploy-upgradable.js -c AxelarGasService -m create2 -y + + - name: Deploy ITS using create2 + run: node evm/deploy-its.js -s "v1.0.0" -m create2 -y + + - name: Deploy new ITS implementation + run: node evm/deploy-its.js -s "v1.1.0" -m create2 --reuseProxy -y + + - name: Upgrade ITS using create2 + run: node evm/deploy-its.js -m create2 -u -y + + - name: InterchainTokenFactory deploy interchain token on current chain + run: node evm/interchainTokenFactory.js --action deployInterchainToken --name "test" --symbol "TST" --decimals 18 --minter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --salt "salt" -y + + - name: InterchainTokenService deploy interchain token on current chain + run: node evm/its.js --action deployInterchainToken --name "test" --symbol "TST" --decimals 18 --minter 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 --destinationChain '' --gasValue 0 --salt "salt" -y + + - name: Add gasOptions to local.json + run: | + jq '.chains.test += {"gasOptions": {"gasLimit": 8000000}} | .chains.test.contracts.AxelarGateway += {"gasOptions": {"gasLimit": 8000000}}' ./axelar-chains-config/info/local.json > temp.json && mv temp.json ./axelar-chains-config/info/local.json + + - name: Redeploy AxelarGateway with gasOptions + run: node evm/deploy-gateway-v6.2.x.js -m create3 -s "AxelarGateway v6.2" --governance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --mintLimiter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -y + + - name: Redeploy ITS with gasOptions in Chain Config + run: node evm/deploy-its.js -s "v1.0.0" -m create2 -y + + - name: Redeploy ITS with gasOptions override via CLI + run: | + node evm/deploy-its.js -s "v1.0.0" -m create2 -y --gasOptions \ + '{"gasLimit": 9000000,"gasPriceAdjustment": 1.1}' From 1d53c76953fa9f86f7e064e8e496144156304eb1 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 16:29:39 +0700 Subject: [PATCH 03/48] chore: add sui cli setup script --- .github/actions/setup-sui/action.yaml | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/actions/setup-sui/action.yaml diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml new file mode 100644 index 00000000..c7bc18d8 --- /dev/null +++ b/.github/actions/setup-sui/action.yaml @@ -0,0 +1,55 @@ +name: Setup SUI Cli +description: 'Setup Sui CLI and install dependencies' + +inputs: + SUI_VERSION: + description: 'The version of Sui CLI to install' + required: true + +runs: + using: 'composite' + + steps: + - name: Debug Action Input + shell: bash + run: echo "SUI_VERSION=${{ inputs.SUI_VERSION }}" + + - name: Install Dependencies + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y libpq-dev + + - name: Cache Sui binaries + id: cache-sui + uses: actions/cache@v4 + with: + path: sui-binaries/ + key: sui-${{ inputs.SUI_VERSION }} + + - name: Download and Install Sui + shell: bash + if: steps.cache-sui.outputs.cache-hit != 'true' + run: | + curl -L -o sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz https://github.com/MystenLabs/sui/releases/download/${{ inputs.SUI_VERSION }}/sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz + tar -xvf sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz + mkdir -p sui-binaries + mv ./sui ./sui-binaries/ + mv ./sui-debug ./sui-binaries/ + mv ./sui-test-validator ./sui-binaries/ + rm -rf sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz + + - name: Save Sui binaries + if: steps.cache-sui.outputs.cache-hit != 'true' + id: cache-sui-save + uses: actions/cache@v4 + with: + path: sui-binaries/ + key: sui-${{ inputs.SUI_VERSION }} + + - name: Add Sui binaries to PATH + shell: bash + run: | + sudo cp ./sui-binaries/sui /usr/local/bin/sui + sudo cp ./sui-binaries/sui-debug /usr/local/bin/sui-debug + sudo cp ./sui-binaries/sui-test-validator /usr/local/bin/sui-test-validator From 68a48fe1d72173b0dafa77b879840387ab055257 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 16:30:08 +0700 Subject: [PATCH 04/48] feat: init sui test scripts --- .github/workflows/test-sui.yaml | 99 ++++++++++++++++++++++ .github/workflows/test.yaml | 140 -------------------------------- sui/test/commands.test.js | 9 -- 3 files changed, 99 insertions(+), 149 deletions(-) create mode 100644 .github/workflows/test-sui.yaml delete mode 100644 .github/workflows/test.yaml delete mode 100644 sui/test/commands.test.js diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml new file mode 100644 index 00000000..24aa2855 --- /dev/null +++ b/.github/workflows/test-sui.yaml @@ -0,0 +1,99 @@ +name: Test Sui + +on: pull_request + +env: + SUI_VERSION: mainnet-v1.25.3 + +jobs: + test-evm: + runs-on: blacksmith-2vcpu-ubuntu-2204 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Node.js + uses: useblacksmith/setup-node@v5 + with: + node-version: 18.x + cache: 'npm' + + - name: Install + run: npm ci + + - name: Setup Sui CLI and install dependencies + uses: ./.github/actions/setup-sui + with: + SUI_VERSION: ${{ env.SUI_VERSION } + + - name: Spin up Sui Network + run: nohup sh -c "sui-test-validator" > nohup.out 2> nohup.err < /dev/null & + + - name: Sleep for 30 seconds + run: sleep 30s + shell: bash + + - name: Prepare local.json + run: | + echo '{ + "sui": { + "name": "Sui", + "axelarId": "sui", + "networkType": "localnet", + "tokenSymbol": "SUI", + "rpc": "http://127.0.0.1:9000", + "faucetUrl": "http://127.0.0.1:9123", + "contracts": { + "AxelarGateway": {} + } + } + }' > ./axelar-chains-config/info/local.json + + # Create .env file with default hardhat private key that's prefunded + - name: Prepare .env + run: | + echo 'PRIVATE_KEY=suiprivkey1qyw6c8t5ws65fcvlcw5rhyt2jd8d6ad6e526shgktlm0x3aelq9rx2lp4wq' >> .env + echo 'ENV=local' >> .env + echo 'SKIP_EXISTING = true' >> .env + + - name: Display local.json + run: cat ./axelar-chains-config/info/local.json + + - name: Request SUI from faucet + run: node sui/faucet.js + + ###### Command: Deploy Contract ###### + + - name: Deploy AxelarGateway + run: node sui/deploy-contract deploy AxelarGateway --signers wallet + + - name: Deploy GasService + run: node sui/deploy-contract deploy GasService + + - name: Deploy Operators + run: node sui/deploy-contract deploy Operators + + - name: Deploy Test + run: node sui/deploy-contract deploy Test + + ###### Command: Gas Service ###### + + - name: Pay Gas + run: node sui/gas-service.js payGas --amount 100 ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0xba76c6980428A0b10CFC5d8ccb61949677A61233 0x1234 + + - name: Refund Gas + run: node sui/gas-service.js refund 0x2 --amount 1 + + - name: Collect Gas + run: node sui/gas-service.js collectGas --amount 0.1 + + ###### Command: GMP ###### + + ###### Command: Gateway ###### + + ###### Command: Operators ###### + + ###### Command: Multisig ###### + + ###### Command: Operators ###### diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index d773b858..00000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,140 +0,0 @@ -name: Test - -on: pull_request - -jobs: - test: - runs-on: blacksmith-2vcpu-ubuntu-2204 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install Node.js - uses: useblacksmith/setup-node@v5 - with: - node-version: 18.x - cache: 'npm' - - - name: Install - run: npm ci - - - name: Spin up Hardhat Network - run: npx hardhat node & - - - name: Prepare local.json - run: | - echo '{ - "chains": { - "test": { - "name": "Test", - "id": "test", - "axelarId": "test", - "chainId": 31337, - "rpc": "http://127.0.0.1:8545", - "tokenSymbol": "TEST", - "contracts": { - "AxelarGasService": { - "collector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - }, - "InterchainGovernance": { - "minimumTimeDelay": 3600 - }, - "AxelarServiceGovernance": { - "minimumTimeDelay": 3600, - "multisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - }, - "Multisig": { - "signers": [ - "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", - "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC" - ], - "threshold": 2 - } - } - } - } - }' > ./axelar-chains-config/info/local.json - - # Create .env file with default hardhat private key that's prefunded - - name: Prepare .env - run: | - echo 'PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' >> .env - echo 'ENV=local' >> .env - echo 'CHAINS=test' >> .env - - - name: Display local.json - run: cat ./axelar-chains-config/info/local.json - - - name: Deploy ConstAddressDeployer - run: node evm/deploy-contract.js -c ConstAddressDeployer -m create -y - - - name: Deploy Create3Deployer - run: node evm/deploy-contract.js -c Create3Deployer -m create2 -y - - - name: Deploy AxelarAmplifierGateway - run: node evm/deploy-amplifier-gateway.js --deployMethod create3 -s "AxelarAmplifierGateway v5.8" --owner 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --domainSeparator 0x361b9fa2ae14de79d4b32164841b42ebc840b9d3ddb98cba1a45dc79a13214fc -y - - - name: Deploy AxelarGateway - run: node evm/deploy-gateway-v6.2.x.js --deployMethod create3 -s "AxelarGateway v6.2" --governance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --mintLimiter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -y - - - name: Call Method on Gateway - run: node evm/gateway.js --action callContract --destinationChain test2 -y - - - name: Deploy InterchainGovernance using create - run: node evm/deploy-contract.js -c InterchainGovernance -m create -y - - - name: Deploy InterchainGovernance using create2 - run: node evm/deploy-contract.js -c InterchainGovernance -m create2 -y - - - name: Deploy InterchainGovernance using create3 - run: node evm/deploy-contract.js -c InterchainGovernance -m create3 -y - - - name: Transfer gateway governance - run: node evm/gateway.js --action transferGovernance -y - - - name: Generate governance upgrade proposal - run: node evm/governance.js --targetContractName AxelarGateway --action upgrade --proposalAction schedule --date 2100-01-01T12:00:00 - - - name: Deploy AxelarServiceGovernance using create3 - run: node evm/deploy-contract.js -c AxelarServiceGovernance -m create3 -y - - - name: Deploy Multisig using create3 - run: node evm/deploy-contract.js -c Multisig -m create3 -y - - - name: Deploy Operators using create3 - run: node evm/deploy-contract.js -c Operators -m create3 -y - - - name: Deploy AxelarGasService using create2 - run: node evm/deploy-upgradable.js -c AxelarGasService -m create2 -y - - - name: Deploy ITS using create2 - run: node evm/deploy-its.js -s "v1.0.0" -m create2 -y - - - name: Deploy new ITS implementation - run: node evm/deploy-its.js -s "v1.1.0" -m create2 --reuseProxy -y - - - name: Upgrade ITS using create2 - run: node evm/deploy-its.js -m create2 -u -y - - - name: InterchainTokenFactory deploy interchain token on current chain - run: node evm/interchainTokenFactory.js --action deployInterchainToken --name "test" --symbol "TST" --decimals 18 --minter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --salt "salt" -y - - - name: InterchainTokenService deploy interchain token on current chain - run: node evm/its.js --action deployInterchainToken --name "test" --symbol "TST" --decimals 18 --minter 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 --destinationChain '' --gasValue 0 --salt "salt" -y - - - name: Add gasOptions to local.json - run: | - jq '.chains.test += {"gasOptions": {"gasLimit": 8000000}} | .chains.test.contracts.AxelarGateway += {"gasOptions": {"gasLimit": 8000000}}' ./axelar-chains-config/info/local.json > temp.json && mv temp.json ./axelar-chains-config/info/local.json - - - name: Redeploy AxelarGateway with gasOptions - run: node evm/deploy-gateway-v6.2.x.js -m create3 -s "AxelarGateway v6.2" --governance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --mintLimiter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -y - - - name: Redeploy ITS with gasOptions in Chain Config - run: node evm/deploy-its.js -s "v1.0.0" -m create2 -y - - - name: Redeploy ITS with gasOptions override via CLI - run: | - node evm/deploy-its.js -s "v1.0.0" -m create2 -y --gasOptions \ - '{"gasLimit": 9000000,"gasPriceAdjustment": 1.1}' diff --git a/sui/test/commands.test.js b/sui/test/commands.test.js deleted file mode 100644 index b051e403..00000000 --- a/sui/test/commands.test.js +++ /dev/null @@ -1,9 +0,0 @@ -describe('Test Sui Commands', () => { - describe('Deploy Contracts', () => {}); - - describe('Gas Service', () => {}); - - describe('GMP', () => {}); - - describe('Gateway', () => {}); -}); From 9c11a868863ff5ee57ee7add1ad8358f5437a9b0 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 18:05:34 +0700 Subject: [PATCH 05/48] chore: fix unclosed } --- .github/workflows/test-sui.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 24aa2855..3949d7db 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -6,7 +6,7 @@ env: SUI_VERSION: mainnet-v1.25.3 jobs: - test-evm: + test-sui: runs-on: blacksmith-2vcpu-ubuntu-2204 steps: @@ -25,7 +25,7 @@ jobs: - name: Setup Sui CLI and install dependencies uses: ./.github/actions/setup-sui with: - SUI_VERSION: ${{ env.SUI_VERSION } + SUI_VERSION: ${{ env.SUI_VERSION }} - name: Spin up Sui Network run: nohup sh -c "sui-test-validator" > nohup.out 2> nohup.err < /dev/null & From 981a6b009a65ebb6e1cd05cabae7f678181ec17c Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 22:12:18 +0700 Subject: [PATCH 06/48] chore: fix path for sui cli --- .github/actions/setup-sui/action.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index c7bc18d8..8e5ca288 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -31,6 +31,7 @@ runs: shell: bash if: steps.cache-sui.outputs.cache-hit != 'true' run: | + mkdir -p sui-cli && cd sui-cli curl -L -o sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz https://github.com/MystenLabs/sui/releases/download/${{ inputs.SUI_VERSION }}/sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz tar -xvf sui-${{ inputs.SUI_VERSION }}-ubuntu-x86_64.tgz mkdir -p sui-binaries @@ -44,12 +45,12 @@ runs: id: cache-sui-save uses: actions/cache@v4 with: - path: sui-binaries/ + path: sui-cli/sui-binaries/ key: sui-${{ inputs.SUI_VERSION }} - name: Add Sui binaries to PATH shell: bash run: | - sudo cp ./sui-binaries/sui /usr/local/bin/sui - sudo cp ./sui-binaries/sui-debug /usr/local/bin/sui-debug - sudo cp ./sui-binaries/sui-test-validator /usr/local/bin/sui-test-validator + sudo cp ./sui-cli/sui-binaries/sui /usr/local/bin/sui + sudo cp ./sui-cli/sui-binaries/sui-debug /usr/local/bin/sui-debug + sudo cp ./sui-cli/sui-binaries/sui-test-validator /usr/local/bin/sui-test-validator From 66b20a39ed31b7ccae784d74ebca5cbe1f235f58 Mon Sep 17 00:00:00 2001 From: npty Date: Mon, 19 Aug 2024 22:19:32 +0700 Subject: [PATCH 07/48] chore: fix cache key --- .github/actions/setup-sui/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index 8e5ca288..f7c6f674 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -24,7 +24,7 @@ runs: id: cache-sui uses: actions/cache@v4 with: - path: sui-binaries/ + path: sui-cli/sui-binaries/ key: sui-${{ inputs.SUI_VERSION }} - name: Download and Install Sui From 9e65554dcd48a63ad75573cc0f7d85733be668ef Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 10:57:30 +0700 Subject: [PATCH 08/48] chore: add gmp sendCall command --- .github/workflows/test-sui.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 3949d7db..7289c206 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -90,6 +90,9 @@ jobs: ###### Command: GMP ###### + - name: Send Call Contract + run: node sui/gmp.js sendCall --contractAddress 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 --method getBalance + ###### Command: Gateway ###### ###### Command: Operators ###### From 9732ac8e77835fe9846f8f6f5e445228c64e9786 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 11:05:52 +0700 Subject: [PATCH 09/48] chore: fix gmp command --- sui/gmp.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sui/gmp.js b/sui/gmp.js index 6aa5ccf2..3d8f1b02 100644 --- a/sui/gmp.js +++ b/sui/gmp.js @@ -1,9 +1,8 @@ const { Command } = require('commander'); const { Transaction } = require('@mysten/sui/transactions'); const { bcs } = require('@mysten/sui/bcs'); -const { saveConfig, printInfo } = require('../common/utils'); +const { loadConfig, saveConfig, printInfo } = require('../common/utils'); const { - loadConfig, getBcsBytesByObjectId, addBaseOptions, addOptionsToCommands, From 8814e7c61627adf772928ce56d8441218c367088 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 16:43:40 +0700 Subject: [PATCH 10/48] feat: add Gateway and Operators tests --- .github/workflows/test-sui.yaml | 36 ++++++++++++++++++++++++++++++--- sui/deploy-contract.js | 1 + sui/gateway.js | 20 +++++++++--------- sui/gmp.js | 5 +++-- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 7289c206..dc3dec22 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -90,13 +90,43 @@ jobs: ###### Command: GMP ###### - - name: Send Call Contract - run: node sui/gmp.js sendCall --contractAddress 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 --method getBalance + - name: Execute Outgoing Call Contract + run: node sui/gmp.js sendCall ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0.1 0x1234 + + # TODO: Fix error in this command + - name: Execute Incoming Call Contract + run: | + node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 ###### Command: Gateway ###### + - name: Gateway Approve + run: node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + + - name: Gateway Call Contract + run: node sui/gateway.js call-contract ethereum 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 + + # TODO: Fix error in this command + - name: Gateway Rotate Signers + run : node sui/gateway.js rotate --signers wallet --proof wallet ###### Command: Operators ###### + - name: Store Capability Object in Operators + run: node sui/operators.js storeCap + + - name: Add Operator + run: node sui/operators.js add 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 + + - name: Collect Gas with Operator + run: node sui/gas-service.js collectGas --amount 1 + + - name: Refund Gas with Operator + run: node sui/gas-service.js refund 0x2 --amount 1 + + - name: Remove Operator + run: node sui/operators.js remove 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 + ###### Command: Multisig ###### - ###### Command: Operators ###### + ###### Command: Transfer Object ###### diff --git a/sui/deploy-contract.js b/sui/deploy-contract.js index 6a2da820..67864a7f 100644 --- a/sui/deploy-contract.js +++ b/sui/deploy-contract.js @@ -195,6 +195,7 @@ async function postDeployAxelarGateway(published, keypair, client, config, chain // Update chain configuration chain.contracts.AxelarGateway = { + ...chain.contracts.AxelarGateway, objects: { Gateway: gateway, RelayerDiscovery: relayerDiscovery, diff --git a/sui/gateway.js b/sui/gateway.js index f83a25fb..fa2884ce 100644 --- a/sui/gateway.js +++ b/sui/gateway.js @@ -20,6 +20,7 @@ const { printWalletInfo, getRawPrivateKey, broadcast, + suiClockAddress, } = require('./utils'); const secp256k1 = require('secp256k1'); @@ -106,11 +107,11 @@ function getProof(keypair, commandType, data, contractConfig, options) { } async function callContract(keypair, client, config, chain, args, options) { - if (!chain.contracts.axelar_gateway) { + if (!chain.contracts.AxelarGateway) { throw new Error('Axelar Gateway package not found.'); } - const contractConfig = chain.contracts.axelar_gateway; + const contractConfig = chain.contracts.AxelarGateway; const packageId = contractConfig.address; const [destinationChain, destinationAddress, payload] = args; @@ -150,11 +151,11 @@ async function callContract(keypair, client, config, chain, args, options) { } async function approveMessages(keypair, client, config, chain, args, options) { - if (!chain.contracts.axelar_gateway) { + if (!chain.contracts.AxelarGateway) { throw new Error('Axelar Gateway package not found.'); } - const contractConfig = chain.contracts.axelar_gateway; + const contractConfig = chain.contracts.AxelarGateway; const packageId = contractConfig.address; const [sourceChain, messageId, sourceAddress, destinationId, payloadHash] = args; @@ -178,7 +179,7 @@ async function approveMessages(keypair, client, config, chain, args, options) { tx.moveCall({ target: `${packageId}::gateway::approve_messages`, arguments: [ - tx.object(contractConfig.objects.gateway), + tx.object(contractConfig.objects.Gateway), tx.pure(bcs.vector(bcs.u8()).serialize(encodedMessages).toBytes()), tx.pure(bcs.vector(bcs.u8()).serialize(encodedProof).toBytes()), ], @@ -190,11 +191,11 @@ async function approveMessages(keypair, client, config, chain, args, options) { } async function rotateSigners(keypair, client, config, chain, args, options) { - if (!chain.contracts.axelar_gateway) { + if (!chain.contracts.AxelarGateway) { throw new Error('Axelar Gateway package not found.'); } - const contractConfig = chain.contracts.axelar_gateway; + const contractConfig = chain.contracts.AxelarGateway; const packageId = contractConfig.address; const signers = await getSigners(keypair, config, chain.axelarId, options); @@ -209,12 +210,13 @@ async function rotateSigners(keypair, client, config, chain, args, options) { const encodedProof = getProof(keypair, COMMAND_TYPE_ROTATE_SIGNERS, encodedSigners, contractConfig, options); const tx = new Transaction(); + console.log('encodedSigners', encodedSigners); tx.moveCall({ target: `${packageId}::gateway::rotate_signers`, arguments: [ - tx.object(contractConfig.objects.gateway), - tx.object('0x6'), + tx.object(contractConfig.objects.Gateway), + tx.object(suiClockAddress), tx.pure(bcs.vector(bcs.u8()).serialize(encodedSigners).toBytes()), tx.pure(bcs.vector(bcs.u8()).serialize(encodedProof).toBytes()), ], diff --git a/sui/gmp.js b/sui/gmp.js index 3d8f1b02..c0cbc62d 100644 --- a/sui/gmp.js +++ b/sui/gmp.js @@ -52,7 +52,7 @@ async function sendCommand(keypair, client, contracts, args, options) { } async function execute(keypair, client, contracts, args, options) { - const [testConfig, , axelarGatewayConfig] = contracts; + const [testConfig, ,axelarGatewayConfig] = contracts; const [sourceChain, messageId, sourceAddress, payload] = args; @@ -60,7 +60,8 @@ async function execute(keypair, client, contracts, args, options) { const discoveryObjectId = axelarGatewayConfig.objects.RelayerDiscovery; // Get the channel id from the options or use the channel id from the deployed test contract object. - const channelId = options.channelId || testConfig.objects.channelId; + const channelId = options.channelId || testConfig.objects.ChannelId; + const singletonObjectId = testConfig.objects.Singleton; if (!channelId) { throw new Error('Please provide either a channel id (--channelId) or deploy the test contract'); From 7cb0727f59ae1abcc22177f0d986a5cab6c354e1 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 16:44:31 +0700 Subject: [PATCH 11/48] chore: comment out error tests --- .github/workflows/test-sui.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index dc3dec22..a5519b6d 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -94,10 +94,10 @@ jobs: run: node sui/gmp.js sendCall ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0.1 0x1234 # TODO: Fix error in this command - - name: Execute Incoming Call Contract - run: | - node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 - node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 + # - name: Execute Incoming Call Contract + # run: | + # node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + # node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 ###### Command: Gateway ###### - name: Gateway Approve @@ -107,8 +107,8 @@ jobs: run: node sui/gateway.js call-contract ethereum 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 # TODO: Fix error in this command - - name: Gateway Rotate Signers - run : node sui/gateway.js rotate --signers wallet --proof wallet + # - name: Gateway Rotate Signers + # run : node sui/gateway.js rotate --signers wallet --proof wallet ###### Command: Operators ###### From a44db6d040760d26eb8a3e66b9d84cb1bb6ea87c Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 16:45:20 +0700 Subject: [PATCH 12/48] chore: remove log --- sui/gateway.js | 1 - 1 file changed, 1 deletion(-) diff --git a/sui/gateway.js b/sui/gateway.js index fa2884ce..76f1b70d 100644 --- a/sui/gateway.js +++ b/sui/gateway.js @@ -210,7 +210,6 @@ async function rotateSigners(keypair, client, config, chain, args, options) { const encodedProof = getProof(keypair, COMMAND_TYPE_ROTATE_SIGNERS, encodedSigners, contractConfig, options); const tx = new Transaction(); - console.log('encodedSigners', encodedSigners); tx.moveCall({ target: `${packageId}::gateway::rotate_signers`, From 76725b63c02b0e731bd435b05f1a6a1dd29218c8 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 17:03:52 +0700 Subject: [PATCH 13/48] feat: add keypair and transfer-object test --- .github/workflows/test-sui.yaml | 21 +++++++++++++++------ sui/gmp.js | 1 - sui/transfer-object.js | 14 +++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index a5519b6d..ff84f033 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -94,10 +94,10 @@ jobs: run: node sui/gmp.js sendCall ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0.1 0x1234 # TODO: Fix error in this command - # - name: Execute Incoming Call Contract - # run: | - # node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 - # node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 + - name: Execute Incoming Call Contract + run: | + node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 ###### Command: Gateway ###### - name: Gateway Approve @@ -107,8 +107,8 @@ jobs: run: node sui/gateway.js call-contract ethereum 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 # TODO: Fix error in this command - # - name: Gateway Rotate Signers - # run : node sui/gateway.js rotate --signers wallet --proof wallet + - name: Gateway Rotate Signers + run : node sui/gateway.js rotate --signers wallet --proof wallet ###### Command: Operators ###### @@ -127,6 +127,15 @@ jobs: - name: Remove Operator run: node sui/operators.js remove 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 + ###### Command: Generate Keypair ###### + - name: Generate Keypair + run: node sui/generate-keypair.js + ###### Command: Multisig ###### + ###### Command: Transfer Object ###### + - name: Transfer Object + run: | + object_id=$(sui client objects --json | jq -r '.[-1].data.objectId') + node sui/transfer-object.js --objectId $object_id --recipient 0xdd7c964ff032273889eb6029a29314413b461629c45c0442c6f9cf8342450c12 diff --git a/sui/gmp.js b/sui/gmp.js index c0cbc62d..8e2ff5b1 100644 --- a/sui/gmp.js +++ b/sui/gmp.js @@ -61,7 +61,6 @@ async function execute(keypair, client, contracts, args, options) { // Get the channel id from the options or use the channel id from the deployed test contract object. const channelId = options.channelId || testConfig.objects.ChannelId; - const singletonObjectId = testConfig.objects.Singleton; if (!channelId) { throw new Error('Please provide either a channel id (--channelId) or deploy the test contract'); diff --git a/sui/transfer-object.js b/sui/transfer-object.js index 2d786127..47f5d41a 100644 --- a/sui/transfer-object.js +++ b/sui/transfer-object.js @@ -1,7 +1,7 @@ const { Transaction } = require('@mysten/sui/transactions'); const { Command, Option } = require('commander'); const { loadConfig, printInfo, validateParameters } = require('../common/utils'); -const { getWallet, printWalletInfo, addExtendedOptions } = require('./utils'); +const { getWallet, printWalletInfo, addExtendedOptions, broadcast } = require('./utils'); async function processCommand(chain, options) { const [keypair, client] = getWallet(chain, options); @@ -38,17 +38,9 @@ async function processCommand(chain, options) { const tx = new Transaction(); tx.transferObjects([`${objectId}`], tx.pure.address(recipient)); - const result = await client.signAndExecuteTransaction({ - transactionBlock: tx, - signer: keypair, - options: { - showObjectChanges: true, - showBalanceChanges: true, - showEvents: true, - }, - }); + const result = await broadcast(client, keypair, tx); - printInfo('Transaction result', JSON.stringify(result)); + printInfo('Object Transferred', result.digest); } async function mainProcessor(options, processor) { From 1786acf66e5143b4091173d3ee80d5d8c5da393f Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 17:04:33 +0700 Subject: [PATCH 14/48] chore: add todo --- .github/workflows/test-sui.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index ff84f033..03573706 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -133,6 +133,7 @@ jobs: ###### Command: Multisig ###### + # TODO: Add multisig tests ###### Command: Transfer Object ###### - name: Transfer Object From ca34fb094ba582ec063dab4283ea9c713cd11614 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 17:08:16 +0700 Subject: [PATCH 15/48] chore: prettier --- .github/workflows/test-sui.yaml | 2 +- sui/gmp.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 03573706..877ec02f 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -108,7 +108,7 @@ jobs: # TODO: Fix error in this command - name: Gateway Rotate Signers - run : node sui/gateway.js rotate --signers wallet --proof wallet + run: node sui/gateway.js rotate --signers wallet --proof wallet ###### Command: Operators ###### diff --git a/sui/gmp.js b/sui/gmp.js index 8e2ff5b1..f2db9ac9 100644 --- a/sui/gmp.js +++ b/sui/gmp.js @@ -52,7 +52,7 @@ async function sendCommand(keypair, client, contracts, args, options) { } async function execute(keypair, client, contracts, args, options) { - const [testConfig, ,axelarGatewayConfig] = contracts; + const [testConfig, , axelarGatewayConfig] = contracts; const [sourceChain, messageId, sourceAddress, payload] = args; From ab3f4b05e392c9a44443311d89190befff759672 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 20 Aug 2024 17:09:54 +0700 Subject: [PATCH 16/48] chore: add `continue-on-error: true` for the command that might failed --- .github/workflows/test-sui.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 877ec02f..6c3e187b 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -95,6 +95,7 @@ jobs: # TODO: Fix error in this command - name: Execute Incoming Call Contract + continue-on-error: true run: | node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 @@ -108,6 +109,7 @@ jobs: # TODO: Fix error in this command - name: Gateway Rotate Signers + continue-on-error: true run: node sui/gateway.js rotate --signers wallet --proof wallet ###### Command: Operators ###### From 4e06bb5b8e9c1ec7a999b240e6c5caaed79237c9 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 14:34:23 +0700 Subject: [PATCH 17/48] chore: add if: always to mark that step as failed when error --- .github/workflows/test-sui.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 6c3e187b..51e63001 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -95,6 +95,7 @@ jobs: # TODO: Fix error in this command - name: Execute Incoming Call Contract + if: always() continue-on-error: true run: | node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 @@ -109,6 +110,7 @@ jobs: # TODO: Fix error in this command - name: Gateway Rotate Signers + if: always() continue-on-error: true run: node sui/gateway.js rotate --signers wallet --proof wallet From e175b086566fc4287a90e36d9388ff30e00f04bd Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 14:36:28 +0700 Subject: [PATCH 18/48] chore: fix using wrong script when collecting and refunding gas --- .github/workflows/test-sui.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 51e63001..cb79ec34 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -123,10 +123,10 @@ jobs: run: node sui/operators.js add 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 - name: Collect Gas with Operator - run: node sui/gas-service.js collectGas --amount 1 + run: node sui/operators.js collectGas --amount 1 - name: Refund Gas with Operator - run: node sui/gas-service.js refund 0x2 --amount 1 + run: node sui/operators.js refund 0x2 --amount 1 - name: Remove Operator run: node sui/operators.js remove 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 From e968ff1061ba1c3fd904fda21d785c70c5d96cb1 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 14:47:27 +0700 Subject: [PATCH 19/48] chore: remove always() --- .github/workflows/test-sui.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index cb79ec34..66214514 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -95,7 +95,6 @@ jobs: # TODO: Fix error in this command - name: Execute Incoming Call Contract - if: always() continue-on-error: true run: | node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 @@ -110,7 +109,6 @@ jobs: # TODO: Fix error in this command - name: Gateway Rotate Signers - if: always() continue-on-error: true run: node sui/gateway.js rotate --signers wallet --proof wallet @@ -142,5 +140,7 @@ jobs: ###### Command: Transfer Object ###### - name: Transfer Object run: | + #TODO Checking the objects + sui client objects --json object_id=$(sui client objects --json | jq -r '.[-1].data.objectId') node sui/transfer-object.js --objectId $object_id --recipient 0xdd7c964ff032273889eb6029a29314413b461629c45c0442c6f9cf8342450c12 From 8ca6c1fb3907d2db5ab689adb8c2398305a45410 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 14:58:29 +0700 Subject: [PATCH 20/48] chore: setup sui localnet --- .github/actions/setup-sui/action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index f7c6f674..67fbd4e2 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -54,3 +54,9 @@ runs: sudo cp ./sui-cli/sui-binaries/sui /usr/local/bin/sui sudo cp ./sui-cli/sui-binaries/sui-debug /usr/local/bin/sui-debug sudo cp ./sui-cli/sui-binaries/sui-test-validator /usr/local/bin/sui-test-validator + + - name: Setup Sui Localnet + shell: bash + run: | + sui client new-env --alias local --rpc http://127.0.0.1:9000 + sui client switch --env local From 0f1c5e23f5525f9285b6d2493ed3beab42409ef8 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 15:14:20 +0700 Subject: [PATCH 21/48] chore: setup random address for sui --- .github/actions/setup-sui/action.yaml | 6 ++++++ .github/workflows/test-sui.yaml | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index 67fbd4e2..ea4554b4 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -60,3 +60,9 @@ runs: run: | sui client new-env --alias local --rpc http://127.0.0.1:9000 sui client switch --env local + sui client new-address secp256k1 wallet + sui client switch --address wallet + SUI_PRIVATE_KEY=$(sui keytool export --key-identity wallet --json | jq .exportedPrivateKey | sed 's/"//g') + SUI_ADDRESS=$(sui keytool export --key-identity wallet --json | jq .key.suiAddress | sed 's/"//g') + echo "SUI_PRIVATE_KEY=${SUI_PRIVATE_KEY}" >> $GITHUB_ENV + echo "SUI_ADDRESS=${SUI_ADDRESS}" >> $GITHUB_ENV diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 66214514..87e12749 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -53,7 +53,7 @@ jobs: # Create .env file with default hardhat private key that's prefunded - name: Prepare .env run: | - echo 'PRIVATE_KEY=suiprivkey1qyw6c8t5ws65fcvlcw5rhyt2jd8d6ad6e526shgktlm0x3aelq9rx2lp4wq' >> .env + echo 'PRIVATE_KEY=$SUI_PRIVATE_KEY' >> .env echo 'ENV=local' >> .env echo 'SKIP_EXISTING = true' >> .env @@ -118,7 +118,7 @@ jobs: run: node sui/operators.js storeCap - name: Add Operator - run: node sui/operators.js add 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 + run: node sui/operators.js add $SUI_ADDRESS - name: Collect Gas with Operator run: node sui/operators.js collectGas --amount 1 @@ -127,7 +127,7 @@ jobs: run: node sui/operators.js refund 0x2 --amount 1 - name: Remove Operator - run: node sui/operators.js remove 0x4e9147724ba2b95242137b8ffe78326d7b35333cb90d42c552b47d0367ef7199 + run: node sui/operators.js remove $SUI_ADDRESS ###### Command: Generate Keypair ###### - name: Generate Keypair From a3043b64bb356edee5c075deab5cae610ba704e0 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 15:25:09 +0700 Subject: [PATCH 22/48] chore: add command to init sui config file --- .github/actions/setup-sui/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index ea4554b4..914d7091 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -58,6 +58,7 @@ runs: - name: Setup Sui Localnet shell: bash run: | + echo -e "y\n\n1" | sui client new-env sui client new-env --alias local --rpc http://127.0.0.1:9000 sui client switch --env local sui client new-address secp256k1 wallet From 843aacf855362e9dd783d3a5822185006fe30fa8 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 15:36:07 +0700 Subject: [PATCH 23/48] fix: setup sui client file --- .github/actions/setup-sui/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index 914d7091..1ebe1f77 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -58,7 +58,7 @@ runs: - name: Setup Sui Localnet shell: bash run: | - echo -e "y\n\n1" | sui client new-env + echo -e "y\n\n1" | sui client envs sui client new-env --alias local --rpc http://127.0.0.1:9000 sui client switch --env local sui client new-address secp256k1 wallet From d64849b453fca03c91c826ec55a84e6b469f44b5 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 17:52:47 +0700 Subject: [PATCH 24/48] chore: fix sui setup error --- .github/actions/setup-sui/action.yaml | 4 +--- .github/workflows/test-sui.yaml | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index 1ebe1f77..d56050dc 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -55,12 +55,10 @@ runs: sudo cp ./sui-cli/sui-binaries/sui-debug /usr/local/bin/sui-debug sudo cp ./sui-cli/sui-binaries/sui-test-validator /usr/local/bin/sui-test-validator - - name: Setup Sui Localnet + - name: Setup Sui Wallet shell: bash run: | echo -e "y\n\n1" | sui client envs - sui client new-env --alias local --rpc http://127.0.0.1:9000 - sui client switch --env local sui client new-address secp256k1 wallet sui client switch --address wallet SUI_PRIVATE_KEY=$(sui keytool export --key-identity wallet --json | jq .exportedPrivateKey | sed 's/"//g') diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 87e12749..2d818ed1 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -34,6 +34,11 @@ jobs: run: sleep 30s shell: bash + - name: Setup Sui Local Network + run: | + sui client new-env --alias local --rpc http://127.0.0.1:9000 + sui client switch --env local + - name: Prepare local.json run: | echo '{ From 2d824f51ad1f48e32f91bf8ca90e500142f16ed1 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 18:09:40 +0700 Subject: [PATCH 25/48] chore: fix var not resolved correctly --- .github/workflows/test-sui.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 2d818ed1..343c7b4d 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -58,7 +58,7 @@ jobs: # Create .env file with default hardhat private key that's prefunded - name: Prepare .env run: | - echo 'PRIVATE_KEY=$SUI_PRIVATE_KEY' >> .env + echo "PRIVATE_KEY=$SUI_PRIVATE_KEY" >> .env echo 'ENV=local' >> .env echo 'SKIP_EXISTING = true' >> .env From fa85ea6afcf8077f19e35c24e67fc81c5bc36f41 Mon Sep 17 00:00:00 2001 From: npty Date: Wed, 21 Aug 2024 18:30:11 +0700 Subject: [PATCH 26/48] chore: fix log --- .github/workflows/test-sui.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 343c7b4d..81e7bb53 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -145,7 +145,5 @@ jobs: ###### Command: Transfer Object ###### - name: Transfer Object run: | - #TODO Checking the objects - sui client objects --json object_id=$(sui client objects --json | jq -r '.[-1].data.objectId') node sui/transfer-object.js --objectId $object_id --recipient 0xdd7c964ff032273889eb6029a29314413b461629c45c0442c6f9cf8342450c12 From a7f961340a81821c8f0939df08e6e03d765ca597 Mon Sep 17 00:00:00 2001 From: npty Date: Fri, 23 Aug 2024 08:45:11 +0000 Subject: [PATCH 27/48] chore: rename test to example --- package-lock.json | 18 +++++------------- package.json | 2 +- sui/deploy-contract.js | 14 +++++++------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index a9f2d8e4..6b05fcbf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.3.1", - "@axelar-network/axelar-cgp-sui": "0.0.0-snapshot.218635e", + "@axelar-network/axelar-cgp-sui": "^0.0.0-snapshot.17fc7f6", "@axelar-network/axelar-gmp-sdk-solidity": "5.10.0", "@axelar-network/interchain-token-service": "1.2.4", "@cosmjs/cosmwasm-stargate": "^0.32.1", @@ -176,15 +176,15 @@ } }, "node_modules/@axelar-network/axelar-cgp-sui": { - "version": "0.0.0-snapshot.218635e", - "resolved": "https://registry.npmjs.org/@axelar-network/axelar-cgp-sui/-/axelar-cgp-sui-0.0.0-snapshot.218635e.tgz", - "integrity": "sha512-+k72piOoq6oz/NFMX57keooSP/OZ7FG8IMPbx5Y8BBIKzxusQzMovZ0inz+StJFfd4i+Ho+FlN98m8tPIqLypg==", + "version": "0.0.0-snapshot.17fc7f6", + "resolved": "https://registry.npmjs.org/@axelar-network/axelar-cgp-sui/-/axelar-cgp-sui-0.0.0-snapshot.17fc7f6.tgz", + "integrity": "sha512-hba0e+bUM59hjNYwfd6SA4D4qJfK5AfpLjcLYdHASlIXr2P08XNgfd3n5gNsiP/F+NWn+cfZ6iq0EG4aOiVPkg==", + "license": "MIT", "dependencies": { "@cosmjs/cosmwasm-stargate": "^0.32.2", "@mysten/sui": "^1.3.0", "ethers": "^5.0.0", "secp256k1": "^5.0.0", - "tmp": "^0.2.1", "typescript": "^5.3.3" }, "engines": { @@ -9935,14 +9935,6 @@ "node": ">= 0.12" } }, - "node_modules/tmp": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", - "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", - "engines": { - "node": ">=14.14" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/package.json b/package.json index 1fbb05ef..14d6a468 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "homepage": "https://github.com/axelarnetwork/axelar-contract-deployments#readme", "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.3.1", - "@axelar-network/axelar-cgp-sui": "0.0.0-snapshot.218635e", + "@axelar-network/axelar-cgp-sui": "^0.0.0-snapshot.17fc7f6", "@axelar-network/axelar-gmp-sdk-solidity": "5.10.0", "@axelar-network/interchain-token-service": "1.2.4", "@cosmjs/cosmwasm-stargate": "^0.32.1", diff --git a/sui/deploy-contract.js b/sui/deploy-contract.js index 67864a7f..90c83f8a 100644 --- a/sui/deploy-contract.js +++ b/sui/deploy-contract.js @@ -42,7 +42,7 @@ const { * 2. Ensure the corresponding folder exists in the specified path * */ -const PACKAGE_DIRS = ['gas_service', 'test', 'axelar_gateway', 'operators', 'abi', 'governance', 'its', 'squid']; +const PACKAGE_DIRS = ['gas_service', 'example', 'axelar_gateway', 'operators', 'abi', 'governance', 'its', 'squid']; /** * Package Mapping Object for Command Options and Post-Deployment Functions @@ -51,7 +51,7 @@ const PACKAGE_CONFIGS = { cmdOptions: { AxelarGateway: () => GATEWAY_CMD_OPTIONS, GasService: () => [], - Test: () => [], + Example: () => [], Operators: () => [], Abi: () => [], Governance: () => [], @@ -61,7 +61,7 @@ const PACKAGE_CONFIGS = { postDeployFunctions: { AxelarGateway: postDeployAxelarGateway, GasService: postDeployGasService, - Test: postDeployTest, + Example: postDeployExample, Operators: postDeployOperators, Abi: {}, Governance: {}, @@ -105,16 +105,16 @@ async function postDeployGasService(published, keypair, client, config, chain, o }; } -async function postDeployTest(published, keypair, client, config, chain, options) { +async function postDeployExample(published, keypair, client, config, chain, options) { const relayerDiscovery = config.sui.contracts.AxelarGateway?.objects?.RelayerDiscovery; - const [singletonObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [`${published.packageId}::test::Singleton`]); + const [singletonObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [`${published.packageId}::gmp::Singleton`]); const channelId = await getSingletonChannelId(client, singletonObjectId); - chain.contracts.Test.objects = { Singleton: singletonObjectId, ChannelId: channelId }; + chain.contracts.Example.objects = { Singleton: singletonObjectId, ChannelId: channelId }; const tx = new Transaction(); tx.moveCall({ - target: `${published.packageId}::test::register_transaction`, + target: `${published.packageId}::gmp::register_transaction`, arguments: [tx.object(relayerDiscovery), tx.object(singletonObjectId)], }); From 40c5b7cdaf5fadc952d5141ab117fd2e8aebfd5d Mon Sep 17 00:00:00 2001 From: npty Date: Fri, 23 Aug 2024 08:47:01 +0000 Subject: [PATCH 28/48] chore: rename test to example in gmp.js --- sui/gmp.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sui/gmp.js b/sui/gmp.js index f2db9ac9..9751b1f5 100644 --- a/sui/gmp.js +++ b/sui/gmp.js @@ -21,9 +21,9 @@ async function sendCommand(keypair, client, contracts, args, options) { const [destinationChain, destinationAddress, feeAmount, payload] = args; const params = options.params; - const [testConfig, gasServiceConfig] = contracts; + const [exampleConfig, gasServiceConfig] = contracts; const gasServiceObjectId = gasServiceConfig.objects.GasService; - const singletonObjectId = testConfig.objects.Singleton; + const singletonObjectId = exampleConfig.objects.Singleton; const unitAmount = getUnitAmount(feeAmount); const walletAddress = keypair.toSuiAddress(); @@ -33,7 +33,7 @@ async function sendCommand(keypair, client, contracts, args, options) { const [coin] = tx.splitCoins(tx.gas, [unitAmount]); tx.moveCall({ - target: `${testConfig.address}::test::send_call`, + target: `${exampleConfig.address}::gmp::send_call`, arguments: [ tx.object(singletonObjectId), tx.object(gasServiceObjectId), @@ -52,18 +52,18 @@ async function sendCommand(keypair, client, contracts, args, options) { } async function execute(keypair, client, contracts, args, options) { - const [testConfig, , axelarGatewayConfig] = contracts; + const [exampleConfig, , axelarGatewayConfig] = contracts; const [sourceChain, messageId, sourceAddress, payload] = args; const gatewayObjectId = axelarGatewayConfig.objects.Gateway; const discoveryObjectId = axelarGatewayConfig.objects.RelayerDiscovery; - // Get the channel id from the options or use the channel id from the deployed test contract object. - const channelId = options.channelId || testConfig.objects.ChannelId; + // Get the channel id from the options or use the channel id from the deployed Example contract object. + const channelId = options.channelId || exampleConfig.objects.ChannelId; if (!channelId) { - throw new Error('Please provide either a channel id (--channelId) or deploy the test contract'); + throw new Error('Please provide either a channel id (--channelId) or deploy the Example contract'); } // Get Discovery table id from discovery object @@ -150,7 +150,7 @@ async function processCommand(command, chain, args, options) { await printWalletInfo(keypair, client, chain, options); - const contracts = [chain.contracts.Test, chain.contracts.GasService, chain.contracts.AxelarGateway]; + const contracts = [chain.contracts.Example, chain.contracts.GasService, chain.contracts.AxelarGateway]; await command(keypair, client, contracts, args, options); } From 0b2791ddcc4f9f73e938610c2c8d686f48b9c15e Mon Sep 17 00:00:00 2001 From: npty Date: Fri, 23 Aug 2024 08:55:46 +0000 Subject: [PATCH 29/48] chore: fix deploy test step --- .github/workflows/test-sui.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 81e7bb53..78ad9631 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -79,8 +79,8 @@ jobs: - name: Deploy Operators run: node sui/deploy-contract deploy Operators - - name: Deploy Test - run: node sui/deploy-contract deploy Test + - name: Deploy Example + run: node sui/deploy-contract deploy Example ###### Command: Gas Service ###### From 8d0dd0393bffa916a3caa564555206009bd2c2d9 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 13:32:47 +0700 Subject: [PATCH 30/48] chore: try adding newNonce for rotate signers --- .github/workflows/test-sui.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 78ad9631..d1ce6fb7 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -115,7 +115,7 @@ jobs: # TODO: Fix error in this command - name: Gateway Rotate Signers continue-on-error: true - run: node sui/gateway.js rotate --signers wallet --proof wallet + run: node sui/gateway.js rotate --signers wallet --proof wallet --newNonce test2 ###### Command: Operators ###### From 1827313917ff9c0f7f21cc684b92f53a93ed7530 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 13:37:36 +0700 Subject: [PATCH 31/48] chore: update arg for gas refund --- .github/workflows/test-sui.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index d1ce6fb7..0cf030c2 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -88,7 +88,7 @@ jobs: run: node sui/gas-service.js payGas --amount 100 ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0xba76c6980428A0b10CFC5d8ccb61949677A61233 0x1234 - name: Refund Gas - run: node sui/gas-service.js refund 0x2 --amount 1 + run: node sui/gas-service.js refund 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 --amount 1 - name: Collect Gas run: node sui/gas-service.js collectGas --amount 0.1 @@ -129,7 +129,7 @@ jobs: run: node sui/operators.js collectGas --amount 1 - name: Refund Gas with Operator - run: node sui/operators.js refund 0x2 --amount 1 + run: node sui/operators.js refund 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 --amount 1 - name: Remove Operator run: node sui/operators.js remove $SUI_ADDRESS From 903956289621d3e41a95305861875661b98caf34 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 13:38:10 +0700 Subject: [PATCH 32/48] chore: rename --- .github/actions/setup-sui/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-sui/action.yaml b/.github/actions/setup-sui/action.yaml index d56050dc..030604cf 100644 --- a/.github/actions/setup-sui/action.yaml +++ b/.github/actions/setup-sui/action.yaml @@ -1,4 +1,4 @@ -name: Setup SUI Cli +name: Setup Sui CLI description: 'Setup Sui CLI and install dependencies' inputs: From 8149a89ac061a09b0f902e295c1f8fcc808c987e Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 13:45:24 +0700 Subject: [PATCH 33/48] chore: edit local.json --- .github/workflows/test-sui.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 0cf030c2..71845609 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -49,9 +49,7 @@ jobs: "tokenSymbol": "SUI", "rpc": "http://127.0.0.1:9000", "faucetUrl": "http://127.0.0.1:9123", - "contracts": { - "AxelarGateway": {} - } + "contracts": {} } }' > ./axelar-chains-config/info/local.json From 74300b30aea90ac17a7dcc67b0f1743c943666d1 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 13:46:07 +0700 Subject: [PATCH 34/48] chore: test gateway before gmp --- .github/workflows/test-sui.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 71845609..2ef66ea2 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -91,18 +91,6 @@ jobs: - name: Collect Gas run: node sui/gas-service.js collectGas --amount 0.1 - ###### Command: GMP ###### - - - name: Execute Outgoing Call Contract - run: node sui/gmp.js sendCall ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0.1 0x1234 - - # TODO: Fix error in this command - - name: Execute Incoming Call Contract - continue-on-error: true - run: | - node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 - node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 - ###### Command: Gateway ###### - name: Gateway Approve run: node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 @@ -115,6 +103,18 @@ jobs: continue-on-error: true run: node sui/gateway.js rotate --signers wallet --proof wallet --newNonce test2 + ###### Command: GMP ###### + + - name: Execute Outgoing Call Contract + run: node sui/gmp.js sendCall ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0.1 0x1234 + + # TODO: Fix error in this command + - name: Execute Incoming Call Contract + continue-on-error: true + run: | + node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 + ###### Command: Operators ###### - name: Store Capability Object in Operators From ffba33aa9698f21234e69fea79fa90b6ee4e1e58 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 13:49:43 +0700 Subject: [PATCH 35/48] chore: update readme for example contract deployment --- .github/workflows/test-sui.yaml | 2 -- sui/README.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 2ef66ea2..bc4ffe01 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -98,9 +98,7 @@ jobs: - name: Gateway Call Contract run: node sui/gateway.js call-contract ethereum 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 - # TODO: Fix error in this command - name: Gateway Rotate Signers - continue-on-error: true run: node sui/gateway.js rotate --signers wallet --proof wallet --newNonce test2 ###### Command: GMP ###### diff --git a/sui/README.md b/sui/README.md index 636858d4..ef5f4a74 100644 --- a/sui/README.md +++ b/sui/README.md @@ -100,7 +100,7 @@ node sui/deploy-contract.js deploy GasService Deploy the test GMP package: ```bash -node sui/deploy-contract.js deploy Test +node sui/deploy-contract.js deploy Example ``` Deploy the Operators package: From c8b556050d1e6c0b7ea31f582801602f0839c48e Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 14:20:48 +0700 Subject: [PATCH 36/48] chore: bump axelar-cgp-sui to 0.4.1 --- package-lock.json | 9 ++++----- package.json | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0b3bff3c..4e5b0c8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.3.1", - "@axelar-network/axelar-cgp-sui": "^0.0.0-snapshot.17fc7f6", + "@axelar-network/axelar-cgp-sui": "^0.4.1", "@axelar-network/axelar-gmp-sdk-solidity": "5.10.0", "@axelar-network/interchain-token-service": "1.2.4", "@cosmjs/cosmwasm-stargate": "^0.32.1", @@ -176,10 +176,9 @@ } }, "node_modules/@axelar-network/axelar-cgp-sui": { - "version": "0.0.0-snapshot.17fc7f6", - "resolved": "https://registry.npmjs.org/@axelar-network/axelar-cgp-sui/-/axelar-cgp-sui-0.0.0-snapshot.17fc7f6.tgz", - "integrity": "sha512-hba0e+bUM59hjNYwfd6SA4D4qJfK5AfpLjcLYdHASlIXr2P08XNgfd3n5gNsiP/F+NWn+cfZ6iq0EG4aOiVPkg==", - "license": "MIT", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@axelar-network/axelar-cgp-sui/-/axelar-cgp-sui-0.4.1.tgz", + "integrity": "sha512-7ZPotOheP0ZxSm++SHsjpvTTsTuyJx747U3S0Ud+3RVXNBMnMCuC0jZsoyqD0sJMJdQLmT4pz/fFOIPCWAhjhw==", "dependencies": { "@cosmjs/cosmwasm-stargate": "^0.32.2", "@mysten/sui": "^1.3.0", diff --git a/package.json b/package.json index 14d6a468..12fc79e1 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "homepage": "https://github.com/axelarnetwork/axelar-contract-deployments#readme", "dependencies": { "@axelar-network/axelar-cgp-solidity": "6.3.1", - "@axelar-network/axelar-cgp-sui": "^0.0.0-snapshot.17fc7f6", + "@axelar-network/axelar-cgp-sui": "^0.4.1", "@axelar-network/axelar-gmp-sdk-solidity": "5.10.0", "@axelar-network/interchain-token-service": "1.2.4", "@cosmjs/cosmwasm-stargate": "^0.32.1", From 6f4e6add9314a47c155bec7fa427caa8a4d12ae8 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 16:07:41 +0700 Subject: [PATCH 37/48] chore: fix executing incoming call contract step --- .github/workflows/test-sui.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index bc4ffe01..0f94e63e 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -106,11 +106,10 @@ jobs: - name: Execute Outgoing Call Contract run: node sui/gmp.js sendCall ethereum 0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05 0.1 0x1234 - # TODO: Fix error in this command - name: Execute Incoming Call Contract - continue-on-error: true run: | - node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + channel_id=$(cat axelar-chains-config/info/local.json | jq '.sui.contracts.Example.objects.ChannelId' | sed 's/"//g') + node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 $channel_id 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 ###### Command: Operators ###### From 8f577a505cf50838e5aa40284bb4a662ffcc4b57 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 16:18:59 +0700 Subject: [PATCH 38/48] chore: log channel id --- .github/workflows/test-sui.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 0f94e63e..8e08b4ea 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -109,6 +109,7 @@ jobs: - name: Execute Incoming Call Contract run: | channel_id=$(cat axelar-chains-config/info/local.json | jq '.sui.contracts.Example.objects.ChannelId' | sed 's/"//g') + echo "Channel ID: $channel_id" node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 $channel_id 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 From 58f496c59e1668e7eddd265f208a050a10fa5361 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 16:20:00 +0700 Subject: [PATCH 39/48] chore: update log index in approve and execute --- .github/workflows/test-sui.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 8e08b4ea..c9ec7451 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -110,8 +110,8 @@ jobs: run: | channel_id=$(cat axelar-chains-config/info/local.json | jq '.sui.contracts.Example.objects.ChannelId' | sed 's/"//g') echo "Channel ID: $channel_id" - node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 $channel_id 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 - node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 + node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-3 0x4F4495243837681061C4743b74B3eEdf548D56A5 $channel_id 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 + node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-3 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 ###### Command: Operators ###### From d0e244d4da78e95a0a5449291942871ce1cd98e8 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 16:24:17 +0700 Subject: [PATCH 40/48] chore: remove extra line --- sui/docs/gmp.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sui/docs/gmp.md b/sui/docs/gmp.md index 77529797..a12ea268 100644 --- a/sui/docs/gmp.md +++ b/sui/docs/gmp.md @@ -57,7 +57,6 @@ This command will execute the message to the contract that associated with the g node sui/gmp.js execute ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-2 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x1234 --channelId 0xcd5d203ea2cf1139af83939e3f74114a31fe682cc90f73a0d2647956bc3e5acf ``` - Note: - `source`, `sourceAddress` and `messageId` needed to be matched with the approve command. - `payload` must be associated with the `payloadHash` in the approve command. From 0f499004df9b530a4a74056fa961d61590490f95 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 17:13:51 +0700 Subject: [PATCH 41/48] chore: add version.json --- .github/workflows/test-sui.yaml | 9 ++++++--- sui/version.json | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 sui/version.json diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index c9ec7451..1364c12c 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -2,9 +2,6 @@ name: Test Sui on: pull_request -env: - SUI_VERSION: mainnet-v1.25.3 - jobs: test-sui: runs-on: blacksmith-2vcpu-ubuntu-2204 @@ -22,6 +19,12 @@ jobs: - name: Install run: npm ci + - name: Read SUI_VERSION from JSON + id: read-json + run: | + SUI_VERSION=$(jq -r '.SUI_VERSION' sui/version.json) + echo "SUI_VERSION=${SUI_VERSION}" >> $GITHUB_ENV + - name: Setup Sui CLI and install dependencies uses: ./.github/actions/setup-sui with: diff --git a/sui/version.json b/sui/version.json new file mode 100644 index 00000000..32a8c3ef --- /dev/null +++ b/sui/version.json @@ -0,0 +1,3 @@ +{ + "SUI_VERSION": "mainnet-v1.25.3" +} From 4efc586fdcfd6291ac49bc9686bda4cfffa15557 Mon Sep 17 00:00:00 2001 From: npty Date: Tue, 27 Aug 2024 17:41:07 +0700 Subject: [PATCH 42/48] chore: print version mismatch message when deploy a contract --- sui/deploy-contract.js | 4 ++++ sui/utils/utils.js | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/sui/deploy-contract.js b/sui/deploy-contract.js index bb9da4e1..9aa99b58 100644 --- a/sui/deploy-contract.js +++ b/sui/deploy-contract.js @@ -27,6 +27,7 @@ const { getSingletonChannelId, getItsChannelId, getSquidChannelId, + checkSuiVersionMatch, } = require('./utils'); /** @@ -246,6 +247,9 @@ async function postDeploySquid(published, keypair, client, config, chain, option async function deploy(keypair, client, supportedContract, config, chain, options) { const { packageDir, packageName } = supportedContract; + // Print warning if version mismatch from defined version in version.json + checkSuiVersionMatch(); + // Deploy package const published = await deployPackage(packageDir, client, keypair, options); diff --git a/sui/utils/utils.js b/sui/utils/utils.js index 46753402..7d083767 100644 --- a/sui/utils/utils.js +++ b/sui/utils/utils.js @@ -2,7 +2,8 @@ const { ethers } = require('hardhat'); const toml = require('toml'); -const { printInfo, printError } = require('../../common/utils'); +const { execSync } = require('child_process'); +const { printInfo, printError, printWarn } = require('../../common/utils'); const { BigNumber, utils: { arrayify, hexlify, toUtf8Bytes, keccak256 }, @@ -73,6 +74,33 @@ const findPublishedObject = (published, packageDir, contractName) => { return published.publishTxn.objectChanges.find((change) => change.objectType === `${packageId}::${packageDir}::${contractName}`); }; +const getInstalledSuiVersion = () => { + const suiVersion = execSync('sui --version').toString().trim(); + return parseVersion(suiVersion); +}; + +const getDefinedSuiVersion = () => { + const version = fs.readFileSync(`${__dirname}/../version.json`, 'utf8'); + const suiVersion = JSON.parse(version).SUI_VERSION; + return parseVersion(suiVersion); +}; + +const parseVersion = (version) => { + const versionMatch = version.match(/\d+\.\d+\.\d+/); + return versionMatch[0]; +}; + +const checkSuiVersionMatch = () => { + const installedVersion = getInstalledSuiVersion(); + const definedVersion = getDefinedSuiVersion(); + + if (installedVersion !== definedVersion) { + printWarn('Version mismatch detected:'); + printWarn(`- Installed SUI version: ${installedVersion}`); + printWarn(`- Version used for tests: ${definedVersion}`); + } +}; + const readMovePackageName = (moveDir) => { try { const moveToml = fs.readFileSync( @@ -220,6 +248,7 @@ module.exports = { paginateAll, suiPackageAddress, suiClockAddress, + checkSuiVersionMatch, findOwnedObjectId, getBcsBytesByObjectId, deployPackage, From e5138752f1d51a0b3b0d29d83fd9c3800300b3e1 Mon Sep 17 00:00:00 2001 From: npty <78221556+npty@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:01:28 +0700 Subject: [PATCH 43/48] feat(sui): add init multisig command (#349) --- .github/workflows/test-sui.yaml | 66 +++++++++++++++++++++++-- sui/faucet.js | 19 ++++--- sui/multisig.js | 87 +++++++++++++++++++++++++++++++-- 3 files changed, 157 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 1364c12c..c38bdb01 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -33,9 +33,13 @@ jobs: - name: Spin up Sui Network run: nohup sh -c "sui-test-validator" > nohup.out 2> nohup.err < /dev/null & - - name: Sleep for 30 seconds - run: sleep 30s - shell: bash + - name: Wait for Sui network + uses: nev7n/wait_for_response@v1 + with: + url: 'http://localhost:9123' + responseCode: 200 + timeout: 60000 + interval: 1000 - name: Setup Sui Local Network run: | @@ -139,7 +143,61 @@ jobs: ###### Command: Multisig ###### - # TODO: Add multisig tests + - name: Init Multisig + run: | + # Create new addresses + sui client new-address secp256k1 multisig1 + sui client new-address secp256k1 multisig2 + + # Export keys and addresses + KEY_1=$(sui keytool export --key-identity multisig1 --json | jq -r .key.publicBase64Key) + KEY_2=$(sui keytool export --key-identity multisig2 --json | jq -r .key.publicBase64Key) + + # Get multisig address + MULTISIG_ADDRESS=$(sui keytool multi-sig-address --pks $KEY_1 $KEY_2 --weights 1 1 --threshold 1 --json | jq -r .multisigAddress) + + # Initialize multisig + node sui/multisig.js --action init --threshold 1 --base64PublicKeys $KEY_1 $KEY_2 --schemeTypes secp256k1 secp256k1 + + # Faucet operations + node sui/faucet.js --recipient $MULTISIG_ADDRESS + + # Set environment variables + echo "MULTISIG_ADDRESS=$MULTISIG_ADDRESS" >> $GITHUB_ENV + + - name: Transfer Upgrade Cap to Multisig Address + run: | + upgrade_cap=$(cat axelar-chains-config/info/local.json | jq -r '.sui.contracts.AxelarGateway.objects.UpgradeCap') + node sui/transfer-object.js --objectId $upgrade_cap --recipient $MULTISIG_ADDRESS + + - name: Generate Unsigned Tx File + run: | + node sui/deploy-contract.js upgrade AxelarGateway any_upgrade --offline --txFilePath ./tx-upgrade.json --sender $MULTISIG_ADDRESS + + - name: Sign Tx File with Multisig Signer + run: | + pk_1=$(sui keytool export --key-identity multisig1 --json | jq .exportedPrivateKey | sed 's/"//g') + pk_2=$(sui keytool export --key-identity multisig2 --json | jq .exportedPrivateKey | sed 's/"//g') + node sui/multisig.js --action sign --txBlockPath ./tx-upgrade.json --signatureFilePath signature-1.json --offline --privateKey $pk_1 + node sui/multisig.js --action sign --txBlockPath ./tx-upgrade.json --signatureFilePath signature-2.json --offline --privateKey $pk_2 + + - name: Submit Signed Tx File + run: | + # Define output file for the executed transaction + output_file="./output.json" + + # Execute the upgrade transaction + node sui/multisig.js --txBlockPath ./tx-upgrade.json --signatureFilePath ./combined.json --action combine --signatures signature-1.json signature-2.json --executeResultPath ${output_file} + + # Store the new package id in a variable + new_package_id=$(jq '.objectChanges[] | select(.type == "published") | .packageId' $output_file | sed 's/"//g') + + # Update the local.json file with the new package id + jq --arg pkg "$new_package_id" '.sui.contracts.AxelarGateway.address = $pkg' axelar-chains-config/info/local.json > temp.json \ + && mv temp.json axelar-chains-config/info/local.json + + - name: Post Upgrade Gateway Approval With New Package ID + run: node sui/gateway.js approve --proof wallet ethereum 0x32034b47cb29d162d9d803cc405356f4ac0ec07fe847ace431385fe8acf3e6e5-10 0x4F4495243837681061C4743b74B3eEdf548D56A5 0x6ce0d81b412abca2770eddb1549c9fcff721889c3aab1203dc93866db22ecc4b 0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432 ###### Command: Transfer Object ###### - name: Transfer Object diff --git a/sui/faucet.js b/sui/faucet.js index a52acdb1..2ffb69b0 100644 --- a/sui/faucet.js +++ b/sui/faucet.js @@ -3,19 +3,20 @@ const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui/faucet'); const { saveConfig, loadConfig, printInfo } = require('../common/utils'); const { getWallet, printWalletInfo, addBaseOptions } = require('./utils'); -const { Command } = require('commander'); +const { Command, Option } = require('commander'); async function processCommand(config, chain, options) { const [keypair, client] = getWallet(chain, options); + const recipient = options.recipient || keypair.toSuiAddress(); await printWalletInfo(keypair, client, chain, options); await requestSuiFromFaucetV0({ host: getFaucetHost(chain.networkType), - recipient: keypair.toSuiAddress(), + recipient, }); - printInfo('Funds requested'); + printInfo('Funds requested', recipient); } async function mainProcessor(options, processor) { @@ -27,13 +28,15 @@ async function mainProcessor(options, processor) { if (require.main === module) { const program = new Command(); - program.name('faucet').description('Query the faucet for funds.'); + program + .name('faucet') + .addOption(new Option('--recipient ', 'recipient to request funds for')) + .description('Query the faucet for funds.') + .action((options) => { + mainProcessor(options, processCommand); + }); addBaseOptions(program); - program.action((options) => { - mainProcessor(options, processCommand); - }); - program.parse(); } diff --git a/sui/multisig.js b/sui/multisig.js index c09fef3a..a1cfbd9e 100644 --- a/sui/multisig.js +++ b/sui/multisig.js @@ -1,9 +1,63 @@ const { Command, Option } = require('commander'); const { fromB64 } = require('@mysten/bcs'); -const { loadConfig, printInfo, validateParameters } = require('../common/utils'); +const { saveConfig } = require('../common/utils'); +const { loadConfig, printInfo, validateParameters, printWarn } = require('../common/utils'); const { getSignedTx, storeSignedTx } = require('../evm/sign-utils'); const { addBaseOptions, getWallet, getMultisig, signTransactionBlockBytes, broadcastSignature } = require('./utils'); +async function initMultisigConfig(chain, options) { + const { base64PublicKeys, threshold } = options; + + if (!base64PublicKeys) { + throw new Error('Please provide public keys with --base64PublicKeys option'); + } + + if (!threshold) { + throw new Error('Please provide threshold with --threshold option'); + } + + const uniqueKeys = new Set(base64PublicKeys); + + if (uniqueKeys.size !== base64PublicKeys.length) { + throw new Error('Duplicate public keys found'); + } + + const schemeTypes = options.schemeTypes || Array(base64PublicKeys.length).fill('secp256k1'); + const weights = options.weights || Array(base64PublicKeys.length).fill(1); + + if (!options.schemeTypes) { + printWarn('Scheme types not provided, defaulting to secp256k1'); + } + + if (!options.weights) { + printWarn('Weights not provided, defaulting to 1'); + } + + if (base64PublicKeys.length !== weights.length) { + throw new Error('Public keys and weights length mismatch'); + } + + if (base64PublicKeys.length !== schemeTypes.length) { + throw new Error('Public keys and scheme types length mismatch'); + } + + const signers = base64PublicKeys.map((key, i) => ({ + publicKey: key, + weight: parseInt(weights[i]), + schemeType: options.schemeTypes[i], + })); + + chain.multisig = { + signers, + threshold: parseInt(threshold), + }; + + printInfo('Saved multisig config'); + + // To print in the separate lines with proper indentation + printInfo(JSON.stringify(chain.multisig, null, 2)); +} + async function signTx(keypair, client, options) { const txFileData = getSignedTx(options.txBlockPath); const txData = txFileData?.unsignedTx; @@ -85,7 +139,12 @@ async function combineSignature(client, chain, options) { if (!options.offline) { const txResult = await broadcastSignature(client, txBlockBytes, combinedSignature); - printInfo('Transaction result', JSON.stringify(txResult)); + + if (options.executeResultPath) { + storeSignedTx(options.executeResultPath, txResult); + } + + printInfo('Executed', txResult.digest); } else { const data = { message: firstSignData.message, @@ -104,6 +163,11 @@ async function processCommand(chain, options) { let fileData; switch (options.action) { + case 'init': { + fileData = await initMultisigConfig(chain, options); + break; + } + case 'sign': { fileData = await signTx(keypair, client, options); break; @@ -143,6 +207,7 @@ async function processCommand(chain, options) { async function mainProcessor(options, processor) { const config = loadConfig(options.env); await processor(config.sui, options); + saveConfig(config, options.env); } if (require.main === module) { @@ -153,12 +218,28 @@ if (require.main === module) { addBaseOptions(program); program.addOption(new Option('--txBlockPath ', 'path to unsigned tx block')); - program.addOption(new Option('--action ', 'action').choices(['sign', 'combine', 'execute']).makeOptionMandatory(true)); + program.addOption(new Option('--action ', 'action').choices(['sign', 'combine', 'execute', 'init']).makeOptionMandatory(true)); program.addOption(new Option('--multisigKey ', 'multisig key').env('MULTISIG_KEY')); program.addOption(new Option('--signatures [files...]', 'array of signed transaction files')); program.addOption(new Option('--offline', 'run in offline mode')); program.addOption(new Option('--combinedSignPath ', 'combined signature file path')); program.addOption(new Option('--signatureFilePath ', 'signed signature will be stored')); + program.addOption(new Option('--executeResultPath ', 'execute result will be stored')); + + // The following options are only used with the init action + program.addOption( + new Option('--base64PublicKeys [base64PublicKeys...]', 'An array of public keys to use for init the multisig address'), + ); + program.addOption( + new Option('--weights [weights...]', 'An array of weight for each base64 public key. The default value is 1 for each'), + ); + program.addOption( + new Option( + '--schemeTypes [schemeTypes...]', + 'An array of scheme types for each base64 public key. The default value is secp256k1 for each', + ), + ); + program.addOption(new Option('--threshold ', 'threshold for multisig')); program.action((options) => { mainProcessor(options, processCommand); From 0ad655d13ee3f4c50514ffa3c966074811b0fde6 Mon Sep 17 00:00:00 2001 From: npty Date: Thu, 29 Aug 2024 12:27:37 +0000 Subject: [PATCH 44/48] chore: check if sui test are needed --- .github/workflows/test-sui.yaml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index c38bdb01..1119dd24 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -3,9 +3,31 @@ name: Test Sui on: pull_request jobs: - test-sui: + check-relevant-changes: + name: Check for Relevant Changes runs-on: blacksmith-2vcpu-ubuntu-2204 + outputs: + run_tests: ${{ steps.filter.outputs.sui == 'true' || steps.filter.outputs.common == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + sui: + - 'sui/**' + common: + - 'common/**' + - name: Summarize Changes + run: | + echo "Changes in sui: ${{ steps.filter.outputs.sui }}" + echo "Changes in common: ${{ steps.filter.outputs.common }}" + test-sui: + name: Test Sui + needs: check-relevant-changes + if: needs.check-relevant-changes.outputs.run_tests == 'true' + runs-on: blacksmith-2vcpu-ubuntu-2204 steps: - name: Checkout code uses: actions/checkout@v4 From 4a0a32f971c0736787467224ec090c01f43932fe Mon Sep 17 00:00:00 2001 From: npty Date: Thu, 29 Aug 2024 12:32:31 +0000 Subject: [PATCH 45/48] chore: check for gh workflows as well --- .github/workflows/test-sui.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 1119dd24..6b4b5433 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -18,6 +18,9 @@ jobs: - 'sui/**' common: - 'common/**' + .github: + - '.github/actions/setup-sui/**' + - '.github/workflows/test-sui.yaml' - name: Summarize Changes run: | From 193770d7de0726c79212f5cbf7a951555193ec55 Mon Sep 17 00:00:00 2001 From: npty Date: Thu, 29 Aug 2024 19:47:46 +0700 Subject: [PATCH 46/48] chore: remove redundant job --- .github/workflows/test-sui.yaml | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 6b4b5433..8d77f115 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -1,31 +1,14 @@ name: Test Sui -on: pull_request +on: + pull_request: + paths: + - sui/** + - common/** + - .github/actions/setup-sui/** + - .github/workflows/test-sui.yaml jobs: - check-relevant-changes: - name: Check for Relevant Changes - runs-on: blacksmith-2vcpu-ubuntu-2204 - outputs: - run_tests: ${{ steps.filter.outputs.sui == 'true' || steps.filter.outputs.common == 'true' }} - steps: - - uses: actions/checkout@v4 - - uses: dorny/paths-filter@v3 - id: filter - with: - filters: | - sui: - - 'sui/**' - common: - - 'common/**' - .github: - - '.github/actions/setup-sui/**' - - '.github/workflows/test-sui.yaml' - - - name: Summarize Changes - run: | - echo "Changes in sui: ${{ steps.filter.outputs.sui }}" - echo "Changes in common: ${{ steps.filter.outputs.common }}" test-sui: name: Test Sui needs: check-relevant-changes From f0a1f8f92d2a999baac16ab4f7c46cf5dae5ba97 Mon Sep 17 00:00:00 2001 From: npty Date: Thu, 29 Aug 2024 19:49:31 +0700 Subject: [PATCH 47/48] chore: remove unneeded checks --- .github/workflows/test-sui.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index 8d77f115..b36a2144 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -11,8 +11,6 @@ on: jobs: test-sui: name: Test Sui - needs: check-relevant-changes - if: needs.check-relevant-changes.outputs.run_tests == 'true' runs-on: blacksmith-2vcpu-ubuntu-2204 steps: - name: Checkout code From d75c9dd379b6288c04cf15e0c18370dc9b7d6a9a Mon Sep 17 00:00:00 2001 From: npty Date: Thu, 29 Aug 2024 19:52:31 +0700 Subject: [PATCH 48/48] chore: prettier --- .github/workflows/test-sui.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-sui.yaml b/.github/workflows/test-sui.yaml index b36a2144..47d14a32 100644 --- a/.github/workflows/test-sui.yaml +++ b/.github/workflows/test-sui.yaml @@ -1,6 +1,6 @@ name: Test Sui -on: +on: pull_request: paths: - sui/**