From d329cd56f2e11f097d63b9dbe829086f995e9a7d Mon Sep 17 00:00:00 2001 From: Serhii Date: Sun, 4 Feb 2024 21:17:12 +0200 Subject: [PATCH] resolve evm related merge conflicts --- cw_evm/lib/evm_chain_client.dart | 9 +++++++++ cw_evm/lib/evm_chain_wallet.dart | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/cw_evm/lib/evm_chain_client.dart b/cw_evm/lib/evm_chain_client.dart index de5b3874a..5e84ec796 100644 --- a/cw_evm/lib/evm_chain_client.dart +++ b/cw_evm/lib/evm_chain_client.dart @@ -14,6 +14,7 @@ import 'package:flutter/services.dart'; import 'package:http/http.dart'; import 'package:erc20/erc20.dart'; import 'package:web3dart/web3dart.dart'; +import 'package:hex/hex.dart' as hex; abstract class EVMChainClient { final httpClient = Client(); @@ -85,6 +86,7 @@ abstract class EVMChainClient { required CryptoCurrency currency, required int exponent, String? contractAddress, + String? data, }) async { assert(currency == CryptoCurrency.eth || currency == CryptoCurrency.maticpoly || @@ -100,6 +102,7 @@ abstract class EVMChainClient { to: EthereumAddress.fromHex(toAddress), maxPriorityFeePerGas: EtherAmount.fromInt(EtherUnit.gwei, priority.tip), amount: isEVMCompatibleChain ? EtherAmount.inWei(BigInt.parse(amount)) : EtherAmount.zero(), + data: data != null ? hexToBytes(data) : null, ); final signedTransaction = @@ -140,12 +143,14 @@ abstract class EVMChainClient { required EthereumAddress to, required EtherAmount amount, EtherAmount? maxPriorityFeePerGas, + Uint8List? data, }) { return Transaction( from: from, to: to, maxPriorityFeePerGas: maxPriorityFeePerGas, value: amount, + data: data, ); } @@ -222,6 +227,10 @@ abstract class EVMChainClient { } } + Uint8List hexToBytes(String hexString) { + return Uint8List.fromList(hex.HEX.decode(hexString.startsWith('0x') ? hexString.substring(2) : hexString)); + } + void stop() { _client?.dispose(); } diff --git a/cw_evm/lib/evm_chain_wallet.dart b/cw_evm/lib/evm_chain_wallet.dart index ea19a8557..e553cf478 100644 --- a/cw_evm/lib/evm_chain_wallet.dart +++ b/cw_evm/lib/evm_chain_wallet.dart @@ -224,6 +224,13 @@ abstract class EVMChainWalletBase final outputs = _credentials.outputs; final hasMultiDestination = outputs.length > 1; + final String? opReturnMemo = outputs.first.memo; + + String? hexOpReturnMemo; + if (opReturnMemo != null) { + hexOpReturnMemo = '0x${opReturnMemo.codeUnits.map((char) => char.toRadixString(16).padLeft(2, '0')).join()}'; + } + final CryptoCurrency transactionCurrency = balance.keys.firstWhere((element) => element.title == _credentials.currency.title); @@ -279,6 +286,7 @@ abstract class EVMChainWalletBase exponent: exponent, contractAddress: transactionCurrency is Erc20Token ? transactionCurrency.contractAddress : null, + data: hexOpReturnMemo, ); return pendingEVMChainTransaction;