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

chore(sui): replace array versions with a mapping of version number to package id #496

Merged
merged 6 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion sui/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const {
suiPackageAddress,
suiClockAddress,
readMovePackageName,
readMovePackageVersion,
getSingletonChannelId,
getItsChannelId,
getSquidChannelId,
Expand Down Expand Up @@ -312,10 +313,14 @@ async function deploy(keypair, client, supportedContract, config, chain, options
printInfo(`Deployed ${packageName} Package`, published.packageId);
printInfo(`Deployed ${packageName} Tx`, published.publishTxn.digest);

const version = readMovePackageVersion(packageDir);
blockchainguyy marked this conversation as resolved.
Show resolved Hide resolved

// Update chain configuration with deployed contract address
chain.contracts[packageName] = {
address: published.packageId,
versions: [published.packageId],
versions: {
npty marked this conversation as resolved.
Show resolved Hide resolved
[version]: published.packageId,
},
};

chain.contracts[packageName].structs = await getStructs(client, published.packageId);
Expand Down
23 changes: 17 additions & 6 deletions sui/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ const checkSuiVersionMatch = () => {
}
};

const readMoveToml = (moveDir) => {
return fs.readFileSync(`${__dirname}/../../node_modules/@axelar-network/axelar-cgp-sui/move/${moveDir}/Move.toml`, 'utf8');
};

const readMovePackageName = (moveDir) => {
try {
const moveToml = fs.readFileSync(
`${__dirname}/../../node_modules/@axelar-network/axelar-cgp-sui/move/${moveDir}/Move.toml`,
'utf8',
);

const { package: movePackage } = toml.parse(moveToml);
const { package: movePackage } = toml.parse(readMoveToml(moveDir));

return movePackage.name;
} catch (err) {
Expand All @@ -109,6 +108,17 @@ const readMovePackageName = (moveDir) => {
}
};

const readMovePackageVersion = (moveDir) => {
try {
const { package: movePackage } = toml.parse(readMoveToml(moveDir));

return movePackage.version;
} catch (err) {
printError('Error reading TOML file');
throw err;
}
};

const getObjectIdsByObjectTypes = (txn, objectTypes) =>
objectTypes.map((objectType) => {
const objectId = txn.objectChanges.find((change) => change.objectType?.includes(objectType))?.objectId;
Expand Down Expand Up @@ -365,6 +375,7 @@ module.exports = {
deployPackage,
findPublishedObject,
readMovePackageName,
readMovePackageVersion,
getObjectIdsByObjectTypes,
getSingletonChannelId,
getItsChannelId,
Expand Down
Loading