Skip to content

Commit

Permalink
allow offline computation for domain separator
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Aug 27, 2024
1 parent 6e3a086 commit 6faca9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,18 @@ async function getDomainSeparator(config, chain, options) {
throw new Error(`missing or invalid chain ID`);
}

printInfo(`Retrieving domain separator for ${chain.name} from Axelar network`);
// const domainSeparator = hexlify((await getContractConfig(config, chain.axelarId)).domain_separator);
const expectedDomainSeparator = calculateDomainSeparator(chain.axelarId, routerAddress, chainId);
if (options.domainSeparator === 'offline') {
printInfo('Computed domain separator offline')
return expectedDomainSeparator;
}

// TODO: add domain separator prediction support to display before amplifier contracts are ready
// if (domainSeparator !== expectedDomainSeparator) {
// throw new Error(`unexpected domain separator (want ${expectedDomainSeparator}, got ${domainSeparator})`);
// }
printInfo(`Retrieving domain separator for ${chain.name} from Axelar network`);
const domainSeparator = hexlify((await getContractConfig(config, chain.axelarId)).domain_separator);

Check failure on line 399 in common/utils.js

View workflow job for this annotation

GitHub Actions / lint

'hexlify' is not defined
if (domainSeparator !== expectedDomainSeparator) {
throw new Error(`unexpected domain separator (want ${expectedDomainSeparator}, got ${domainSeparator})`);
}

return expectedDomainSeparator;
}
Expand Down
2 changes: 1 addition & 1 deletion sui/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ const GATEWAY_CMD_OPTIONS = [
new Option('--minimumRotationDelay <minimumRotationDelay>', 'minium delay for signer rotations (in second)')
.argParser((val) => parseInt(val) * 1000)
.default(24 * 60 * 60),
new Option('--domainSeparator <domainSeparator>', 'domain separator'),
new Option('--domainSeparator <domainSeparator>', 'domain separator (pass in the keccak256 hash value OR "offline" meaning that its computed locally)'),
new Option('--nonce <nonce>', 'nonce for the signer (defaults to HashZero)'),
new Option('--previousSigners <previousSigners>', 'number of previous signers to retain').default('15'),
];
Expand Down

0 comments on commit 6faca9d

Please sign in to comment.