Fixed EIP-1559 from address calculation bug (#1610).
This commit is contained in:
parent
2a7ce0e72a
commit
319987ec3e
@ -71,7 +71,7 @@ interface _Block {
|
|||||||
miner: string;
|
miner: string;
|
||||||
extraData: string;
|
extraData: string;
|
||||||
|
|
||||||
baseFee?: null | BigNumber;
|
baseFeePerGas?: null | BigNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Block extends _Block {
|
export interface Block extends _Block {
|
||||||
@ -238,12 +238,12 @@ export abstract class Provider implements OnceBlockable {
|
|||||||
|
|
||||||
let maxFeePerGas = null, maxPriorityFeePerGas = null;
|
let maxFeePerGas = null, maxPriorityFeePerGas = null;
|
||||||
|
|
||||||
if (block && block.baseFee) {
|
if (block && block.baseFeePerGas) {
|
||||||
// We may want to compute this more accurately in the future,
|
// We may want to compute this more accurately in the future,
|
||||||
// using the formula "check if the base fee is correct".
|
// using the formula "check if the base fee is correct".
|
||||||
// See: https://eips.ethereum.org/EIPS/eip-1559
|
// See: https://eips.ethereum.org/EIPS/eip-1559
|
||||||
maxPriorityFeePerGas = BigNumber.from("1000000000");
|
maxPriorityFeePerGas = BigNumber.from("1000000000");
|
||||||
maxFeePerGas = block.baseFee.mul(2).add(maxPriorityFeePerGas);
|
maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice };
|
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice };
|
||||||
|
@ -145,7 +145,7 @@ export class Formatter {
|
|||||||
|
|
||||||
transactions: Formatter.allowNull(Formatter.arrayOf(hash)),
|
transactions: Formatter.allowNull(Formatter.arrayOf(hash)),
|
||||||
|
|
||||||
baseFee: Formatter.allowNull(bigNumber)
|
baseFeePerGas: Formatter.allowNull(bigNumber)
|
||||||
};
|
};
|
||||||
|
|
||||||
formats.blockWithTransactions = shallowCopy(formats.block);
|
formats.blockWithTransactions = shallowCopy(formats.block);
|
||||||
|
@ -362,7 +362,7 @@ function _parseEip1559(payload: Uint8Array): Transaction {
|
|||||||
nonce: handleNumber(transaction[1]).toNumber(),
|
nonce: handleNumber(transaction[1]).toNumber(),
|
||||||
maxPriorityFeePerGas: maxPriorityFeePerGas,
|
maxPriorityFeePerGas: maxPriorityFeePerGas,
|
||||||
maxFeePerGas: maxFeePerGas,
|
maxFeePerGas: maxFeePerGas,
|
||||||
gasPrice: maxPriorityFeePerGas.add(maxFeePerGas),
|
gasPrice: maxFeePerGas,
|
||||||
gasLimit: handleNumber(transaction[4]),
|
gasLimit: handleNumber(transaction[4]),
|
||||||
to: handleAddress(transaction[5]),
|
to: handleAddress(transaction[5]),
|
||||||
value: handleNumber(transaction[6]),
|
value: handleNumber(transaction[6]),
|
||||||
@ -375,7 +375,7 @@ function _parseEip1559(payload: Uint8Array): Transaction {
|
|||||||
|
|
||||||
tx.hash = keccak256(payload);
|
tx.hash = keccak256(payload);
|
||||||
|
|
||||||
_parseEipSignature(tx, transaction.slice(9), _serializeEip2930);
|
_parseEipSignature(tx, transaction.slice(9), _serializeEip1559);
|
||||||
|
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user