dev
dart 45 lines 1.16 KB
Raw
1 import 'package:cw_evm/clients/evm_chain_client.dart';
2 import 'package:flutter/foundation.dart';
3 import 'package:web3dart/web3dart.dart';
4
5 class BaseClient extends EVMChainClient {
6 BaseClient() : super(chainId: 8453);
7
8 @override
9 Transaction createTransaction({
10 required EthereumAddress from,
11 required EthereumAddress to,
12 required EtherAmount amount,
13 EtherAmount? maxPriorityFeePerGas,
14 Uint8List? data,
15 int? maxGas,
16 EtherAmount? gasPrice,
17 EtherAmount? maxFeePerGas,
18 int? nonce,
19 }) {
20 EtherAmount? finalGasPrice = gasPrice;
21
22 if (gasPrice == null && maxFeePerGas != null) {
23 // If we have EIP-1559 parameters but no legacy gasPrice, then use maxFeePerGas as gasPrice
24 finalGasPrice = maxFeePerGas;
25 }
26
27 return Transaction(
28 from: from,
29 to: to,
30 value: amount,
31 data: data,
32 maxGas: maxGas,
33 gasPrice: finalGasPrice,
34 nonce: nonce,
35 // maxFeePerGas: maxFeePerGas,
36 // maxPriorityFeePerGas: maxPriorityFeePerGas,
37 );
38 }
39
40 @override
41 Uint8List prepareSignedTransactionForSending(Uint8List signedTransaction) => signedTransaction;
42
43 @override
44 int get chainId => 8453;
45 }