@algorandfoundation/algokit-utils 7.0.0 → 8.0.0-beta.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 (148) hide show
  1. package/README.md +14 -3
  2. package/account/account.d.ts +4 -1
  3. package/account/account.js +4 -3
  4. package/account/account.js.map +1 -1
  5. package/account/account.mjs +5 -4
  6. package/account/account.mjs.map +1 -1
  7. package/account/get-dispenser-account.d.ts +1 -1
  8. package/amount.d.ts +1 -0
  9. package/amount.js +3 -2
  10. package/amount.js.map +1 -1
  11. package/amount.mjs +3 -3
  12. package/amount.mjs.map +1 -1
  13. package/app-client.d.ts +4 -4
  14. package/app-client.js +4 -4
  15. package/app-client.js.map +1 -1
  16. package/app-client.mjs +4 -4
  17. package/app-client.mjs.map +1 -1
  18. package/app-deploy.js +23 -5
  19. package/app-deploy.js.map +1 -1
  20. package/app-deploy.mjs +24 -6
  21. package/app-deploy.mjs.map +1 -1
  22. package/app.js +7 -4
  23. package/app.js.map +1 -1
  24. package/app.mjs +7 -4
  25. package/app.mjs.map +1 -1
  26. package/index.js +1 -1
  27. package/index.mjs +2 -2
  28. package/indexer-lookup.d.ts +10 -8
  29. package/indexer-lookup.js +14 -10
  30. package/indexer-lookup.js.map +1 -1
  31. package/indexer-lookup.mjs +14 -10
  32. package/indexer-lookup.mjs.map +1 -1
  33. package/network-client.d.ts +1 -7
  34. package/network-client.js +2 -9
  35. package/network-client.js.map +1 -1
  36. package/network-client.mjs +2 -9
  37. package/network-client.mjs.map +1 -1
  38. package/package.json +2 -2
  39. package/testing/_asset.d.ts +2 -1
  40. package/testing/account.d.ts +4 -3
  41. package/testing/account.js +8 -2
  42. package/testing/account.js.map +1 -1
  43. package/testing/account.mjs +9 -3
  44. package/testing/account.mjs.map +1 -1
  45. package/testing/fixtures/algorand-fixture.js +5 -6
  46. package/testing/fixtures/algorand-fixture.js.map +1 -1
  47. package/testing/fixtures/algorand-fixture.mjs +5 -6
  48. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  49. package/testing/test-logger.js +7 -1
  50. package/testing/test-logger.js.map +1 -1
  51. package/testing/test-logger.mjs +7 -1
  52. package/testing/test-logger.mjs.map +1 -1
  53. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -1
  54. package/transaction/perform-atomic-transaction-composer-simulate.js +14 -10
  55. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  56. package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -11
  57. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  58. package/transaction/transaction.d.ts +1 -17
  59. package/transaction/transaction.js +110 -82
  60. package/transaction/transaction.js.map +1 -1
  61. package/transaction/transaction.mjs +112 -83
  62. package/transaction/transaction.mjs.map +1 -1
  63. package/transfer/transfer.js +3 -1
  64. package/transfer/transfer.js.map +1 -1
  65. package/transfer/transfer.mjs +3 -1
  66. package/transfer/transfer.mjs.map +1 -1
  67. package/types/account-manager.d.ts +20 -20
  68. package/types/account-manager.js +27 -20
  69. package/types/account-manager.js.map +1 -1
  70. package/types/account-manager.mjs +28 -21
  71. package/types/account-manager.mjs.map +1 -1
  72. package/types/account.d.ts +8 -8
  73. package/types/account.js +2 -2
  74. package/types/account.js.map +1 -1
  75. package/types/account.mjs +3 -3
  76. package/types/account.mjs.map +1 -1
  77. package/types/algo-http-client-with-retry.d.ts +1 -2
  78. package/types/algo-http-client-with-retry.js +33 -3
  79. package/types/algo-http-client-with-retry.js.map +1 -1
  80. package/types/algo-http-client-with-retry.mjs +32 -2
  81. package/types/algo-http-client-with-retry.mjs.map +1 -1
  82. package/types/algorand-client-transaction-creator.d.ts +11 -11
  83. package/types/algorand-client-transaction-sender.d.ts +97 -97
  84. package/types/algorand-client-transaction-sender.js.map +1 -1
  85. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  86. package/types/algorand-client.d.ts +3 -3
  87. package/types/algorand-client.js +1 -1
  88. package/types/algorand-client.js.map +1 -1
  89. package/types/algorand-client.mjs +1 -1
  90. package/types/algorand-client.mjs.map +1 -1
  91. package/types/app-client.d.ts +280 -279
  92. package/types/app-client.js +10 -10
  93. package/types/app-client.js.map +1 -1
  94. package/types/app-client.mjs +11 -11
  95. package/types/app-client.mjs.map +1 -1
  96. package/types/app-deployer.d.ts +4 -4
  97. package/types/app-deployer.js +22 -23
  98. package/types/app-deployer.js.map +1 -1
  99. package/types/app-deployer.mjs +23 -24
  100. package/types/app-deployer.mjs.map +1 -1
  101. package/types/app-factory.d.ts +128 -138
  102. package/types/app-factory.js +4 -3
  103. package/types/app-factory.js.map +1 -1
  104. package/types/app-factory.mjs +5 -4
  105. package/types/app-factory.mjs.map +1 -1
  106. package/types/app-manager.d.ts +5 -5
  107. package/types/app-manager.js +11 -15
  108. package/types/app-manager.js.map +1 -1
  109. package/types/app-manager.mjs +12 -16
  110. package/types/app-manager.mjs.map +1 -1
  111. package/types/app.d.ts +4 -4
  112. package/types/app.js.map +1 -1
  113. package/types/app.mjs.map +1 -1
  114. package/types/asset-manager.d.ts +5 -5
  115. package/types/asset-manager.js +8 -11
  116. package/types/asset-manager.js.map +1 -1
  117. package/types/asset-manager.mjs +8 -11
  118. package/types/asset-manager.mjs.map +1 -1
  119. package/types/client-manager.d.ts +2 -9
  120. package/types/client-manager.js +9 -19
  121. package/types/client-manager.js.map +1 -1
  122. package/types/client-manager.mjs +9 -19
  123. package/types/client-manager.mjs.map +1 -1
  124. package/types/composer.d.ts +22 -22
  125. package/types/composer.js +73 -83
  126. package/types/composer.js.map +1 -1
  127. package/types/composer.mjs +74 -84
  128. package/types/composer.mjs.map +1 -1
  129. package/types/dispenser-client.d.ts +2 -1
  130. package/types/dispenser-client.js +5 -1
  131. package/types/dispenser-client.js.map +1 -1
  132. package/types/dispenser-client.mjs +5 -1
  133. package/types/dispenser-client.mjs.map +1 -1
  134. package/types/indexer.d.ts +74 -755
  135. package/types/indexer.js.map +1 -1
  136. package/types/indexer.mjs.map +1 -1
  137. package/types/kmd-account-manager.d.ts +2 -2
  138. package/types/kmd-account-manager.js.map +1 -1
  139. package/types/kmd-account-manager.mjs.map +1 -1
  140. package/types/network-client.d.ts +1 -1
  141. package/types/network-client.js.map +1 -1
  142. package/types/network-client.mjs.map +1 -1
  143. package/types/testing.d.ts +5 -6
  144. package/types/urlTokenBaseHTTPClient.d.ts +0 -40
  145. package/types/urlTokenBaseHTTPClient.js +0 -153
  146. package/types/urlTokenBaseHTTPClient.js.map +0 -1
  147. package/types/urlTokenBaseHTTPClient.mjs +0 -151
  148. package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import algosdk from 'algosdk';
