( network: string, safeAddress: string, tokenAddress: string, receiverAddress: string, amount: string, mnemonic?: string )
| 5 | const { toWei } = Web3.utils; |
| 6 | |
| 7 | export async function bridgeToLayer1( |
| 8 | network: string, |
| 9 | safeAddress: string, |
| 10 | tokenAddress: string, |
| 11 | receiverAddress: string, |
| 12 | amount: string, |
| 13 | mnemonic?: string |
| 14 | ): Promise<void> { |
| 15 | const amountInWei = toWei(amount); |
| 16 | |
| 17 | let web3 = await getWeb3(network, mnemonic); |
| 18 | let tokenBridge = await getSDK('TokenBridgeHomeSide', web3); |
| 19 | let assets = await getSDK('Assets', web3); |
| 20 | let { symbol } = await assets.getTokenInfo(tokenAddress); |
| 21 | receiverAddress = receiverAddress ?? (await web3.eth.getAccounts())[0]; |
| 22 | |
| 23 | let blockExplorer = await getConstant('blockExplorer', web3); |
| 24 | |
| 25 | console.log(`Bridging ${amount} ${symbol} from layer 2 safe ${safeAddress} to layer 1 account ${receiverAddress}...`); |
| 26 | let result = await tokenBridge.relayTokens(safeAddress, tokenAddress, receiverAddress, amountInWei); |
| 27 | console.log(`Approve transaction hash: ${blockExplorer}/tx/${result.transactionHash}`); |
| 28 | } |
| 29 | |
| 30 | export async function awaitBridgedToLayer1( |
| 31 | network: string, |
no test coverage detected