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

feat: added a transaction builder for better argument input. #52

Merged
merged 15 commits into from
Jul 8, 2024
Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ target/

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

move_comile
4 changes: 2 additions & 2 deletions move/abi/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 2
manifest_digest = "7DED727D47EB51E5059409B19CC373C6D9AF249D837E9153E7368F3898025E41"
manifest_digest = "134C22A16B63D227C88D4E1F5D02607C8E7C2D0FA5D3BAD6136E0041F441654D"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ name = "Sui" },
Expand All @@ -21,6 +21,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.1"
compiler-version = "1.26.1"
edition = "2024.beta"
flavor = "sui"
3 changes: 2 additions & 1 deletion move/abi/Move.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "Abi"
version = "0.1.0"
published-at = "0x41fb7e9c9d8851ecbfd4b89c910c0465de0cd0cf757c4bb261a8a6019ea33390"
edition = "2024.beta"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.25.3" }

[addresses]
abi = "0x103"
abi = "0x0"
4 changes: 0 additions & 4 deletions move/abi/info.json

This file was deleted.

2 changes: 1 addition & 1 deletion move/axelar_gateway/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 2
manifest_digest = "11FAF5CFE0A4A2EBCD5E370FAD144FFF14243A85492B718A2B26A15CF7F0B571"
manifest_digest = "B3F1114AF6420DAFC5501B8A333236271B0467A5D00AF701F02D79AEC565E6E5"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ name = "Sui" },
Expand Down
1 change: 1 addition & 0 deletions move/axelar_gateway/Move.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "AxelarGateway"
version = "0.1.0"
published-at = "0x571841ce66dce70e51a123299ed140d6509566c97eb905331b5f28732c707c56"
edition = "2024.beta"

[dependencies]
Expand Down
6 changes: 0 additions & 6 deletions move/axelar_gateway/info.json

This file was deleted.

2 changes: 1 addition & 1 deletion move/gas_service/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.1"
compiler-version = "1.26.1"
edition = "2024.beta"
flavor = "sui"
5 changes: 0 additions & 5 deletions move/gas_service/info.json

This file was deleted.

4 changes: 0 additions & 4 deletions move/governance/info.json

This file was deleted.

2 changes: 1 addition & 1 deletion move/interchain_token/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.1"
compiler-version = "1.26.1"
edition = "2024.beta"
flavor = "sui"
2 changes: 1 addition & 1 deletion move/its/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.1"
compiler-version = "1.26.1"
edition = "2024.beta"
flavor = "sui"
5 changes: 0 additions & 5 deletions move/its/info.json

This file was deleted.

2 changes: 1 addition & 1 deletion move/squid/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.1"
compiler-version = "1.26.1"
edition = "2024.beta"
flavor = "sui"
5 changes: 0 additions & 5 deletions move/squid/info.json

This file was deleted.

