-
Notifications
You must be signed in to change notification settings - Fork 10
/
eth2weth-lock.js
37 lines (26 loc) · 1.36 KB
/
eth2weth-lock.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
global.wanchain_js_testnet = true;// define testnet or mainnet
let ccUtil = require("wanchain-js-sdk").ccUtil;
let WalletCore = require("wanchain-js-sdk").walletCore;
const {config, SLEEPTIME} = require('./conf/config');
const { ethInboundInput } = require('./conf/input');
/**
* Requirements:
* - Ethereum account has enough to cover the value defined in `ethInboundInput` plus gas
*/
async function main(){
walletCore = new WalletCore(config);
await walletCore.init();
console.log('Starting init walletCore');
srcChain = global.crossInvoker.getSrcChainNameByContractAddr('ETH', 'ETH');
dstChain = global.crossInvoker.getSrcChainNameByContractAddr('WAN', 'WAN');
// checking available storeman groups which serve ETH coin transaction
storemanList = (await ccUtil.getSmgList('ETH')).sort((a, b) => b.inboundQuota - a.inboundQuota);
ethInboundInput.lockInput.txFeeRatio = storemanList[0].txFeeRatio;
ethInboundInput.lockInput.storeman = storemanList[0].ethAddress;
console.log('Starting eth inbound lock', ethInboundInput.lockInput);
// Invoke the lock transaction on Ethereum
retLock = await global.crossInvoker.invoke(srcChain, dstChain, 'LOCK', ethInboundInput.lockInput);
console.log(`The Lock Hash is ${retLock.result}`);
process.exit(0);
}
main();