File tree Expand file tree Collapse file tree 4 files changed +44
-16
lines changed
test/unit/transactionBuilder Expand file tree Collapse file tree 4 files changed +44
-16
lines changed Original file line number Diff line number Diff line change @@ -4,25 +4,23 @@ import EthereumCommon from '@ethereumjs/common';
44/**
55 * A Common object defining the chain and the hardfork for CELO Testnet
66 */
7- export const testnetCommon = EthereumCommon . forCustomChain (
8- 'mainnet' , // It's a test net based on the main ethereum net
7+ export const testnetCommon = EthereumCommon . custom (
98 {
109 name : 'alfajores' ,
1110 networkId : ( coins . get ( 'tcelo' ) . network as EthereumNetwork ) . chainId ,
1211 chainId : ( coins . get ( 'tcelo' ) . network as EthereumNetwork ) . chainId ,
1312 } ,
14- 'petersburg'
13+ { hardfork : 'london' }
1514) ;
1615
1716/**
1817 * A Common object defining the chain and the hardfork for CELO Mainnet
1918 */
20- export const mainnetCommon = EthereumCommon . forCustomChain (
21- 'mainnet' ,
19+ export const mainnetCommon = EthereumCommon . custom (
2220 {
2321 name : 'rc1' ,
2422 networkId : ( coins . get ( 'celo' ) . network as EthereumNetwork ) . chainId ,
2523 chainId : ( coins . get ( 'celo' ) . network as EthereumNetwork ) . chainId ,
2624 } ,
27- 'petersburg'
25+ { hardfork : 'london' }
2826) ;
Original file line number Diff line number Diff line change 11import { BaseCoin as CoinConfig } from '@bitgo/statics' ;
22import EthereumCommon from '@ethereumjs/common' ;
3- import { Transaction as EthTransaction , LegacyTxData } from '@bitgo/sdk-coin-eth' ;
4- import { CeloTransactionData } from './types' ;
3+ import { Transaction as EthTransaction } from '@bitgo/sdk-coin-eth' ;
4+ // import { CeloTransactionData } from './types';
55import * as Utils from './utils' ;
66
77export class Transaction extends EthTransaction {
8- setTransactionData ( txData : LegacyTxData ) : void {
9- this . _transactionData = CeloTransactionData . fromJson ( txData ) ;
10- this . updateFields ( ) ;
11- }
8+ // setTransactionData(txData: LegacyTxData): void {
9+ // this._transactionData = CeloTransactionData.fromJson(txData);
10+ // this.updateFields();
11+ // }
1212
1313 /** @inheritdoc */
1414 public static fromSerialized (
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { StakingBuilder } from './stakingBuilder';
77import { StakingCall } from './stakingCall' ;
88import { getCommon , walletSimpleByteCode } from './utils' ;
99import { TransferBuilder } from './transferBuilder' ;
10- import { addHexPrefix } from 'ethereumjs-util' ;
10+ // import { addHexPrefix } from 'ethereumjs-util';
1111import BigNumber from 'bignumber.js' ;
1212
1313export class TransactionBuilder extends EthTransactionBuilder {
@@ -228,9 +228,9 @@ export class TransactionBuilder extends EthTransactionBuilder {
228228 *
229229 * @protected for internal use when the enableFinalVField flag is true.
230230 */
231- protected getFinalV ( ) : string {
232- return addHexPrefix ( this . _common . chainIdBN ( ) . toString ( 16 ) ) ;
233- }
231+ // protected getFinalV(): string {
232+ // return addHexPrefix(this._common.chainIdBN().toString(16));
233+ // }
234234
235235 /**
236236 * The value to send along with this transaction. 0 by default
Original file line number Diff line number Diff line change @@ -167,6 +167,36 @@ describe('Send transaction', function () {
167167 should . equal ( txJson . from , undefined ) ;
168168 } ) ;
169169
170+ it ( 'should build txn with eip1559' , async function ( ) {
171+ const txBuilder = getBuilder ( 'tcelo' ) as TransactionBuilder ;
172+ txBuilder . fee ( {
173+ fee : '1000000000' ,
174+ gasLimit : '12100000' ,
175+ eip1559 : {
176+ maxFeePerGas : '7593123' ,
177+ maxPriorityFeePerGas : '150' ,
178+ } ,
179+ } ) ;
180+ txBuilder . counter ( 2 ) ;
181+ txBuilder . type ( TransactionType . Send ) ;
182+ txBuilder . contract ( '0x8f977e912ef500548a0c3be6ddde9899f1199b81' ) ;
183+ txBuilder
184+ . transfer ( )
185+ . coin ( 'tcusd' )
186+ . amount ( '1000000000' )
187+ . to ( '0x19645032c7f1533395d44a629462e751084d3e4c' )
188+ . expirationTime ( 1590066728 )
189+ . contractSequenceId ( 5 )
190+ . key ( key ) ;
191+ txBuilder . sign ( { key : testData . PRIVATE_KEY } ) ;
192+ const tx = await txBuilder . build ( ) ;
193+ const txJson = tx . toJson ( ) ;
194+ should . equal ( txJson . gasLimit , '12100000' ) ;
195+ should . equal ( txJson . _type , 'EIP1559' ) ;
196+ should . equal ( txJson . maxFeePerGas , '7593123' ) ;
197+ should . equal ( txJson . maxPriorityFeePerGas , '150' ) ;
198+ } ) ;
199+
170200 it ( 'a send token transaction without final v' , async ( ) => {
171201 const recipient = '0x19645032c7f1533395d44a629462e751084d3e4c' ;
172202 const contractAddress = '0x8f977e912ef500548a0c3be6ddde9899f1199b81' ;
You can’t perform that action at this time.
0 commit comments