Skip to content

Commit 1904ce5

Browse files
committed
SDK changes
1 parent f24e84b commit 1904ce5

File tree

5 files changed

+117
-1
lines changed

5 files changed

+117
-1
lines changed

sdk/src/services/BackendWalletService.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,72 @@ export class BackendWalletService {
629629
});
630630
}
631631

632+
/**
633+
* Send a batch of raw transactions atomically
634+
* Send a batch of raw transactions in a single UserOp. Can only be used with smart wallets.
635+
* @param chain A chain ID ("137") or slug ("polygon-amoy-testnet"). Chain ID is preferred.
636+
* @param xBackendWalletAddress Backend wallet address
637+
* @param requestBody
638+
* @param simulateTx Simulates the transaction before adding it to the queue, returning an error if it fails simulation. Note: This step is less performant and recommended only for debugging purposes.
639+
* @param xIdempotencyKey Transactions submitted with the same idempotency key will be de-duplicated. Only the last 100000 transactions are compared.
640+
* @param xAccountAddress Smart account address
641+
* @param xAccountFactoryAddress Smart account factory address. If omitted, Engine will try to resolve it from the contract.
642+
* @param xAccountSalt Smart account salt as string or hex. This is used to predict the smart account address. Useful when creating multiple accounts with the same admin and only needed when deploying the account as part of a userop.
643+
* @returns any Default Response
644+
* @throws ApiError
645+
*/
646+
public sendTransactionsAtomic(
647+
chain: string,
648+
xBackendWalletAddress: string,
649+
requestBody: {
650+
transactions: Array<{
651+
/**
652+
* A contract or wallet address
653+
*/
654+
toAddress?: string;
655+
data: string;
656+
value: string;
657+
}>;
658+
},
659+
simulateTx: boolean = false,
660+
xIdempotencyKey?: string,
661+
xAccountAddress?: string,
662+
xAccountFactoryAddress?: string,
663+
xAccountSalt?: string,
664+
): CancelablePromise<{
665+
result: {
666+
/**
667+
* Queue ID
668+
*/
669+
queueId: string;
670+
};
671+
}> {
672+
return this.httpRequest.request({
673+
method: 'POST',
674+
url: '/backend-wallet/{chain}/send-transactions-atomic',
675+
path: {
676+
'chain': chain,
677+
},
678+
headers: {
679+
'x-backend-wallet-address': xBackendWalletAddress,
680+
'x-idempotency-key': xIdempotencyKey,
681+
'x-account-address': xAccountAddress,
682+
'x-account-factory-address': xAccountFactoryAddress,
683+
'x-account-salt': xAccountSalt,
684+
},
685+
query: {
686+
'simulateTx': simulateTx,
687+
},
688+
body: requestBody,
689+
mediaType: 'application/json',
690+
errors: {
691+
400: `Bad Request`,
692+
404: `Not Found`,
693+
500: `Internal Server Error`,
694+
},
695+
});
696+
}
697+
632698
/**
633699
* Sign a transaction
634700
* Sign a transaction
@@ -833,6 +899,7 @@ export class BackendWalletService {
833899
onchainStatus: ('success' | 'reverted' | null);
834900
effectiveGasPrice: (string | null);
835901
cumulativeGasUsed: (string | null);
902+
batchOperations: null;
836903
}>;
837904
};
838905
}> {
@@ -928,6 +995,7 @@ export class BackendWalletService {
928995
onchainStatus: ('success' | 'reverted' | null);
929996
effectiveGasPrice: (string | null);
930997
cumulativeGasUsed: (string | null);
998+
batchOperations: null;
931999
} | string);
9321000
}>;
9331001
}> {

sdk/src/services/ContractService.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,50 @@ export class ContractService {
4646
});
4747
}
4848

49+
/**
50+
* Batch read from multiple contracts
51+
* Execute multiple contract read operations in a single call using Multicall
52+
* @param chain
53+
* @param requestBody
54+
* @returns any Default Response
55+
* @throws ApiError
56+
*/
57+
public readBatch(
58+
chain: string,
59+
requestBody: {
60+
calls: Array<{
61+
contractAddress: string;
62+
functionName: string;
63+
functionAbi?: string;
64+
args?: Array<any>;
65+
}>;
66+
/**
67+
* Address of the multicall contract to use. If omitted, multicall3 contract will be used (0xcA11bde05977b3631167028862bE2a173976CA11).
68+
*/
69+
multicallAddress?: string;
70+
},
71+
): CancelablePromise<{
72+
results: Array<{
73+
success: boolean;
74+
result: any;
75+
}>;
76+
}> {
77+
return this.httpRequest.request({
78+
method: 'POST',
79+
url: '/contract/{chain}/read-batch',
80+
path: {
81+
'chain': chain,
82+
},
83+
body: requestBody,
84+
mediaType: 'application/json',
85+
errors: {
86+
400: `Bad Request`,
87+
404: `Not Found`,
88+
500: `Internal Server Error`,
89+
},
90+
});
91+
}
92+
4993
/**
5094
* Write to contract
5195
* Call a write function on a contract.

sdk/src/services/TransactionService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class TransactionService {
7878
onchainStatus: ('success' | 'reverted' | null);
7979
effectiveGasPrice: (string | null);
8080
cumulativeGasUsed: (string | null);
81+
batchOperations: null;
8182
}>;
8283
totalCount: number;
8384
};
@@ -162,6 +163,7 @@ export class TransactionService {
162163
onchainStatus: ('success' | 'reverted' | null);
163164
effectiveGasPrice: (string | null);
164165
cumulativeGasUsed: (string | null);
166+
batchOperations: null;
165167
};
166168
}> {
167169
return this.httpRequest.request({
@@ -245,6 +247,7 @@ export class TransactionService {
245247
onchainStatus: ('success' | 'reverted' | null);
246248
effectiveGasPrice: (string | null);
247249
cumulativeGasUsed: (string | null);
250+
batchOperations: null;
248251
}>;
249252
totalCount: number;
250253
};

src/scripts/generate-sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from "node:path";
44
import { kill } from "node:process";
55

66
const ENGINE_OPENAPI_URL = "https://demo.web3api.thirdweb.com/json";
7-
// const ENGINE_OPENAPI_URL = "http://localhost:3005/json";
7+
// const ENGINE_OPENAPI_URL = "http://127.0.0.1:3005/json";
88
const REPLACE_LOG_FILE = "sdk/replacement_log.txt";
99

1010
type BasicOpenAPISpec = {

src/server/routes/webhooks/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export async function testWebhookRoute(fastify: FastifyInstance) {
9393
paymasterAndData: null,
9494
userOpHash: null,
9595
accountSalt: null,
96+
batchOperations: null,
9697

9798
// Off-chain details
9899
functionName: "transfer",

0 commit comments

Comments
 (0)