Skip to content

Commit c0d83fc

Browse files
committed
add header to all v5 endpoints + fix SDK upgrade type incompatibilities
1 parent 534435f commit c0d83fc

File tree

28 files changed

+134
-28
lines changed

28 files changed

+134
-28
lines changed

src/server/routes/backend-wallet/send-transaction-batch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ export async function sendTransactionBatch(fastify: FastifyInstance) {
5656
},
5757
handler: async (request, reply) => {
5858
const { chain } = request.params;
59-
const { "x-backend-wallet-address": fromAddress } =
60-
request.headers as Static<typeof walletHeaderSchema>;
59+
const {
60+
"x-backend-wallet-address": fromAddress,
61+
"x-transaction-mode": transactionMode,
62+
} = request.headers as Static<typeof walletHeaderSchema>;
6163
const chainId = await getChainIdFromChain(chain);
6264

6365
const transactionRequests = request.body;
@@ -70,6 +72,7 @@ export async function sendTransactionBatch(fastify: FastifyInstance) {
7072
insertedTransaction: {
7173
isUserOp: false,
7274
chainId,
75+
transactionMode,
7376
from: fromAddress as Address,
7477
to: toAddress as Address | undefined,
7578
data: data as Hex,

src/server/routes/backend-wallet/send-transaction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export async function sendTransaction(fastify: FastifyInstance) {
7272
"x-idempotency-key": idempotencyKey,
7373
"x-account-address": accountAddress,
7474
"x-account-factory-address": accountFactoryAddress,
75+
"x-transaction-mode": transactionMode,
7576
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
7677

7778
const chainId = await getChainIdFromChain(chain);
@@ -89,6 +90,7 @@ export async function sendTransaction(fastify: FastifyInstance) {
8990
accountAddress: accountAddress as Address,
9091
signerAddress: fromAddress as Address,
9192
target: toAddress as Address | undefined,
93+
transactionMode: undefined,
9294
accountFactoryAddress: maybeAddress(
9395
accountFactoryAddress,
9496
"x-account-factory-address",
@@ -106,6 +108,7 @@ export async function sendTransaction(fastify: FastifyInstance) {
106108
from: fromAddress as Address,
107109
to: toAddress as Address | undefined,
108110
data: data as Hex,
111+
transactionMode: transactionMode,
109112
value: BigInt(value),
110113
...parseTransactionOverrides(txOverrides),
111114
},

src/server/routes/backend-wallet/sign-transaction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Type, type Static } from "@sinclair/typebox";
22
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
4-
import type { Hex } from "thirdweb";
5-
import type { TransactionSerializable } from "viem";
64
import { getAccount } from "../../../shared/utils/account";
75
import {
86
getChecksumAddress,
@@ -13,6 +11,7 @@ import { toTransactionType } from "../../../shared/utils/sdk";
1311
import { createCustomError } from "../../middleware/error";
1412
import { standardResponseSchema } from "../../schemas/shared-api-schemas";
1513
import { walletHeaderSchema } from "../../schemas/wallet";
14+
import type { Hex } from "thirdweb";
1615

1716
const requestBodySchema = Type.Object({
1817
transaction: Type.Object({
@@ -86,7 +85,8 @@ export async function signTransaction(fastify: FastifyInstance) {
8685
maxFeePerGas: maybeBigInt(transaction.maxFeePerGas),
8786
maxPriorityFeePerGas: maybeBigInt(transaction.maxPriorityFeePerGas),
8887
ccipReadEnabled: transaction.ccipReadEnabled,
89-
} as TransactionSerializable;
88+
};
89+
9090
const signature = await account.signTransaction(serializableTransaction);
9191

9292
reply.status(StatusCodes.OK).send({

src/server/routes/backend-wallet/simulate-transaction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export async function simulateTransaction(fastify: FastifyInstance) {
8282
const {
8383
"x-backend-wallet-address": walletAddress,
8484
"x-account-address": accountAddress,
85+
"x-transaction-mode": transactionMode,
8586
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
8687

8788
const chainId = await getChainIdFromChain(chain);
@@ -99,6 +100,7 @@ export async function simulateTransaction(fastify: FastifyInstance) {
99100
functionArgs: args,
100101
data: data as Hex | undefined,
101102
value: value ? BigInt(value) : 0n,
103+
transactionMode: transactionMode,
102104

103105
...(accountAddress
104106
? {

src/server/routes/backend-wallet/transfer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export async function transfer(fastify: FastifyInstance) {
8888
const {
8989
"x-backend-wallet-address": walletAddress,
9090
"x-idempotency-key": idempotencyKey,
91+
"x-transaction-mode": transactionMode,
9192
} = request.headers as Static<typeof walletHeaderSchema>;
9293
const { simulateTx: shouldSimulate } = request.query;
9394

@@ -109,6 +110,7 @@ export async function transfer(fastify: FastifyInstance) {
109110
value: toWei(amount),
110111
extension: "none",
111112
functionName: "transfer",
113+
transactionMode,
112114
...parseTransactionOverrides(txOverrides),
113115
};
114116
} else {
@@ -143,6 +145,7 @@ export async function transfer(fastify: FastifyInstance) {
143145
extension: "erc20",
144146
functionName: "transfer",
145147
functionArgs: [to, amount, currencyAddress],
148+
transactionMode,
146149
...parseTransactionOverrides(txOverrides),
147150
};
148151
}

src/server/routes/contract/extensions/account-factory/write/create-account.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const createAccount = async (fastify: FastifyInstance) => {
7474
"x-account-factory-address": accountFactoryAddress,
7575
"x-account-salt": accountSalt,
7676
"x-idempotency-key": idempotencyKey,
77+
"x-transaction-mode": transactionMode,
7778
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
7879
const chainId = await getChainIdFromChain(chain);
7980

@@ -116,6 +117,7 @@ export const createAccount = async (fastify: FastifyInstance) => {
116117
txOverrides,
117118
idempotencyKey,
118119
shouldSimulate: simulateTx,
120+
transactionMode,
119121
});
120122

121123
// Note: This is a temporary solution to cache the deployed address's factory for 7 days.

src/server/routes/contract/extensions/erc1155/write/claim-to.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export async function erc1155claimTo(fastify: FastifyInstance) {
8383
"x-idempotency-key": idempotencyKey,
8484
"x-account-factory-address": accountFactoryAddress,
8585
"x-account-salt": accountSalt,
86+
"x-transaction-mode": transactionMode,
8687
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
8788

8889
const chainId = await getChainIdFromChain(chain);
@@ -113,6 +114,7 @@ export async function erc1155claimTo(fastify: FastifyInstance) {
113114
txOverrides,
114115
idempotencyKey,
115116
shouldSimulate: simulateTx,
117+
transactionMode,
116118
});
117119

118120
reply.status(StatusCodes.OK).send({

src/server/routes/contract/extensions/erc1155/write/mint-to.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export async function erc1155mintTo(fastify: FastifyInstance) {
8282
"x-idempotency-key": idempotencyKey,
8383
"x-account-factory-address": accountFactoryAddress,
8484
"x-account-salt": accountSalt,
85+
"x-transaction-mode": transactionMode,
8586
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
8687

8788
const chainId = await getChainIdFromChain(_chain);
@@ -129,6 +130,7 @@ export async function erc1155mintTo(fastify: FastifyInstance) {
129130
extension: "erc1155",
130131
functionName: "mintTo",
131132
shouldSimulate: simulateTx,
133+
transactionMode,
132134
});
133135

134136
reply.status(StatusCodes.OK).send({

src/server/routes/contract/extensions/erc1155/write/transfer-from.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export async function erc1155transferFrom(fastify: FastifyInstance) {
8787
"x-idempotency-key": idempotencyKey,
8888
"x-account-factory-address": accountFactoryAddress,
8989
"x-account-salt": accountSalt,
90+
"x-transaction-mode": transactionMode,
9091
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
9192

9293
const chainId = await getChainIdFromChain(chain);
@@ -117,6 +118,7 @@ export async function erc1155transferFrom(fastify: FastifyInstance) {
117118
shouldSimulate: simulateTx,
118119
functionName: "safeTransferFrom",
119120
extension: "erc1155",
121+
transactionMode,
120122
});
121123

122124
reply.status(StatusCodes.OK).send({

src/server/routes/contract/extensions/erc1155/write/transfer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export async function erc1155transfer(fastify: FastifyInstance) {
7979
"x-idempotency-key": idempotencyKey,
8080
"x-account-factory-address": accountFactoryAddress,
8181
"x-account-salt": accountSalt,
82+
"x-transaction-mode": transactionMode,
8283
} = request.headers as Static<typeof walletWithAAHeaderSchema>;
8384

8485
const chainId = await getChainIdFromChain(chain);
@@ -109,6 +110,7 @@ export async function erc1155transfer(fastify: FastifyInstance) {
109110
shouldSimulate: simulateTx,
110111
functionName: "safeTransferFrom",
111112
extension: "erc1155",
113+
transactionMode,
112114
});
113115

114116
reply.status(StatusCodes.OK).send({

0 commit comments

Comments
 (0)