Fix eth transaction hash for Thorchain Integration

This commit is contained in:
Serhii 2024-02-16 20:12:24 +02:00
parent 6c72a67b4a
commit 40e6cdf0b3
2 changed files with 11 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import 'dart:typed_data';
import 'package:cw_core/pending_transaction.dart';
import 'package:web3dart/crypto.dart';
import 'package:hex/hex.dart' as Hex;
class PendingEVMChainTransaction with PendingTransaction {
final Function sendTransaction;
@ -38,5 +39,12 @@ class PendingEVMChainTransaction with PendingTransaction {
String get hex => bytesToHex(signedTransaction, include0x: true);
@override
String get id => '';
String get id {
final String eip1559Hex = '0x02${hex.substring(2)}';
final Uint8List bytes = Uint8List.fromList(Hex.HEX.decode(eip1559Hex.substring(2)));
var txid = keccak256(bytes);
return '0x${Hex.HEX.encode(txid)}';
}
}

View file

@ -141,7 +141,8 @@ class ThorChainExchangeProvider extends ExchangeProvider {
@override
Future<Trade> findTradeById({required String id}) async {
if (id.isEmpty) throw Exception('Trade id is empty');
final uri = Uri.parse('$_baseURL$_txInfoPath$id');
final formattedId = id.startsWith('0x') ? id.substring(2) : id;
final uri = Uri.parse('$_baseURL$_txInfoPath$formattedId');
final response = await http.get(uri);
if (response.statusCode == 404) {