File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
server/routes/contract/write Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
- import { type Static , Type } from "@sinclair/typebox" ;
1
+ import { Type , type Static } from "@sinclair/typebox" ;
2
2
import type { FastifyInstance } from "fastify" ;
3
3
import { StatusCodes } from "http-status-codes" ;
4
4
import { prepareContractCall , resolveMethod } from "thirdweb" ;
@@ -100,6 +100,7 @@ export async function writeToContract(fastify: FastifyInstance) {
100
100
} ) ;
101
101
102
102
const queueId = await queueTransaction ( {
103
+ functionName,
103
104
transaction,
104
105
fromAddress : requiredAddress ( fromAddress , "x-backend-wallet-address" ) ,
105
106
toAddress : maybeAddress ( contractAddress , "to" ) ,
Original file line number Diff line number Diff line change 1
1
import type { Static } from "@sinclair/typebox" ;
2
2
import { StatusCodes } from "http-status-codes" ;
3
3
import {
4
+ encode ,
4
5
type Address ,
5
6
type Hex ,
6
7
type PreparedTransaction ,
7
- encode ,
8
8
} from "thirdweb" ;
9
+ import { resolvePromisedValue } from "thirdweb/utils" ;
9
10
import { createCustomError } from "../../server/middleware/error" ;
10
11
import type { txOverridesWithValueSchema } from "../../server/schemas/txOverrides" ;
11
12
import { parseTransactionOverrides } from "../../server/utils/transactionOverrides" ;
@@ -25,8 +26,16 @@ export type QueuedTransactionParams = {
25
26
> ;
26
27
idempotencyKey ?: string ;
27
28
shouldSimulate ?: boolean ;
29
+ functionName ?: string ;
28
30
} ;
29
31
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
+ */
30
39
export async function queueTransaction ( args : QueuedTransactionParams ) {
31
40
const {
32
41
transaction,
@@ -38,6 +47,7 @@ export async function queueTransaction(args: QueuedTransactionParams) {
38
47
txOverrides,
39
48
idempotencyKey,
40
49
shouldSimulate,
50
+ functionName,
41
51
} = args ;
42
52
43
53
let data : Hex ;
@@ -56,9 +66,9 @@ export async function queueTransaction(args: QueuedTransactionParams) {
56
66
from : fromAddress ,
57
67
to : toAddress ,
58
68
data,
59
-
69
+ functionName : functionName ,
70
+ value : await resolvePromisedValue ( transaction . value ) ,
60
71
...parseTransactionOverrides ( txOverrides ) ,
61
-
62
72
...( accountAddress
63
73
? {
64
74
isUserOp : true ,
You can’t perform that action at this time.
0 commit comments