Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
support eip-1559
Browse files Browse the repository at this point in the history
  • Loading branch information
XWJACK committed Oct 9, 2021
1 parent e0c903d commit 852dba3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/hdwallet-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { wordlist } from "ethereum-cryptography/bip39/wordlists/english";
import * as EthUtil from "ethereumjs-util";
import ethJSWallet from "ethereumjs-wallet";
import { hdkey as EthereumHDKey } from "ethereumjs-wallet";
import { Transaction } from "@ethereumjs/tx";
import { Transaction, FeeMarketEIP1559Transaction } from "@ethereumjs/tx";
import Common from "@ethereumjs/common";

// @ts-ignore
Expand Down Expand Up @@ -125,7 +125,7 @@ class HDWalletProvider {
this.hardfork =
chainSettings && chainSettings.hardfork
? chainSettings.hardfork
: "istanbul";
: "london";

const self = this;
this.engine.addProvider(
Expand Down Expand Up @@ -170,7 +170,13 @@ class HDWalletProvider {
)
};
}
const tx = Transaction.fromTxData(txParams, txOptions);

// Taken from https://github.com/ethers-io/ethers.js/blob/2a7ce0e72a1e0c9469e10392b0329e75e341cf18/packages/abstract-signer/src.ts/index.ts#L215
const hasEip1559 = (txParams.maxFeePerGas !== undefined || txParams.maxPriorityFeePerGas !== undefined);
const tx = hasEip1559 ?
FeeMarketEIP1559Transaction.fromTxData(txParams, txOptions) :
Transaction.fromTxData(txParams, txOptions);

const signedTx = tx.sign(pkey as Buffer);
const rawTx = `0x${signedTx.serialize().toString("hex")}`;
cb(null, rawTx);
Expand Down

0 comments on commit 852dba3

Please sign in to comment.