resolve evm related merge conflicts

This commit is contained in:
Serhii 2024-02-04 21:17:12 +02:00
parent 5ac5f7ef00
commit d329cd56f2
2 changed files with 17 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import 'package:flutter/services.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:erc20/erc20.dart'; import 'package:erc20/erc20.dart';
import 'package:web3dart/web3dart.dart'; import 'package:web3dart/web3dart.dart';
import 'package:hex/hex.dart' as hex;
abstract class EVMChainClient { abstract class EVMChainClient {
final httpClient = Client(); final httpClient = Client();
@ -85,6 +86,7 @@ abstract class EVMChainClient {
required CryptoCurrency currency, required CryptoCurrency currency,
required int exponent, required int exponent,
String? contractAddress, String? contractAddress,
String? data,
}) async { }) async {
assert(currency == CryptoCurrency.eth || assert(currency == CryptoCurrency.eth ||
currency == CryptoCurrency.maticpoly || currency == CryptoCurrency.maticpoly ||
@ -100,6 +102,7 @@ abstract class EVMChainClient {
to: EthereumAddress.fromHex(toAddress), to: EthereumAddress.fromHex(toAddress),
maxPriorityFeePerGas: EtherAmount.fromInt(EtherUnit.gwei, priority.tip), maxPriorityFeePerGas: EtherAmount.fromInt(EtherUnit.gwei, priority.tip),
amount: isEVMCompatibleChain ? EtherAmount.inWei(BigInt.parse(amount)) : EtherAmount.zero(), amount: isEVMCompatibleChain ? EtherAmount.inWei(BigInt.parse(amount)) : EtherAmount.zero(),
data: data != null ? hexToBytes(data) : null,
); );
final signedTransaction = final signedTransaction =
@ -140,12 +143,14 @@ abstract class EVMChainClient {
required EthereumAddress to, required EthereumAddress to,
required EtherAmount amount, required EtherAmount amount,
EtherAmount? maxPriorityFeePerGas, EtherAmount? maxPriorityFeePerGas,
Uint8List? data,
}) { }) {
return Transaction( return Transaction(
from: from, from: from,
to: to, to: to,
maxPriorityFeePerGas: maxPriorityFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas,
value: amount, 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() { void stop() {
_client?.dispose(); _client?.dispose();
} }

View file

@ -224,6 +224,13 @@ abstract class EVMChainWalletBase
final outputs = _credentials.outputs; final outputs = _credentials.outputs;
final hasMultiDestination = outputs.length > 1; 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 = final CryptoCurrency transactionCurrency =
balance.keys.firstWhere((element) => element.title == _credentials.currency.title); balance.keys.firstWhere((element) => element.title == _credentials.currency.title);
@ -279,6 +286,7 @@ abstract class EVMChainWalletBase
exponent: exponent, exponent: exponent,
contractAddress: contractAddress:
transactionCurrency is Erc20Token ? transactionCurrency.contractAddress : null, transactionCurrency is Erc20Token ? transactionCurrency.contractAddress : null,
data: hexOpReturnMemo,
); );
return pendingEVMChainTransaction; return pendingEVMChainTransaction;