-
Notifications
You must be signed in to change notification settings - Fork 10
/
werc20tk2erc20tk-lock.js
36 lines (26 loc) · 1.5 KB
/
werc20tk2erc20tk-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
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 { e20OutboundInput } = 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('WAN', 'WAN');
dstChain = global.crossInvoker.getSrcChainNameByContractAddr(e20OutboundInput.tokenAddr, 'ETH');
e20OutboundInput.coin2WanRatio = await ccUtil.getToken2WanRatio(e20OutboundInput.tokenAddr);
e20OutboundInput.lockInput.txFeeRatio = (await global.crossInvoker.getStoremanGroupList(srcChain, dstChain))[0].txFeeRatio;
e20OutboundInput.lockInput.storeman = (await ccUtil.syncTokenStoremanGroups('ETH', e20OutboundInput.tokenAddr))[0].smgWanAddr;
e20OutboundInput.lockInput.decimals = (await ccUtil.getTokenInfo(e20OutboundInput.tokenAddr, 'ETH')).decimals;
console.log('Starting eth outbound lock', e20OutboundInput.lockInput);
// Invoke the lock transaction on wanchain
retLock = await global.crossInvoker.invoke(srcChain, dstChain, 'LOCK', e20OutboundInput.lockInput);
console.log(`The Lock Hash is ${retLock.result}`);
process.exit(0);
}
main();