Skip to content

Commit 319987e

Browse files
committed
Fixed EIP-1559 from address calculation bug (#1610).
1 parent 2a7ce0e commit 319987e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/abstract-provider/src.ts/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ interface _Block {
7171
miner: string;
7272
extraData: string;
7373

74-
baseFee?: null | BigNumber;
74+
baseFeePerGas?: null | BigNumber;
7575
}
7676

7777
export interface Block extends _Block {
@@ -238,12 +238,12 @@ export abstract class Provider implements OnceBlockable {
238238

239239
let maxFeePerGas = null, maxPriorityFeePerGas = null;
240240

241-
if (block && block.baseFee) {
241+
if (block && block.baseFeePerGas) {
242242
// We may want to compute this more accurately in the future,
243243
// using the formula "check if the base fee is correct".
244244
// See: https://eips.ethereum.org/EIPS/eip-1559
245245
maxPriorityFeePerGas = BigNumber.from("1000000000");
246-
maxFeePerGas = block.baseFee.mul(2).add(maxPriorityFeePerGas);
246+
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
247247
}
248248

249249
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice };

packages/providers/src.ts/formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class Formatter {
145145

146146
transactions: Formatter.allowNull(Formatter.arrayOf(hash)),
147147

148-
baseFee: Formatter.allowNull(bigNumber)
148+
baseFeePerGas: Formatter.allowNull(bigNumber)
149149
};
150150

151151
formats.blockWithTransactions = shallowCopy(formats.block);

packages/transactions/src.ts/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ function _parseEip1559(payload: Uint8Array): Transaction {
362362
nonce: handleNumber(transaction[1]).toNumber(),
363363
maxPriorityFeePerGas: maxPriorityFeePerGas,
364364
maxFeePerGas: maxFeePerGas,
365-
gasPrice: maxPriorityFeePerGas.add(maxFeePerGas),
365+
gasPrice: maxFeePerGas,
366366
gasLimit: handleNumber(transaction[4]),
367367
to: handleAddress(transaction[5]),
368368
value: handleNumber(transaction[6]),
@@ -375,7 +375,7 @@ function _parseEip1559(payload: Uint8Array): Transaction {
375375

376376
tx.hash = keccak256(payload);
377377

378-
_parseEipSignature(tx, transaction.slice(9), _serializeEip2930);
378+
_parseEipSignature(tx, transaction.slice(9), _serializeEip1559);
379379

380380
return tx;
381381
}

0 commit comments

Comments
 (0)