Skip to content

Commit 215c458

Browse files
committed
Address review comments
1 parent 1904ce5 commit 215c458

File tree

6 files changed

+33
-26
lines changed

6 files changed

+33
-26
lines changed

sdk/src/services/BackendWalletService.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ export class BackendWalletService {
631631

632632
/**
633633
* Send a batch of raw transactions atomically
634-
* Send a batch of raw transactions in a single UserOp. Can only be used with smart wallets.
634+
* Send a batch of raw transactions in a single UserOp. Transactions will be sent in-order and atomically. Can only be used with smart wallets.
635635
* @param chain A chain ID ("137") or slug ("polygon-amoy-testnet"). Chain ID is preferred.
636636
* @param xBackendWalletAddress Backend wallet address
637637
* @param requestBody
@@ -643,7 +643,7 @@ export class BackendWalletService {
643643
* @returns any Default Response
644644
* @throws ApiError
645645
*/
646-
public sendTransactionsAtomic(
646+
public sendTransactionBatchAtomic(
647647
chain: string,
648648
xBackendWalletAddress: string,
649649
requestBody: {
@@ -652,7 +652,13 @@ export class BackendWalletService {
652652
* A contract or wallet address
653653
*/
654654
toAddress?: string;
655+
/**
656+
* A valid hex string
657+
*/
655658
data: string;
659+
/**
660+
* An amount in wei (no decimals). Example: "50000000000"
661+
*/
656662
value: string;
657663
}>;
658664
},
@@ -671,7 +677,7 @@ export class BackendWalletService {
671677
}> {
672678
return this.httpRequest.request({
673679
method: 'POST',
674-
url: '/backend-wallet/{chain}/send-transactions-atomic',
680+
url: '/backend-wallet/{chain}/send-transaction-batch-atomic',
675681
path: {
676682
'chain': chain,
677683
},

src/server/routes/backend-wallet/send-transactions-atomic.ts renamed to src/server/routes/backend-wallet/send-transaction-batch-atomic.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import type { Address, Hex } from "thirdweb";
55
import { insertTransaction } from "../../../shared/utils/transaction/insert-transaction";
6-
import { AddressSchema } from "../../schemas/address";
76
import {
87
requestQuerystringSchema,
98
standardResponseSchema,
@@ -22,36 +21,29 @@ import {
2221
WalletDetailsError,
2322
} from "../../../shared/db/wallets/get-wallet-details";
2423
import { createCustomError } from "../../middleware/error";
24+
import { RawTransactionParamsSchema } from "../../schemas/transaction/raw-transaction-parms";
2525

2626
const requestBodySchema = Type.Object({
27-
transactions: Type.Array(
28-
Type.Object({
29-
toAddress: Type.Optional(AddressSchema),
30-
data: Type.String({
31-
examples: ["0x..."],
32-
}),
33-
value: Type.String({
34-
examples: ["10000000"],
35-
}),
36-
}),
37-
),
27+
transactions: Type.Array(RawTransactionParamsSchema, {
28+
minItems: 1,
29+
}),
3830
});
3931

40-
export async function sendTransactionsAtomicRoute(fastify: FastifyInstance) {
32+
export async function sendTransactionBatchAtomicRoute(fastify: FastifyInstance) {
4133
fastify.route<{
4234
Params: Static<typeof walletChainParamSchema>;
4335
Body: Static<typeof requestBodySchema>;
4436
Reply: Static<typeof transactionWritesResponseSchema>;
4537
Querystring: Static<typeof requestQuerystringSchema>;
4638
}>({
4739
method: "POST",
48-
url: "/backend-wallet/:chain/send-transactions-atomic",
40+
url: "/backend-wallet/:chain/send-transaction-batch-atomic",
4941
schema: {
5042
summary: "Send a batch of raw transactions atomically",
5143
description:
52-
"Send a batch of raw transactions in a single UserOp. Can only be used with smart wallets.",
44+
"Send a batch of raw transactions in a single UserOp. Transactions will be sent in-order and atomically. Can only be used with smart wallets.",
5345
tags: ["Backend Wallet"],
54-
operationId: "sendTransactionsAtomic",
46+
operationId: "sendTransactionBatchAtomic",
5547
params: walletChainParamSchema,
5648
body: requestBodySchema,
5749
headers: Type.Omit(walletWithAAHeaderSchema, ["x-transaction-mode"]),

src/server/routes/contract/read/read-batch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type RouteGeneric = {
5959
Reply: Static<typeof responseSchema>;
6060
};
6161

62-
export async function readMulticallRoute(fastify: FastifyInstance) {
62+
export async function readBatchRoute(fastify: FastifyInstance) {
6363
fastify.route<RouteGeneric>({
6464
method: "POST",
6565
url: "/contract/:chain/read-batch",

src/server/routes/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ import { getWebhooksEventTypes } from "./webhooks/events";
111111
import { getAllWebhooksData } from "./webhooks/get-all";
112112
import { revokeWebhook } from "./webhooks/revoke";
113113
import { testWebhookRoute } from "./webhooks/test";
114-
import { readMulticallRoute } from "./contract/read/read-batch";
115-
import { sendTransactionsAtomicRoute } from "./backend-wallet/send-transactions-atomic";
114+
import { readBatchRoute } from "./contract/read/read-batch";
115+
import { sendTransactionBatchAtomicRoute } from "./backend-wallet/send-transaction-batch-atomic";
116116

117117
export async function withRoutes(fastify: FastifyInstance) {
118118
// Backend Wallets
@@ -126,7 +126,7 @@ export async function withRoutes(fastify: FastifyInstance) {
126126
await fastify.register(withdraw);
127127
await fastify.register(sendTransaction);
128128
await fastify.register(sendTransactionBatch);
129-
await fastify.register(sendTransactionsAtomicRoute);
129+
await fastify.register(sendTransactionBatchAtomicRoute);
130130
await fastify.register(signTransaction);
131131
await fastify.register(signMessageRoute);
132132
await fastify.register(signTypedData);
@@ -195,7 +195,7 @@ export async function withRoutes(fastify: FastifyInstance) {
195195

196196
// Generic
197197
await fastify.register(readContract);
198-
await fastify.register(readMulticallRoute);
198+
await fastify.register(readBatchRoute);
199199
await fastify.register(writeToContract);
200200

201201
// Contract Events
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Type } from "@sinclair/typebox";
2+
import { AddressSchema, HexSchema } from "../address";
3+
import { WeiAmountStringSchema } from "../number";
4+
5+
export const RawTransactionParamsSchema = Type.Object({
6+
toAddress: Type.Optional(AddressSchema),
7+
data: HexSchema,
8+
value: WeiAmountStringSchema,
9+
});

src/shared/db/wallets/get-wallet-details.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LruMap from "mnemonist/lru-map";
1+
import LRUMap from "mnemonist/lru-map";
22
import { getAddress } from "thirdweb";
33
import { z } from "zod";
44
import type { PrismaTransaction } from "../../schemas/prisma";
@@ -131,7 +131,7 @@ export type SmartBackendWalletType = (typeof SmartBackendWalletTypes)[number];
131131
export type BackendWalletType = (typeof BackendWalletTypes)[number];
132132
export type ParsedWalletDetails = z.infer<typeof walletDetailsSchema>;
133133

134-
export const walletDetailsCache = new LruMap<string, ParsedWalletDetails>(2048);
134+
export const walletDetailsCache = new LRUMap<string, ParsedWalletDetails>(2048);
135135
/**
136136
* Return the wallet details for the given address.
137137
*

0 commit comments

Comments
 (0)