Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use axelar-cgp-sui 0.3.0 and sui sdk 1.x #315

Merged
merged 8 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 37 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"dependencies": {
"@0xpolygonhermez/zkevm-commonjs": "github:0xpolygonhermez/zkevm-commonjs#v1.0.0",
"@axelar-network/axelar-cgp-solidity": "6.3.1",
"@axelar-network/axelar-cgp-sui": "https://github.com/axelarnetwork/axelar-cgp-sui.git",
"@axelar-network/axelar-cgp-sui": "^0.3.0",
"@axelar-network/axelar-gmp-sdk-solidity": "5.9.0",
"@axelar-network/interchain-token-service": "1.2.4",
"@cosmjs/cosmwasm-stargate": "^0.32.1",
"@ledgerhq/hw-app-eth": "6.32.2",
"@mysten/sui.js": "^0.54.1",
"@mysten/sui": "^1.3.0",
"@stellar/stellar-sdk": "^12.0.0-rc3",
"axios": "^1.6.2",
"path": "^0.12.7"
Expand Down
7 changes: 3 additions & 4 deletions sui/deploy-contract.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { saveConfig, printInfo } = require('../evm/utils');
const { Command, Argument, Option } = require('commander');
const { publishPackage, updateMoveToml } = require('@axelar-network/axelar-cgp-sui/scripts/publish-package');

const { updateMoveToml } = require('@axelar-network/axelar-cgp-sui');
const { addBaseOptions } = require('./cli-utils');
const { getWallet, printWalletInfo } = require('./sign-utils');
const { loadSuiConfig, findPublishedObject } = require('./utils');
const { loadSuiConfig, findPublishedObject, deployPackage } = require('./utils');

// Add more contracts here to support more modules deployment
const contractMap = {
Expand All @@ -25,7 +24,7 @@ async function processCommand(contractName, config, chain, options) {
chain.contracts[contractName] = {};
}

const published = await publishPackage(packageName, client, keypair);
const published = await deployPackage(packageName, client, keypair);
const packageId = published.packageId;

updateMoveToml(packageName, packageId);
Expand Down
15 changes: 10 additions & 5 deletions sui/deploy-gateway.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { saveConfig, prompt, printInfo } = require('../evm/utils');
const { Command, Option } = require('commander');
const { TransactionBlock } = require('@mysten/sui.js/transactions');
const { bcs } = require('@mysten/sui.js/bcs');
const { Transaction } = require('@mysten/sui/transactions');
const { bcs } = require('@mysten/sui/bcs');
const { ethers } = require('hardhat');
const {
utils: { arrayify, hexlify, toUtf8Bytes, keccak256 },
Expand Down Expand Up @@ -53,7 +53,7 @@ async function processCommand(config, chain, options) {
}

const contractConfig = chain.contracts.axelar_gateway;
const { minimumRotationDelay, domainSeparator } = options;
const { minimumRotationDelay, previousSignerRetention, domainSeparator } = options;
const signers = await getSigners(keypair, config, chain, options);
const operator = options.operator || keypair.toSuiAddress();

Expand All @@ -73,7 +73,7 @@ async function processCommand(config, chain, options) {
})
.toBytes();

const tx = new TransactionBlock();
const tx = new Transaction();

const separator = tx.moveCall({
target: `${packageId}::bytes32::new`,
Expand All @@ -86,7 +86,8 @@ async function processCommand(config, chain, options) {
tx.object(creatorCap.objectId),
tx.pure.address(operator),
separator,
tx.pure(minimumRotationDelay),
tx.pure.u64(minimumRotationDelay),
tx.pure.u64(previousSignerRetention),
tx.pure(bcs.vector(bcs.u8()).serialize(encodedSigners).toBytes()),
tx.object('0x6'),
],
Expand All @@ -103,6 +104,7 @@ async function processCommand(config, chain, options) {
contractConfig.domainSeparator = domainSeparator;
contractConfig.operator = operator;
contractConfig.minimumRotationDelay = minimumRotationDelay;
contractConfig.previousSignerRetention = previousSignerRetention;

printInfo('Gateway deployed', JSON.stringify(contractConfig, null, 2));
}
Expand All @@ -124,6 +126,9 @@ if (require.main === module) {
program.addOption(new Option('--signers <signers>', 'JSON with the initial signer set').env('SIGNERS'));
program.addOption(new Option('--operator <operator>', 'operator for the gateway (defaults to the deployer address)').env('OPERATOR'));
program.addOption(new Option('--minimumRotationDelay <minimumRotationDelay>', 'minium delay for signer rotations (in ms)').default(0));
program.addOption(
new Option('--previousSignerRetention <previousSignerRetention>', 'minium delay for signer retention (in ms)').default(0),
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
);
program.addOption(new Option('--domainSeparator <domainSeparator>', 'domain separator').default(HashZero));
program.addOption(new Option('--nonce <nonce>', 'nonce for the signer (defaults to HashZero)'));

Expand Down
4 changes: 2 additions & 2 deletions sui/deploy-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { saveConfig, prompt, printInfo } = require('../evm/utils');
const { Command, Option } = require('commander');
const { TransactionBlock } = require('@mysten/sui.js/transactions');
const { Transaction } = require('@mysten/sui/transactions');
const { ethers } = require('hardhat');
const {
constants: { HashZero },
Expand Down Expand Up @@ -33,7 +33,7 @@ async function processCommand(config, chain, options) {

const singleton = published.publishTxn.objectChanges.find((change) => change.objectType === `${published.packageId}::test::Singleton`);

const tx = new TransactionBlock();
const tx = new Transaction();

tx.moveCall({
target: `${published.packageId}::test::register_transaction`,
Expand Down
6 changes: 3 additions & 3 deletions sui/deploy-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Command, Option } = require('commander');
const { TxBuilder, updateMoveToml } = require('@axelar-network/axelar-cgp-sui');
const { bcs } = require('@mysten/sui.js/bcs');
const { bcs } = require('@mysten/sui/bcs');
const { fromB64, toB64 } = require('@mysten/bcs');
const { saveConfig, printInfo, validateParameters, prompt, writeJSON } = require('../evm/utils');
const { addBaseOptions } = require('./cli-utils');
Expand Down Expand Up @@ -44,7 +44,7 @@ async function upgradePackage(client, keypair, packageName, packageConfig, build
if (offline) {
options.txBytes = txBytes;
} else {
const signature = (await keypair.signTransactionBlock(txBytes)).signature;
const signature = (await keypair.signTransaction(txBytes)).signature;
const result = await client.executeTransactionBlock({
transactionBlock: txBytes,
signature,
Expand Down Expand Up @@ -78,7 +78,7 @@ async function deployPackage(chain, client, keypair, packageName, packageConfig,
return;
}

const signature = (await keypair.signTransactionBlock(txBytes)).signature;
const signature = (await keypair.signTransaction(txBytes)).signature;
const publishTxn = await client.executeTransactionBlock({
transactionBlock: txBytes,
signature,
Expand Down
2 changes: 1 addition & 1 deletion sui/faucet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { addBaseOptions } = require('./cli-utils');
const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui.js/faucet');
const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui/faucet');
const { getWallet, printWalletInfo } = require('./sign-utils');
const { Command } = require('commander');
const { saveConfig, loadConfig, printInfo } = require('../evm/utils');
Expand Down
12 changes: 6 additions & 6 deletions sui/gas-service.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { saveConfig, printInfo, printError } = require('../evm/utils');
const { Command } = require('commander');
const { TransactionBlock } = require('@mysten/sui.js/transactions');
const { bcs } = require('@mysten/sui.js/bcs');
const { Transaction } = require('@mysten/sui/transactions');
const { bcs } = require('@mysten/sui/bcs');
const { gasServiceStruct } = require('./types-utils');
const { loadSuiConfig, getBcsBytesByObjectId } = require('./utils');
const { ethers } = require('hardhat');
Expand All @@ -24,7 +24,7 @@ async function payGas(keypair, client, gasServiceConfig, args, options) {
const [destinationChain, destinationAddress, channelId, payload] = args;
const unitAmount = options.amount;

const tx = new TransactionBlock();
const tx = new Transaction();
const [coin] = tx.splitCoins(tx.gas, [unitAmount]);

tx.moveCall({
Expand Down Expand Up @@ -57,7 +57,7 @@ async function addGas(keypair, client, gasServiceConfig, args, options) {
const [messageId] = args;
const unitAmount = options.amount;

const tx = new TransactionBlock();
const tx = new Transaction();
const [coin] = tx.splitCoins(tx.gas, [unitAmount]);

tx.moveCall({
Expand Down Expand Up @@ -94,7 +94,7 @@ async function collectGas(keypair, client, gasServiceConfig, args, options) {
return;
}

const tx = new TransactionBlock();
const tx = new Transaction();

tx.moveCall({
target: `${gasServicePackageId}::gas_service::collect_gas`,
Expand Down Expand Up @@ -130,7 +130,7 @@ async function refund(keypair, client, gasServiceConfig, args, options) {
return;
}

const tx = new TransactionBlock();
const tx = new Transaction();
tx.moveCall({
target: `${gasServicePackageId}::gas_service::refund`,
arguments: [
Expand Down
10 changes: 5 additions & 5 deletions sui/gateway.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { saveConfig, printInfo } = require('../evm/utils');
const { Command, Option } = require('commander');
const { TransactionBlock } = require('@mysten/sui.js/transactions');
const { bcs } = require('@mysten/sui.js/bcs');
const { Transaction } = require('@mysten/sui/transactions');
const { bcs } = require('@mysten/sui/bcs');
const { ethers } = require('hardhat');
const {
utils: { arrayify, keccak256, toUtf8Bytes },
Expand Down Expand Up @@ -109,7 +109,7 @@ async function callContract(keypair, client, config, chain, args, options) {

let channel = options.channel;

const tx = new TransactionBlock();
const tx = new Transaction();

// Create a temporary channel if one wasn't provided
if (!options.channel) {
Expand Down Expand Up @@ -165,7 +165,7 @@ async function approveMessages(keypair, client, config, chain, args, options) {

const encodedProof = getProof(keypair, COMMAND_TYPE_APPROVE_MESSAGES, encodedMessages, contractConfig, options);

const tx = new TransactionBlock();
const tx = new Transaction();

tx.moveCall({
target: `${packageId}::gateway::approve_messages`,
Expand Down Expand Up @@ -200,7 +200,7 @@ async function rotateSigners(keypair, client, config, chain, args, options) {

const encodedProof = getProof(keypair, COMMAND_TYPE_ROTATE_SIGNERS, encodedSigners, contractConfig, options);

const tx = new TransactionBlock();
const tx = new Transaction();

tx.moveCall({
target: `${packageId}::gateway::rotate_signers`,
Expand Down
2 changes: 1 addition & 1 deletion sui/multisig.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function combineSignature(client, chain, options) {
const txBlockBytes = fromB64(txBytes);

const combinedSignature = multiSigPublicKey.combinePartialSignatures(signatureArray);
const isValid = await multiSigPublicKey.verifyTransactionBlock(txBlockBytes, combinedSignature);
const isValid = await multiSigPublicKey.verifyTransaction(txBlockBytes, combinedSignature);

if (!isValid) {
throw new Error(`Verification failed for message [${txBytes}]`);
Expand Down
Loading
Loading