MCPcopy Create free account
hub / github.com/etherspot/transaction-kit / batch

Method batch

lib/TransactionKit.ts:1012–1039  ·  view source on GitHub ↗

* Selects a batch by name for subsequent batch operations. * * This method sets the current batch context to the specified batch name, allowing batch-level operations such as remove, getState, and reset. Throws an error if the batch name is invalid or does not exist. * * @param params -

({ batchName }: BatchParams)

Source from the content-addressed store, hash-verified

1010 * - This method is chainable and is typically used to manage or inspect a batch of transactions.
1011 */
1012 batch({ batchName }: BatchParams): IBatch {
1013 if (typeof batchName !== 'string' || batchName.trim() === '') {
1014 this.throwError(
1015 'batch(): batchName is required and must be a non-empty string.'
1016 );
1017 }
1018 if (!this.batches[batchName]) {
1019 this.throwError(`batch(): Batch '${batchName}' does not exist.`);
1020 }
1021 this.selectedBatchName = batchName;
1022 this.workingTransaction = undefined;
1023 this.selectedTransactionName = undefined;
1024 log('batch(): Selected batch', batchName, this.debugMode);
1025 // Only allow remove, getState, and reset after selecting a batch
1026 // eslint-disable-next-line @typescript-eslint/no-this-alias
1027 const self = this;
1028 return {
1029 remove() {
1030 return self.remove();
1031 },
1032 getState() {
1033 return self.getState();
1034 },
1035 reset() {
1036 return self.reset();
1037 },
1038 };
1039 }
1040
1041 /**
1042 * Adds the current transaction to a specified batch, creating the batch if it does not exist.

Callers

nothing calls this directly

Calls 2

throwErrorMethod · 0.95
logFunction · 0.90

Tested by

no test coverage detected