Skip to content

Commit 526a11b

Browse files
authored
fix: allow calling syncRetry on any transaction status (#726)
1 parent 420350f commit 526a11b

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/server/routes/transaction/syncRetry.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import { Static, Type } from "@sinclair/typebox";
2-
import { FastifyInstance } from "fastify";
1+
import { Type, type Static } from "@sinclair/typebox";
2+
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { toSerializableTransaction } from "thirdweb";
55
import { TransactionDB } from "../../../db/transactions/db";
66
import { getAccount } from "../../../utils/account";
77
import { getBlockNumberish } from "../../../utils/block";
88
import { getChain } from "../../../utils/chain";
9-
import { msSince } from "../../../utils/date";
109
import { getChecksumAddress, maybeBigInt } from "../../../utils/primitiveTypes";
1110
import { thirdwebClient } from "../../../utils/sdk";
12-
import { SentTransaction } from "../../../utils/transaction/types";
11+
import type { SentTransaction } from "../../../utils/transaction/types";
1312
import { enqueueTransactionWebhook } from "../../../utils/transaction/webhook";
14-
import { reportUsage } from "../../../utils/usage";
1513
import { MineTransactionQueue } from "../../../worker/queues/mineTransactionQueue";
1614
import { createCustomError } from "../../middleware/error";
1715
import { TransactionHashSchema } from "../../schemas/address";
@@ -71,7 +69,7 @@ export async function syncRetryTransaction(fastify: FastifyInstance) {
7169
"TRANSACTION_NOT_FOUND",
7270
);
7371
}
74-
if (transaction.status !== "sent" || transaction.isUserOp) {
72+
if (transaction.isUserOp || !("nonce" in transaction)) {
7573
throw createCustomError(
7674
"Transaction cannot be retried.",
7775
StatusCodes.BAD_REQUEST,
@@ -103,6 +101,7 @@ export async function syncRetryTransaction(fastify: FastifyInstance) {
103101
// Update state if the send was successful.
104102
const sentTransaction: SentTransaction = {
105103
...transaction,
104+
status: "sent",
106105
resendCount: transaction.resendCount + 1,
107106
sentAt: new Date(),
108107
sentAtBlock: await getBlockNumberish(chainId),
@@ -127,17 +126,3 @@ export async function syncRetryTransaction(fastify: FastifyInstance) {
127126
},
128127
});
129128
}
130-
131-
const _reportUsageSuccess = async (sentTransaction: SentTransaction) => {
132-
const chain = await getChain(sentTransaction.chainId);
133-
reportUsage([
134-
{
135-
action: "send_tx",
136-
input: {
137-
...sentTransaction,
138-
provider: chain.rpc,
139-
msSinceQueue: msSince(sentTransaction.queuedAt),
140-
},
141-
},
142-
]);
143-
};

0 commit comments

Comments
 (0)