ethereum/scripts: reduce register script
This commit is contained in:
parent
e09a2616bf
commit
6ebd57be58
|
@ -6,16 +6,19 @@ const NFTBridge = artifacts.require("NFTBridgeEntrypoint");
|
|||
const BridgeImplementationFullABI = jsonfile.readFileSync(
|
||||
"../build/contracts/BridgeImplementation.json"
|
||||
).abi;
|
||||
const solTokenBridgeVAA = process.env.REGISTER_SOL_TOKEN_BRIDGE_VAA;
|
||||
const solNFTBridgeVAA = process.env.REGISTER_SOL_NFT_BRIDGE_VAA;
|
||||
const terraTokenBridgeVAA = process.env.REGISTER_TERRA_TOKEN_BRIDGE_VAA;
|
||||
const terraNFTBridgeVAA = process.env.REGISTER_TERRA_NFT_BRIDGE_VAA;
|
||||
const terra2TokenBridgeVAA = process.env.REGISTER_TERRA2_TOKEN_BRIDGE_VAA;
|
||||
const bscTokenBridgeVAA = process.env.REGISTER_BSC_TOKEN_BRIDGE_VAA;
|
||||
const algoTokenBridgeVAA = process.env.REGISTER_ALGO_TOKEN_BRIDGE_VAA;
|
||||
const nearTokenBridgeVAA = process.env.REGISTER_NEAR_TOKEN_BRIDGE_VAA;
|
||||
const wormchainTokenBridgeVAA = process.env.REGISTER_WORMCHAIN_TOKEN_BRIDGE_VAA;
|
||||
const aptosTokenBridgeVAA = process.env.REGISTER_APTOS_TOKEN_BRIDGE_VAA;
|
||||
|
||||
// The input parameter is a RegExp
|
||||
// It returns an array of process.env variables satisfying the input RegExp
|
||||
function getFilteredEnvs(regexp) {
|
||||
const filteredEnvs = [];
|
||||
for (const [key, value] of Object.entries(process.env)) {
|
||||
if (regexp.test(key) && value) {
|
||||
console.log("getFilteredEnvs: pushing " + key);
|
||||
filteredEnvs.push(value);
|
||||
}
|
||||
}
|
||||
return filteredEnvs;
|
||||
}
|
||||
|
||||
module.exports = async function(callback) {
|
||||
try {
|
||||
|
@ -29,85 +32,32 @@ module.exports = async function(callback) {
|
|||
NFTBridge.address
|
||||
);
|
||||
|
||||
// Register the Solana token bridge endpoint
|
||||
console.log("Registering solana...");
|
||||
await tokenBridge.methods.registerChain("0x" + solTokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
const TokenBridgeRegExp = new RegExp("REGISTER_.*_TOKEN_BRIDGE_VAA");
|
||||
const NFTBridgeRegExp = new RegExp("REGISTER_.*_NFT_BRIDGE_VAA");
|
||||
|
||||
// Register the Solana NFT bridge endpoint
|
||||
await nftBridge.methods.registerChain("0x" + solNFTBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
const TokenBridgeVAAs = getFilteredEnvs(TokenBridgeRegExp);
|
||||
const NFTBridgeVAAs = getFilteredEnvs(NFTBridgeRegExp);
|
||||
|
||||
// Register the terra token bridge endpoint
|
||||
console.log("Registering Terra...");
|
||||
await tokenBridge.methods.registerChain("0x" + terraTokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
|
||||
// Register the terra NFT bridge endpoint
|
||||
await nftBridge.methods.registerChain("0x" + terraNFTBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
|
||||
// Register the terra2 token bridge endpoint
|
||||
console.log("Registering Terra2...");
|
||||
await tokenBridge.methods.registerChain("0x" + terra2TokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
|
||||
// Register the BSC endpoint
|
||||
console.log("Registering BSC...");
|
||||
await tokenBridge.methods.registerChain("0x" + bscTokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
|
||||
// Register the ALGO endpoint
|
||||
console.log("Registering Algo...");
|
||||
await tokenBridge.methods.registerChain("0x" + algoTokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
|
||||
// Register the near token bridge endpoint
|
||||
console.log("Registering Near...");
|
||||
await tokenBridge.methods.registerChain("0x" + nearTokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
|
||||
// Register the wormhole token bridge endpoint
|
||||
console.log("Registering Wormchain...");
|
||||
await tokenBridge.methods
|
||||
.registerChain("0x" + wormchainTokenBridgeVAA)
|
||||
.send({
|
||||
// Register the token bridge endpoints
|
||||
console.log("Registering " + TokenBridgeVAAs.length + " Token Bridges...");
|
||||
for (const vaa of TokenBridgeVAAs) {
|
||||
await tokenBridge.methods.registerChain("0x" + vaa).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
}
|
||||
|
||||
// Register the APTOS endpoint
|
||||
console.log("Registering Aptos...");
|
||||
await tokenBridge.methods.registerChain("0x" + aptosTokenBridgeVAA).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
// Register the NFT bridge endpoints
|
||||
console.log("Registering " + NFTBridgeVAAs.length + " NFT Bridges...");
|
||||
for (const vaa of NFTBridgeVAAs) {
|
||||
await nftBridge.methods.registerChain("0x" + vaa).send({
|
||||
value: 0,
|
||||
from: accounts[0],
|
||||
gasLimit: 2000000,
|
||||
});
|
||||
}
|
||||
console.log("Finished registering all Bridges...");
|
||||
|
||||
callback();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue