Skip to content

Commit

Permalink
Evm tx (#7)
Browse files Browse the repository at this point in the history
* implement a raw evm transaction

* add check for the length of the decoded Uint8list

* fix dart analyze

* refactor function signature

* add hex prefix to address

* fix test result

---------

Co-authored-by: dev2-nomo <dev2@nomo.app>
  • Loading branch information
nomo-app and dev2-nomo authored Nov 22, 2023
1 parent 0a6af0b commit e91c274
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/src/crypto/evm/function_signature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FunctionSignature {
final sublist = data.sublist(offset, offset + 32).toHex;

final arg = switch (value) {
"address" => sublist.substring(24),
"address" => "0x" + sublist.substring(24),
"uint256" => sublist.toBigIntFromHex,
"uint256[]" => () {
final field_length = data
Expand Down Expand Up @@ -113,7 +113,7 @@ class FunctionSignature {

if (contractFunction == null) {
return FunctionSignature(
"function not found",
"unknown",
null,
decodeDataValues(data, {}),
);
Expand Down
9 changes: 6 additions & 3 deletions lib/src/domain/entities/transactions/evm_transaction.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:typed_data';

import 'package:hive/hive.dart';
import 'package:walletkit_dart/walletkit_dart.dart';

Expand Down Expand Up @@ -111,9 +110,13 @@ abstract base class EVMTransaction extends GenericTransaction {
required this.input,
});

FunctionSignature get getFunctionSignature {
FunctionSignature? get getFunctionSignature {
if (!_cachedFunctionSigs.containsKey(hash)) {
_cachedFunctionSigs[hash] = FunctionSignature.fromData(input);
try {
_cachedFunctionSigs[hash] = FunctionSignature.fromData(input);
} catch (e) {
return null;
}
}
return _cachedFunctionSigs[hash]!;
}
Expand Down
2 changes: 1 addition & 1 deletion test/ci/parsing/reverse-hash-computation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main() {
});

expect(functionSignature.args?[0].value,
"05870f1507d820212e921e1f39f14660336231d1");
"0x05870f1507d820212e921e1f39f14660336231d1");
expect(functionSignature.args?[1].value, BigInt.from(15942468));
});

Expand Down

0 comments on commit e91c274

Please sign in to comment.