From 6faca9d14857ca97bc1a1b25db1ec7bdcd7c8fd8 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Tue, 27 Aug 2024 04:55:25 +0400 Subject: [PATCH] allow offline computation for domain separator --- common/utils.js | 16 ++++++++++------ sui/deploy-contract.js | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/utils.js b/common/utils.js index 3aacb270..4d51ba8e 100644 --- a/common/utils.js +++ b/common/utils.js @@ -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); + + if (domainSeparator !== expectedDomainSeparator) { + throw new Error(`unexpected domain separator (want ${expectedDomainSeparator}, got ${domainSeparator})`); + } return expectedDomainSeparator; } diff --git a/sui/deploy-contract.js b/sui/deploy-contract.js index 09a91fb7..ff9cba48 100644 --- a/sui/deploy-contract.js +++ b/sui/deploy-contract.js @@ -327,7 +327,7 @@ const GATEWAY_CMD_OPTIONS = [ new Option('--minimumRotationDelay ', 'minium delay for signer rotations (in second)') .argParser((val) => parseInt(val) * 1000) .default(24 * 60 * 60), - new Option('--domainSeparator ', 'domain separator'), + new Option('--domainSeparator ', 'domain separator (pass in the keccak256 hash value OR "offline" meaning that its computed locally)'), new Option('--nonce ', 'nonce for the signer (defaults to HashZero)'), new Option('--previousSigners ', 'number of previous signers to retain').default('15'), ];