Skip to content

Commit

Permalink
Update interface to match patched methods (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebrianchen authored Mar 22, 2022
1 parent 7cb9852 commit 635f1ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -129,6 +128,9 @@ export interface AlchemyEth extends Eth {
item: Log | Syncing | BlockHeader | string | Transaction,
) => void,
): Subscription<Log | BlockHeader | Syncing | string>;
getMaxPriorityFeePerGas(
callback?: (error: Error, fee: string) => void,
): Promise<string>;
}

interface EthereumWindow extends Window {
Expand Down Expand Up @@ -235,7 +237,6 @@ export function createAlchemyWeb3(
};
patchSubscriptions(alchemyWeb3);
patchEnableCustomRPC(alchemyWeb3);
patchEthFeeHistoryMethod(alchemyWeb3);
patchEthMaxPriorityFeePerGasMethod(alchemyWeb3);
return alchemyWeb3;
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/web3-adapter/customRPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
15 changes: 0 additions & 15 deletions src/web3-adapter/eth_feeHistory.ts

This file was deleted.

0 comments on commit 635f1ba

Please sign in to comment.