1
+ import algosdk, { TransactionType, stringifyJSON, Address } from 'algosdk';
2
2
  import { Buffer } from 'buffer';
3
3
  import { Config } from '../config.mjs';
4
4
  import { EventType } from '../types/lifecycle-events.mjs';
@@ -6,7 +6,6 @@ import { toNumber } from '../util.mjs';
6
6
  import { performAtomicTransactionComposerSimulate } from './perform-atomic-transaction-composer-simulate.mjs';
7
7
 
8
8
  var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
9
- var modelsv2 = algosdk.modelsv2;
10
9
  const MAX_TRANSACTION_GROUP_SIZE = 16;
11
10
  const MAX_APP_CALL_FOREIGN_REFERENCES = 8;
12
11
  const MAX_APP_CALL_ACCOUNT_REFERENCES = 4;
@@ -87,7 +86,7 @@ function encodeLease(lease) {
87
86
  * @returns The public address
88
87
  */
89
88
  const getSenderAddress = function (sender) {
90
- return typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr : sender.address();
89
+ return typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr.toString() : sender.address().toString();
91
90
  };
92
91
  /**
93
92
  * @deprecated Use `AlgorandClient` / `TransactionComposer` to construct transactions instead or
@@ -260,7 +259,7 @@ async function populateAppCallResources(atc, algod) {
260
259
  const unnamedResourcesAccessed = await getUnnamedAppCallResourcesAccessed(atc, algod);
261
260
  const group = atc.buildGroup();
262
261
  unnamedResourcesAccessed.txns.forEach((r, i) => {
263
- if (r === undefined)
262
+ if (r === undefined || group[i].txn.type !== TransactionType.appl)
264
263
  return;
265
264
  if (r.boxes || r.extraBoxRefs)
266
265
  throw Error('Unexpected boxes at the transaction level');
@@ -268,22 +267,19 @@ async function populateAppCallResources(atc, algod) {
268
267
  throw Error('Unexpected app local at the transaction level');
269
268
  if (r.assetHoldings)
270
269
  throw Error('Unexpected asset holding at the transaction level');
271
- // Do accounts first because the account limit is 4
272
- r.accounts?.forEach((a) => {
273
- group[i].txn.appAccounts = [...(group[i].txn.appAccounts ?? []), algosdk.decodeAddress(a)];
274
- });
275
- r.apps?.forEach((a) => {
276
- group[i].txn.appForeignApps = [...(group[i].txn.appForeignApps ?? []), Number(a)];
277
- });
278
- r.assets?.forEach((a) => {
279
- group[i].txn.appForeignAssets = [...(group[i].txn.appForeignAssets ?? []), Number(a)];
280
- });
281
- const accounts = group[i].txn.appAccounts?.length || 0;
270
+ group[i].txn['applicationCall'] = {
271
+ ...group[i].txn.applicationCall,
272
+ accounts: [...(group[i].txn?.applicationCall?.accounts ?? []), ...(r.accounts ?? [])],
273
+ foreignApps: [...(group[i].txn?.applicationCall?.foreignApps ?? []), ...(r.apps ?? [])],
274
+ foreignAssets: [...(group[i].txn?.applicationCall?.foreignAssets ?? []), ...(r.assets ?? [])],
275
+ boxes: [...(group[i].txn?.applicationCall?.boxes ?? []), ...(r.boxes ?? [])],
276
+ };
277
+ const accounts = group[i].txn.applicationCall?.accounts?.length ?? 0;
282
278
  if (accounts > MAX_APP_CALL_ACCOUNT_REFERENCES)
283
279
  throw Error(`Account reference limit of ${MAX_APP_CALL_ACCOUNT_REFERENCES} exceeded in transaction ${i}`);
284
- const assets = group[i].txn.appForeignAssets?.length || 0;
285
- const apps = group[i].txn.appForeignApps?.length || 0;
286
- const boxes = group[i].txn.boxes?.length || 0;
280
+ const assets = group[i].txn.applicationCall?.foreignAssets?.length ?? 0;
281
+ const apps = group[i].txn.applicationCall?.foreignApps?.length ?? 0;
282
+ const boxes = group[i].txn.applicationCall?.boxes?.length ?? 0;
287
283
  if (accounts + assets + apps + boxes > MAX_APP_CALL_FOREIGN_REFERENCES) {
288
284
  throw Error(`Resource reference limit of ${MAX_APP_CALL_FOREIGN_REFERENCES} exceeded in transaction ${i}`);
289
285
  }
@@ -292,10 +288,10 @@ async function populateAppCallResources(atc, algod) {
292
288
  const isApplBelowLimit = (t) => {
293
289
  if (t.txn.type !== algosdk.TransactionType.appl)
294
290
  return false;
295
- const accounts = t.txn.appAccounts?.length || 0;
296
- const assets = t.txn.appForeignAssets?.length || 0;
297
- const apps = t.txn.appForeignApps?.length || 0;
298
- const boxes = t.txn.boxes?.length || 0;
291
+ const accounts = t.txn.applicationCall?.accounts?.length ?? 0;
292
+ const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0;
293
+ const apps = t.txn.applicationCall?.foreignApps?.length ?? 0;
294
+ const boxes = t.txn.applicationCall?.boxes?.length ?? 0;
299
295
  return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES;
300
296
  };
301
297
  // If this is a asset holding or app local, first try to find a transaction that already has the account available
@@ -306,22 +302,26 @@ async function populateAppCallResources(atc, algod) {
306
302
  return false;
307
303
  return (
308
304
  // account is in the foreign accounts array
309
- t.txn.appAccounts?.map((a) => algosdk.encodeAddress(a.publicKey)).includes(account) ||
305
+ t.txn.applicationCall?.accounts?.map((a) => a.toString()).includes(account.toString()) ||
310
306
  // account is available as an app account
311
- t.txn.appForeignApps?.map((a) => algosdk.getApplicationAddress(a)).includes(account) ||
307
+ t.txn.applicationCall?.foreignApps?.map((a) => algosdk.getApplicationAddress(a).toString()).includes(account.toString()) ||
312
308
  // account is available since it's in one of the fields
313
- Object.values(t.txn)
314
- .map((f) => JSON.stringify(f))
315
- .includes(JSON.stringify(algosdk.decodeAddress(account))));
309
+ Object.values(t.txn).some((f) => stringifyJSON(f, (_, v) => (v instanceof Address ? v.toString() : v))?.includes(account.toString())));
316
310
  });
317
311
  if (txnIndex > -1) {
318
312
  if (type === 'assetHolding') {
319
313
  const { asset } = reference;
320
- txns[txnIndex].txn.appForeignAssets = [...(txns[txnIndex].txn.appForeignAssets ?? []), Number(asset)];
314
+ txns[txnIndex].txn['applicationCall'] = {
315
+ ...txns[txnIndex].txn.applicationCall,
316
+ foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],
317
+ };
321
318
  }
322
319
  else {
323
320
  const { app } = reference;
324
- txns[txnIndex].txn.appForeignApps = [...(txns[txnIndex].txn.appForeignApps ?? []), Number(app)];
321
+ txns[txnIndex].txn['applicationCall'] = {
322
+ ...txns[txnIndex].txn.applicationCall,
323
+ foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
324
+ };
325
325
  }
326
326
  return;
327
327
  }
@@ -330,20 +330,23 @@ async function populateAppCallResources(atc, algod) {
330
330
  if (!isApplBelowLimit(t))
331
331
  return false;
332
332
  // check if there is space in the accounts array
333
- if ((t.txn.appAccounts?.length || 0) >= MAX_APP_CALL_ACCOUNT_REFERENCES)
333
+ if ((t.txn.applicationCall?.accounts?.length ?? 0) >= MAX_APP_CALL_ACCOUNT_REFERENCES)
334
334
  return false;
335
335
  if (type === 'assetHolding') {
336
336
  const { asset } = reference;
337
- return t.txn.appForeignAssets?.includes(Number(asset));
337
+ return t.txn.applicationCall?.foreignAssets?.includes(asset);
338
338
  }
339
339
  else {
340
340
  const { app } = reference;
341
- return t.txn.appForeignApps?.includes(Number(app)) || t.txn.appIndex === Number(app);
341
+ return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app;
342
342
  }
343
343
  });
344
344
  if (txnIndex > -1) {
345
345
  const { account } = reference;
346
- txns[txnIndex].txn.appAccounts = [...(txns[txnIndex].txn.appAccounts ?? []), algosdk.decodeAddress(account)];
346
+ txns[txnIndex].txn['applicationCall'] = {
347
+ ...txns[txnIndex].txn.applicationCall,
348
+ accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
349
+ };
347
350
  return;
348
351
  }
349
352
  }
@@ -354,10 +357,13 @@ async function populateAppCallResources(atc, algod) {
354
357
  if (!isApplBelowLimit(t))
355
358
  return false;
356
359
  // If the app is in the foreign array OR the app being called, then we know it's available
357
- return t.txn.appForeignApps?.includes(Number(app)) || t.txn.appIndex === Number(app);
360
+ return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app;
358
361
  });
359
362
  if (txnIndex > -1) {
360
- txns[txnIndex].txn.boxes = [...(txns[txnIndex].txn.boxes ?? []), { appIndex: Number(app), name }];
363
+ txns[txnIndex].txn['applicationCall'] = {
364
+ ...txns[txnIndex].txn.applicationCall,
365
+ boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name }]],
366
+ };
361
367
  return;
362
368
  }
363
369
  }
@@ -365,12 +371,12 @@ async function populateAppCallResources(atc, algod) {
365
371
  const txnIndex = txns.findIndex((t) => {
366
372
  if (t.txn.type !== algosdk.TransactionType.appl)
367
373
  return false;
368
- const accounts = t.txn.appAccounts?.length || 0;
374
+ const accounts = t.txn.applicationCall?.accounts?.length ?? 0;
369
375
  if (type === 'account')
370
376
  return accounts < MAX_APP_CALL_ACCOUNT_REFERENCES;
371
- const assets = t.txn.appForeignAssets?.length || 0;
372
- const apps = t.txn.appForeignApps?.length || 0;
373
- const boxes = t.txn.boxes?.length || 0;
377
+ const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0;
378
+ const apps = t.txn.applicationCall?.foreignApps?.length ?? 0;
379
+ const boxes = t.txn.applicationCall?.boxes?.length ?? 0;
374
380
  // If we're adding local state or asset holding, we need space for the acocunt and the other reference
375
381
  if (type === 'assetHolding' || type === 'appLocal') {
376
382
  return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES - 1 && accounts < MAX_APP_CALL_ACCOUNT_REFERENCES;
@@ -385,30 +391,57 @@ async function populateAppCallResources(atc, algod) {
385
391
  throw Error('No more transactions below reference limit. Add another app call to the group.');
386
392
  }
387
393
  if (type === 'account') {
388
- txns[txnIndex].txn.appAccounts = [...(txns[txnIndex].txn.appAccounts ?? []), algosdk.decodeAddress(reference)];
394
+ txns[txnIndex].txn['applicationCall'] = {
395
+ ...txns[txnIndex].txn.applicationCall,
396
+ accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[reference]],
397
+ };
389
398
  }
390
399
  else if (type === 'app') {
391
- txns[txnIndex].txn.appForeignApps = [...(txns[txnIndex].txn.appForeignApps ?? []), Number(reference)];
400
+ txns[txnIndex].txn['applicationCall'] = {
401
+ ...txns[txnIndex].txn.applicationCall,
402
+ foreignApps: [
403
+ ...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []),
404
+ ...[typeof reference === 'bigint' ? reference : BigInt(reference)],
405
+ ],
406
+ };
392
407
  }
393
408
  else if (type === 'box') {
394
409
  const { app, name } = reference;
395
- txns[txnIndex].txn.boxes = [...(txns[txnIndex].txn.boxes ?? []), { appIndex: Number(app), name }];
410
+ txns[txnIndex].txn['applicationCall'] = {
411
+ ...txns[txnIndex].txn.applicationCall,
412
+ boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name }]],
413
+ };
396
414
  if (app.toString() !== '0') {
397
- txns[txnIndex].txn.appForeignApps = [...(txns[txnIndex].txn.appForeignApps ?? []), Number(app)];
415
+ txns[txnIndex].txn['applicationCall'] = {
416
+ ...txns[txnIndex].txn.applicationCall,
417
+ foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
418
+ };
398
419
  }
399
420
  }
400
421
  else if (type === 'assetHolding') {
401
422
  const { asset, account } = reference;
402
- txns[txnIndex].txn.appForeignAssets = [...(txns[txnIndex].txn.appForeignAssets ?? []), Number(asset)];
403
- txns[txnIndex].txn.appAccounts = [...(txns[txnIndex].txn.appAccounts ?? []), algosdk.decodeAddress(account)];
423
+ txns[txnIndex].txn['applicationCall'] = {
424
+ ...txns[txnIndex].txn.applicationCall,
425
+ foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],
426
+ accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
427
+ };
404
428
  }
405
429
  else if (type === 'appLocal') {
406
430
  const { app, account } = reference;
407
- txns[txnIndex].txn.appAccounts = [...(txns[txnIndex].txn.appAccounts ?? []), algosdk.decodeAddress(account)];
408
- txns[txnIndex].txn.appForeignApps = [...(txns[txnIndex].txn.appForeignApps ?? []), Number(app)];
431
+ txns[txnIndex].txn['applicationCall'] = {
432
+ ...txns[txnIndex].txn.applicationCall,
433
+ foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
434
+ accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
435
+ };
409
436
  }
410
437
  else if (type === 'asset') {
411
- txns[txnIndex].txn.appForeignAssets = [...(txns[txnIndex].txn.appForeignAssets ?? []), Number(reference)];
438
+ txns[txnIndex].txn['applicationCall'] = {
439
+ ...txns[txnIndex].txn.applicationCall,
440
+ foreignAssets: [
441
+ ...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []),
442
+ ...[typeof reference === 'bigint' ? reference : BigInt(reference)],
443
+ ],
444
+ };
412
445
  }
413
446
  };
414
447
  const g = unnamedResourcesAccessed.group;
@@ -467,20 +500,14 @@ async function populateAppCallResources(atc, algod) {
467
500
  const sendAtomicTransactionComposer = async function (atcSend, algod) {
468
501
  const { atc: givenAtc, sendParams, ...executeParams } = atcSend;
469
502
  let atc;
470
- // const hasAppCalls = () =>
471
- // givenAtc
472
- // .buildGroup()
473
- // .map((t) => t.txn.type)
474
- // .includes(algosdk.TransactionType.appl)
475
503
  atc = givenAtc;
476
504
  try {
505
+ const transactionsWithSigner = atc.buildGroup();
477
506
  // If populateAppCallResources is true OR if populateAppCallResources is undefined and there are app calls, then populate resources
478
- // NOTE: Temporary false by default until this algod bug is fixed: https://github.com/algorand/go-algorand/issues/5914
479
507
  const populateResources = executeParams?.populateAppCallResources ?? sendParams?.populateAppCallResources ?? Config.populateAppCallResources;
480
- if (populateResources) {
508
+ if (populateResources && transactionsWithSigner.map((t) => t.txn.type).includes(algosdk.TransactionType.appl)) {
481
509
  atc = await populateAppCallResources(givenAtc, algod);
482
510
  }
483
- const transactionsWithSigner = atc.buildGroup();
484
511
  const transactionsToSend = transactionsWithSigner.map((t) => {
485
512
  return t.txn;
486
513
  });
@@ -504,11 +531,11 @@ const sendAtomicTransactionComposer = async function (atcSend, algod) {
504
531
  Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`);
505
532
  }
506
533
  else {
507
- Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(`Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${algosdk.encodeAddress(transactionsToSend[0].from.publicKey)}`);
534
+ Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(`Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${transactionsToSend[0].sender.toString()}`);
508
535
  }
509
536
  let confirmations = undefined;
510
537
  if (!sendParams?.skipWaiting) {
511
- confirmations = await Promise.all(transactionsToSend.map(async (t) => modelsv2.PendingTransactionResponse.from_obj_for_encoding(await algod.pendingTransactionInformation(t.txID()).do())));
538
+ confirmations = await Promise.all(transactionsToSend.map(async (t) => await algod.pendingTransactionInformation(t.txID()).do()));
512
539
  }
513
540
  return {
514
541
  groupId,
@@ -528,6 +555,9 @@ const sendAtomicTransactionComposer = async function (atcSend, algod) {
528
555
  // Remove headers as it doesn't have anything useful.
529
556
  delete e.response?.headers;
530
557
  err.response = e.response;
558
+ // body property very noisy
559
+ if (e.response && 'body' in e.response)
560
+ delete err.response.body;
531
561
  err.name = e.name;
532
562
  }
533
563
  if (Config.debug && typeof e === 'object') {
@@ -543,7 +573,7 @@ const sendAtomicTransactionComposer = async function (atcSend, algod) {
543
573
  if (simulate && simulate.txnGroups[0].failedAt) {
544
574
  for (const txn of simulate.txnGroups[0].txnResults) {
545
575
  err.traces.push({
546
- trace: txn.execTrace?.get_obj_for_encoding(),
576
+ trace: txn.execTrace?.toEncodingData(),
547
577
  appBudget: txn.appBudgetConsumed,
548
578
  logicSigBudget: txn.logicSigBudgetConsumed,
549
579
  logs: txn.txnResult.logs,
@@ -597,22 +627,6 @@ function getABIReturnValue(result) {
597
627
  : result.returnValue,
598
628
  };
599
629
  }
600
- /**
601
- * @deprecated Use `performAtomicTransactionComposerSimulate`, dry-run is a deprecated Algorand feature.
602
- *
603
- * Performs a dry run of the transactions loaded into the given AtomicTransactionComposer`
604
- * @param atc The AtomicTransactionComposer` with transaction(s) loaded
605
- * @param algod An Algod client
606
- * @returns The dryrun result
607
- */
608
- async function performAtomicTransactionComposerDryrun(atc, algod) {
609
- const signedTransactions = await atc.gatherSignatures();
610
- const txns = signedTransactions.map((t) => {
611
- return algosdk.decodeSignedTransaction(t);
612
- });
613
- const dryrun = await algosdk.createDryrun({ client: algod, txns });
614
- return new algosdk.DryrunResult(await algod.dryrun(dryrun).do());
615
- }
616
630
  /**
617
631
  * @deprecated Use `TransactionComposer` (`algorand.newGroup()`) or `AtomicTransactionComposer` to construct and send group transactions instead.
618
632
  *
@@ -665,7 +679,7 @@ const waitForConfirmation = async function (transactionId, maxRoundsToWait, algo
665
679
  throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`);
666
680
  }
667
681
  // Get current round
668
- const status = modelsv2.NodeStatusResponse.from_obj_for_encoding(await algod.status().do());
682
+ const status = await algod.status().do();
669
683
  if (status === undefined) {
670
684
  throw new Error('Unable to get node status');
671
685
  }
@@ -674,7 +688,7 @@ const waitForConfirmation = async function (transactionId, maxRoundsToWait, algo
674
688
  let currentRound = startRound;
675
689
  while (currentRound < startRound + BigInt(maxRoundsToWait)) {
676
690
  try {
677
- const pendingInfo = modelsv2.PendingTransactionResponse.from_obj_for_encoding(await algod.pendingTransactionInformation(transactionId).do());
691
+ const pendingInfo = await algod.pendingTransactionInformation(transactionId).do();
678
692
  if (pendingInfo !== undefined) {
679
693
  const confirmedRound = pendingInfo.confirmedRound;
680
694
  if (confirmedRound && confirmedRound > 0) {
@@ -712,17 +726,19 @@ const waitForConfirmation = async function (transactionId, maxRoundsToWait, algo
712
726
  */
713
727
  function capTransactionFee(transaction, maxAcceptableFee) {
714
728
  // If a flat fee hasn't already been defined
715
- if (!transaction.flatFee) {
729
+ if (!('flatFee' in transaction) || !transaction.flatFee) {
716
730
  // Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee
717
731
  // Will be based on the current suggested fee-per-byte value.
718
732
  if (transaction.fee > maxAcceptableFee.microAlgo) {
719
733
  throw new Error(`Cancelled transaction due to high network congestion fees. Algorand suggested fees would cause this transaction to cost ${transaction.fee} µALGO. Cap for this transaction is ${maxAcceptableFee.microAlgo} µALGO.`);
720
734
  }
721
- else if (transaction.fee > algosdk.ALGORAND_MIN_TX_FEE) {
735
+ else if (transaction.fee > 1000000) {
722
736
  Config.logger.warn(`Algorand network congestion fees are in effect. This transaction will incur a fee of ${transaction.fee} µALGO.`);
723
737
  }
724
738
  // Now set the flat on the transaction. Otherwise the network may increase the fee above our cap and perform the transaction.
725
- transaction.flatFee = true;
739
+ if ('flatFee' in transaction) {
740
+ transaction.flatFee = true;
741
+ }
726
742
  }
727
743
  }
728
744
  /**
@@ -736,7 +752,9 @@ function controlFees(transaction, feeControl) {
736
752
  const { fee, maxFee } = feeControl;
737
753
  if (fee) {
738
754
  transaction.fee = Number(fee.microAlgo);
739
- transaction.flatFee = true;
755
+ if ('flatFee' in transaction) {
756
+ transaction.flatFee = true;
757
+ }
740
758
  }
741
759
  if (maxFee !== undefined) {
742
760
  capTransactionFee(transaction, maxFee);
@@ -752,7 +770,18 @@ function controlFees(transaction, feeControl) {
752
770
  * @returns The suggested transaction parameters
753
771
  */
754
772
  async function getTransactionParams(params, algod) {
755
- return params ? { ...params } : await algod.getTransactionParams().do();
773
+ if (params) {
774
+ return { ...params };
775
+ }
776
+ const p = await algod.getTransactionParams().do();
777
+ return {
778
+ fee: p.fee,
779
+ firstValid: p.firstValid,
780
+ lastValid: p.lastValid,
781
+ genesisID: p.genesisID,
782
+ genesisHash: p.genesisHash,
783
+ minFee: p.minFee,
784
+ };
756
785
  }
757
786
  /**
758
787
  * @deprecated Use `atc.clone().buildGroup()` instead.
@@ -770,5 +799,5 @@ function getAtomicTransactionComposerTransactions(atc) {
770
799
  }
771
800
  }
772
801
 
773
- export { MAX_APP_CALL_ACCOUNT_REFERENCES, MAX_APP_CALL_FOREIGN_REFERENCES, MAX_TRANSACTION_GROUP_SIZE, capTransactionFee, controlFees, encodeLease, encodeTransactionNote, getABIReturnValue, getAtomicTransactionComposerTransactions, getSenderAddress, getSenderTransactionSigner, getTransactionParams, getTransactionWithSigner, performAtomicTransactionComposerDryrun, populateAppCallResources, sendAtomicTransactionComposer, sendGroupOfTransactions, sendTransaction, signTransaction, waitForConfirmation };
802
+ export { MAX_APP_CALL_ACCOUNT_REFERENCES, MAX_APP_CALL_FOREIGN_REFERENCES, MAX_TRANSACTION_GROUP_SIZE, capTransactionFee, controlFees, encodeLease, encodeTransactionNote, getABIReturnValue, getAtomicTransactionComposerTransactions, getSenderAddress, getSenderTransactionSigner, getTransactionParams, getTransactionWithSigner, populateAppCallResources, sendAtomicTransactionComposer, sendGroupOfTransactions, sendTransaction, signTransaction, waitForConfirmation };
774
803
  //# sourceMappingURL=transaction.mjs.map