4 changes: 2 additions & 2 deletions move/test/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 2
manifest_digest = "CF736E0717CB61683E6D638E781AA77454AE00BCA196A7FD23E4ACDBD78C0A5A"
manifest_digest = "E39FD071E9EFD0729A4D15C389E9E5EF831FB1E0DB9B2A6E35AFD0DC302863A1"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
dependencies = [
{ name = "AxelarGateway" },
Expand Down Expand Up @@ -30,6 +30,6 @@ dependencies = [
]

[move.toolchain-version]
compiler-version = "1.25.1"
compiler-version = "1.26.1"
edition = "2024.beta"
flavor = "sui"
3 changes: 2 additions & 1 deletion move/test/Move.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "Test"
version = "0.1.0"
published-at = "0x5de4d52cd17c6e0483598bebb3243a886edefeb216e5ecc7c578edfeb8a7b4a9"
edition = "2024.beta"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.25.3" }
AxelarGateway = { local = "../axelar_gateway" }

[addresses]
test = "0x200"
test = "0x5de4d52cd17c6e0483598bebb3243a886edefeb216e5ecc7c578edfeb8a7b4a9"
62 changes: 3 additions & 59 deletions scripts/publish-package.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
require('dotenv').config();
const { setConfig, getFullObject, requestSuiFromFaucet } = require('./utils');
const { requestSuiFromFaucet, updateMoveToml } = require('./utils');
const { Ed25519Keypair } = require('@mysten/sui.js/keypairs/ed25519');
const { TransactionBlock } = require('@mysten/sui.js/transactions');
const { SuiClient } = require('@mysten/sui.js/client');
const { execSync } = require('child_process');
const { parseEnv } = require('./utils');
const tmp = require('tmp');
const fs = require('fs');
const path = require('path');

async function publishPackage(packageName, client, keypair) {
const toml = fs.readFileSync(`${__dirname}/../move/${packageName}/Move.toml`, 'utf8');
fs.writeFileSync(`${__dirname}/../move/${packageName}/Move.toml`, fillAddresses(toml, '0x0', packageName));
updateMoveToml(packageName, '0x0');

// remove all controlled temporary objects on process exit
const address = keypair.getPublicKey().toSuiAddress();
Expand Down Expand Up @@ -48,74 +46,20 @@ async function publishPackage(packageName, client, keypair) {
showObjectChanges: true,
showContent: true,
},
requestType: 'WaitForLocalExecution',
});
if (publishTxn.effects?.status.status !== 'success') throw new Error('Publish Tx failed');

const packageId = (publishTxn.objectChanges?.filter((a) => a.type === 'published') ?? [])[0].packageId;

console.info(`Published package ${packageId} from address ${address}}`);

return { packageId, publishTxn };
}

function updateMoveToml(packageName, packageId) {
const path = `${__dirname}/../move/${packageName}/Move.toml`;
const toml = fs.readFileSync(path, 'utf8');
fs.writeFileSync(path, fillAddresses(insertPublishedAt(toml, packageId), packageId, packageName));
}

function insertPublishedAt(toml, packageId) {
const lines = toml.split('\n');
const versionLineIndex = lines.findIndex((line) => line.slice(0, 7) === 'version');

if (!(lines[versionLineIndex + 1].slice(0, 12) === 'published-at')) {
lines.splice(versionLineIndex + 1, 0, '');
}

lines[versionLineIndex + 1] = `published-at = "${packageId}"`;
return lines.join('\n');
}

function fillAddresses(toml, address, packageName) {
const lines = toml.split('\n');
const addressesIndex = lines.findIndex((line) => line.slice(0, 11) === '[addresses]');

for (let i = addressesIndex + 1; i < lines.length; i++) {
const line = lines[i];
const eqIndex = line.indexOf('=');

if (eqIndex < 0 || line.slice(0, eqIndex - 1) !== packageName) {
continue;
}

lines[i] = line.slice(0, eqIndex + 1) + ` "${address}"`;
}

return lines.join('\n');
}

async function publishPackageFull(packageName, client, keypair, env) {
const { packageId, publishTxn } = await publishPackage(packageName, client, keypair);
const info = require(`${__dirname}/../move/${packageName}/info.json`);
const config = {};
config.packageId = packageId;

for (const singleton of info.singletons) {
const object = publishTxn.objectChanges.find((object) => object.objectType === `${packageId}::${singleton}`);
config[singleton] = await getFullObject(object, client);
}

setConfig(packageName, env.alias, config);
updateMoveToml(packageName, packageId);

return { packageId, publishTxn };
}

module.exports = {
publishPackage,
updateMoveToml,
publishPackageFull,
};

if (require.main === module) {
Expand All @@ -134,6 +78,6 @@ if (require.main === module) {
await requestSuiFromFaucet(env, address);
}

await publishPackageFull(packageName, client, keypair, env);
await publishPackage(packageName, client, keypair, env);
})();
}
Loading
Loading