const { amount, account, currency, routerAddress, routerEthAddress, target, loading, onSuccess, onError, quote, } = props; if (!loading) return ""; const { getExtraData, } = VM.require('bluebiu.near/widget/Blast.BridgeAuthority.Util'); const L1BlastBridgeProxyAbi = [ { "inputs": [ { "internalType": "address", "name": "_localToken", "type": "address" }, { "internalType": "address", "name": "_remoteToken", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }, { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, { "internalType": "bytes", "name": "_extraData", "type": "bytes" } ], "name": "bridgeERC20", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ] const L2BlastBridgeAbi = [ { "inputs": [ { "internalType": "address", "name": "_localToken", "type": "address" }, { "internalType": "address", "name": "_remoteToken", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }, { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, { "internalType": "bytes", "name": "_extraData", "type": "bytes" } ], "name": "bridgeERC20", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ] const signer = Ethers.provider().getSigner() const rawAmount = new Big(amount).mul(Math.pow(10, currency.decimals)).toString() if (target.id === 81457) { let pRes // const L1BlastBridgeProxy = '0x3a05E5d33d7Ab3864D53aaEc93c8301C1Fa49115' if (currency.isNative) { const params = { from: account, to: routerAddress, value: rawAmount, } pRes = signer.sendTransaction(params).then(tx => { console.log('tx:', tx) // Storage.privateSet(tx.hash, tx); return tx.wait() }) } else { const L1BridgeContract = new ethers.Contract( routerAddress, L1BlastBridgeProxyAbi, signer ) pRes = L1BridgeContract.bridgeERC20( currency.targetAddress, currency.address, rawAmount, 800000, getExtraData(amount), { gasLimit: 800000 } ).then(tx => tx.wait()) } pRes.then(res => { console.log('res: ', res) onSuccess(res); }).catch(err => { console.log('err:', err) onError(err); }) } else { const L2BlastBridge = '0x4300000000000000000000000000000000000005' let pRes let nonce, blockNumber if (currency.isNative) { const params = { from: account, to: L2BlastBridge, value: rawAmount, } pRes = signer.sendTransaction(params).then(tx => { console.log('tx:', tx) nonce = tx.nonce return tx.wait() }) } else { const L2BridgeContract = new ethers.Contract( routerAddress, L2BlastBridgeAbi, signer ) pRes = L2BridgeContract.bridgeERC20( currency.address, '0x6B175474E89094C44Da98b954EedeAC495271d0F', rawAmount, 800000, getExtraData(amount), { gasLimit: 800000 } ).then(tx => tx.wait()) } pRes.then(res => { blockNumber = res.blockNumber console.log('res', res) Storage.privateSet(res.transactionHash, { nonce, blockNumber, }); onSuccess(res); }).catch(err => { onError(err); }) } return "";