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

feat(sui): support utils contract deployment #373

Merged
merged 19 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
5 changes: 4 additions & 1 deletion .github/workflows/test-sui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ jobs:

###### Command: Deploy Contract ######

- name: Deploy Utils
run: node sui/deploy-contract deploy Utils

- name: Deploy AxelarGateway
run: node sui/deploy-contract deploy AxelarGateway --signers wallet

Expand Down Expand Up @@ -204,7 +207,7 @@ jobs:

- name: Generate Unsigned Tx File
run: |
node sui/deploy-contract.js upgrade AxelarGateway any_upgrade --offline --txFilePath ./tx-upgrade.json --sender $MULTISIG_ADDRESS
node sui/deploy-contract.js upgrade AxelarGateway any_upgrade --offline --txFilePath ./tx-upgrade.json --sender $MULTISIG_ADDRESS --packageDependencies Utils

- name: Sign Tx File with Multisig Signer
run: |
Expand Down
2 changes: 1 addition & 1 deletion common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ async function getDomainSeparator(config, chain, options) {
}

printInfo(`Retrieving domain separator for ${chain.name} from Axelar network`);
const domainSeparator = hexlify((await getContractConfig(config, chain.axelarId)).domain_separator);
const domainSeparator = hexlify((await getContractConfig(config, chain.axelarId)).domainSeparator);
npty marked this conversation as resolved.
Show resolved Hide resolved

if (domainSeparator !== expectedDomainSeparator) {
throw new Error(`unexpected domain separator (want ${expectedDomainSeparator}, got ${domainSeparator})`);
Expand Down
9 changes: 4 additions & 5 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.6.1",
"@axelar-network/axelar-cgp-sui": "^0.6.3",
"@axelar-network/axelar-gmp-sdk-solidity": "5.10.0",
"@axelar-network/interchain-token-service": "1.2.4",
"@cosmjs/cosmwasm-stargate": "^0.32.1",
Expand Down
7 changes: 7 additions & 0 deletions sui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ node sui/faucet.js

Deploy the gateway package:

> Before deploying the gateway package, make sure to deploy the Utils package.
npty marked this conversation as resolved.
Show resolved Hide resolved
- By querying the signer set from the Amplifier contract (this only works if Amplifier contracts have been setup):

```bash
Expand Down Expand Up @@ -91,6 +92,12 @@ policy should be one of the following:

Provide `--txFilePath` with `--offline` to generate tx data file for offline signing.

Deploy the Utils package:

```bash
node sui/deploy-contract.js deploy Utils
```

Deploy the Gas Service package:

```bash
Expand Down
16 changes: 10 additions & 6 deletions sui/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const {
* 2. Ensure the corresponding folder exists in the specified path
*
*/
const PACKAGE_DIRS = ['gas_service', 'example', 'axelar_gateway', 'operators', 'abi', 'governance', 'its', 'squid'];
const PACKAGE_DIRS = ['utils', 'gas_service', 'example', 'axelar_gateway', 'operators', 'abi', 'governance', 'its', 'squid'];

/**
* Package Mapping Object for Command Options and Post-Deployment Functions
Expand All @@ -56,14 +56,13 @@ const PACKAGE_CONFIGS = {
Governance: () => [],
ITS: () => [],
Squid: () => [],
Utils: () => [],
npty marked this conversation as resolved.
Show resolved Hide resolved
},
postDeployFunctions: {
AxelarGateway: postDeployAxelarGateway,
GasService: postDeployGasService,
Example: postDeployExample,
Operators: postDeployOperators,
Abi: {},
Governance: {},
ITS: postDeployIts,
Squid: postDeploySquid,
},
Expand Down Expand Up @@ -251,7 +250,10 @@ async function deploy(keypair, client, supportedContract, config, chain, options

// Execute post-deployment function
const executePostDeploymentFn = PACKAGE_CONFIGS.postDeployFunctions[packageName];
await executePostDeploymentFn(published, keypair, client, config, chain, options);

if (executePostDeploymentFn) {
await executePostDeploymentFn(published, keypair, client, config, chain, options);
}

printInfo(`${packageName} Configuration Updated`, JSON.stringify(chain.contracts[packageName], null, 2));
}
Expand All @@ -269,16 +271,17 @@ async function upgrade(keypair, client, supportedPackage, policy, config, chain,
const contractConfig = contractsConfig?.[packageName];

validateParameters({ isNonEmptyString: { packageName } });
const moveDir = `${__dirname}/move`;
npty marked this conversation as resolved.
Show resolved Hide resolved

if (packageDependencies) {
npty marked this conversation as resolved.
Show resolved Hide resolved
for (const dependencies of packageDependencies) {
npty marked this conversation as resolved.
Show resolved Hide resolved
npty marked this conversation as resolved.
Show resolved Hide resolved
const packageId = contractsConfig[dependencies]?.address;
updateMoveToml(dependencies, packageId);
updateMoveToml(dependencies.toLowerCase(), packageId, moveDir);
npty marked this conversation as resolved.
Show resolved Hide resolved
npty marked this conversation as resolved.
Show resolved Hide resolved
}
}

const builder = new TxBuilder(client);
await upgradePackage(client, keypair, supportedPackage, contractConfig, builder, options);
await upgradePackage(client, keypair, supportedPackage, contractConfig, builder, moveDir, options);
}

async function mainProcessor(args, options, processor) {
Expand Down Expand Up @@ -372,6 +375,7 @@ if (require.main === module) {
.addOption(new Option('--sender <sender>', 'transaction sender'))
.addOption(new Option('--digest <digest>', 'digest hash for upgrade'))
.addOption(new Option('--offline', 'store tx block for sign'))
.addOption(new Option('--packageDependencies [packageDependencies...]', 'package dependencies'))
.addOption(new Option('--txFilePath <file>', 'unsigned transaction will be stored'))
.action((policy, options) => {
mainProcessor([supportedPackage, policy], options, upgrade);
Expand Down
4 changes: 2 additions & 2 deletions sui/utils/upgrade-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ function getUpgradePolicyId(policy) {
}
}

async function upgradePackage(client, keypair, packageToUpgrade, contractConfig, builder, options) {
async function upgradePackage(client, keypair, packageToUpgrade, contractConfig, builder, moveDir, options) {
const { packageDir, packageName } = packageToUpgrade;
const { modules, dependencies, digest } = await builder.getContractBuild(packageDir);
const { modules, dependencies, digest } = await builder.getContractBuild(packageDir, moveDir);
const { offline } = options;
const sender = options.sender || keypair.toSuiAddress();
const upgradeCap = contractConfig.objects?.UpgradeCap;
Expand Down
Loading