From fb03a36a4600df0130adced5f34d71a096e60a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Sousa?= Date: Wed, 24 Apr 2024 22:10:56 +0100 Subject: [PATCH 1/2] save salt in config file --- cosmwasm/deploy-contract.js | 3 ++- cosmwasm/utils.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cosmwasm/deploy-contract.js b/cosmwasm/deploy-contract.js index dc84824f..e3ef59e3 100644 --- a/cosmwasm/deploy-contract.js +++ b/cosmwasm/deploy-contract.js @@ -363,9 +363,10 @@ const upload = (client, wallet, chainName, config, options) => { printInfo('Uploading contract binary'); return uploadContract(client, wallet, config, options) - .then(({ address, codeId }) => { + .then(({ address, codeId, usedSalt }) => { printInfo('Uploaded contract binary'); contractConfig.codeId = codeId; + contractConfig.salt = usedSalt; if (!address) { return; diff --git a/cosmwasm/utils.js b/cosmwasm/utils.js index adf37c55..73c13c04 100644 --- a/cosmwasm/utils.js +++ b/cosmwasm/utils.js @@ -35,16 +35,17 @@ const uploadContract = async (client, wallet, config, options) => { return client.upload(account.address, wasm, uploadFee).then(({ checksum, codeId }) => ({ checksum, codeId, account })); }) .then(({ account, checksum, codeId }) => { + const usedSalt = salt || contractName.concat(chainNames); const address = instantiate2 ? instantiate2Address( fromHex(checksum), account.address, - fromHex(getSaltFromKey(salt || contractName.concat(chainNames))), + fromHex(getSaltFromKey(usedSalt)), 'axelar', ) : null; - return { codeId, address }; + return { codeId, address, usedSalt }; }); }; From 6237ac1f7db687fffa8d46ad9149ece54f38411d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Sousa?= Date: Wed, 24 Apr 2024 22:18:09 +0100 Subject: [PATCH 2/2] addendum --- cosmwasm/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cosmwasm/utils.js b/cosmwasm/utils.js index 73c13c04..ea2e33d0 100644 --- a/cosmwasm/utils.js +++ b/cosmwasm/utils.js @@ -49,7 +49,7 @@ const uploadContract = async (client, wallet, config, options) => { }); }; -const instantiateContract = (client, wallet, initMsg, config, { contractName, salt, instantiate2, chainNames, admin }) => { +const instantiateContract = (client, wallet, initMsg, config, { contractName, instantiate2, admin }) => { return wallet .getAccounts() .then(([account]) => { @@ -64,7 +64,7 @@ const instantiateContract = (client, wallet, initMsg, config, { contractName, sa ? client.instantiate2( account.address, contractConfig.codeId, - fromHex(getSaltFromKey(salt || contractName.concat(chainNames))), + contractConfig.salt, initMsg, contractName, initFee,