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

fix(sui): improve sui gateway deployment params #248

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 18 additions & 2 deletions sui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,26 @@ Use the `-e local` (or `ENV=local` in the `.env` config) flag with scripts to ru
node sui/faucet.js
```

2. Deploy the gateway:
2. Deploy the gateway package:

- By querying the signer set from the Amplifier contract (this only works if Amplifier contracts have been setup):

```bash
node sui/deploy-gateway.js
```

Use `--help` flag to see other setup params that can be overridden.

- For testing convenience, you can use the secp256k1 wallet as the signer set for the gateway.

```bash
node sui/deploy-gateway.js --signers wallet
```

- You can also provide a JSON object with a full signer set:

```bash
node sui/deploy-gateway.js -e testnet --signers '{"signers": [{"pubkey": "0x020194ead85b350d90472117e6122cf1764d93bf17d6de4b51b03d19afc4d6302b", "weight": 1}], "threshold": 1, "nonce": ""}'
node sui/deploy-gateway.js -e testnet --signers '{"signers": [{"pubkey": "0x020194ead85b350d90472117e6122cf1764d93bf17d6de4b51b03d19afc4d6302b", "weight": 1}], "threshold": 1, "nonce": "0x0000000000000000000000000000000000000000000000000000000000000000"}'
```

3. Deploy the test GMP package:
Expand Down
21 changes: 17 additions & 4 deletions sui/deploy-gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ const { addBaseOptions } = require('./cli-utils');
const { getWallet, printWalletInfo } = require('./sign-utils');
const { getAmplifierSigners, loadSuiConfig } = require('./utils');

async function getSigners(config, chain, options) {
if (options.signers) {
async function getSigners(keypair, config, chain, options) {
if (options.signers === 'wallet') {
const pubkey = keypair.getPublicKey().toRawBytes();
printInfo('Using wallet pubkey as the signer for the gateway', hexlify(pubkey));

if (keypair.getKeyScheme() !== 'Secp256k1') {
throw new Error('Only Secp256k1 pubkeys are supported by the gateway');
}

return {
signers: [{ pubkey, weight: 1 }],
threshold: 1,
nonce: HashZero,
};
} else if (options.signers) {
printInfo('Using provided signers', options.signers);

const signers = JSON.parse(options.signers);
Expand All @@ -23,7 +36,7 @@ async function getSigners(config, chain, options) {
return { pubkey: arrayify(pubkey), weight };
}),
threshold: signers.threshold,
nonce: signers.nonce || HashZero,
nonce: arrayify(signers.nonce) || HashZero,
};
}

Expand All @@ -41,7 +54,7 @@ async function processCommand(config, chain, options) {

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

if (prompt(`Proceed with deployment on ${chain.name}?`, options.yes)) {
Expand Down
Loading