Skip to content

Commit 7cb2cfc

Browse files
authored
add functionName to queueTransaction params (#727)
1 parent 526a11b commit 7cb2cfc

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/server/routes/contract/write/write.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Static, Type } from "@sinclair/typebox";
1+
import { Type, type Static } from "@sinclair/typebox";
22
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { prepareContractCall, resolveMethod } from "thirdweb";
@@ -100,6 +100,7 @@ export async function writeToContract(fastify: FastifyInstance) {
100100
});
101101

102102
const queueId = await queueTransaction({
103+
functionName,
103104
transaction,
104105
fromAddress: requiredAddress(fromAddress, "x-backend-wallet-address"),
105106
toAddress: maybeAddress(contractAddress, "to"),

src/utils/transaction/queueTransation.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { Static } from "@sinclair/typebox";
22
import { StatusCodes } from "http-status-codes";
33
import {
4+
encode,
45
type Address,
56
type Hex,
67
type PreparedTransaction,
7-
encode,
88
} from "thirdweb";
9+
import { resolvePromisedValue } from "thirdweb/utils";
910
import { createCustomError } from "../../server/middleware/error";
1011
import type { txOverridesWithValueSchema } from "../../server/schemas/txOverrides";
1112
import { parseTransactionOverrides } from "../../server/utils/transactionOverrides";
@@ -25,8 +26,16 @@ export type QueuedTransactionParams = {
2526
>;
2627
idempotencyKey?: string;
2728
shouldSimulate?: boolean;
29+
functionName?: string;
2830
};
2931

32+
/**
33+
* Encodes a transaction to generate data, and inserts it into the transaction queue using the insertTransaction()
34+
*
35+
* Note:
36+
* - functionName must be be provided to populate the functionName field in the queued transaction
37+
* - value and chain details are resolved from the transaction
38+
*/
3039
export async function queueTransaction(args: QueuedTransactionParams) {
3140
const {
3241
transaction,
@@ -38,6 +47,7 @@ export async function queueTransaction(args: QueuedTransactionParams) {
3847
txOverrides,
3948
idempotencyKey,
4049
shouldSimulate,
50+
functionName,
4151
} = args;
4252

4353
let data: Hex;
@@ -56,9 +66,9 @@ export async function queueTransaction(args: QueuedTransactionParams) {
5666
from: fromAddress,
5767
to: toAddress,
5868
data,
59-
69+
functionName: functionName,
70+
value: await resolvePromisedValue(transaction.value),
6071
...parseTransactionOverrides(txOverrides),
61-
6272
...(accountAddress
6373
? {
6474
isUserOp: true,

0 commit comments

Comments
 (0)