@algorandfoundation/algokit-utils 7.0.0 → 8.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/README.md +14 -3
- package/account/account.d.ts +4 -1
- package/account/account.js +4 -3
- package/account/account.js.map +1 -1
- package/account/account.mjs +5 -4
- package/account/account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +1 -1
- package/amount.d.ts +1 -0
- package/amount.js +3 -2
- package/amount.js.map +1 -1
- package/amount.mjs +3 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +4 -4
- package/app-client.js +4 -4
- package/app-client.js.map +1 -1
- package/app-client.mjs +4 -4
- package/app-client.mjs.map +1 -1
- package/app-deploy.js +23 -5
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +24 -6
- package/app-deploy.mjs.map +1 -1
- package/app.js +7 -4
- package/app.js.map +1 -1
- package/app.mjs +7 -4
- package/app.mjs.map +1 -1
- package/index.js +1 -1
- package/index.mjs +2 -2
- package/indexer-lookup.d.ts +10 -8
- package/indexer-lookup.js +14 -10
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +14 -10
- package/indexer-lookup.mjs.map +1 -1
- package/network-client.d.ts +1 -7
- package/network-client.js +2 -9
- package/network-client.js.map +1 -1
- package/network-client.mjs +2 -9
- package/network-client.mjs.map +1 -1
- package/package.json +2 -2
- package/testing/_asset.d.ts +2 -1
- package/testing/account.d.ts +4 -3
- package/testing/account.js +8 -2
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +9 -3
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.js +5 -6
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +5 -6
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/test-logger.js +7 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +7 -1
- package/testing/test-logger.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js +14 -10
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -11
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +1 -17
- package/transaction/transaction.js +110 -82
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +112 -83
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer.js +3 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +3 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +20 -20
- package/types/account-manager.js +27 -20
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +28 -21
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +8 -8
- package/types/account.js +2 -2
- package/types/account.js.map +1 -1
- package/types/account.mjs +3 -3
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +1 -2
- package/types/algo-http-client-with-retry.js +33 -3
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +32 -2
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +11 -11
- package/types/algorand-client-transaction-sender.d.ts +97 -97
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +3 -3
- package/types/algorand-client.js +1 -1
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +1 -1
- package/types/algorand-client.mjs.map +1 -1
- package/types/app-client.d.ts +280 -279
- package/types/app-client.js +10 -10
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +11 -11
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +4 -4
- package/types/app-deployer.js +22 -23
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +23 -24
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +128 -138
- package/types/app-factory.js +4 -3
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +5 -4
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +5 -5
- package/types/app-manager.js +11 -15
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +12 -16
- package/types/app-manager.mjs.map +1 -1
- package/types/app.d.ts +4 -4
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +5 -5
- package/types/asset-manager.js +8 -11
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +8 -11
- package/types/asset-manager.mjs.map +1 -1
- package/types/client-manager.d.ts +2 -9
- package/types/client-manager.js +9 -19
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +9 -19
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +22 -22
- package/types/composer.js +73 -83
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +74 -84
- package/types/composer.mjs.map +1 -1
- package/types/dispenser-client.d.ts +2 -1
- package/types/dispenser-client.js +5 -1
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +5 -1
- package/types/dispenser-client.mjs.map +1 -1
- package/types/indexer.d.ts +74 -755
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +2 -2
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/network-client.d.ts +1 -1
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +5 -6
- package/types/urlTokenBaseHTTPClient.d.ts +0 -40
- package/types/urlTokenBaseHTTPClient.js +0 -153
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/types/urlTokenBaseHTTPClient.mjs +0 -151
- package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
|
@@ -8,7 +8,6 @@ var util = require('../util.js');
|
|
|
8
8
|
var performAtomicTransactionComposerSimulate = require('./perform-atomic-transaction-composer-simulate.js');
|
|
9
9
|
|
|
10
10
|
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
11
|
-
var modelsv2 = algosdk.modelsv2;
|
|
12
11
|
const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
13
12
|
const MAX_APP_CALL_FOREIGN_REFERENCES = 8;
|
|
14
13
|
const MAX_APP_CALL_ACCOUNT_REFERENCES = 4;
|
|
@@ -89,7 +88,7 @@ function encodeLease(lease) {
|
|
|
89
88
|
* @returns The public address
|
|
90
89
|
*/
|
|
91
90
|
const getSenderAddress = function (sender) {
|
|
92
|
-
return typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr : sender.address();
|
|
91
|
+
return typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr.toString() : sender.address().toString();
|
|
93
92
|
};
|
|
94
93
|
/**
|
|
95
94
|
* @deprecated Use `AlgorandClient` / `TransactionComposer` to construct transactions instead or
|
|
@@ -262,7 +261,7 @@ async function populateAppCallResources(atc, algod) {
|
|
|
262
261
|
const unnamedResourcesAccessed = await getUnnamedAppCallResourcesAccessed(atc, algod);
|
|
263
262
|
const group = atc.buildGroup();
|
|
264
263
|
unnamedResourcesAccessed.txns.forEach((r, i) => {
|
|
265
|
-
if (r === undefined)
|
|
264
|
+
if (r === undefined || group[i].txn.type !== algosdk.TransactionType.appl)
|
|
266
265
|
return;
|
|
267
266
|
if (r.boxes || r.extraBoxRefs)
|
|
268
267
|
throw Error('Unexpected boxes at the transaction level');
|
|
@@ -270,22 +269,19 @@ async function populateAppCallResources(atc, algod) {
|
|
|
270
269
|
throw Error('Unexpected app local at the transaction level');
|
|
271
270
|
if (r.assetHoldings)
|
|
272
271
|
throw Error('Unexpected asset holding at the transaction level');
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
group[i].txn.appForeignAssets = [...(group[i].txn.appForeignAssets ?? []), Number(a)];
|
|
282
|
-
});
|
|
283
|
-
const accounts = group[i].txn.appAccounts?.length || 0;
|
|
272
|
+
group[i].txn['applicationCall'] = {
|
|
273
|
+
...group[i].txn.applicationCall,
|
|
274
|
+
accounts: [...(group[i].txn?.applicationCall?.accounts ?? []), ...(r.accounts ?? [])],
|
|
275
|
+
foreignApps: [...(group[i].txn?.applicationCall?.foreignApps ?? []), ...(r.apps ?? [])],
|
|
276
|
+
foreignAssets: [...(group[i].txn?.applicationCall?.foreignAssets ?? []), ...(r.assets ?? [])],
|
|
277
|
+
boxes: [...(group[i].txn?.applicationCall?.boxes ?? []), ...(r.boxes ?? [])],
|
|
278
|
+
};
|
|
279
|
+
const accounts = group[i].txn.applicationCall?.accounts?.length ?? 0;
|
|
284
280
|
if (accounts > MAX_APP_CALL_ACCOUNT_REFERENCES)
|
|
285
281
|
throw Error(`Account reference limit of ${MAX_APP_CALL_ACCOUNT_REFERENCES} exceeded in transaction ${i}`);
|
|
286
|
-
const assets = group[i].txn.
|
|
287
|
-
const apps = group[i].txn.
|
|
288
|
-
const boxes = group[i].txn.boxes?.length
|
|
282
|
+
const assets = group[i].txn.applicationCall?.foreignAssets?.length ?? 0;
|
|
283
|
+
const apps = group[i].txn.applicationCall?.foreignApps?.length ?? 0;
|
|
284
|
+
const boxes = group[i].txn.applicationCall?.boxes?.length ?? 0;
|
|
289
285
|
if (accounts + assets + apps + boxes > MAX_APP_CALL_FOREIGN_REFERENCES) {
|
|
290
286
|
throw Error(`Resource reference limit of ${MAX_APP_CALL_FOREIGN_REFERENCES} exceeded in transaction ${i}`);
|
|
291
287
|
}
|
|
@@ -294,10 +290,10 @@ async function populateAppCallResources(atc, algod) {
|
|
|
294
290
|
const isApplBelowLimit = (t) => {
|
|
295
291
|
if (t.txn.type !== algosdk.TransactionType.appl)
|
|
296
292
|
return false;
|
|
297
|
-
const accounts = t.txn.
|
|
298
|
-
const assets = t.txn.
|
|
299
|
-
const apps = t.txn.
|
|
300
|
-
const boxes = t.txn.boxes?.length
|
|
293
|
+
const accounts = t.txn.applicationCall?.accounts?.length ?? 0;
|
|
294
|
+
const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0;
|
|
295
|
+
const apps = t.txn.applicationCall?.foreignApps?.length ?? 0;
|
|
296
|
+
const boxes = t.txn.applicationCall?.boxes?.length ?? 0;
|
|
301
297
|
return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES;
|
|
302
298
|
};
|
|
303
299
|
// If this is a asset holding or app local, first try to find a transaction that already has the account available
|
|
@@ -308,22 +304,26 @@ async function populateAppCallResources(atc, algod) {
|
|
|
308
304
|
return false;
|
|
309
305
|
return (
|
|
310
306
|
// account is in the foreign accounts array
|
|
311
|
-
t.txn.
|
|
307
|
+
t.txn.applicationCall?.accounts?.map((a) => a.toString()).includes(account.toString()) ||
|
|
312
308
|
// account is available as an app account
|
|
313
|
-
t.txn.
|
|
309
|
+
t.txn.applicationCall?.foreignApps?.map((a) => algosdk.getApplicationAddress(a).toString()).includes(account.toString()) ||
|
|
314
310
|
// account is available since it's in one of the fields
|
|
315
|
-
Object.values(t.txn)
|
|
316
|
-
.map((f) => JSON.stringify(f))
|
|
317
|
-
.includes(JSON.stringify(algosdk.decodeAddress(account))));
|
|
311
|
+
Object.values(t.txn).some((f) => algosdk.stringifyJSON(f, (_, v) => (v instanceof algosdk.Address ? v.toString() : v))?.includes(account.toString())));
|
|
318
312
|
});
|
|
319
313
|
if (txnIndex > -1) {
|
|
320
314
|
if (type === 'assetHolding') {
|
|
321
315
|
const { asset } = reference;
|
|
322
|
-
txns[txnIndex].txn
|
|
316
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
317
|
+
...txns[txnIndex].txn.applicationCall,
|
|
318
|
+
foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],
|
|
319
|
+
};
|
|
323
320
|
}
|
|
324
321
|
else {
|
|
325
322
|
const { app } = reference;
|
|
326
|
-
txns[txnIndex].txn
|
|
323
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
324
|
+
...txns[txnIndex].txn.applicationCall,
|
|
325
|
+
foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
|
|
326
|
+
};
|
|
327
327
|
}
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
@@ -332,20 +332,23 @@ async function populateAppCallResources(atc, algod) {
|
|
|
332
332
|
if (!isApplBelowLimit(t))
|
|
333
333
|
return false;
|
|
334
334
|
// check if there is space in the accounts array
|
|
335
|
-
if ((t.txn.
|
|
335
|
+
if ((t.txn.applicationCall?.accounts?.length ?? 0) >= MAX_APP_CALL_ACCOUNT_REFERENCES)
|
|
336
336
|
return false;
|
|
337
337
|
if (type === 'assetHolding') {
|
|
338
338
|
const { asset } = reference;
|
|
339
|
-
return t.txn.
|
|
339
|
+
return t.txn.applicationCall?.foreignAssets?.includes(asset);
|
|
340
340
|
}
|
|
341
341
|
else {
|
|
342
342
|
const { app } = reference;
|
|
343
|
-
return t.txn.
|
|
343
|
+
return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app;
|
|
344
344
|
}
|
|
345
345
|
});
|
|
346
346
|
if (txnIndex > -1) {
|
|
347
347
|
const { account } = reference;
|
|
348
|
-
txns[txnIndex].txn
|
|
348
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
349
|
+
...txns[txnIndex].txn.applicationCall,
|
|
350
|
+
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
|
|
351
|
+
};
|
|
349
352
|
return;
|
|
350
353
|
}
|
|
351
354
|
}
|
|
@@ -356,10 +359,13 @@ async function populateAppCallResources(atc, algod) {
|
|
|
356
359
|
if (!isApplBelowLimit(t))
|
|
357
360
|
return false;
|
|
358
361
|
// If the app is in the foreign array OR the app being called, then we know it's available
|
|
359
|
-
return t.txn.
|
|
362
|
+
return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app;
|
|
360
363
|
});
|
|
361
364
|
if (txnIndex > -1) {
|
|
362
|
-
txns[txnIndex].txn
|
|
365
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
366
|
+
...txns[txnIndex].txn.applicationCall,
|
|
367
|
+
boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name }]],
|
|
368
|
+
};
|
|
363
369
|
return;
|
|
364
370
|
}
|
|
365
371
|
}
|
|
@@ -367,12 +373,12 @@ async function populateAppCallResources(atc, algod) {
|
|
|
367
373
|
const txnIndex = txns.findIndex((t) => {
|
|
368
374
|
if (t.txn.type !== algosdk.TransactionType.appl)
|
|
369
375
|
return false;
|
|
370
|
-
const accounts = t.txn.
|
|
376
|
+
const accounts = t.txn.applicationCall?.accounts?.length ?? 0;
|
|
371
377
|
if (type === 'account')
|
|
372
378
|
return accounts < MAX_APP_CALL_ACCOUNT_REFERENCES;
|
|
373
|
-
const assets = t.txn.
|
|
374
|
-
const apps = t.txn.
|
|
375
|
-
const boxes = t.txn.boxes?.length
|
|
379
|
+
const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0;
|
|
380
|
+
const apps = t.txn.applicationCall?.foreignApps?.length ?? 0;
|
|
381
|
+
const boxes = t.txn.applicationCall?.boxes?.length ?? 0;
|
|
376
382
|
// If we're adding local state or asset holding, we need space for the acocunt and the other reference
|
|
377
383
|
if (type === 'assetHolding' || type === 'appLocal') {
|
|
378
384
|
return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES - 1 && accounts < MAX_APP_CALL_ACCOUNT_REFERENCES;
|
|
@@ -387,30 +393,57 @@ async function populateAppCallResources(atc, algod) {
|
|
|
387
393
|
throw Error('No more transactions below reference limit. Add another app call to the group.');
|
|
388
394
|
}
|
|
389
395
|
if (type === 'account') {
|
|
390
|
-
txns[txnIndex].txn
|
|
396
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
397
|
+
...txns[txnIndex].txn.applicationCall,
|
|
398
|
+
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[reference]],
|
|
399
|
+
};
|
|
391
400
|
}
|
|
392
401
|
else if (type === 'app') {
|
|
393
|
-
txns[txnIndex].txn
|
|
402
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
403
|
+
...txns[txnIndex].txn.applicationCall,
|
|
404
|
+
foreignApps: [
|
|
405
|
+
...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []),
|
|
406
|
+
...[typeof reference === 'bigint' ? reference : BigInt(reference)],
|
|
407
|
+
],
|
|
408
|
+
};
|
|
394
409
|
}
|
|
395
410
|
else if (type === 'box') {
|
|
396
411
|
const { app, name } = reference;
|
|
397
|
-
txns[txnIndex].txn
|
|
412
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
413
|
+
...txns[txnIndex].txn.applicationCall,
|
|
414
|
+
boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name }]],
|
|
415
|
+
};
|
|
398
416
|
if (app.toString() !== '0') {
|
|
399
|
-
txns[txnIndex].txn
|
|
417
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
418
|
+
...txns[txnIndex].txn.applicationCall,
|
|
419
|
+
foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
|
|
420
|
+
};
|
|
400
421
|
}
|
|
401
422
|
}
|
|
402
423
|
else if (type === 'assetHolding') {
|
|
403
424
|
const { asset, account } = reference;
|
|
404
|
-
txns[txnIndex].txn
|
|
405
|
-
|
|
425
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
426
|
+
...txns[txnIndex].txn.applicationCall,
|
|
427
|
+
foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],
|
|
428
|
+
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
|
|
429
|
+
};
|
|
406
430
|
}
|
|
407
431
|
else if (type === 'appLocal') {
|
|
408
432
|
const { app, account } = reference;
|
|
409
|
-
txns[txnIndex].txn
|
|
410
|
-
|
|
433
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
434
|
+
...txns[txnIndex].txn.applicationCall,
|
|
435
|
+
foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],
|
|
436
|
+
accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],
|
|
437
|
+
};
|
|
411
438
|
}
|
|
412
439
|
else if (type === 'asset') {
|
|
413
|
-
txns[txnIndex].txn
|
|
440
|
+
txns[txnIndex].txn['applicationCall'] = {
|
|
441
|
+
...txns[txnIndex].txn.applicationCall,
|
|
442
|
+
foreignAssets: [
|
|
443
|
+
...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []),
|
|
444
|
+
...[typeof reference === 'bigint' ? reference : BigInt(reference)],
|
|
445
|
+
],
|
|
446
|
+
};
|
|
414
447
|
}
|
|
415
448
|
};
|
|
416
449
|
const g = unnamedResourcesAccessed.group;
|
|
@@ -469,20 +502,14 @@ async function populateAppCallResources(atc, algod) {
|
|
|
469
502
|
const sendAtomicTransactionComposer = async function (atcSend, algod) {
|
|
470
503
|
const { atc: givenAtc, sendParams, ...executeParams } = atcSend;
|
|
471
504
|
let atc;
|
|
472
|
-
// const hasAppCalls = () =>
|
|
473
|
-
// givenAtc
|
|
474
|
-
// .buildGroup()
|
|
475
|
-
// .map((t) => t.txn.type)
|
|
476
|
-
// .includes(algosdk.TransactionType.appl)
|
|
477
505
|
atc = givenAtc;
|
|
478
506
|
try {
|
|
507
|
+
const transactionsWithSigner = atc.buildGroup();
|
|
479
508
|
// If populateAppCallResources is true OR if populateAppCallResources is undefined and there are app calls, then populate resources
|
|
480
|
-
// NOTE: Temporary false by default until this algod bug is fixed: https://github.com/algorand/go-algorand/issues/5914
|
|
481
509
|
const populateResources = executeParams?.populateAppCallResources ?? sendParams?.populateAppCallResources ?? config.Config.populateAppCallResources;
|
|
482
|
-
if (populateResources) {
|
|
510
|
+
if (populateResources && transactionsWithSigner.map((t) => t.txn.type).includes(algosdk.TransactionType.appl)) {
|
|
483
511
|
atc = await populateAppCallResources(givenAtc, algod);
|
|
484
512
|
}
|
|
485
|
-
const transactionsWithSigner = atc.buildGroup();
|
|
486
513
|
const transactionsToSend = transactionsWithSigner.map((t) => {
|
|
487
514
|
return t.txn;
|
|
488
515
|
});
|
|
@@ -506,11 +533,11 @@ const sendAtomicTransactionComposer = async function (atcSend, algod) {
|
|
|
506
533
|
config.Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`);
|
|
507
534
|
}
|
|
508
535
|
else {
|
|
509
|
-
config.Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(`Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${
|
|
536
|
+
config.Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(`Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${transactionsToSend[0].sender.toString()}`);
|
|
510
537
|
}
|
|
511
538
|
let confirmations = undefined;
|
|
512
539
|
if (!sendParams?.skipWaiting) {
|
|
513
|
-
confirmations = await Promise.all(transactionsToSend.map(async (t) =>
|
|
540
|
+
confirmations = await Promise.all(transactionsToSend.map(async (t) => await algod.pendingTransactionInformation(t.txID()).do()));
|
|
514
541
|
}
|
|
515
542
|
return {
|
|
516
543
|
groupId,
|
|
@@ -530,6 +557,9 @@ const sendAtomicTransactionComposer = async function (atcSend, algod) {
|
|
|
530
557
|
// Remove headers as it doesn't have anything useful.
|
|
531
558
|
delete e.response?.headers;
|
|
532
559
|
err.response = e.response;
|
|
560
|
+
// body property very noisy
|
|
561
|
+
if (e.response && 'body' in e.response)
|
|
562
|
+
delete err.response.body;
|
|
533
563
|
err.name = e.name;
|
|
534
564
|
}
|
|
535
565
|
if (config.Config.debug && typeof e === 'object') {
|
|
@@ -545,7 +575,7 @@ const sendAtomicTransactionComposer = async function (atcSend, algod) {
|
|
|
545
575
|
if (simulate && simulate.txnGroups[0].failedAt) {
|
|
546
576
|
for (const txn of simulate.txnGroups[0].txnResults) {
|
|
547
577
|
err.traces.push({
|
|
548
|
-
trace: txn.execTrace?.
|
|
578
|
+
trace: txn.execTrace?.toEncodingData(),
|
|
549
579
|
appBudget: txn.appBudgetConsumed,
|
|
550
580
|
logicSigBudget: txn.logicSigBudgetConsumed,
|
|
551
581
|
logs: txn.txnResult.logs,
|
|
@@ -599,22 +629,6 @@ function getABIReturnValue(result) {
|
|
|
599
629
|
: result.returnValue,
|
|
600
630
|
};
|
|
601
631
|
}
|
|
602
|
-
/**
|
|
603
|
-
* @deprecated Use `performAtomicTransactionComposerSimulate`, dry-run is a deprecated Algorand feature.
|
|
604
|
-
*
|
|
605
|
-
* Performs a dry run of the transactions loaded into the given AtomicTransactionComposer`
|
|
606
|
-
* @param atc The AtomicTransactionComposer` with transaction(s) loaded
|
|
607
|
-
* @param algod An Algod client
|
|
608
|
-
* @returns The dryrun result
|
|
609
|
-
*/
|
|
610
|
-
async function performAtomicTransactionComposerDryrun(atc, algod) {
|
|
611
|
-
const signedTransactions = await atc.gatherSignatures();
|
|
612
|
-
const txns = signedTransactions.map((t) => {
|
|
613
|
-
return algosdk.decodeSignedTransaction(t);
|
|
614
|
-
});
|
|
615
|
-
const dryrun = await algosdk.createDryrun({ client: algod, txns });
|
|
616
|
-
return new algosdk.DryrunResult(await algod.dryrun(dryrun).do());
|
|
617
|
-
}
|
|
618
632
|
/**
|
|
619
633
|
* @deprecated Use `TransactionComposer` (`algorand.newGroup()`) or `AtomicTransactionComposer` to construct and send group transactions instead.
|
|
620
634
|
*
|
|
@@ -667,7 +681,7 @@ const waitForConfirmation = async function (transactionId, maxRoundsToWait, algo
|
|
|
667
681
|
throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`);
|
|
668
682
|
}
|
|
669
683
|
// Get current round
|
|
670
|
-
const status =
|
|
684
|
+
const status = await algod.status().do();
|
|
671
685
|
if (status === undefined) {
|
|
672
686
|
throw new Error('Unable to get node status');
|
|
673
687
|
}
|
|
@@ -676,7 +690,7 @@ const waitForConfirmation = async function (transactionId, maxRoundsToWait, algo
|
|
|
676
690
|
let currentRound = startRound;
|
|
677
691
|
while (currentRound < startRound + BigInt(maxRoundsToWait)) {
|
|
678
692
|
try {
|
|
679
|
-
const pendingInfo =
|
|
693
|
+
const pendingInfo = await algod.pendingTransactionInformation(transactionId).do();
|
|
680
694
|
if (pendingInfo !== undefined) {
|
|
681
695
|
const confirmedRound = pendingInfo.confirmedRound;
|
|
682
696
|
if (confirmedRound && confirmedRound > 0) {
|
|
@@ -714,17 +728,19 @@ const waitForConfirmation = async function (transactionId, maxRoundsToWait, algo
|
|
|
714
728
|
*/
|
|
715
729
|
function capTransactionFee(transaction, maxAcceptableFee) {
|
|
716
730
|
// If a flat fee hasn't already been defined
|
|
717
|
-
if (!transaction.flatFee) {
|
|
731
|
+
if (!('flatFee' in transaction) || !transaction.flatFee) {
|
|
718
732
|
// Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee
|
|
719
733
|
// Will be based on the current suggested fee-per-byte value.
|
|
720
734
|
if (transaction.fee > maxAcceptableFee.microAlgo) {
|
|
721
735
|
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.`);
|
|
722
736
|
}
|
|
723
|
-
else if (transaction.fee >
|
|
737
|
+
else if (transaction.fee > 1000000) {
|
|
724
738
|
config.Config.logger.warn(`Algorand network congestion fees are in effect. This transaction will incur a fee of ${transaction.fee} µALGO.`);
|
|
725
739
|
}
|
|
726
740
|
// Now set the flat on the transaction. Otherwise the network may increase the fee above our cap and perform the transaction.
|
|
727
|
-
|
|
741
|
+
if ('flatFee' in transaction) {
|
|
742
|
+
transaction.flatFee = true;
|
|
743
|
+
}
|
|
728
744
|
}
|
|
729
745
|
}
|
|
730
746
|
/**
|
|
@@ -738,7 +754,9 @@ function controlFees(transaction, feeControl) {
|
|
|
738
754
|
const { fee, maxFee } = feeControl;
|
|
739
755
|
if (fee) {
|
|
740
756
|
transaction.fee = Number(fee.microAlgo);
|
|
741
|
-
|
|
757
|
+
if ('flatFee' in transaction) {
|
|
758
|
+
transaction.flatFee = true;
|
|
759
|
+
}
|
|
742
760
|
}
|
|
743
761
|
if (maxFee !== undefined) {
|
|
744
762
|
capTransactionFee(transaction, maxFee);
|
|
@@ -754,7 +772,18 @@ function controlFees(transaction, feeControl) {
|
|
|
754
772
|
* @returns The suggested transaction parameters
|
|
755
773
|
*/
|
|
756
774
|
async function getTransactionParams(params, algod) {
|
|
757
|
-
|
|
775
|
+
if (params) {
|
|
776
|
+
return { ...params };
|
|
777
|
+
}
|
|
778
|
+
const p = await algod.getTransactionParams().do();
|
|
779
|
+
return {
|
|
780
|
+
fee: p.fee,
|
|
781
|
+
firstValid: p.firstValid,
|
|
782
|
+
lastValid: p.lastValid,
|
|
783
|
+
genesisID: p.genesisID,
|
|
784
|
+
genesisHash: p.genesisHash,
|
|
785
|
+
minFee: p.minFee,
|
|
786
|
+
};
|
|
758
787
|
}
|
|
759
788
|
/**
|
|
760
789
|
* @deprecated Use `atc.clone().buildGroup()` instead.
|
|
@@ -785,7 +814,6 @@ exports.getSenderAddress = getSenderAddress;
|
|
|
785
814
|
exports.getSenderTransactionSigner = getSenderTransactionSigner;
|
|
786
815
|
exports.getTransactionParams = getTransactionParams;
|
|
787
816
|
exports.getTransactionWithSigner = getTransactionWithSigner;
|
|
788
|
-
exports.performAtomicTransactionComposerDryrun = performAtomicTransactionComposerDryrun;
|
|
789
817
|
exports.populateAppCallResources = populateAppCallResources;
|
|
790
818
|
exports.sendAtomicTransactionComposer = sendAtomicTransactionComposer;
|
|
791
819
|
exports.sendGroupOfTransactions = sendGroupOfTransactions;
|