Skip to content

Commit e6ea0e9

Browse files
feat(sdk-coin-celo): support eip1559 for celo
Ticket: COIN-2046 TICKET: COIN-2046
1 parent f4af4ae commit e6ea0e9

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

modules/sdk-coin-celo/src/lib/resources.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff 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
);

modules/sdk-coin-celo/src/lib/transaction.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { BaseCoin as CoinConfig } from '@bitgo/statics';
22
import 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';
55
import * as Utils from './utils';
66

77
export 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(

modules/sdk-coin-celo/test/unit/transactionBuilder/send.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff 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';

0 commit comments

Comments
 (0)