* Estimates and sends all batches of transactions. * * Provides comprehensive batch sending with support for both modular and delegatedEoa wallet modes. Groups transactions by chainId for efficient multi-chain processing, estimates gas and costs, and sends user operations with proper error han
({
onlyBatchNames,
paymasterDetails,
authorization,
}: SendBatchesParams = {})
| 3319 | * - For single transaction sending, use `send()` instead |
| 3320 | */ |
| 3321 | async sendBatches({ |
| 3322 | onlyBatchNames, |
| 3323 | paymasterDetails, |
| 3324 | authorization, |
| 3325 | }: SendBatchesParams = {}): Promise<BatchSendResult> { |
| 3326 | // ======================================================================== |
| 3327 | // STEP 1: INPUT VALIDATION AND SETUP |
| 3328 | // ======================================================================== |
| 3329 | |
| 3330 | // Prevent concurrent sending to avoid race conditions |
| 3331 | if (this.isSending) { |
| 3332 | this.throwError( |
| 3333 | 'Another batch sending is already in progress. Please wait for it to complete.' |
| 3334 | ); |
| 3335 | } |
| 3336 | |
| 3337 | // Validate onlyBatchNames parameter if provided |
| 3338 | if (onlyBatchNames) { |
| 3339 | if (!Array.isArray(onlyBatchNames)) { |
| 3340 | this.throwError('onlyBatchNames must be an array of strings'); |
| 3341 | } |
| 3342 | onlyBatchNames.forEach((name, index) => { |
| 3343 | if (typeof name !== 'string' || name.trim() === '') { |
| 3344 | this.throwError( |
| 3345 | `onlyBatchNames[${index}] must be a non-empty string` |
| 3346 | ); |
| 3347 | } |
| 3348 | }); |
| 3349 | } |
| 3350 | |
| 3351 | // Set sending state flags |
| 3352 | this.isSending = true; |
| 3353 | this.containsSendingError = false; |
| 3354 | |
| 3355 | const walletMode = this.#etherspotProvider.getWalletMode(); |
| 3356 | log(`sendBatches(): Wallet mode: ${walletMode}`, undefined, this.debugMode); |
| 3357 | |
| 3358 | // Initialize result structure |
| 3359 | const result: BatchSendResult = { |
| 3360 | batches: {}, |
| 3361 | isEstimatedSuccessfully: true, |
| 3362 | isSentSuccessfully: true, |
| 3363 | }; |
| 3364 | |
| 3365 | // ======================================================================== |
| 3366 | // STEP 2: DETERMINE BATCHES TO SEND |
| 3367 | // ======================================================================== |
| 3368 | |
| 3369 | // Use provided batch names or send all existing batches |
| 3370 | const batchesToSend = onlyBatchNames || Object.keys(this.batches); |
| 3371 | |
| 3372 | if (batchesToSend.length === 0) { |
| 3373 | log('sendBatches(): No batches to send', this.debugMode); |
| 3374 | this.isSending = false; |
| 3375 | return result; |
| 3376 | } |
| 3377 | |
| 3378 | // ======================================================================== |
nothing calls this directly
no test coverage detected