Skip to content

Commit 9ce1bdd

Browse files
feat: feat: add feePayerAddress parameter to aptosRawTransaction and nftMint functions
1 parent 6862894 commit 9ce1bdd

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

packages/core-js/src/userop/aptosRawTransaction.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import GatewayClientRepository from '@/api/gateway.js';
22
import type OktoClient from '@/core/index.js';
33
import { BaseError } from '@/errors/base.js';
44
import { getChains } from '@/explorer/chain.js';
5-
import type { UserOp } from '@/types/core.js';
5+
import type { Address, UserOp } from '@/types/core.js';
66
import { Constants } from '@/utils/index.js';
77
import { generateUUID, nonceToBigInt } from '@/utils/nonce.js';
88
import {
@@ -32,12 +32,17 @@ import {
3232
export async function aptosRawTransaction(
3333
oc: OktoClient,
3434
data: AptosRawTransactionIntentParams,
35+
feePayerAddress?: Address,
3536
): Promise<UserOp> {
3637
if (!oc.isLoggedIn()) {
3738
throw new BaseError('User not logged in');
3839
}
3940
validateSchema(AptosRawTransactionIntentParamsSchema, data);
4041

42+
if (!feePayerAddress) {
43+
feePayerAddress = Constants.FEE_PAYER_ADDRESS;
44+
}
45+
4146
const nonce = generateUUID();
4247

4348
const jobParametersAbiType = '(string caip2Id, bytes[] transactions)';
@@ -92,6 +97,7 @@ export async function aptosRawTransaction(
9297
toHex(nonceToBigInt(nonce), { size: 32 }),
9398
oc.clientSWA,
9499
oc.userSWA,
100+
feePayerAddress,
95101
encodeAbiParameters(
96102
parseAbiParameters('(bool gsnEnabled, bool sponsorshipEnabled)'),
97103
[

packages/core-js/src/userop/nftMint.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import GatewayClientRepository from '@/api/gateway.js';
22
import type OktoClient from '@/core/index.js';
33
import { BaseError } from '@/errors/base.js';
44
import { getChains } from '@/explorer/chain.js';
5-
import type { UserOp } from '@/types/core.js';
5+
import type { Address, UserOp } from '@/types/core.js';
66
import { Constants } from '@/utils/index.js';
77
import { generateUUID, nonceToBigInt } from '@/utils/nonce.js';
88
import {
@@ -29,6 +29,7 @@ import { NftMintParamsSchema, validateSchema } from './userOpInputValidator.js';
2929
export async function nftMint(
3030
oc: OktoClient,
3131
data: NftMintParams,
32+
feePayerAddress?: Address,
3233
): Promise<UserOp> {
3334
if (!oc.isLoggedIn()) {
3435
throw new BaseError('User not logged in');
@@ -38,6 +39,10 @@ export async function nftMint(
3839

3940
const nonce = generateUUID();
4041

42+
if (!feePayerAddress) {
43+
feePayerAddress = Constants.FEE_PAYER_ADDRESS;
44+
}
45+
4146
const jobParametersAbiType =
4247
'(string caip2Id, string nftName, string collectionAddress, string uri, bytes data)';
4348
const gsnDataAbiType = `(bool isRequired, string[] requiredNetworks, ${jobParametersAbiType}[] tokens)`;
@@ -84,6 +89,7 @@ export async function nftMint(
8489
toHex(nonceToBigInt(nonce), { size: 32 }),
8590
oc.clientSWA,
8691
oc.userSWA,
92+
feePayerAddress,
8793
encodeAbiParameters(
8894
parseAbiParameters('(bool gsnEnabled, bool sponsorshipEnabled)'),
8995
[

packages/core-js/src/userop/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export type AptosFunctionArgumentTypes =
101101
| ArrayBuffer
102102
| Array<AptosFunctionArgumentTypes>;
103103

104-
105104
export interface AptosRawTransaction {
106105
function: string;
107106
typeArguments: string[];

packages/core-js/src/userop/userOpInputValidator.ts

+26-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,32 @@ export const AptosRawTransactionIntentParamsSchema = z
160160
.min(1, 'Function cannot be empty'),
161161
typeArguments: z.array(z.string()).optional().default([]),
162162
functionArguments: z
163-
.array(z.union([z.string(), z.number()]))
163+
.array(
164+
z.union([
165+
z.string(),
166+
z.number(),
167+
z.boolean(),
168+
z.bigint(),
169+
z.null(),
170+
z.undefined(),
171+
z.instanceof(Uint8Array),
172+
z.instanceof(ArrayBuffer),
173+
z.array(
174+
z.lazy(() =>
175+
z.union([
176+
z.string(),
177+
z.number(),
178+
z.boolean(),
179+
z.bigint(),
180+
z.null(),
181+
z.undefined(),
182+
z.instanceof(Uint8Array),
183+
z.instanceof(ArrayBuffer),
184+
]),
185+
),
186+
),
187+
]),
188+
)
164189
.optional()
165190
.default([]),
166191
}),

0 commit comments

Comments
 (0)