8
8
transactionWritesResponseSchema ,
9
9
} from "../../schemas/sharedApiSchemas" ;
10
10
import { txOverridesSchema } from "../../schemas/txOverrides" ;
11
- import { walletHeaderSchema } from "../../schemas/wallet" ;
11
+ import { walletWithAAHeaderSchema } from "../../schemas/wallet" ;
12
12
import { getChainIdFromChain } from "../../utils/chain" ;
13
13
14
14
const ParamsSchema = Type . Object ( {
@@ -57,7 +57,7 @@ export async function sendTransaction(fastify: FastifyInstance) {
57
57
operationId : "sendTransaction" ,
58
58
params : ParamsSchema ,
59
59
body : requestBodySchema ,
60
- headers : walletHeaderSchema ,
60
+ headers : walletWithAAHeaderSchema ,
61
61
querystring : requestQuerystringSchema ,
62
62
response : {
63
63
...standardResponseSchema ,
@@ -71,19 +71,37 @@ export async function sendTransaction(fastify: FastifyInstance) {
71
71
const {
72
72
"x-backend-wallet-address" : fromAddress ,
73
73
"x-idempotency-key" : idempotencyKey ,
74
- } = request . headers as Static < typeof walletHeaderSchema > ;
74
+ "x-account-address" : accountAddress ,
75
+ } = request . headers as Static < typeof walletWithAAHeaderSchema > ;
75
76
const chainId = await getChainIdFromChain ( chain ) ;
76
77
77
- const { id : queueId } = await queueTxRaw ( {
78
- chainId : chainId . toString ( ) ,
79
- fromAddress,
80
- toAddress,
81
- data,
82
- value,
83
- simulateTx,
84
- idempotencyKey,
85
- ...txOverrides ,
86
- } ) ;
78
+ let queueId : string ;
79
+ if ( accountAddress ) {
80
+ const { id } = await queueTxRaw ( {
81
+ chainId : chainId . toString ( ) ,
82
+ signerAddress : fromAddress ,
83
+ accountAddress,
84
+ target : toAddress ,
85
+ data,
86
+ value,
87
+ simulateTx,
88
+ idempotencyKey,
89
+ ...txOverrides ,
90
+ } ) ;
91
+ queueId = id ;
92
+ } else {
93
+ const { id } = await queueTxRaw ( {
94
+ chainId : chainId . toString ( ) ,
95
+ fromAddress,
96
+ toAddress,
97
+ data,
98
+ value,
99
+ simulateTx,
100
+ idempotencyKey,
101
+ ...txOverrides ,
102
+ } ) ;
103
+ queueId = id ;
104
+ }
87
105
88
106
reply . status ( StatusCodes . OK ) . send ( {
89
107
result : {
0 commit comments