Skip to content

Commit

Permalink
Merge branch 'main' into talal/testnet-its
Browse files Browse the repository at this point in the history
  • Loading branch information
talalashraf authored Dec 16, 2024
2 parents 1b89019 + 5cb30ff commit 8474a73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cosmwasm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const prepareWallet = async ({ mnemonic }) => await DirectSecp256k1HdWallet.from
const prepareClient = async ({ axelar: { rpc, gasPrice } }, wallet) =>
await SigningCosmWasmClient.connectWithSigner(rpc, wallet, { gasPrice });

const pascalToKebab = (str) => str.replace(/([A-Z])/g, (group) => `-${group.toLowerCase()}`).replace(/^-/, '');
const pascalToSnake = (str) => str.replace(/([A-Z])/g, (group) => `_${group.toLowerCase()}`).replace(/^_/, '');

const isValidCosmosAddress = (str) => {
try {
Expand All @@ -61,7 +61,7 @@ const getSalt = (salt, contractName, chainName) => fromHex(getSaltFromKey(salt |

const getLabel = ({ contractName, label }) => label || contractName;

const readWasmFile = ({ artifactPath, contractName }) => readFileSync(`${artifactPath}/${pascalToKebab(contractName)}.wasm`);
const readWasmFile = ({ artifactPath, contractName }) => readFileSync(`${artifactPath}/${pascalToSnake(contractName)}.wasm`);

const initContractConfig = (config, { contractName, chainName }) => {
config.axelar = config.axelar || {};
Expand Down
22 changes: 17 additions & 5 deletions sui/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ const supportedPackages = PACKAGE_DIRS.map((dir) => ({
*/

async function postDeployRelayerDiscovery(published, keypair, client, config, chain, options) {
const [relayerDiscoveryObjectId, relayerDiscoveryObjectIdv0] = getObjectIdsByObjectTypes(published.publishTxn, [
const [relayerDiscoveryObjectId, relayerDiscoveryObjectIdv0, ownerCap] = getObjectIdsByObjectTypes(published.publishTxn, [
`${published.packageId}::discovery::RelayerDiscovery`,
`${published.packageId}::relayer_discovery_v0::RelayerDiscovery_v0`,
`${published.packageId}::owner_cap::OwnerCap`,
]);

chain.contracts.RelayerDiscovery.objects = {
RelayerDiscovery: relayerDiscoveryObjectId,
RelayerDiscoveryv0: relayerDiscoveryObjectIdv0,
OwnerCap: ownerCap,
};
}

Expand Down Expand Up @@ -235,15 +237,22 @@ async function postDeployAxelarGateway(published, keypair, client, config, chain
async function postDeployIts(published, keypair, client, config, chain, options) {
const relayerDiscovery = chain.contracts.RelayerDiscovery?.objects?.RelayerDiscovery;

const [itsObjectId, itsv0ObjectId, ownerCapObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [
const [itsObjectId, itsv0ObjectId, ownerCapObjectId, upgradeCapObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [
`${published.packageId}::its::ITS`,
`${published.packageId}::its_v0::ITS_v0`,
`${published.packageId}::owner_cap::OwnerCap`,
`${suiPackageAddress}::package::UpgradeCap`,
]);

const channelId = await getItsChannelId(client, itsv0ObjectId);

chain.contracts.ITS.objects = { ITS: itsObjectId, ITSv0: itsv0ObjectId, ChannelId: channelId, OwnerCap: ownerCapObjectId };
chain.contracts.ITS.objects = {
ITS: itsObjectId,
ITSv0: itsv0ObjectId,
ChannelId: channelId,
OwnerCap: ownerCapObjectId,
UpgradeCap: upgradeCapObjectId,
};

const tx = new Transaction();
tx.moveCall({
Expand All @@ -257,9 +266,12 @@ async function postDeployIts(published, keypair, client, config, chain, options)
async function postDeploySquid(published, keypair, client, config, chain, options) {
const relayerDiscovery = chain.contracts.RelayerDiscovery?.objects?.RelayerDiscovery;

const [squidObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [`${published.packageId}::squid::Squid`]);
const [squidObjectId, ownerCapObjectId] = getObjectIdsByObjectTypes(published.publishTxn, [
`${published.packageId}::squid::Squid`,
`${published.packageId}::owner_cap::OwnerCap`,
]);
const channelId = await getSquidChannelId(client, squidObjectId);
chain.contracts.Squid.objects = { Squid: squidObjectId, ChannelId: channelId };
chain.contracts.Squid.objects = { Squid: squidObjectId, ChannelId: channelId, OwnerCap: ownerCapObjectId };

const tx = new Transaction();
tx.moveCall({
Expand Down

0 comments on commit 8474a73

Please sign in to comment.