diff --git a/src/index.ts b/src/index.ts index 0e55934..dbbde58 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,7 +32,6 @@ import { JsonRpcSenders } from "./util/jsonRpc"; import { callWhenDone } from "./util/promises"; import { makeAlchemyContext } from "./web3-adapter/alchemyContext"; import { patchEnableCustomRPC } from "./web3-adapter/customRPC"; -import { patchEthFeeHistoryMethod } from "./web3-adapter/eth_feeHistory"; import { patchEthMaxPriorityFeePerGasMethod } from "./web3-adapter/eth_maxPriorityFeePerGas"; import { RestPayloadSender } from "./web3-adapter/sendRestPayload"; @@ -129,6 +128,9 @@ export interface AlchemyEth extends Eth { item: Log | Syncing | BlockHeader | string | Transaction, ) => void, ): Subscription; + getMaxPriorityFeePerGas( + callback?: (error: Error, fee: string) => void, + ): Promise; } interface EthereumWindow extends Window { @@ -235,7 +237,6 @@ export function createAlchemyWeb3( }; patchSubscriptions(alchemyWeb3); patchEnableCustomRPC(alchemyWeb3); - patchEthFeeHistoryMethod(alchemyWeb3); patchEthMaxPriorityFeePerGasMethod(alchemyWeb3); return alchemyWeb3; } @@ -317,7 +318,9 @@ function processTokenBalanceResponse( /** * Updates Web3's internal subscription architecture to also handle Alchemy - * specific subscriptions. + * specific subscriptions. This is to handle alternate namings of the existing + * subscription endpoints, but the officially documented interfaces are + * specified in the AlchemyEth interface. */ function patchSubscriptions(web3: Web3): void { const { eth } = web3; diff --git a/src/web3-adapter/customRPC.ts b/src/web3-adapter/customRPC.ts index a917a50..d07c407 100644 --- a/src/web3-adapter/customRPC.ts +++ b/src/web3-adapter/customRPC.ts @@ -10,6 +10,10 @@ interface PatchParams { const MethodFn: any = Method; +/** + * Private method to enable adding custom RPC calls to the web3 object. This + * allows the addition of custom endpoints to the web3 object. + */ export function patchEnableCustomRPC(web3: any): void { web3.eth.customRPC = function (opts: PatchParams) { const newMethod = new MethodFn({ diff --git a/src/web3-adapter/eth_feeHistory.ts b/src/web3-adapter/eth_feeHistory.ts deleted file mode 100644 index 85cfefe..0000000 --- a/src/web3-adapter/eth_feeHistory.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { formatters } from "web3-core-helpers"; -import { toNumber } from "web3-utils"; - -export function patchEthFeeHistoryMethod(web3: any): void { - web3.eth.customRPC({ - name: "getFeeHistory", - call: "eth_feeHistory", - params: 3, - inputFormatter: [ - toNumber, - formatters.inputBlockNumberFormatter, - (value: any) => value, - ], - }); -}