Skip to content

Commit

Permalink
Update account.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Nov 7, 2024
1 parent 9b1cf6c commit 11e538f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import { createViemClient, getDataFetcher } from "./config";
import { ChainId, LiquidityProviders, RPParams } from "sushi";
import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts";
import { erc20Abi, multicall3Abi, orderbookAbi, routeProcessor3Abi } from "./abis";
import { getTransactionCount } from "viem/_types/actions/public/getTransactionCount";
import { context, Context, SpanStatusCode, trace, Tracer } from "@opentelemetry/api";
import { BotConfig, CliOptions, ViemClient, TokenDetails, OwnedOrder } from "./types";
import { createNonceManager, NonceManagerSource, parseAbi, PublicClient } from "viem";
import {
parseAbi,
hexToNumber,
numberToHex,
PublicClient,
createNonceManager,
NonceManagerSource,
} from "viem";

/** Standard base path for eth accounts */
export const BasePath = "m/44'/60'/0'/0/" as const;
Expand Down Expand Up @@ -1100,3 +1106,20 @@ export function noneSource(): NonceManagerSource {
set() {},
};
}

/**
* Perfomrs a eth_getTransactionCount rpc request
*/
async function getTransactionCount(
client: any,
{ address, blockTag = "latest", blockNumber }: any,
): Promise<number> {
const count = await client.request(
{
method: "eth_getTransactionCount",
params: [address, blockNumber ? numberToHex(blockNumber) : blockTag],
},
{ dedupe: Boolean(blockNumber) },
);
return hexToNumber(count);
}

0 comments on commit 11e538f

Please sign in to comment.