diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/subproviders/src/subproviders/nonce_tracker.ts | 9 | ||||
-rw-r--r-- | packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts index 4b5c34f69..6c1d54882 100644 --- a/packages/subproviders/src/subproviders/nonce_tracker.ts +++ b/packages/subproviders/src/subproviders/nonce_tracker.ts @@ -13,9 +13,9 @@ import { OptionalNextCallback, } from '../types'; - import { Subprovider } from './subprovider'; +// We do not export this since this is not our error, and we do not throw this error const NONCE_TOO_LOW_ERROR_MESSAGE = 'Transaction nonce is too low'; export class NonceTrackerSubprovider extends Subprovider { private _nonceCache: { [address: string]: string } = {}; @@ -36,7 +36,8 @@ export class NonceTrackerSubprovider extends Subprovider { return address; case 'eth_sendRawTransaction': const transaction = NonceTrackerSubprovider._reconstructTransaction(payload); - address = `0x${transaction.getSenderAddress().toString('hex')}`.toLowerCase(); + const addressRaw = transaction.getSenderAddress().toString('hex').toLowerCase(); + address = `0x${addressRaw}`; return address; default: throw new Error(NonceSubproviderErrors.CannotDetermineAddressFromPayload); @@ -87,8 +88,8 @@ export class NonceTrackerSubprovider extends Subprovider { if (nextHexNonce.length % 2) { nextHexNonce = `0${nextHexNonce}`; } - nextHexNonce = `0x${nextHexNonce}`; - this._nonceCache[address] = nextHexNonce; + const nextPrefixedHexNonce = `0x${nextHexNonce}`; + this._nonceCache[address] = nextPrefixedHexNonce; } private _handleSendTransactionError(payload: JSONRPCPayload, err: Error): void { const address = NonceTrackerSubprovider._determineAddress(payload); diff --git a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts index 738b8bc95..e98d9023c 100644 --- a/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts +++ b/packages/subproviders/test/unit/nonce_tracker_subprovider_test.ts @@ -38,13 +38,13 @@ describe('NonceTrackerSubprovider', () => { '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13', ]; function createFixtureSubprovider() { - let firstGetTransactionCount = true; + let isFirstGetTransactionCount = true; const fixedBlockNumberAndTransactionCountProvider = new FixtureSubprovider({ eth_getBlockByNumber: '0x01', eth_getTransactionCount: (data: any, next: any, end: any) => { // For testing caching we return different results on the second call - if (firstGetTransactionCount) { - firstGetTransactionCount = false; + if (isFirstGetTransactionCount) { + isFirstGetTransactionCount = false; end(null, '0x00'); } else { end(null, '0x99'); |