2022-05-05 17:51:24 -07:00
|
|
|
#!/usr/bin/env node
|
2022-10-13 19:17:42 -07:00
|
|
|
|
|
|
|
// <sigh>
|
|
|
|
// when the native secp256k1 is missing, the eccrypto library decides TO PRINT A MESSAGE TO STDOUT:
|
|
|
|
// https://github.com/bitchan/eccrypto/blob/a4f4a5f85ef5aa1776dfa1b7801cad808264a19c/index.js#L23
|
|
|
|
//
|
|
|
|
// do you use a CLI tool that depends on that library and try to pipe the output
|
|
|
|
// of the tool into another? tough luck
|
|
|
|
//
|
|
|
|
// for lack of a better way to stop this, we patch the console.info function to
|
|
|
|
// drop that particular message...
|
|
|
|
// </sigh>
|
|
|
|
const info = console.info;
|
2022-10-21 10:40:17 -07:00
|
|
|
console.info = function(x: string) {
|
2022-10-13 19:17:42 -07:00
|
|
|
if (x != "secp256k1 unavailable, reverting to browser version") {
|
2022-10-14 08:20:45 -07:00
|
|
|
info(x);
|
2022-10-13 19:17:42 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-05-05 17:51:24 -07:00
|
|
|
import yargs from "yargs";
|
|
|
|
|
|
|
|
import { hideBin } from "yargs/helpers";
|
|
|
|
|
2022-10-06 12:39:34 -07:00
|
|
|
import { fromBech32, toHex } from "@cosmjs/encoding";
|
2022-05-05 17:51:24 -07:00
|
|
|
import * as vaa from "./vaa";
|
|
|
|
import { impossible, Payload, serialiseVAA, VAA } from "./vaa";
|
2022-06-25 07:04:31 -07:00
|
|
|
import { ethers } from "ethers";
|
|
|
|
import { NETWORKS } from "./networks";
|
2022-06-29 05:30:16 -07:00
|
|
|
import base58 from "bs58";
|
2022-10-24 15:12:02 -07:00
|
|
|
import { sha3_256 } from "js-sha3";
|
2022-08-28 05:34:42 -07:00
|
|
|
import { isOutdated } from "./cmds/update";
|
2022-10-21 10:40:17 -07:00
|
|
|
import { setDefaultWasm } from "@certusone/wormhole-sdk/lib/cjs/solana/wasm";
|
|
|
|
import { assertChain, assertEVMChain, ChainName, CHAINS, CONTRACTS as SDK_CONTRACTS, isCosmWasmChain, isEVMChain, isTerraChain, toChainId, toChainName } from "@certusone/wormhole-sdk/lib/cjs/utils/consts";
|
2022-05-05 17:51:24 -07:00
|
|
|
|
|
|
|
setDefaultWasm("node");
|
|
|
|
|
2022-08-28 05:34:42 -07:00
|
|
|
if (isOutdated()) {
|
2022-10-14 08:20:45 -07:00
|
|
|
console.error(
|
|
|
|
"\x1b[33m%s\x1b[0m",
|
|
|
|
"WARNING: 'worm' is out of date. Run 'worm update' to update."
|
|
|
|
);
|
2022-08-28 05:34:42 -07:00
|
|
|
}
|
|
|
|
|
2022-05-05 17:51:24 -07:00
|
|
|
const GOVERNANCE_CHAIN = 1;
|
|
|
|
const GOVERNANCE_EMITTER =
|
|
|
|
"0000000000000000000000000000000000000000000000000000000000000004";
|
|
|
|
|
2022-10-21 10:40:17 -07:00
|
|
|
// TODO: remove this once the aptos SDK changes are merged in
|
2022-10-13 18:21:01 -07:00
|
|
|
const OVERRIDES = {
|
|
|
|
MAINNET: {
|
2022-10-17 05:10:05 -07:00
|
|
|
aptos: {
|
2022-10-14 08:20:45 -07:00
|
|
|
token_bridge:
|
|
|
|
"0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f",
|
|
|
|
core: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
|
|
|
|
},
|
2022-10-13 18:21:01 -07:00
|
|
|
},
|
|
|
|
TESTNET: {
|
|
|
|
aptos: {
|
2022-10-14 08:20:45 -07:00
|
|
|
token_bridge:
|
|
|
|
"0x576410486a2da45eee6c949c995670112ddf2fbeedab20350d506328eefc9d4f",
|
|
|
|
core: "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625",
|
|
|
|
},
|
2022-10-13 18:21:01 -07:00
|
|
|
},
|
|
|
|
DEVNET: {
|
|
|
|
aptos: {
|
2022-10-14 08:20:45 -07:00
|
|
|
token_bridge:
|
|
|
|
"0x84a5f374d29fc77e370014dce4fd6a55b58ad608de8074b0be5571701724da31",
|
|
|
|
core: "0xde0036a9600559e295d5f6802ef6f3f802f510366e0c23912b0655d972166017",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-10-13 18:21:01 -07:00
|
|
|
|
2022-10-17 15:30:49 -07:00
|
|
|
export const CONTRACTS = {
|
2022-10-13 18:21:01 -07:00
|
|
|
MAINNET: { ...SDK_CONTRACTS.MAINNET, ...OVERRIDES.MAINNET },
|
|
|
|
TESTNET: { ...SDK_CONTRACTS.TESTNET, ...OVERRIDES.TESTNET },
|
|
|
|
DEVNET: { ...SDK_CONTRACTS.DEVNET, ...OVERRIDES.DEVNET },
|
|
|
|
};
|
|
|
|
|
2022-05-05 17:51:24 -07:00
|
|
|
function makeVAA(
|
|
|
|
emitterChain: number,
|
|
|
|
emitterAddress: string,
|
|
|
|
signers: string[],
|
|
|
|
p: Payload
|
|
|
|
): VAA<Payload> {
|
|
|
|
let v: VAA<Payload> = {
|
|
|
|
version: 1,
|
|
|
|
guardianSetIndex: 0,
|
|
|
|
signatures: [],
|
|
|
|
timestamp: 1,
|
|
|
|
nonce: 1,
|
|
|
|
emitterChain: emitterChain,
|
|
|
|
emitterAddress: emitterAddress,
|
|
|
|
sequence: BigInt(Math.floor(Math.random() * 100000000)),
|
|
|
|
consistencyLevel: 0,
|
|
|
|
payload: p,
|
|
|
|
};
|
|
|
|
v.signatures = vaa.sign(signers, v);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
yargs(hideBin(process.argv))
|
2022-08-28 05:34:42 -07:00
|
|
|
//TODO(csongor): refactor all commands into the directory structure.
|
2022-10-14 08:20:45 -07:00
|
|
|
.commandDir("cmds")
|
2022-05-05 17:51:24 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Generate
|
|
|
|
.command(
|
|
|
|
"generate",
|
|
|
|
"generate VAAs (devnet and testnet only)",
|
|
|
|
(yargs) => {
|
|
|
|
return (
|
|
|
|
yargs
|
|
|
|
.option("guardian-secret", {
|
|
|
|
alias: "g",
|
|
|
|
required: true,
|
2022-06-25 07:04:31 -07:00
|
|
|
describe: "Guardians' secret keys (CSV)",
|
2022-05-05 17:51:24 -07:00
|
|
|
type: "string",
|
|
|
|
})
|
|
|
|
// Registration
|
|
|
|
.command(
|
|
|
|
"registration",
|
|
|
|
"Generate registration VAA",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.option("chain", {
|
|
|
|
alias: "c",
|
|
|
|
describe: "Chain to register",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("contract-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Contract to register",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("module", {
|
|
|
|
alias: "m",
|
|
|
|
describe: "Module to upgrade",
|
|
|
|
type: "string",
|
|
|
|
choices: ["NFTBridge", "TokenBridge"],
|
|
|
|
required: true,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
(argv) => {
|
|
|
|
let module = argv["module"] as "NFTBridge" | "TokenBridge";
|
|
|
|
assertChain(argv["chain"]);
|
|
|
|
let payload: vaa.PortalRegisterChain<typeof module> = {
|
|
|
|
module,
|
|
|
|
type: "RegisterChain",
|
|
|
|
chain: 0,
|
|
|
|
emitterChain: toChainId(argv["chain"]),
|
2022-08-18 07:42:11 -07:00
|
|
|
emitterAddress: parseAddress(
|
|
|
|
argv["chain"],
|
|
|
|
argv["contract-address"]
|
|
|
|
),
|
2022-05-05 17:51:24 -07:00
|
|
|
};
|
|
|
|
let v = makeVAA(
|
|
|
|
GOVERNANCE_CHAIN,
|
|
|
|
GOVERNANCE_EMITTER,
|
|
|
|
argv["guardian-secret"].split(","),
|
|
|
|
payload
|
|
|
|
);
|
|
|
|
console.log(serialiseVAA(v));
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// Upgrade
|
|
|
|
.command(
|
|
|
|
"upgrade",
|
|
|
|
"Generate contract upgrade VAA",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.option("chain", {
|
|
|
|
alias: "c",
|
|
|
|
describe: "Chain to upgrade",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("contract-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Contract to upgrade to",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("module", {
|
|
|
|
alias: "m",
|
|
|
|
describe: "Module to upgrade",
|
|
|
|
type: "string",
|
|
|
|
choices: ["Core", "NFTBridge", "TokenBridge"],
|
|
|
|
required: true,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
(argv) => {
|
|
|
|
assertChain(argv["chain"]);
|
|
|
|
let module = argv["module"] as
|
|
|
|
| "Core"
|
|
|
|
| "NFTBridge"
|
|
|
|
| "TokenBridge";
|
2022-06-29 11:31:22 -07:00
|
|
|
let payload: vaa.ContractUpgrade = {
|
2022-05-05 17:51:24 -07:00
|
|
|
module,
|
|
|
|
type: "ContractUpgrade",
|
|
|
|
chain: toChainId(argv["chain"]),
|
2022-08-18 07:42:11 -07:00
|
|
|
address: parseCodeAddress(
|
|
|
|
argv["chain"],
|
|
|
|
argv["contract-address"]
|
|
|
|
),
|
2022-05-05 17:51:24 -07:00
|
|
|
};
|
|
|
|
let v = makeVAA(
|
|
|
|
GOVERNANCE_CHAIN,
|
|
|
|
GOVERNANCE_EMITTER,
|
|
|
|
argv["guardian-secret"].split(","),
|
|
|
|
payload
|
|
|
|
);
|
|
|
|
console.log(serialiseVAA(v));
|
|
|
|
}
|
|
|
|
)
|
2022-10-13 18:21:01 -07:00
|
|
|
.command(
|
|
|
|
"attestation",
|
|
|
|
"Generate a token attestation VAA",
|
|
|
|
// TODO: putting 'any' here is a workaround for the following error:
|
|
|
|
//
|
|
|
|
// Type instantiation is excessively deep and possibly infinite.
|
|
|
|
//
|
|
|
|
// The type of the yargs builder grows too big for typescript's
|
|
|
|
// liking, and there's no way to increase the limit. So we
|
|
|
|
// overapproximate with the 'any' type which reduces the typechecking stack.
|
|
|
|
// This is not a great solution, and instead we should move toward
|
|
|
|
// breaking up the commands into multiple modules in the 'cmds' folder.
|
|
|
|
(yargs: any) => {
|
|
|
|
return yargs
|
|
|
|
.option("emitter-chain", {
|
|
|
|
alias: "e",
|
|
|
|
describe: "Emitter chain of the VAA",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("emitter-address", {
|
|
|
|
alias: "f",
|
|
|
|
describe: "Emitter address of the VAA",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("chain", {
|
|
|
|
alias: "c",
|
|
|
|
describe: "Token's chain",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("token-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Token's address",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("decimals", {
|
|
|
|
alias: "d",
|
|
|
|
describe: "Token's decimals",
|
|
|
|
type: "number",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("symbol", {
|
|
|
|
alias: "s",
|
|
|
|
describe: "Token's symbol",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("name", {
|
|
|
|
alias: "n",
|
|
|
|
describe: "Token's name",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
(argv) => {
|
|
|
|
let emitter_chain = argv["emitter-chain"] as string;
|
|
|
|
assertChain(argv["chain"]);
|
|
|
|
assertChain(emitter_chain);
|
|
|
|
let payload: vaa.TokenBridgeAttestMeta = {
|
|
|
|
module: "TokenBridge",
|
|
|
|
type: "AttestMeta",
|
|
|
|
chain: 0,
|
|
|
|
// TODO: remove these casts (only here because of the workaround above)
|
2022-10-14 08:20:45 -07:00
|
|
|
tokenAddress: parseAddress(
|
|
|
|
argv["chain"],
|
|
|
|
argv["token-address"] as string
|
|
|
|
),
|
2022-10-13 18:21:01 -07:00
|
|
|
tokenChain: toChainId(argv["chain"]),
|
|
|
|
decimals: argv["decimals"] as number,
|
|
|
|
symbol: argv["symbol"] as string,
|
2022-10-14 08:20:45 -07:00
|
|
|
name: argv["name"] as string,
|
|
|
|
};
|
2022-10-13 18:21:01 -07:00
|
|
|
let v = makeVAA(
|
|
|
|
toChainId(emitter_chain),
|
|
|
|
parseAddress(emitter_chain, argv["emitter-address"] as string),
|
|
|
|
argv["guardian-secret"].split(","),
|
|
|
|
payload
|
|
|
|
);
|
|
|
|
console.log(serialiseVAA(v));
|
|
|
|
}
|
|
|
|
)
|
2022-05-05 17:51:24 -07:00
|
|
|
);
|
|
|
|
},
|
|
|
|
(_) => {
|
|
|
|
yargs.showHelp();
|
|
|
|
}
|
|
|
|
)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2022-06-25 07:04:31 -07:00
|
|
|
// Misc
|
2022-05-05 17:51:24 -07:00
|
|
|
.command(
|
|
|
|
"parse <vaa>",
|
2022-06-29 16:51:30 -07:00
|
|
|
"Parse a VAA (can be in either hex or base64 format)",
|
2022-05-05 17:51:24 -07:00
|
|
|
(yargs) => {
|
|
|
|
return yargs.positional("vaa", {
|
|
|
|
describe: "vaa",
|
|
|
|
type: "string",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
2022-06-29 11:01:28 -07:00
|
|
|
let buf: Buffer;
|
|
|
|
try {
|
2022-08-18 07:42:11 -07:00
|
|
|
buf = Buffer.from(String(argv.vaa), "hex");
|
2022-06-29 11:01:28 -07:00
|
|
|
if (buf.length == 0) {
|
2022-08-18 07:42:11 -07:00
|
|
|
throw Error("Couldn't parse VAA as hex");
|
2022-06-29 11:01:28 -07:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2022-08-18 07:42:11 -07:00
|
|
|
buf = Buffer.from(String(argv.vaa), "base64");
|
2022-06-29 11:01:28 -07:00
|
|
|
if (buf.length == 0) {
|
2022-08-18 07:42:11 -07:00
|
|
|
throw Error("Couldn't parse VAA as base64 or hex");
|
2022-06-29 11:01:28 -07:00
|
|
|
}
|
|
|
|
}
|
2022-05-05 17:51:24 -07:00
|
|
|
const parsed_vaa = vaa.parse(buf);
|
2022-06-29 05:30:16 -07:00
|
|
|
let parsed_vaa_with_digest = parsed_vaa;
|
2022-08-18 07:42:11 -07:00
|
|
|
parsed_vaa_with_digest["digest"] = vaa.vaaDigest(parsed_vaa);
|
2022-06-29 05:30:16 -07:00
|
|
|
console.log(parsed_vaa_with_digest);
|
2022-06-25 07:04:31 -07:00
|
|
|
}
|
2022-08-18 07:42:11 -07:00
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"recover <digest> <signature>",
|
|
|
|
"Recover an address from a signature",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.positional("digest", {
|
|
|
|
describe: "digest",
|
|
|
|
type: "string",
|
|
|
|
})
|
|
|
|
.positional("signature", {
|
|
|
|
describe: "signature",
|
|
|
|
type: "string",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
|
|
|
console.log(
|
|
|
|
ethers.utils.recoverAddress(hex(argv["digest"]), hex(argv["signature"]))
|
|
|
|
);
|
2022-06-25 07:04:31 -07:00
|
|
|
}
|
2022-08-18 07:42:11 -07:00
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"contract <network> <chain> <module>",
|
|
|
|
"Print contract address",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.positional("network", {
|
|
|
|
describe: "network",
|
|
|
|
type: "string",
|
|
|
|
choices: ["mainnet", "testnet", "devnet"],
|
|
|
|
})
|
|
|
|
.positional("chain", {
|
|
|
|
describe: "Chain to query",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
})
|
|
|
|
.positional("module", {
|
|
|
|
describe: "Module to query",
|
|
|
|
type: "string",
|
|
|
|
choices: ["Core", "NFTBridge", "TokenBridge"],
|
2022-09-06 06:20:51 -07:00
|
|
|
})
|
|
|
|
.option("emitter", {
|
|
|
|
alias: "e",
|
|
|
|
describe: "Print in emitter address format",
|
|
|
|
type: "boolean",
|
|
|
|
default: false,
|
|
|
|
required: false,
|
2022-08-18 07:42:11 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
|
|
|
assertChain(argv["chain"]);
|
|
|
|
const network = argv.network.toUpperCase();
|
|
|
|
if (
|
|
|
|
network !== "MAINNET" &&
|
|
|
|
network !== "TESTNET" &&
|
|
|
|
network !== "DEVNET"
|
|
|
|
) {
|
|
|
|
throw Error(`Unknown network: ${network}`);
|
|
|
|
}
|
2022-10-06 12:39:34 -07:00
|
|
|
let chain = argv["chain"];
|
2022-08-18 07:42:11 -07:00
|
|
|
let module = argv["module"] as "Core" | "NFTBridge" | "TokenBridge";
|
2022-10-06 12:39:34 -07:00
|
|
|
let addr = "";
|
2022-08-18 07:42:11 -07:00
|
|
|
switch (module) {
|
|
|
|
case "Core":
|
2022-09-06 06:20:51 -07:00
|
|
|
addr = CONTRACTS[network][chain]["core"];
|
2022-08-18 07:42:11 -07:00
|
|
|
break;
|
|
|
|
case "NFTBridge":
|
2022-09-06 06:20:51 -07:00
|
|
|
addr = CONTRACTS[network][chain]["nft_bridge"];
|
2022-08-18 07:42:11 -07:00
|
|
|
break;
|
|
|
|
case "TokenBridge":
|
2022-09-06 06:20:51 -07:00
|
|
|
addr = CONTRACTS[network][chain]["token_bridge"];
|
2022-08-18 07:42:11 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
impossible(module);
|
|
|
|
}
|
2022-09-06 06:20:51 -07:00
|
|
|
if (argv["emitter"]) {
|
2022-10-21 10:40:17 -07:00
|
|
|
const emitter = require("@certusone/wormhole-sdk/lib/cjs/bridge/getEmitterAddress")
|
2022-10-06 12:39:34 -07:00
|
|
|
if (chain === "solana" || chain === "pythnet") {
|
|
|
|
// TODO: Create an isSolanaChain()
|
2022-10-21 10:40:17 -07:00
|
|
|
addr = await emitter.getEmitterAddressSolana(addr);
|
2022-10-27 11:52:23 -07:00
|
|
|
} else if (isCosmWasmChain(chain)) {
|
2022-10-21 10:40:17 -07:00
|
|
|
addr = await emitter.getEmitterAddressTerra(addr);
|
2022-09-06 06:20:51 -07:00
|
|
|
} else if (chain === "algorand") {
|
2022-10-21 10:40:17 -07:00
|
|
|
addr = emitter.getEmitterAddressAlgorand(BigInt(addr));
|
2022-09-06 06:20:51 -07:00
|
|
|
} else if (chain === "near") {
|
2022-10-21 10:40:17 -07:00
|
|
|
addr = emitter.getEmitterAddressNear(addr);
|
2022-09-06 06:20:51 -07:00
|
|
|
} else {
|
2022-10-21 10:40:17 -07:00
|
|
|
addr = emitter.getEmitterAddressEth(addr);
|
2022-09-06 06:20:51 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(addr);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"chain-id <chain>",
|
|
|
|
"Print the wormhole chain ID integer associated with the specified chain name",
|
|
|
|
(yargs) => {
|
2022-10-06 12:39:34 -07:00
|
|
|
return yargs.positional("chain", {
|
|
|
|
describe: "Chain to query",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
});
|
2022-09-06 06:20:51 -07:00
|
|
|
},
|
|
|
|
async (argv) => {
|
2022-10-06 12:39:34 -07:00
|
|
|
assertChain(argv["chain"]);
|
2022-09-06 06:20:51 -07:00
|
|
|
console.log(toChainId(argv["chain"]));
|
2022-08-18 07:42:11 -07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"rpc <network> <chain>",
|
|
|
|
"Print RPC address",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.positional("network", {
|
|
|
|
describe: "network",
|
|
|
|
type: "string",
|
|
|
|
choices: ["mainnet", "testnet", "devnet"],
|
|
|
|
})
|
|
|
|
.positional("chain", {
|
|
|
|
describe: "Chain to query",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
|
|
|
assertChain(argv["chain"]);
|
|
|
|
const network = argv.network.toUpperCase();
|
|
|
|
if (
|
|
|
|
network !== "MAINNET" &&
|
|
|
|
network !== "TESTNET" &&
|
|
|
|
network !== "DEVNET"
|
|
|
|
) {
|
|
|
|
throw Error(`Unknown network: ${network}`);
|
|
|
|
}
|
|
|
|
console.log(NETWORKS[network][argv["chain"]].rpc);
|
2022-06-25 07:04:31 -07:00
|
|
|
}
|
2022-08-18 07:42:11 -07:00
|
|
|
)
|
2022-10-14 08:20:45 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Near utilities
|
|
|
|
.command(
|
|
|
|
"near",
|
|
|
|
"NEAR utilites",
|
|
|
|
(yargs) => {
|
2022-10-21 10:40:17 -07:00
|
|
|
const near = require("./near")
|
2022-10-14 08:20:45 -07:00
|
|
|
return (
|
|
|
|
yargs
|
|
|
|
.option("module", {
|
|
|
|
alias: "m",
|
|
|
|
describe: "Module to query",
|
|
|
|
type: "string",
|
|
|
|
choices: ["Core", "NFTBridge", "TokenBridge"],
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("network", {
|
|
|
|
alias: "n",
|
|
|
|
describe: "network",
|
|
|
|
type: "string",
|
|
|
|
choices: ["mainnet", "testnet", "devnet"],
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("account", {
|
|
|
|
describe: "near deployment account",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("attach", {
|
|
|
|
describe: "attach some near",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("target", {
|
|
|
|
describe: "near account to upgrade",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("mnemonic", {
|
|
|
|
describe: "near private keys",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("keys", {
|
|
|
|
describe: "near private keys",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.command(
|
|
|
|
"contract-update <file>",
|
|
|
|
"Submit a contract update using our specific APIs",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs.positional("file", {
|
|
|
|
type: "string",
|
|
|
|
describe: "wasm",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
2022-10-21 10:40:17 -07:00
|
|
|
await near.upgrade_near(argv);
|
2022-10-14 08:20:45 -07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"deploy <file>",
|
|
|
|
"Submit a contract update using near APIs",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs.positional("file", {
|
|
|
|
type: "string",
|
|
|
|
describe: "wasm",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
2022-10-21 10:40:17 -07:00
|
|
|
await near.deploy_near(argv);
|
2022-10-14 08:20:45 -07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
(_) => {
|
|
|
|
yargs.showHelp();
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2022-06-25 07:04:31 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Evm utilities
|
2022-08-18 07:42:11 -07:00
|
|
|
.command(
|
|
|
|
"evm",
|
|
|
|
"EVM utilites",
|
|
|
|
(yargs) => {
|
2022-10-21 10:40:17 -07:00
|
|
|
const evm = require("./evm")
|
2022-08-18 07:42:11 -07:00
|
|
|
return yargs
|
|
|
|
.option("rpc", {
|
|
|
|
describe: "RPC endpoint",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.command(
|
|
|
|
"address-from-secret <secret>",
|
|
|
|
"Compute a 20 byte eth address from a 32 byte private key",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs.positional("secret", {
|
|
|
|
type: "string",
|
|
|
|
describe: "Secret key (32 bytes)",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
(argv) => {
|
|
|
|
console.log(ethers.utils.computeAddress(argv["secret"]));
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"storage-update",
|
|
|
|
"Update a storage slot on an EVM fork during testing (anvil or hardhat)",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.option("contract-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Contract address",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("storage-slot", {
|
|
|
|
alias: "k",
|
|
|
|
describe: "Storage slot to modify",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("value", {
|
|
|
|
alias: "v",
|
|
|
|
describe: "Value to write into the slot (32 bytes)",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
2022-10-21 10:40:17 -07:00
|
|
|
const result = await evm.setStorageAt(
|
2022-08-18 07:42:11 -07:00
|
|
|
argv["rpc"],
|
|
|
|
evm_address(argv["contract-address"]),
|
|
|
|
argv["storage-slot"],
|
|
|
|
["uint256"],
|
|
|
|
[argv["value"]]
|
|
|
|
);
|
|
|
|
console.log(result);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.command("chains", "Return all EVM chains", async (_) => {
|
|
|
|
console.log(
|
|
|
|
Object.values(CHAINS)
|
|
|
|
.map((id) => toChainName(id))
|
|
|
|
.filter((name) => isEVMChain(name))
|
|
|
|
.join(" ")
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.command(
|
|
|
|
"info",
|
|
|
|
"Query info about the on-chain state of the contract",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.option("chain", {
|
|
|
|
alias: "c",
|
|
|
|
describe: "Chain to query",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("module", {
|
|
|
|
alias: "m",
|
|
|
|
describe: "Module to query",
|
|
|
|
type: "string",
|
|
|
|
choices: ["Core", "NFTBridge", "TokenBridge"],
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("network", {
|
|
|
|
alias: "n",
|
|
|
|
describe: "network",
|
|
|
|
type: "string",
|
|
|
|
choices: ["mainnet", "testnet", "devnet"],
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("contract-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Contract to query (override config)",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("implementation-only", {
|
|
|
|
alias: "i",
|
|
|
|
describe: "Only query implementation (faster)",
|
|
|
|
type: "boolean",
|
|
|
|
default: false,
|
|
|
|
required: false,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
|
|
|
assertChain(argv["chain"]);
|
|
|
|
assertEVMChain(argv["chain"]);
|
|
|
|
const network = argv.network.toUpperCase();
|
|
|
|
if (
|
|
|
|
network !== "MAINNET" &&
|
|
|
|
network !== "TESTNET" &&
|
|
|
|
network !== "DEVNET"
|
|
|
|
) {
|
|
|
|
throw Error(`Unknown network: ${network}`);
|
|
|
|
}
|
|
|
|
let module = argv["module"] as "Core" | "NFTBridge" | "TokenBridge";
|
|
|
|
let rpc = argv["rpc"] ?? NETWORKS[network][argv["chain"]].rpc;
|
|
|
|
if (argv["implementation-only"]) {
|
|
|
|
console.log(
|
2022-10-21 10:40:17 -07:00
|
|
|
await evm.getImplementation(
|
2022-08-18 07:42:11 -07:00
|
|
|
network,
|
|
|
|
argv["chain"],
|
|
|
|
module,
|
|
|
|
argv["contract-address"],
|
|
|
|
rpc
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
console.log(
|
|
|
|
JSON.stringify(
|
2022-10-21 10:40:17 -07:00
|
|
|
await evm.query_contract_evm(
|
2022-08-18 07:42:11 -07:00
|
|
|
network,
|
|
|
|
argv["chain"],
|
|
|
|
module,
|
|
|
|
argv["contract-address"],
|
|
|
|
rpc
|
|
|
|
),
|
|
|
|
null,
|
|
|
|
2
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.command(
|
|
|
|
"hijack",
|
|
|
|
"Override the guardian set of the core bridge contract during testing (anvil or hardhat)",
|
|
|
|
(yargs) => {
|
|
|
|
return yargs
|
|
|
|
.option("core-contract-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Core contract address",
|
|
|
|
type: "string",
|
|
|
|
default: CONTRACTS.MAINNET.ethereum.core,
|
|
|
|
})
|
|
|
|
.option("guardian-address", {
|
|
|
|
alias: "g",
|
|
|
|
required: true,
|
|
|
|
describe: "Guardians' public addresses (CSV)",
|
|
|
|
type: "string",
|
|
|
|
})
|
|
|
|
.option("guardian-set-index", {
|
|
|
|
alias: "i",
|
|
|
|
required: false,
|
|
|
|
describe:
|
|
|
|
"New guardian set index (if unspecified, default to overriding the current index)",
|
|
|
|
type: "number",
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
|
|
|
const guardian_addresses = argv["guardian-address"].split(",");
|
|
|
|
let rpc = argv["rpc"] ?? NETWORKS.DEVNET.ethereum.rpc;
|
2022-10-21 10:40:17 -07:00
|
|
|
await evm.hijack_evm(
|
2022-08-18 07:42:11 -07:00
|
|
|
rpc,
|
|
|
|
argv["core-contract-address"],
|
|
|
|
guardian_addresses,
|
|
|
|
argv["guardian-set-index"]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
2022-06-25 07:04:31 -07:00
|
|
|
(_) => {
|
|
|
|
yargs.showHelp();
|
2022-05-05 17:51:24 -07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Submit
|
|
|
|
.command(
|
|
|
|
"submit <vaa>",
|
|
|
|
"Execute a VAA",
|
|
|
|
(yargs) => {
|
2022-10-14 08:20:45 -07:00
|
|
|
// @ts-ignore
|
2022-05-05 17:51:24 -07:00
|
|
|
return yargs
|
|
|
|
.positional("vaa", {
|
|
|
|
describe: "vaa",
|
|
|
|
type: "string",
|
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
.option("chain", {
|
|
|
|
alias: "c",
|
|
|
|
describe: "chain name",
|
|
|
|
type: "string",
|
|
|
|
choices: Object.keys(CHAINS),
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("network", {
|
|
|
|
alias: "n",
|
|
|
|
describe: "network",
|
|
|
|
type: "string",
|
|
|
|
choices: ["mainnet", "testnet", "devnet"],
|
|
|
|
required: true,
|
2022-06-25 07:04:31 -07:00
|
|
|
})
|
|
|
|
.option("contract-address", {
|
|
|
|
alias: "a",
|
|
|
|
describe: "Contract to submit VAA to (override config)",
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
})
|
|
|
|
.option("rpc", {
|
|
|
|
describe: "RPC endpoint",
|
|
|
|
type: "string",
|
2022-08-18 07:42:11 -07:00
|
|
|
required: false,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
async (argv) => {
|
2022-05-05 17:51:24 -07:00
|
|
|
const vaa_hex = String(argv.vaa);
|
|
|
|
const buf = Buffer.from(vaa_hex, "hex");
|
|
|
|
const parsed_vaa = vaa.parse(buf);
|
|
|
|
|
2022-06-30 16:02:16 -07:00
|
|
|
vaa.assertKnownPayload(parsed_vaa);
|
2022-05-05 17:51:24 -07:00
|
|
|
|
|
|
|
console.log(parsed_vaa.payload);
|
|
|
|
|
|
|
|
const network = argv.network.toUpperCase();
|
|
|
|
if (
|
|
|
|
network !== "MAINNET" &&
|
|
|
|
network !== "TESTNET" &&
|
|
|
|
network !== "DEVNET"
|
|
|
|
) {
|
|
|
|
throw Error(`Unknown network: ${network}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We figure out the target chain to submit the VAA to.
|
|
|
|
// The VAA might specify this itself (for example a contract upgrade VAA
|
|
|
|
// or a token transfer VAA), in which case we just submit the VAA to
|
|
|
|
// that target chain.
|
|
|
|
//
|
|
|
|
// If the VAA does not have a target (e.g. chain registration VAAs or
|
|
|
|
// guardian set upgrade VAAs), we require the '--chain' argument to be
|
|
|
|
// set on the command line.
|
|
|
|
//
|
|
|
|
// As a sanity check, in the event that the VAA does specify a target
|
|
|
|
// and the '--chain' argument is also set, we issue an error if those
|
|
|
|
// two don't agree instead of silently taking the VAA's target chain.
|
|
|
|
|
|
|
|
// get VAA chain
|
|
|
|
const vaa_chain_id = parsed_vaa.payload.chain;
|
|
|
|
assertChain(vaa_chain_id);
|
|
|
|
const vaa_chain = toChainName(vaa_chain_id);
|
|
|
|
|
|
|
|
// get chain from command line arg
|
|
|
|
const cli_chain = argv["chain"];
|
|
|
|
|
|
|
|
let chain: ChainName;
|
|
|
|
if (cli_chain !== undefined) {
|
|
|
|
assertChain(cli_chain);
|
|
|
|
if (vaa_chain !== "unset" && cli_chain !== vaa_chain) {
|
|
|
|
throw Error(
|
|
|
|
`Specified target chain (${cli_chain}) does not match VAA target chain (${vaa_chain})`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
chain = cli_chain;
|
|
|
|
} else {
|
|
|
|
chain = vaa_chain;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (chain === "unset") {
|
|
|
|
throw Error(
|
|
|
|
"This VAA does not specify the target chain, please provide it by hand using the '--chain' flag."
|
|
|
|
);
|
|
|
|
} else if (isEVMChain(chain)) {
|
2022-10-21 10:40:17 -07:00
|
|
|
const evm = require("./evm")
|
|
|
|
await evm.execute_evm(
|
2022-08-18 07:42:11 -07:00
|
|
|
parsed_vaa.payload,
|
|
|
|
buf,
|
|
|
|
network,
|
|
|
|
chain,
|
|
|
|
argv["contract-address"],
|
|
|
|
argv["rpc"]
|
|
|
|
);
|
2022-06-07 08:36:21 -07:00
|
|
|
} else if (isTerraChain(chain)) {
|
2022-10-21 10:40:17 -07:00
|
|
|
const terra = require("./terra")
|
|
|
|
await terra.execute_terra(parsed_vaa.payload, buf, network, chain);
|
2022-08-19 08:29:57 -07:00
|
|
|
} else if (chain === "solana" || chain === "pythnet") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const solana = require("./solana")
|
|
|
|
await solana.execute_solana(parsed_vaa, buf, network, chain);
|
2022-05-05 17:51:24 -07:00
|
|
|
} else if (chain === "algorand") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const algorand = require("./algorand")
|
|
|
|
await algorand.execute_algorand(
|
2022-08-22 07:39:39 -07:00
|
|
|
parsed_vaa.payload,
|
2022-11-01 10:21:13 -07:00
|
|
|
new Uint8Array(Buffer.from(vaa_hex, "hex")),
|
2022-08-22 07:39:39 -07:00
|
|
|
network
|
|
|
|
);
|
2022-05-05 17:51:24 -07:00
|
|
|
} else if (chain === "near") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const near = require("./near")
|
|
|
|
await near.execute_near(parsed_vaa.payload, vaa_hex, network);
|
2022-07-15 06:03:03 -07:00
|
|
|
} else if (chain === "injective") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const injective = require("./injective")
|
|
|
|
await injective.execute_injective(parsed_vaa.payload, buf, network);
|
2022-10-11 12:30:09 -07:00
|
|
|
} else if (chain === "xpla") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const xpla = require("./xpla")
|
|
|
|
await xpla.execute_xpla(parsed_vaa.payload, buf, network);
|
2022-07-15 06:03:03 -07:00
|
|
|
} else if (chain === "osmosis") {
|
|
|
|
throw Error("OSMOSIS is not supported yet");
|
|
|
|
} else if (chain === "sui") {
|
|
|
|
throw Error("SUI is not supported yet");
|
|
|
|
} else if (chain === "aptos") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const aptos = require("./aptos")
|
|
|
|
await aptos.execute_aptos(
|
2022-10-14 08:20:45 -07:00
|
|
|
parsed_vaa.payload,
|
|
|
|
buf,
|
|
|
|
network,
|
|
|
|
argv["contract-address"],
|
|
|
|
argv["rpc"]
|
|
|
|
);
|
2022-10-24 15:18:23 -07:00
|
|
|
} else if (chain === "wormchain") {
|
2022-10-21 13:28:04 -07:00
|
|
|
throw Error("Wormchain is not supported yet");
|
2022-05-05 17:51:24 -07:00
|
|
|
} else {
|
|
|
|
// If you get a type error here, hover over `chain`'s type and it tells you
|
|
|
|
// which cases are not handled
|
|
|
|
impossible(chain);
|
|
|
|
}
|
|
|
|
}
|
2022-08-28 03:14:40 -07:00
|
|
|
)
|
|
|
|
.strict()
|
2022-10-14 08:20:45 -07:00
|
|
|
.demandCommand().argv;
|
2022-06-25 07:04:31 -07:00
|
|
|
|
|
|
|
function hex(x: string): string {
|
2022-08-18 07:42:11 -07:00
|
|
|
return ethers.utils.hexlify(x, { allowMissingPrefix: true });
|
2022-06-25 07:04:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function evm_address(x: string): string {
|
2022-08-18 07:42:11 -07:00
|
|
|
return hex(x).substring(2).padStart(64, "0");
|
2022-06-25 07:04:31 -07:00
|
|
|
}
|
2022-06-29 05:30:16 -07:00
|
|
|
|
|
|
|
function parseAddress(chain: ChainName, address: string): string {
|
|
|
|
if (chain === "unset") {
|
2022-08-18 07:42:11 -07:00
|
|
|
throw Error("Chain unset");
|
2022-06-29 05:30:16 -07:00
|
|
|
} else if (isEVMChain(chain)) {
|
2022-08-18 07:42:11 -07:00
|
|
|
return "0x" + evm_address(address);
|
2022-10-06 12:39:34 -07:00
|
|
|
} else if (isCosmWasmChain(chain)) {
|
2022-08-18 07:42:11 -07:00
|
|
|
return "0x" + toHex(fromBech32(address).data).padStart(64, "0");
|
2022-08-19 08:29:57 -07:00
|
|
|
} else if (chain === "solana" || chain === "pythnet") {
|
2022-08-18 07:42:11 -07:00
|
|
|
return "0x" + toHex(base58.decode(address)).padStart(64, "0");
|
2022-06-29 05:30:16 -07:00
|
|
|
} else if (chain === "algorand") {
|
2022-06-29 12:22:50 -07:00
|
|
|
// TODO: is there a better native format for algorand?
|
2022-08-18 07:42:11 -07:00
|
|
|
return "0x" + evm_address(address);
|
2022-06-29 05:30:16 -07:00
|
|
|
} else if (chain === "near") {
|
2022-10-06 12:39:34 -07:00
|
|
|
return "0x" + hex(address).substring(2).padStart(64, "0");
|
2022-07-15 06:03:03 -07:00
|
|
|
} else if (chain === "osmosis") {
|
|
|
|
throw Error("OSMOSIS is not supported yet");
|
|
|
|
} else if (chain === "sui") {
|
2022-08-18 07:42:11 -07:00
|
|
|
throw Error("SUI is not supported yet");
|
2022-07-15 06:03:03 -07:00
|
|
|
} else if (chain === "aptos") {
|
2022-10-24 15:12:02 -07:00
|
|
|
if (/^(0x)?[0-9a-fA-F]+$/.test(address)) {
|
|
|
|
return "0x" + evm_address(address);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sha3_256(Buffer.from(address)); // address is hash of fully qualified type
|
2022-10-24 15:18:23 -07:00
|
|
|
} else if (chain === "wormchain") {
|
2022-10-21 10:40:17 -07:00
|
|
|
const sdk = require("@certusone/wormhole-sdk/lib/cjs/utils/array")
|
|
|
|
return "0x" + sdk.tryNativeToHexString(address, chain);
|
2022-06-29 05:30:16 -07:00
|
|
|
} else {
|
2022-08-18 07:42:11 -07:00
|
|
|
impossible(chain);
|
2022-06-29 05:30:16 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function parseCodeAddress(chain: ChainName, address: string): string {
|
|
|
|
if (isTerraChain(chain)) {
|
2022-08-18 07:42:11 -07:00
|
|
|
return "0x" + parseInt(address, 10).toString(16).padStart(64, "0");
|
2022-06-29 05:30:16 -07:00
|
|
|
} else {
|
2022-08-18 07:42:11 -07:00
|
|
|
return parseAddress(chain, address);
|
2022-06-29 05:30:16 -07:00
|
|
|
}
|
|
|
|
}
|