Skip to content

Commit 38f2691

Browse files
authored
updated lastNonce to be -1 if a new chain write op is detected (#94)
1 parent f57afd2 commit 38f2691

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

server/helpers/dbOperations.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import { Knex } from "knex";
1+
import { Static } from "@sinclair/typebox";
22
import { getChainByChainId, getChainBySlug } from "@thirdweb-dev/chains";
3-
import { createCustomError } from "../../core/error/customError";
4-
import { StatusCodes } from "http-status-codes";
5-
import { v4 as uuid } from "uuid";
6-
import { connectWithDatabase, getSDK } from "../../core";
7-
import { FastifyRequest } from "fastify";
83
import {
9-
ChainId,
104
DeployTransaction,
115
Transaction,
126
TransactionError,
137
} from "@thirdweb-dev/sdk";
8+
import { BigNumber } from "ethers";
9+
import { FastifyRequest } from "fastify";
10+
import { StatusCodes } from "http-status-codes";
11+
import { Knex } from "knex";
12+
import { v4 as uuid } from "uuid";
13+
import { connectWithDatabase, getSDK } from "../../core";
14+
import { insertIntoWallets } from "../../core/database/dbOperation";
15+
import { createCustomError } from "../../core/error/customError";
16+
import { WalletData } from "../../core/interfaces";
17+
import { getWalletNonce } from "../../core/services/blockchain";
1418
import {
15-
TransactionStatusEnum,
1619
TransactionSchema,
20+
TransactionStatusEnum,
1721
transactionResponseSchema,
1822
} from "../schemas/transaction";
19-
import { Static } from "@sinclair/typebox";
20-
import { WalletData } from "../../core/interfaces";
21-
import { getWalletNonce } from "../../core/services/blockchain";
22-
import { BigNumber } from "ethers";
23-
import { insertIntoWallets } from "../../core/database/dbOperation";
2423

2524
const checkNetworkInWalletDB = async (
2625
database: Knex,
@@ -92,7 +91,7 @@ export const queueTransaction = async (
9291
chainId: chainId.toLowerCase(),
9392
blockchainNonce: BigNumber.from(walletNonce ?? 0).toNumber(),
9493
lastSyncedTimestamp: new Date(),
95-
lastUsedNonce: 0,
94+
lastUsedNonce: -1,
9695
walletType: chainData.slug,
9796
};
9897

0 commit comments

Comments
 (0)