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

clients/js: support alternative aptos networks #4234

Merged
Merged
Changes from all commits
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
53 changes: 38 additions & 15 deletions clients/js/src/cmds/aptos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ export const builder = (y: typeof yargs) =>
"init-token-bridge",
"Init token bridge contract",
(yargs) =>
yargs.option("network", NETWORK_OPTIONS).option("rpc", RPC_OPTIONS),
yargs
.option("network", NETWORK_OPTIONS)
.option("rpc", RPC_OPTIONS)
.option("contract-address", {
describe: "Core contract address",
type: "string",
demandOption: false,
}),
async (argv) => {
const network = getNetwork(argv.network);
const contract_address = evm_address(
contracts.tokenBridge(network, "Aptos")
);
const contract_address =
argv["contract-address"] ||
evm_address(contracts.tokenBridge(network, "Aptos"));
const rpc = argv.rpc ?? NETWORKS[network].Aptos.rpc;
await callEntryFunc(
network,
Expand Down Expand Up @@ -104,13 +111,18 @@ export const builder = (y: typeof yargs) =>
demandOption: true,
describe: "Initial guardian's addresses (CSV)",
type: "string",
})
.option("contract-address", {
describe: "Core contract address",
type: "string",
demandOption: false,
}),
async (argv) => {
const network = getNetwork(argv.network);

const contract_address = evm_address(
contracts.coreBridge(network, "Aptos")
);
const contract_address =
argv["contract-address"] ||
evm_address(contracts.coreBridge(network, "Aptos"));
const guardian_addresses = argv["guardian-address"]
.split(",")
.map((address) => evm_address(address).substring(24));
Expand Down Expand Up @@ -196,11 +208,15 @@ export const builder = (y: typeof yargs) =>
const b = serializePackage(p);
const seed = Buffer.from(argv["seed"], "ascii");

let module_name = APTOS_DEPLOYER_ADDRESS_DEVNET + "::deployer";
if (network == "Testnet" || network == "Mainnet") {
module_name =
"0x0108bc32f7de18a5f6e1e7d6ee7aff9f5fc858d0d87ac0da94dd8d2a5d267d6b::deployer";
let deployer = APTOS_DEPLOYER_ADDRESS_DEVNET;
const addresses = argv["named-addresses"]?.split(",") || [];
for (const addressPair of addresses) {
const [name, address] = addressPair.split("=");
if (name === "deployer") {
deployer = address;
}
}
const module_name = deployer + "::deployer";
const rpc = argv.rpc ?? NETWORKS[network].Aptos.rpc;
await callEntryFunc(
network,
Expand All @@ -223,12 +239,19 @@ export const builder = (y: typeof yargs) =>
describe: "Message to send",
demandOption: true,
})
.option("network", NETWORK_OPTIONS),
.option("network", NETWORK_OPTIONS)
.option("rpc", RPC_OPTIONS)
.option("sender", {
describe: "Sender address",
type: "string",
demandOption: false,
}),
async (argv) => {
const network = getNetwork(argv.network);
const rpc = NETWORKS[network].Aptos.rpc;
let module_name = APTOS_DEPLOYER_ADDRESS_DEVNET + "::sender";
if (network == "Testnet" || network == "Mainnet") {
const rpc = argv.rpc ?? NETWORKS[network].Aptos.rpc;
let module_name =
(argv.sender || APTOS_DEPLOYER_ADDRESS_DEVNET) + "::sender";
if (!argv.sender && (network == "Testnet" || network == "Mainnet")) {
module_name =
"0x0108bc32f7de18a5f6e1e7d6ee7aff9f5fc858d0d87ac0da94dd8d2a5d267d6b::sender";
}
Expand Down
Loading