@algorandfoundation/algokit-utils 7.0.0-beta.8 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/account/account.js +6 -4
- package/account/account.js.map +1 -1
- package/account/account.mjs +6 -4
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.js.map +1 -1
- package/amount.mjs.map +1 -1
- package/app-client.js.map +1 -1
- package/app-client.mjs.map +1 -1
- package/app-deploy.js +2 -10
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +3 -11
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +2 -2
- package/app.js +2 -2
- package/app.js.map +1 -1
- package/app.mjs +2 -2
- package/app.mjs.map +1 -1
- package/asset.js.map +1 -1
- package/asset.mjs.map +1 -1
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs.map +1 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +6 -0
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.js.map +1 -1
- package/network-client.mjs.map +1 -1
- package/package.json +5 -5
- package/testing/account.js.map +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/legacy-bridge.js +2 -2
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +3 -3
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +14 -7
- package/transaction/transaction.js +57 -31
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +55 -30
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +1 -1
- package/types/account-manager.js +10 -8
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +11 -9
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +9 -0
- package/types/account.js.map +1 -1
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +2 -2
- package/types/algorand-client-transaction-creator.d.ts +5 -3
- package/types/algorand-client-transaction-creator.js +3 -1
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +3 -1
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +12 -8
- package/types/algorand-client-transaction-sender.js +6 -2
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +6 -2
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +3 -4
- package/types/algorand-client.js +2 -5
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +4 -4
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.js.map +1 -1
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +31 -20
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +97 -78
- package/types/app-client.js +171 -54
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +169 -52
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.js +1 -1
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +2 -2
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +30 -10
- package/types/app-factory.js +26 -20
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +26 -20
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.js +105 -23
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +105 -23
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.js +8 -2
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +8 -2
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +8 -7
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +4 -4
- package/types/asset-manager.js +2 -2
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +2 -2
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +1 -10
- package/types/async-event-emitter.js +0 -5
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +1 -6
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.js +2 -2
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +2 -2
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +40 -25
- package/types/composer.js +114 -40
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +115 -39
- package/types/composer.mjs.map +1 -1
- package/types/config.js.map +1 -1
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +1 -1
- package/types/debugging.js +1 -1
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +1 -1
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs.map +1 -1
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.js +1 -1
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +2 -2
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -3
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +1 -1
- package/types/urlTokenBaseHTTPClient.js.map +1 -1
- package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
- package/util.js.map +1 -1
- package/util.mjs.map +1 -1
package/types/composer.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
2
|
import { Config } from '../config.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import { encodeLease, sendAtomicTransactionComposer } from '../transaction/transaction.mjs';
|
|
3
|
+
import { encodeLease, sendAtomicTransactionComposer, getABIReturnValue } from '../transaction/transaction.mjs';
|
|
5
4
|
import { APP_PAGE_MAX_SIZE } from './app.mjs';
|
|
6
5
|
import { AppManager } from './app-manager.mjs';
|
|
7
|
-
import { EventType } from './
|
|
6
|
+
import { EventType } from './lifecycle-events.mjs';
|
|
8
7
|
import { genesisIdIsLocalNet } from './network-client.mjs';
|
|
9
8
|
|
|
9
|
+
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
10
10
|
var isTransactionWithSigner = algosdk.isTransactionWithSigner;
|
|
11
11
|
var encodeAddress = algosdk.encodeAddress;
|
|
12
12
|
var modelsv2 = algosdk.modelsv2;
|
|
13
13
|
const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
14
|
-
/**
|
|
15
|
-
class
|
|
14
|
+
/** TransactionComposer helps you compose and execute transactions as a transaction group. */
|
|
15
|
+
class TransactionComposer {
|
|
16
16
|
/**
|
|
17
|
-
* Create
|
|
17
|
+
* Create a `TransactionComposer`.
|
|
18
18
|
* @param params The configuration for this composer
|
|
19
19
|
*/
|
|
20
20
|
constructor(params) {
|
|
@@ -221,6 +221,15 @@ class AlgoKitComposer {
|
|
|
221
221
|
this.txns.push({ ...params, type: 'keyReg' });
|
|
222
222
|
return this;
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Add an offline key registration transaction to the transaction group.
|
|
226
|
+
* @param params The offline key registration transaction parameters
|
|
227
|
+
* @returns The composer so you can chain method calls
|
|
228
|
+
*/
|
|
229
|
+
addOfflineKeyRegistration(params) {
|
|
230
|
+
this.txns.push({ ...params, type: 'keyReg' });
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
224
233
|
/**
|
|
225
234
|
* Add the transactions within an `AtomicTransactionComposer` to the transaction group.
|
|
226
235
|
* @param atc The `AtomicTransactionComposer` to build transactions from and add to the group
|
|
@@ -234,7 +243,7 @@ class AlgoKitComposer {
|
|
|
234
243
|
buildAtc(atc, processTransaction) {
|
|
235
244
|
const group = atc.buildGroup();
|
|
236
245
|
const txnWithSigners = group.map((ts, idx) => {
|
|
237
|
-
// Remove underlying group ID from the transaction since it will be re-grouped when this
|
|
246
|
+
// Remove underlying group ID from the transaction since it will be re-grouped when this TransactionComposer is built
|
|
238
247
|
ts.txn.group = undefined;
|
|
239
248
|
// Process transaction if a function is provided
|
|
240
249
|
ts.txn = processTransaction?.(ts.txn, idx) ?? ts.txn;
|
|
@@ -291,14 +300,22 @@ class AlgoKitComposer {
|
|
|
291
300
|
*/
|
|
292
301
|
async buildMethodCall(params, suggestedParams, includeSigner) {
|
|
293
302
|
const methodArgs = [];
|
|
303
|
+
const transactionsForGroup = [];
|
|
294
304
|
const isAbiValue = (x) => {
|
|
295
305
|
if (Array.isArray(x))
|
|
296
306
|
return x.length == 0 || x.every(isAbiValue);
|
|
297
307
|
return typeof x === 'bigint' || typeof x === 'boolean' || typeof x === 'number' || typeof x === 'string' || x instanceof Uint8Array;
|
|
298
308
|
};
|
|
299
|
-
for (let i =
|
|
309
|
+
for (let i = (params.args ?? []).length - 1; i >= 0; i--) {
|
|
300
310
|
const arg = params.args[i];
|
|
301
311
|
if (arg === undefined) {
|
|
312
|
+
// An undefined transaction argument signals that the value will be supplied by a method call argument
|
|
313
|
+
if (algosdk.abiTypeIsTransaction(params.method.args[i].type) && transactionsForGroup.length > 0) {
|
|
314
|
+
// Move the last transaction from the group to the method call arguments to appease algosdk
|
|
315
|
+
const placeholderTransaction = transactionsForGroup.splice(-1, 1)[0];
|
|
316
|
+
methodArgs.push(placeholderTransaction);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
302
319
|
throw Error(`No value provided for argument ${i + 1} within call to ${params.method.name}`);
|
|
303
320
|
}
|
|
304
321
|
if (isAbiValue(arg)) {
|
|
@@ -311,7 +328,10 @@ class AlgoKitComposer {
|
|
|
311
328
|
}
|
|
312
329
|
if ('method' in arg) {
|
|
313
330
|
const tempTxnWithSigners = await this.buildMethodCall(arg, suggestedParams, includeSigner);
|
|
314
|
-
|
|
331
|
+
// If there is any transaction args, add to the atc
|
|
332
|
+
// Everything else should be added as method args
|
|
333
|
+
methodArgs.push(...tempTxnWithSigners.slice(-1)); // Add the method call itself as a method arg
|
|
334
|
+
transactionsForGroup.push(...tempTxnWithSigners.slice(0, -1).reverse()); // Add any transaction arguments to the atc
|
|
315
335
|
continue;
|
|
316
336
|
}
|
|
317
337
|
const txn = await arg;
|
|
@@ -323,10 +343,11 @@ class AlgoKitComposer {
|
|
|
323
343
|
? params.signer.signer
|
|
324
344
|
: params.signer
|
|
325
345
|
: this.getSigner(encodeAddress(txn.from.publicKey))
|
|
326
|
-
:
|
|
346
|
+
: TransactionComposer.NULL_SIGNER,
|
|
327
347
|
});
|
|
328
348
|
}
|
|
329
349
|
const methodAtc = new algosdk.AtomicTransactionComposer();
|
|
350
|
+
transactionsForGroup.reverse().forEach((txn) => methodAtc.addTransaction(txn));
|
|
330
351
|
const appId = Number('appId' in params ? params.appId : 0n);
|
|
331
352
|
const approvalProgram = 'approvalProgram' in params
|
|
332
353
|
? typeof params.approvalProgram === 'string'
|
|
@@ -356,10 +377,10 @@ class AlgoKitComposer {
|
|
|
356
377
|
? Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0)) / APP_PAGE_MAX_SIZE)
|
|
357
378
|
: 0
|
|
358
379
|
: undefined,
|
|
359
|
-
numLocalInts: appId === 0 ? ('schema' in params ? params.schema?.localInts ?? 0 : 0) : undefined,
|
|
360
|
-
numLocalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.localByteSlices ?? 0 : 0) : undefined,
|
|
361
|
-
numGlobalInts: appId === 0 ? ('schema' in params ? params.schema?.globalInts ?? 0 : 0) : undefined,
|
|
362
|
-
numGlobalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.globalByteSlices ?? 0 : 0) : undefined,
|
|
380
|
+
numLocalInts: appId === 0 ? ('schema' in params ? (params.schema?.localInts ?? 0) : 0) : undefined,
|
|
381
|
+
numLocalByteSlices: appId === 0 ? ('schema' in params ? (params.schema?.localByteSlices ?? 0) : 0) : undefined,
|
|
382
|
+
numGlobalInts: appId === 0 ? ('schema' in params ? (params.schema?.globalInts ?? 0) : 0) : undefined,
|
|
383
|
+
numGlobalByteSlices: appId === 0 ? ('schema' in params ? (params.schema?.globalByteSlices ?? 0) : 0) : undefined,
|
|
363
384
|
method: params.method,
|
|
364
385
|
signer: includeSigner
|
|
365
386
|
? params.signer
|
|
@@ -367,8 +388,8 @@ class AlgoKitComposer {
|
|
|
367
388
|
? params.signer.signer
|
|
368
389
|
: params.signer
|
|
369
390
|
: this.getSigner(params.sender)
|
|
370
|
-
:
|
|
371
|
-
methodArgs: methodArgs,
|
|
391
|
+
: TransactionComposer.NULL_SIGNER,
|
|
392
|
+
methodArgs: methodArgs.reverse(),
|
|
372
393
|
// note, lease, and rekeyTo are set in the common build step
|
|
373
394
|
note: undefined,
|
|
374
395
|
lease: undefined,
|
|
@@ -481,12 +502,12 @@ class AlgoKitComposer {
|
|
|
481
502
|
txn = algosdk.makeApplicationCreateTxnFromObject({
|
|
482
503
|
...sdkParams,
|
|
483
504
|
extraPages: 'extraProgramPages' in params
|
|
484
|
-
? params.extraProgramPages ?? Math.floor((approvalProgram.length + clearStateProgram.length) / APP_PAGE_MAX_SIZE)
|
|
505
|
+
? (params.extraProgramPages ?? Math.floor((approvalProgram.length + clearStateProgram.length) / APP_PAGE_MAX_SIZE))
|
|
485
506
|
: 0,
|
|
486
|
-
numLocalInts: 'schema' in params ? params.schema?.localInts ?? 0 : 0,
|
|
487
|
-
numLocalByteSlices: 'schema' in params ? params.schema?.localByteSlices ?? 0 : 0,
|
|
488
|
-
numGlobalInts: 'schema' in params ? params.schema?.globalInts ?? 0 : 0,
|
|
489
|
-
numGlobalByteSlices: 'schema' in params ? params.schema?.globalByteSlices ?? 0 : 0,
|
|
507
|
+
numLocalInts: 'schema' in params ? (params.schema?.localInts ?? 0) : 0,
|
|
508
|
+
numLocalByteSlices: 'schema' in params ? (params.schema?.localByteSlices ?? 0) : 0,
|
|
509
|
+
numGlobalInts: 'schema' in params ? (params.schema?.globalInts ?? 0) : 0,
|
|
510
|
+
numGlobalByteSlices: 'schema' in params ? (params.schema?.globalByteSlices ?? 0) : 0,
|
|
490
511
|
approvalProgram: approvalProgram,
|
|
491
512
|
clearProgram: clearStateProgram,
|
|
492
513
|
});
|
|
@@ -497,7 +518,32 @@ class AlgoKitComposer {
|
|
|
497
518
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
498
519
|
}
|
|
499
520
|
buildKeyReg(params, suggestedParams) {
|
|
500
|
-
|
|
521
|
+
let txn;
|
|
522
|
+
if ('voteKey' in params) {
|
|
523
|
+
// algosdk throws when voteFirst is 0, so we need to set it to 1, then switch back to 0 after creating the transaction
|
|
524
|
+
const voteFirst = params.voteFirst === 0n ? 1n : params.voteFirst;
|
|
525
|
+
txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({
|
|
526
|
+
from: params.sender,
|
|
527
|
+
voteKey: params.voteKey,
|
|
528
|
+
selectionKey: params.selectionKey,
|
|
529
|
+
voteFirst: Number(voteFirst),
|
|
530
|
+
voteLast: Number(params.voteLast),
|
|
531
|
+
voteKeyDilution: Number(params.voteKeyDilution),
|
|
532
|
+
suggestedParams,
|
|
533
|
+
nonParticipation: false,
|
|
534
|
+
stateProofKey: params.stateProofKey,
|
|
535
|
+
});
|
|
536
|
+
if (params.voteFirst === 0n) {
|
|
537
|
+
txn.voteFirst = 0;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({
|
|
542
|
+
from: params.sender,
|
|
543
|
+
suggestedParams,
|
|
544
|
+
nonParticipation: params.preventAccountFromEverParticipatingAgain,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
501
547
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
502
548
|
}
|
|
503
549
|
/** Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` since those ones can have custom signers that need to be retrieved. */
|
|
@@ -564,7 +610,7 @@ class AlgoKitComposer {
|
|
|
564
610
|
: [];
|
|
565
611
|
transactions.push(...transactionsWithSigner.map((ts) => ts.txn));
|
|
566
612
|
transactionsWithSigner.forEach((ts, idx) => {
|
|
567
|
-
if (ts.signer && ts.signer !==
|
|
613
|
+
if (ts.signer && ts.signer !== TransactionComposer.NULL_SIGNER) {
|
|
568
614
|
signers.set(idx, ts.signer);
|
|
569
615
|
}
|
|
570
616
|
});
|
|
@@ -659,30 +705,60 @@ class AlgoKitComposer {
|
|
|
659
705
|
* @returns The simulation result
|
|
660
706
|
*/
|
|
661
707
|
async simulate(options) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
await
|
|
669
|
-
|
|
670
|
-
|
|
708
|
+
const atc = options?.skipSignatures ? new AtomicTransactionComposer() : this.atc;
|
|
709
|
+
// Build the transactions
|
|
710
|
+
if (options?.skipSignatures) {
|
|
711
|
+
options.allowEmptySignatures = true;
|
|
712
|
+
options.fixSigners = true;
|
|
713
|
+
// Build transactions uses empty signers
|
|
714
|
+
const transactions = await this.buildTransactions();
|
|
715
|
+
for (const txn of transactions.transactions) {
|
|
716
|
+
atc.addTransaction({ txn, signer: TransactionComposer.NULL_SIGNER });
|
|
717
|
+
}
|
|
718
|
+
atc['methodCalls'] = transactions.methodCalls;
|
|
671
719
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
720
|
+
else {
|
|
721
|
+
// Build creates real signatures
|
|
722
|
+
await this.build();
|
|
723
|
+
}
|
|
724
|
+
const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({
|
|
725
|
+
txnGroups: [],
|
|
726
|
+
...options,
|
|
727
|
+
...(Config.debug
|
|
728
|
+
? {
|
|
729
|
+
allowEmptySignatures: true,
|
|
730
|
+
fixSigners: true,
|
|
731
|
+
allowMoreLogging: true,
|
|
732
|
+
execTraceConfig: new modelsv2.SimulateTraceConfig({
|
|
733
|
+
enable: true,
|
|
734
|
+
scratchChange: true,
|
|
735
|
+
stackChange: true,
|
|
736
|
+
stateChange: true,
|
|
737
|
+
}),
|
|
738
|
+
}
|
|
739
|
+
: undefined),
|
|
740
|
+
}));
|
|
741
|
+
const failedGroup = simulateResponse?.txnGroups[0];
|
|
742
|
+
if (failedGroup?.failureMessage) {
|
|
743
|
+
const errorMessage = `Transaction failed at transaction(s) ${failedGroup.failedAt?.join(', ') || 'unknown'} in the group. ${failedGroup.failureMessage}`;
|
|
744
|
+
const error = new Error(errorMessage);
|
|
745
|
+
if (Config.debug) {
|
|
746
|
+
await Config.events.emitAsync(EventType.TxnGroupSimulated, { simulateResponse });
|
|
747
|
+
}
|
|
675
748
|
error.simulateResponse = simulateResponse;
|
|
676
749
|
throw error;
|
|
677
750
|
}
|
|
678
|
-
|
|
751
|
+
if (Config.debug && Config.traceAll) {
|
|
752
|
+
await Config.events.emitAsync(EventType.TxnGroupSimulated, { simulateResponse });
|
|
753
|
+
}
|
|
754
|
+
const transactions = atc.buildGroup().map((t) => t.txn);
|
|
679
755
|
return {
|
|
680
756
|
confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
|
|
681
757
|
transactions: transactions,
|
|
682
758
|
txIds: transactions.map((t) => t.txID()),
|
|
683
759
|
groupId: Buffer.from(transactions[0].group ?? new Uint8Array()).toString('base64'),
|
|
684
760
|
simulateResponse,
|
|
685
|
-
returns: methodResults.map(
|
|
761
|
+
returns: methodResults.map(getABIReturnValue),
|
|
686
762
|
};
|
|
687
763
|
}
|
|
688
764
|
/**
|
|
@@ -699,7 +775,7 @@ class AlgoKitComposer {
|
|
|
699
775
|
}
|
|
700
776
|
}
|
|
701
777
|
/** Signer used to represent a lack of signer */
|
|
702
|
-
|
|
778
|
+
TransactionComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
|
|
703
779
|
|
|
704
|
-
export { MAX_TRANSACTION_GROUP_SIZE,
|
|
780
|
+
export { MAX_TRANSACTION_GROUP_SIZE, TransactionComposer };
|
|
705
781
|
//# sourceMappingURL=composer.mjs.map
|