@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.
- 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
|
@@ -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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
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.
|
|
285
|
-
const apps = group[i].txn.
|
|
286
|
-
const boxes = group[i].txn.boxes?.length
|
|
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.
|
|
296
|
-
const assets = t.txn.
|
|
297
|
-
const apps = t.txn.
|
|
298
|
-
const boxes = t.txn.boxes?.length
|
|
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.
|
|
305
|
+
t.txn.applicationCall?.accounts?.map((a) => a.toString()).includes(account.toString()) ||
|
|
310
306
|
// account is available as an app account
|
|
311
|
-
t.txn.
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
337
|
+
return t.txn.applicationCall?.foreignAssets?.includes(asset);
|
|
338
338
|
}
|
|
339
339
|
else {
|
|
340
340
|
const { app } = reference;
|
|
341
|
-
return t.txn.
|
|
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
|
|
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.
|
|
360
|
+
return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app;
|
|
358
361
|
});
|
|
359
362
|
if (txnIndex > -1) {
|
|
360
|
-
txns[txnIndex].txn
|
|
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.
|
|
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.
|
|
372
|
-
const apps = t.txn.
|
|
373
|
-
const boxes = t.txn.boxes?.length
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
403
|
-
|
|
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
|
|
408
|
-
|
|
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
|
|
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 ${
|
|
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) =>
|
|
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?.
|
|
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 =
|
|
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 =
|
|
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 >
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|