-
Notifications
You must be signed in to change notification settings - Fork 10
/
erc20tk2werc20tk-lock.js
37 lines (26 loc) · 1.49 KB
/
erc20tk2werc20tk-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 { e20InboundInput } = 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(e20InboundInput.tokenAddr, 'ETH');
dstChain = global.crossInvoker.getSrcChainNameByContractAddr('WAN', 'WAN');
storemanList = (await ccUtil.getSmgList('ETH')).sort((a, b) => b.inboundQuota - a.inboundQuota);
e20InboundInput.lockInput.txFeeRatio = (await global.crossInvoker.getStoremanGroupList(srcChain, dstChain))[0].txFeeRatio;
e20InboundInput.lockInput.storeman = (await ccUtil.syncTokenStoremanGroups('ETH', e20InboundInput.tokenAddr))[0].smgOrigAddr;
e20InboundInput.lockInput.decimals = (await ccUtil.getTokenInfo(e20InboundInput.tokenAddr, 'ETH')).decimals;
console.log('Starting ERC20 inbound lock', e20InboundInput.lockInput);
// Invoke the lock transaction on Ethereum
retLock = await global.crossInvoker.invoke(srcChain, dstChain, 'LOCK', e20InboundInput.lockInput);
console.log(`The ERC20 Lock Hash is ${retLock.result}`);
process.exit(0);
}
main();