From f53d180753b478b38b204faf039e2a8f5dfaca5a Mon Sep 17 00:00:00 2001 From: Evan Gray <56235822+evan-gray@users.noreply.github.com> Date: Tue, 10 Aug 2021 19:46:13 -0400 Subject: [PATCH] scripts: try catch truffle execs Change-Id: Id9b27812cd393056ef373d8ec2569ba75f0caea8 --- ethereum/scripts/deploy_test_token.js | 51 +++++++++++++---------- ethereum/scripts/register_solana_chain.js | 23 ++++++---- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/ethereum/scripts/deploy_test_token.js b/ethereum/scripts/deploy_test_token.js index a794a72ac..17c8ff23b 100644 --- a/ethereum/scripts/deploy_test_token.js +++ b/ethereum/scripts/deploy_test_token.js @@ -3,32 +3,37 @@ const TokenImplementation = artifacts.require("TokenImplementation") module.exports = async function(callback) { - const accounts = await web3.eth.getAccounts(); + try { + const accounts = await web3.eth.getAccounts(); - // deploy token contract - const tokenAddress = (await TokenImplementation.new()).address; - const token = new web3.eth.Contract(TokenImplementation.abi, tokenAddress); + // deploy token contract + const tokenAddress = (await TokenImplementation.new()).address; + const token = new web3.eth.Contract(TokenImplementation.abi, tokenAddress); - console.log("Token deployed at: "+tokenAddress); + console.log("Token deployed at: "+tokenAddress); - // initialize token contract - await token.methods.initialize( - "Test Token", - "TKN", - "18", // decimals - accounts[0], // owner - "0", - "0x00000000000000000000000000000000" - ).send({ - from:accounts[0], - gas:1000000 - }); + // initialize token contract + await token.methods.initialize( + "Test Token", + "TKN", + "18", // decimals + accounts[0], // owner + "0", + "0x00000000000000000000000000000000" + ).send({ + from:accounts[0], + gas:1000000 + }); - // mint 1000 units - await token.methods.mint(accounts[0], "1000000000000000000000").send({ - from:accounts[0], - gas:1000000 - }); + // mint 1000 units + await token.methods.mint(accounts[0], "1000000000000000000000").send({ + from:accounts[0], + gas:1000000 + }); - callback(); + callback(); + } + catch (e) { + callback(e); + } } \ No newline at end of file diff --git a/ethereum/scripts/register_solana_chain.js b/ethereum/scripts/register_solana_chain.js index 046498fc4..324e31fe8 100644 --- a/ethereum/scripts/register_solana_chain.js +++ b/ethereum/scripts/register_solana_chain.js @@ -6,15 +6,20 @@ const TokenImplementation = artifacts.require("TokenImplementation"); const BridgeImplementationFullABI = jsonfile.readFileSync("../build/contracts/BridgeImplementation.json").abi module.exports = async function (callback) { - const accounts = await web3.eth.getAccounts(); - const initialized = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address); + try { + const accounts = await web3.eth.getAccounts(); + const initialized = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address); - // Register the Solana endpoint - await initialized.methods.registerChain("0x01000000000100c9f4230109e378f7efc0605fb40f0e1869f2d82fda5b1dfad8a5a2dafee85e033d155c18641165a77a2db6a7afbf2745b458616cb59347e89ae0c7aa3e7cc2d400000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e4272696467650100000001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f").send({ - value: 0, - from: accounts[0], - gasLimit: 2000000 - }); + // Register the Solana endpoint + await initialized.methods.registerChain("0x01000000000100c9f4230109e378f7efc0605fb40f0e1869f2d82fda5b1dfad8a5a2dafee85e033d155c18641165a77a2db6a7afbf2745b458616cb59347e89ae0c7aa3e7cc2d400000000010000000100010000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000546f6b656e4272696467650100000001c69a1b1a65dd336bf1df6a77afb501fc25db7fc0938cb08595a9ef473265cb4f").send({ + value: 0, + from: accounts[0], + gasLimit: 2000000 + }); - callback(); + callback(); + } + catch (e) { + callback(e); + } } \ No newline at end of file