Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ctFlutterV2 into chores/wallet_sample_enhancements
  • Loading branch information
quetool committed Apr 9, 2024
2 parents d00f18c + 133febc commit 971145e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/apis/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,21 @@ extension TransactionExtension2 on Map<String, dynamic> {
(this['maxPriorityFeePerGas'] as String?).toEthereAmount(),
maxGas: (this['maxGas'] as String?).toIntFromHex(),
nonce: (this['nonce'] as String?).toInt(),
data: (this['data'] != null && this['data'] != '0x')
? Uint8List.fromList(hex.decode(this['data']!))
: null,
data: _parseTransactionData(this['data']),
);
}
}

Uint8List? _parseTransactionData(dynamic data) {
if (data != null && data != '0x') {
if (data.startsWith('0x')) {
return Uint8List.fromList(hex.decode(data.substring(2)));
}
return Uint8List.fromList(hex.decode(data));
}
return null;
}

extension EtheraAmountExtension on String? {
EtherAmount? toEthereAmount() {
if (this != null) {
Expand Down

0 comments on commit 971145e

Please sign in to comment.