@algorandfoundation/algokit-utils 7.0.0-beta.9 → 7.0.1

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.
Files changed (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -2
  3. package/account/account.js +6 -4
  4. package/account/account.js.map +1 -1
  5. package/account/account.mjs +6 -4
  6. package/account/account.mjs.map +1 -1
  7. package/account/get-account-config-from-environment.js.map +1 -1
  8. package/account/get-account-config-from-environment.mjs.map +1 -1
  9. package/account/get-account.js.map +1 -1
  10. package/account/get-account.mjs.map +1 -1
  11. package/account/get-dispenser-account.js.map +1 -1
  12. package/account/get-dispenser-account.mjs.map +1 -1
  13. package/account/mnemonic-account.js.map +1 -1
  14. package/account/mnemonic-account.mjs.map +1 -1
  15. package/amount.js.map +1 -1
  16. package/amount.mjs.map +1 -1
  17. package/app-client.js.map +1 -1
  18. package/app-client.mjs.map +1 -1
  19. package/app-deploy.js +2 -10
  20. package/app-deploy.js.map +1 -1
  21. package/app-deploy.mjs +3 -11
  22. package/app-deploy.mjs.map +1 -1
  23. package/app.d.ts +2 -2
  24. package/app.js +2 -2
  25. package/app.js.map +1 -1
  26. package/app.mjs +2 -2
  27. package/app.mjs.map +1 -1
  28. package/asset.js.map +1 -1
  29. package/asset.mjs.map +1 -1
  30. package/debugging/debugging.js.map +1 -1
  31. package/debugging/debugging.mjs.map +1 -1
  32. package/dispenser-client.js.map +1 -1
  33. package/dispenser-client.mjs.map +1 -1
  34. package/index.d.ts +1 -0
  35. package/index.js +6 -0
  36. package/index.js.map +1 -1
  37. package/index.mjs +2 -1
  38. package/index.mjs.map +1 -1
  39. package/indexer-lookup.js.map +1 -1
  40. package/indexer-lookup.mjs.map +1 -1
  41. package/localnet/get-kmd-wallet-account.js.map +1 -1
  42. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  43. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  44. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  45. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  46. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  47. package/localnet/is-localnet.js.map +1 -1
  48. package/localnet/is-localnet.mjs.map +1 -1
  49. package/network-client.js.map +1 -1
  50. package/network-client.mjs.map +1 -1
  51. package/package.json +5 -5
  52. package/testing/account.js.map +1 -1
  53. package/testing/account.mjs.map +1 -1
  54. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  55. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  56. package/testing/fixtures/algorand-fixture.js.map +1 -1
  57. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  58. package/testing/indexer.js.map +1 -1
  59. package/testing/indexer.mjs.map +1 -1
  60. package/testing/test-logger.js.map +1 -1
  61. package/testing/test-logger.mjs.map +1 -1
  62. package/testing/transaction-logger.js.map +1 -1
  63. package/testing/transaction-logger.mjs.map +1 -1
  64. package/transaction/legacy-bridge.js +2 -2
  65. package/transaction/legacy-bridge.js.map +1 -1
  66. package/transaction/legacy-bridge.mjs +3 -3
  67. package/transaction/legacy-bridge.mjs.map +1 -1
  68. package/transaction/perform-atomic-transaction-composer-simulate.js +1 -0
  69. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  70. package/transaction/perform-atomic-transaction-composer-simulate.mjs +1 -0
  71. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  72. package/transaction/transaction.d.ts +14 -7
  73. package/transaction/transaction.js +57 -31
  74. package/transaction/transaction.js.map +1 -1
  75. package/transaction/transaction.mjs +55 -30
  76. package/transaction/transaction.mjs.map +1 -1
  77. package/transfer/transfer-algos.js.map +1 -1
  78. package/transfer/transfer-algos.mjs.map +1 -1
  79. package/transfer/transfer.js.map +1 -1
  80. package/transfer/transfer.mjs.map +1 -1
  81. package/types/account-manager.d.ts +1 -1
  82. package/types/account-manager.js +10 -8
  83. package/types/account-manager.js.map +1 -1
  84. package/types/account-manager.mjs +11 -9
  85. package/types/account-manager.mjs.map +1 -1
  86. package/types/account.d.ts +9 -0
  87. package/types/account.js.map +1 -1
  88. package/types/account.mjs.map +1 -1
  89. package/types/algo-http-client-with-retry.js.map +1 -1
  90. package/types/algo-http-client-with-retry.mjs.map +1 -1
  91. package/types/algorand-client-interface.d.ts +2 -2
  92. package/types/algorand-client-transaction-creator.d.ts +5 -3
  93. package/types/algorand-client-transaction-creator.js +3 -1
  94. package/types/algorand-client-transaction-creator.js.map +1 -1
  95. package/types/algorand-client-transaction-creator.mjs +3 -1
  96. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  97. package/types/algorand-client-transaction-sender.d.ts +12 -8
  98. package/types/algorand-client-transaction-sender.js +6 -2
  99. package/types/algorand-client-transaction-sender.js.map +1 -1
  100. package/types/algorand-client-transaction-sender.mjs +6 -2
  101. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  102. package/types/algorand-client.d.ts +3 -4
  103. package/types/algorand-client.js +2 -5
  104. package/types/algorand-client.js.map +1 -1
  105. package/types/algorand-client.mjs +4 -4
  106. package/types/algorand-client.mjs.map +1 -1
  107. package/types/amount.js.map +1 -1
  108. package/types/amount.mjs.map +1 -1
  109. package/types/app-arc56.d.ts +31 -20
  110. package/types/app-arc56.js.map +1 -1
  111. package/types/app-arc56.mjs.map +1 -1
  112. package/types/app-client.d.ts +21 -10
  113. package/types/app-client.js +143 -36
  114. package/types/app-client.js.map +1 -1
  115. package/types/app-client.mjs +141 -34
  116. package/types/app-client.mjs.map +1 -1
  117. package/types/app-deployer.js +1 -1
  118. package/types/app-deployer.js.map +1 -1
  119. package/types/app-deployer.mjs +2 -2
  120. package/types/app-deployer.mjs.map +1 -1
  121. package/types/app-factory.d.ts +32 -21
  122. package/types/app-factory.js +8 -2
  123. package/types/app-factory.js.map +1 -1
  124. package/types/app-factory.mjs +8 -2
  125. package/types/app-factory.mjs.map +1 -1
  126. package/types/app-manager.js +105 -23
  127. package/types/app-manager.js.map +1 -1
  128. package/types/app-manager.mjs +105 -23
  129. package/types/app-manager.mjs.map +1 -1
  130. package/types/app-spec.js +8 -2
  131. package/types/app-spec.js.map +1 -1
  132. package/types/app-spec.mjs +8 -2
  133. package/types/app-spec.mjs.map +1 -1
  134. package/types/app.d.ts +8 -7
  135. package/types/app.js.map +1 -1
  136. package/types/app.mjs.map +1 -1
  137. package/types/asset-manager.d.ts +4 -4
  138. package/types/asset-manager.js +2 -2
  139. package/types/asset-manager.js.map +1 -1
  140. package/types/asset-manager.mjs +2 -2
  141. package/types/asset-manager.mjs.map +1 -1
  142. package/types/async-event-emitter.d.ts +1 -10
  143. package/types/async-event-emitter.js +0 -5
  144. package/types/async-event-emitter.js.map +1 -1
  145. package/types/async-event-emitter.mjs +1 -6
  146. package/types/async-event-emitter.mjs.map +1 -1
  147. package/types/client-manager.js +2 -2
  148. package/types/client-manager.js.map +1 -1
  149. package/types/client-manager.mjs +2 -2
  150. package/types/client-manager.mjs.map +1 -1
  151. package/types/composer.d.ts +56 -30
  152. package/types/composer.js +103 -47
  153. package/types/composer.js.map +1 -1
  154. package/types/composer.mjs +104 -46
  155. package/types/composer.mjs.map +1 -1
  156. package/types/config.d.ts +0 -4
  157. package/types/config.js.map +1 -1
  158. package/types/config.mjs.map +1 -1
  159. package/types/debugging.d.ts +1 -1
  160. package/types/debugging.js +1 -1
  161. package/types/debugging.js.map +1 -1
  162. package/types/debugging.mjs +1 -1
  163. package/types/debugging.mjs.map +1 -1
  164. package/types/dispenser-client.js.map +1 -1
  165. package/types/dispenser-client.mjs.map +1 -1
  166. package/types/indexer.js.map +1 -1
  167. package/types/indexer.mjs.map +1 -1
  168. package/types/kmd-account-manager.js +1 -1
  169. package/types/kmd-account-manager.js.map +1 -1
  170. package/types/kmd-account-manager.mjs +2 -2
  171. package/types/kmd-account-manager.mjs.map +1 -1
  172. package/types/lifecycle-events.d.ts +10 -0
  173. package/types/lifecycle-events.js +8 -0
  174. package/types/lifecycle-events.js.map +1 -0
  175. package/types/lifecycle-events.mjs +8 -0
  176. package/types/lifecycle-events.mjs.map +1 -0
  177. package/types/logging.js.map +1 -1
  178. package/types/logging.mjs.map +1 -1
  179. package/types/logic-error.d.ts +2 -3
  180. package/types/logic-error.js +3 -3
  181. package/types/logic-error.js.map +1 -1
  182. package/types/logic-error.mjs +3 -3
  183. package/types/logic-error.mjs.map +1 -1
  184. package/types/network-client.js.map +1 -1
  185. package/types/network-client.mjs.map +1 -1
  186. package/types/testing.d.ts +1 -1
  187. package/types/transaction.d.ts +1 -1
  188. package/types/urlTokenBaseHTTPClient.js.map +1 -1
  189. package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
  190. package/util.js.map +1 -1
  191. package/util.mjs.map +1 -1
@@ -1,10 +1,9 @@
1
1
  import algosdk from 'algosdk';
2
2
  import { Config } from '../config.mjs';
3
- import { performAtomicTransactionComposerSimulate } from '../transaction/perform-atomic-transaction-composer-simulate.mjs';
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 './async-event-emitter.mjs';
6
+ import { EventType } from './lifecycle-events.mjs';
8
7
  import { genesisIdIsLocalNet } from './network-client.mjs';
9
8
 
10
9
  var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
@@ -12,10 +11,10 @@ var isTransactionWithSigner = algosdk.isTransactionWithSigner;
12
11
  var encodeAddress = algosdk.encodeAddress;
13
12
  var modelsv2 = algosdk.modelsv2;
14
13
  const MAX_TRANSACTION_GROUP_SIZE = 16;
15
- /** AlgoKit Composer helps you compose and execute transactions as a transaction group. */
16
- class AlgoKitComposer {
14
+ /** TransactionComposer helps you compose and execute transactions as a transaction group. */
15
+ class TransactionComposer {
17
16
  /**
18
- * Create an `AlgoKitComposer`.
17
+ * Create a `TransactionComposer`.
19
18
  * @param params The configuration for this composer
20
19
  */
21
20
  constructor(params) {
@@ -222,6 +221,15 @@ class AlgoKitComposer {
222
221
  this.txns.push({ ...params, type: 'keyReg' });
223
222
  return this;
224
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
+ }
225
233
  /**
226
234
  * Add the transactions within an `AtomicTransactionComposer` to the transaction group.
227
235
  * @param atc The `AtomicTransactionComposer` to build transactions from and add to the group
@@ -235,7 +243,7 @@ class AlgoKitComposer {
235
243
  buildAtc(atc, processTransaction) {
236
244
  const group = atc.buildGroup();
237
245
  const txnWithSigners = group.map((ts, idx) => {
238
- // Remove underlying group ID from the transaction since it will be re-grouped when this AlgoKitComposer is built
246
+ // Remove underlying group ID from the transaction since it will be re-grouped when this TransactionComposer is built
239
247
  ts.txn.group = undefined;
240
248
  // Process transaction if a function is provided
241
249
  ts.txn = processTransaction?.(ts.txn, idx) ?? ts.txn;
@@ -292,14 +300,22 @@ class AlgoKitComposer {
292
300
  */
293
301
  async buildMethodCall(params, suggestedParams, includeSigner) {
294
302
  const methodArgs = [];
303
+ const transactionsForGroup = [];
295
304
  const isAbiValue = (x) => {
296
305
  if (Array.isArray(x))
297
306
  return x.length == 0 || x.every(isAbiValue);
298
307
  return typeof x === 'bigint' || typeof x === 'boolean' || typeof x === 'number' || typeof x === 'string' || x instanceof Uint8Array;
299
308
  };
300
- for (let i = 0; i < (params.args ?? []).length; i++) {
309
+ for (let i = (params.args ?? []).length - 1; i >= 0; i--) {
301
310
  const arg = params.args[i];
302
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
+ }
303
319
  throw Error(`No value provided for argument ${i + 1} within call to ${params.method.name}`);
304
320
  }
305
321
  if (isAbiValue(arg)) {
@@ -312,7 +328,10 @@ class AlgoKitComposer {
312
328
  }
313
329
  if ('method' in arg) {
314
330
  const tempTxnWithSigners = await this.buildMethodCall(arg, suggestedParams, includeSigner);
315
- methodArgs.push(...tempTxnWithSigners);
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
316
335
  continue;
317
336
  }
318
337
  const txn = await arg;
@@ -324,10 +343,11 @@ class AlgoKitComposer {
324
343
  ? params.signer.signer
325
344
  : params.signer
326
345
  : this.getSigner(encodeAddress(txn.from.publicKey))
327
- : AlgoKitComposer.NULL_SIGNER,
346
+ : TransactionComposer.NULL_SIGNER,
328
347
  });
329
348
  }
330
349
  const methodAtc = new algosdk.AtomicTransactionComposer();
350
+ transactionsForGroup.reverse().forEach((txn) => methodAtc.addTransaction(txn));
331
351
  const appId = Number('appId' in params ? params.appId : 0n);
332
352
  const approvalProgram = 'approvalProgram' in params
333
353
  ? typeof params.approvalProgram === 'string'
@@ -357,10 +377,10 @@ class AlgoKitComposer {
357
377
  ? Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0)) / APP_PAGE_MAX_SIZE)
358
378
  : 0
359
379
  : undefined,
360
- numLocalInts: appId === 0 ? ('schema' in params ? params.schema?.localInts ?? 0 : 0) : undefined,
361
- numLocalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.localByteSlices ?? 0 : 0) : undefined,
362
- numGlobalInts: appId === 0 ? ('schema' in params ? params.schema?.globalInts ?? 0 : 0) : undefined,
363
- 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,
364
384
  method: params.method,
365
385
  signer: includeSigner
366
386
  ? params.signer
@@ -368,8 +388,8 @@ class AlgoKitComposer {
368
388
  ? params.signer.signer
369
389
  : params.signer
370
390
  : this.getSigner(params.sender)
371
- : AlgoKitComposer.NULL_SIGNER,
372
- methodArgs: methodArgs,
391
+ : TransactionComposer.NULL_SIGNER,
392
+ methodArgs: methodArgs.reverse(),
373
393
  // note, lease, and rekeyTo are set in the common build step
374
394
  note: undefined,
375
395
  lease: undefined,
@@ -482,12 +502,12 @@ class AlgoKitComposer {
482
502
  txn = algosdk.makeApplicationCreateTxnFromObject({
483
503
  ...sdkParams,
484
504
  extraPages: 'extraProgramPages' in params
485
- ? 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))
486
506
  : 0,
487
- numLocalInts: 'schema' in params ? params.schema?.localInts ?? 0 : 0,
488
- numLocalByteSlices: 'schema' in params ? params.schema?.localByteSlices ?? 0 : 0,
489
- numGlobalInts: 'schema' in params ? params.schema?.globalInts ?? 0 : 0,
490
- 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,
491
511
  approvalProgram: approvalProgram,
492
512
  clearProgram: clearStateProgram,
493
513
  });
@@ -498,7 +518,32 @@ class AlgoKitComposer {
498
518
  return this.commonTxnBuildStep(params, txn, suggestedParams);
499
519
  }
500
520
  buildKeyReg(params, suggestedParams) {
501
- const txn = algosdk.makeKeyRegistrationTxnWithSuggestedParams(params.sender, undefined, params.voteKey, params.selectionKey, Number(params.voteFirst), Number(params.voteLast), Number(params.voteKeyDilution), suggestedParams, undefined, false, params.stateProofKey);
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
+ }
502
547
  return this.commonTxnBuildStep(params, txn, suggestedParams);
503
548
  }
