diff --git a/package-lock.json b/package-lock.json index a9f2d8e4..1c96f88d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3116,9 +3116,9 @@ } }, "node_modules/axios": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz", - "integrity": "sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw==", + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.5.tgz", + "integrity": "sha512-fZu86yCo+svH3uqJ/yTdQ0QHpQu5oL+/QE+QPSv6BZSkDAoky9vytxp7u5qk83OJFS3kEBcesWni9WTZAv3tSw==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -4373,9 +4373,9 @@ } }, "node_modules/elliptic": { - "version": "6.5.6", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.6.tgz", - "integrity": "sha512-mpzdtpeCLuS3BmE3pO3Cpp5bbjlOPY2Q0PgoF+Od1XZrHLYI28Xe3ossCmYCQt11FQKEYd9+PF8jymTvtWJSHQ==", + "version": "6.5.7", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", + "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -7605,9 +7605,9 @@ "peer": true }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "peer": true, "dependencies": { diff --git a/sui/README.md b/sui/README.md index 373fed84..636858d4 100644 --- a/sui/README.md +++ b/sui/README.md @@ -189,6 +189,11 @@ node sui/gateway.js rotate --signers wallet --proof wallet --currentNonce test - Use the same nonce for `--currentNonce` as the `--nonce` when deploying the gateway. +To submit a proof constructed on Amplifier, run the following with the multisig session id, +```bash +node sui/gateway.js submitProof [multisig session id] +``` + ### Multisig To create a Multisig, follow the documentation [here](https://docs.sui.io/guides/developer/cryptography/multisig). diff --git a/sui/gateway.js b/sui/gateway.js index 5d20dc95..9646e746 100644 --- a/sui/gateway.js +++ b/sui/gateway.js @@ -202,7 +202,7 @@ async function approve(keypair, client, config, chain, contractConfig, args, opt 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()), ], @@ -213,32 +213,49 @@ async function approve(keypair, client, config, chain, contractConfig, args, opt printInfo('Approved messages', receipt.digest); } -async function rotateSigners(keypair, client, config, chain, contractConfig, args, options) { +async function submitProof(keypair, client, config, chain, contractConfig, args, options) { const packageId = contractConfig.address; - const [multisigSessionId] = args; + const [ multisigSessionId ] = args; const { payload, status } = await getMultisigProof(config, chain.axelarId, multisigSessionId); - if (!payload.verifier_set) { - throw new Error('No signers to rotate'); - } - if (!status.completed) { throw new Error('Multisig session not completed'); } const executeData = executeDataStruct.parse(arrayify('0x' + status.completed.execute_data)); + if (!payload.verifier_set) { + throw new Error('No signers to rotate'); + } + const tx = new Transaction(); - tx.moveCall({ - target: `${packageId}::gateway::rotate_signers`, - arguments: [ - tx.object(contractConfig.objects.Gateway), - tx.object(suiClockAddress), - tx.pure(bcs.vector(bcs.u8()).serialize(new Uint8Array(executeData.payload)).toBytes()), - tx.pure(bcs.vector(bcs.u8()).serialize(new Uint8Array(executeData.proof)).toBytes()), - ], - }); + if (payload.verifier_set) { + printInfo('Submitting rotate_signers'); + + tx.moveCall({ + target: `${packageId}::gateway::rotate_signers`, + arguments: [ + tx.object(contractConfig.objects.Gateway), + tx.object(suiClockAddress), + tx.pure(bcs.vector(bcs.u8()).serialize(new Uint8Array(executeData.payload)).toBytes()), + tx.pure(bcs.vector(bcs.u8()).serialize(new Uint8Array(executeData.proof)).toBytes()), + ], + }); + } else if (payload.messages) { + printInfo('Submitting approve_messages'); + + tx.moveCall({ + target: `${packageId}::gateway::approve_messages`, + arguments: [ + tx.object(contractConfig.objects.Gateway), + tx.pure(bcs.vector(bcs.u8()).serialize(new Uint8Array(executeData.payload)).toBytes()), + tx.pure(bcs.vector(bcs.u8()).serialize(new Uint8Array(executeData.proof)).toBytes()), + ], + }); + } else { + throw new Error(`Unknown payload type: ${payload}`); + } const receipt = await broadcast(client, keypair, tx); @@ -271,9 +288,9 @@ async function rotate(keypair, client, config, chain, contractConfig, args, opti ], }); - await broadcast(client, keypair, tx); + const receipt = await broadcast(client, keypair, tx); - printInfo('Signers rotated succesfully'); + printInfo('Signers rotated', receipt.digest); } async function mainProcessor(processor, args, options) { @@ -324,10 +341,10 @@ if (require.main === module) { }); program - .command('rotateSigners ') - .description('Rotate signers at the gateway contract from amplifier proof') + .command('submitProof ') + .description('Submit proof for the provided amplifier multisig session id') .action((multisigSessionId, options) => { - mainProcessor(rotateSigners, [multisigSessionId], options); + mainProcessor(submitProof, [multisigSessionId], options); }); program