From 13e72663cb94dee307692316dda09f27184093e0 Mon Sep 17 00:00:00 2001 From: dev2-nomo <147811533+dev2-nomo@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:56:44 +0100 Subject: [PATCH] fix rlp decoding bug (#5) --- lib/src/crypto/evm/function_signature.dart | 2 +- lib/src/crypto/evm/rlp.dart | 3 ++- lib/walletkit_dart.dart | 2 ++ test/ci/parsing/reverse-hash-computation_test.dart | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/crypto/evm/function_signature.dart b/lib/src/crypto/evm/function_signature.dart index b4ff8b9f4..c1e6710e5 100644 --- a/lib/src/crypto/evm/function_signature.dart +++ b/lib/src/crypto/evm/function_signature.dart @@ -113,7 +113,7 @@ class FunctionSignature { if (contractFunction == null) { return FunctionSignature( - "unknown", + "function not found", null, decodeDataValues(data, {}), ); diff --git a/lib/src/crypto/evm/rlp.dart b/lib/src/crypto/evm/rlp.dart index a1ffe8cbe..454ea87b9 100644 --- a/lib/src/crypto/evm/rlp.dart +++ b/lib/src/crypto/evm/rlp.dart @@ -134,7 +134,8 @@ Transaction getTransactionFromMessageHash(String messageHex) { BigInt gasPrice = parseAsHexBigInt(en.result[1]); BigInt gasLimit = parseAsHexBigInt(en.result[2]); String evmAddress = en.result[3]; - BigInt value = parseAsHexBigInt(en.result[4]); + + BigInt value = parseAsHexBigInt(en.result[4] == "" ? "0x0" : en.result[4]); final Uint8List data = Uint8List.fromList(hex.decode(en.result[5])); return Transaction( diff --git a/lib/walletkit_dart.dart b/lib/walletkit_dart.dart index a6ad712b8..211af8dd8 100644 --- a/lib/walletkit_dart.dart +++ b/lib/walletkit_dart.dart @@ -52,3 +52,5 @@ export 'src/domain/entities/hd_wallet_type.dart'; export 'src/domain/entities/address_type.dart'; export 'src/crypto/evm/rlp.dart'; + +export 'src/crypto/evm/function_signature.dart'; diff --git a/test/ci/parsing/reverse-hash-computation_test.dart b/test/ci/parsing/reverse-hash-computation_test.dart index 7c13fbde8..2e7bf6496 100644 --- a/test/ci/parsing/reverse-hash-computation_test.dart +++ b/test/ci/parsing/reverse-hash-computation_test.dart @@ -1,7 +1,6 @@ import 'dart:typed_data'; import 'package:convert/convert.dart'; import 'package:test/test.dart'; -import 'package:walletkit_dart/src/crypto/evm/function_signature.dart'; import 'package:walletkit_dart/walletkit_dart.dart'; void main() {