504
549
  /** Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` since those ones can have custom signers that need to be retrieved. */
@@ -565,7 +610,7 @@ class AlgoKitComposer {
565
610
  : [];
566
611
  transactions.push(...transactionsWithSigner.map((ts) => ts.txn));
567
612
  transactionsWithSigner.forEach((ts, idx) => {
568
- if (ts.signer && ts.signer !== AlgoKitComposer.NULL_SIGNER) {
613
+ if (ts.signer && ts.signer !== TransactionComposer.NULL_SIGNER) {
569
614
  signers.set(idx, ts.signer);
570
615
  }
571
616
  });
@@ -655,19 +700,17 @@ class AlgoKitComposer {
655
700
  async execute(params) {
656
701
  return this.send(params);
657
702
  }
658
- /**
659
- * Compose the atomic transaction group and simulate sending it to the network
660
- * @returns The simulation result
661
- */
662
703
  async simulate(options) {
663
- const atc = options?.skipSignatures ? new AtomicTransactionComposer() : this.atc;
704
+ const { skipSignatures = false, ...rawOptions } = options ?? {};
705
+ const atc = skipSignatures ? new AtomicTransactionComposer() : this.atc;
664
706
  // Build the transactions
665
- if (options?.skipSignatures) {
666
- options.allowEmptySignatures = true;
707
+ if (skipSignatures) {
708
+ rawOptions.allowEmptySignatures = true;
709
+ rawOptions.fixSigners = true;
667
710
  // Build transactions uses empty signers
668
711
  const transactions = await this.buildTransactions();
669
712
  for (const txn of transactions.transactions) {
670
- atc.addTransaction({ txn, signer: AlgoKitComposer.NULL_SIGNER });
713
+ atc.addTransaction({ txn, signer: TransactionComposer.NULL_SIGNER });
671
714
  }
672
715
  atc['methodCalls'] = transactions.methodCalls;
673
716
  }
@@ -675,21 +718,36 @@ class AlgoKitComposer {
675
718
  // Build creates real signatures
676
719
  await this.build();
677
720
  }
678
- if (Config.debug && !Config.traceAll) {
679
- // Dump the traces to a file for use with AlgoKit AVM debugger
680
- // Checks for false on traceAll because it should have been already
681
- // executed above
682
- const simulateResponse = await performAtomicTransactionComposerSimulate(atc, this.algod);
683
- await Config.events.emitAsync(EventType.TxnGroupSimulated, {
684
- simulateResponse,
685
- });
686
- }
687
- const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({ txnGroups: [], ...options }));
688
- if (simulateResponse && simulateResponse.txnGroups[0].failedAt) {
689
- const error = new Error(`Transaction failed at transaction(s) ${simulateResponse.txnGroups[0].failedAt.join(', ')} in the group. ${simulateResponse.txnGroups.find((x) => x.failureMessage)?.failureMessage}`);
721
+ const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({
722
+ txnGroups: [],
723
+ ...rawOptions,
724
+ ...(Config.debug
725
+ ? {
726
+ allowEmptySignatures: true,
727
+ fixSigners: true,
728
+ allowMoreLogging: true,
729
+ execTraceConfig: new modelsv2.SimulateTraceConfig({
730
+ enable: true,
731
+ scratchChange: true,
732
+ stackChange: true,
733
+ stateChange: true,
734
+ }),
735
+ }
736
+ : undefined),
737
+ }));
738
+ const failedGroup = simulateResponse?.txnGroups[0];
739
+ if (failedGroup?.failureMessage) {
740
+ const errorMessage = `Transaction failed at transaction(s) ${failedGroup.failedAt?.join(', ') || 'unknown'} in the group. ${failedGroup.failureMessage}`;
741
+ const error = new Error(errorMessage);
742
+ if (Config.debug) {
743
+ await Config.events.emitAsync(EventType.TxnGroupSimulated, { simulateResponse });
744
+ }
690
745
  error.simulateResponse = simulateResponse;
691
746
  throw error;
692
747
  }
748
+ if (Config.debug && Config.traceAll) {
749
+ await Config.events.emitAsync(EventType.TxnGroupSimulated, { simulateResponse });
750
+ }
693
751
  const transactions = atc.buildGroup().map((t) => t.txn);
694
752
  return {
695
753
  confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
@@ -697,7 +755,7 @@ class AlgoKitComposer {
697
755
  txIds: transactions.map((t) => t.txID()),
698
756
  groupId: Buffer.from(transactions[0].group ?? new Uint8Array()).toString('base64'),
699
757
  simulateResponse,
700
- returns: methodResults.map((m) => m),
758
+ returns: methodResults.map(getABIReturnValue),
701
759
  };
702
760
  }
703
761
  /**
@@ -714,7 +772,7 @@ class AlgoKitComposer {
714
772
  }
715
773
  }
716
774
  /** Signer used to represent a lack of signer */
717
- AlgoKitComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
775
+ TransactionComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
718
776
 
719
- export { MAX_TRANSACTION_GROUP_SIZE, AlgoKitComposer as default };
777
+ export { MAX_TRANSACTION_GROUP_SIZE, TransactionComposer };
720
778
  //# sourceMappingURL=composer.mjs.map