From 13f79a96b3d3dd940abf8ecd9777c464f9a340c8 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 28 Oct 2020 22:41:35 +0100 Subject: [PATCH] devnet: use real account and nonce for send-lockups.js ghstack-source-id: fb233fa7275fc52d96edc6dfa1f08a7bf26b8736 Pull Request resolved: https://github.com/certusone/wormhole/pull/61 --- ethereum/migrations/1_initial_migration.js | 2 ++ ethereum/src/send-lockups.js | 23 ++++++++++++++-------- solana/devnet_setup.sh | 8 ++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ethereum/migrations/1_initial_migration.js b/ethereum/migrations/1_initial_migration.js index 2bf0a2b0ab..35768e0122 100644 --- a/ethereum/migrations/1_initial_migration.js +++ b/ethereum/migrations/1_initial_migration.js @@ -1,5 +1,6 @@ const WrappedAsset = artifacts.require("WrappedAsset"); const Wormhole = artifacts.require("Wormhole"); +const ERC20 = artifacts.require("ERC20PresetMinterPauser"); module.exports = async function (deployer) { await deployer.deploy(WrappedAsset); @@ -7,4 +8,5 @@ module.exports = async function (deployer) { keys: ["0xbeFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe"], expiration_time: 0 }, WrappedAsset.address, 1000); + await deployer.deploy(ERC20, "Test Token","TKN"); }; diff --git a/ethereum/src/send-lockups.js b/ethereum/src/send-lockups.js index 5be2675308..ad98e9664c 100644 --- a/ethereum/src/send-lockups.js +++ b/ethereum/src/send-lockups.js @@ -26,19 +26,26 @@ function sleep(ms) { module.exports = function(callback) { const fn = async () => { let bridge = await Wormhole.deployed(); - - let token = await ERC20.new("Test Token", "TKN"); + let token = await ERC20.deployed(); + console.log("Token:", token.address); await token.mint("0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1", "1000000000000000000"); await token.approve(bridge.address, "1000000000000000000"); while (true) { let ev = await bridge.lockAssets( - token.address, /* asset address */ - "1000000005", /* amount */ - "0x1230000000000000000000000000000000000000000000000000000000000000", /* recipient */ - 1, /* target chain: solana */ - 0, /* nonce */ - false /* refund dust? */ + /* asset address */ + token.address, + /* amount */ + "1000000005", + /* recipient + * 7EFk3VrWeb29SWJPQs5cUyqcY3fQd33S9gELkGybRzeu base58 -> hex) */ + "0x5c8b574eced4dbea1bbf23d5149564791900129ede419a6860e3e706b426b2ba", + /* target chain: solana */ + 1, + /* nonce */ + Math.floor(Math.random() * 65535), + /* refund dust? */ + false ); let block = await web3.eth.getBlock('latest'); diff --git a/solana/devnet_setup.sh b/solana/devnet_setup.sh index 1462fe27f9..9175822265 100755 --- a/solana/devnet_setup.sh +++ b/solana/devnet_setup.sh @@ -41,6 +41,14 @@ echo "Created token account $account" # Mint new tokens owned by our CLI account cli mint "$token" 10000000000 "$account" +# Create wrapped asset for the token we mint in send-lockups.js (2 = Ethereum, 9 decimals) +wrapped_token=$(cli create-wrapped "$bridge_address" 2 9 000000000000000000000000CfEB869F69431e42cdB54A4F4f105C19C080A601 | grep 'Wrapped Mint address' | awk '{ print $4 }') +echo "Created wrapped token $token" + +# Create token account to receive wrapped assets from send-lockups.js +wrapped_account=$(cli create-account --seed=934893 "$wrapped_token" | grep 'Creating account' | awk '{ print $3 }') +echo "Created wrapped token account $wrapped_account" + # Do lock transactions while : ; do # Uncomment for simulated debugging transactions