Skip to content

Commit

Permalink
deps: switch from ethjs-query to @ethersproject/providers (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat authored Sep 25, 2023
1 parent 42f0bc2 commit 1537632
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 100 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write"
},
"dependencies": {
"async-mutex": "^0.3.1",
"ethjs-query": "^0.3.8"
"@ethersproject/providers": "^5.7.2",
"async-mutex": "^0.3.1"
},
"devDependencies": {
"@metamask/eslint-config": "^10.0.0",
Expand Down
9 changes: 4 additions & 5 deletions src/NonceTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'assert';
import { Mutex } from 'async-mutex';

// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
const EthQuery = require('ethjs-query');
const { Web3Provider } = require('@ethersproject/providers');
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
const BlockTracker = require('eth-block-tracker');

Expand Down Expand Up @@ -94,7 +94,7 @@ export class NonceTracker {

private blockTracker: typeof BlockTracker;

private ethQuery: typeof EthQuery;
private web3: typeof Web3Provider;

private getPendingTransactions: (address: string) => Transaction[];

Expand All @@ -105,7 +105,7 @@ export class NonceTracker {
constructor(opts: NonceTrackerOptions) {
this.provider = opts.provider;
this.blockTracker = opts.blockTracker;
this.ethQuery = new EthQuery(opts.provider);
this.web3 = new Web3Provider(opts.provider);
this.getPendingTransactions = opts.getPendingTransactions;
this.getConfirmedTransactions = opts.getConfirmedTransactions;
this.lockMap = {};
Expand Down Expand Up @@ -210,11 +210,10 @@ export class NonceTracker {
// we need to make sure our base count
// and pending count are from the same block
const blockNumber: string = await this.blockTracker.getLatestBlock();
const baseCountBN = await this.ethQuery.getTransactionCount(
const baseCount: number = await this.web3.getTransactionCount(
address,
blockNumber,
);
const baseCount: number = baseCountBN.toNumber();
assert(
Number.isInteger(baseCount),
`nonce-tracker - baseCount is not an integer - got: (${typeof baseCount}) "${baseCount}"`,
Expand Down
Loading

0 comments on commit 1537632

Please sign in to comment.