@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.
- package/LICENSE +21 -0
- package/README.md +9 -2
- package/account/account.js +6 -4
- package/account/account.js.map +1 -1
- package/account/account.mjs +6 -4
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.js.map +1 -1
- package/amount.mjs.map +1 -1
- package/app-client.js.map +1 -1
- package/app-client.mjs.map +1 -1
- package/app-deploy.js +2 -10
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +3 -11
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +2 -2
- package/app.js +2 -2
- package/app.js.map +1 -1
- package/app.mjs +2 -2
- package/app.mjs.map +1 -1
- package/asset.js.map +1 -1
- package/asset.mjs.map +1 -1
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs.map +1 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +6 -0
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.js.map +1 -1
- package/network-client.mjs.map +1 -1
- package/package.json +5 -5
- package/testing/account.js.map +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/legacy-bridge.js +2 -2
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +3 -3
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +14 -7
- package/transaction/transaction.js +57 -31
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +55 -30
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +1 -1
- package/types/account-manager.js +10 -8
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +11 -9
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +9 -0
- package/types/account.js.map +1 -1
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +2 -2
- package/types/algorand-client-transaction-creator.d.ts +5 -3
- package/types/algorand-client-transaction-creator.js +3 -1
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +3 -1
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +12 -8
- package/types/algorand-client-transaction-sender.js +6 -2
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +6 -2
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +3 -4
- package/types/algorand-client.js +2 -5
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +4 -4
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.js.map +1 -1
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +31 -20
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +21 -10
- package/types/app-client.js +143 -36
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +141 -34
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.js +1 -1
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +2 -2
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +32 -21
- package/types/app-factory.js +8 -2
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +8 -2
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.js +105 -23
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +105 -23
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.js +8 -2
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +8 -2
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +8 -7
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +4 -4
- package/types/asset-manager.js +2 -2
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +2 -2
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +1 -10
- package/types/async-event-emitter.js +0 -5
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +1 -6
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.js +2 -2
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +2 -2
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +56 -30
- package/types/composer.js +103 -47
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +104 -46
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +0 -4
- package/types/config.js.map +1 -1
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +1 -1
- package/types/debugging.js +1 -1
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +1 -1
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs.map +1 -1
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.js +1 -1
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +2 -2
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -3
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +1 -1
- package/types/transaction.d.ts +1 -1
- package/types/urlTokenBaseHTTPClient.js.map +1 -1
- package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
- package/util.js.map +1 -1
- package/util.mjs.map +1 -1
package/types/composer.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var algosdk = require('algosdk');
|
|
6
4
|
var config = require('../config.js');
|
|
7
|
-
var performAtomicTransactionComposerSimulate = require('../transaction/perform-atomic-transaction-composer-simulate.js');
|
|
8
5
|
var transaction = require('../transaction/transaction.js');
|
|
9
6
|
var types_app = require('./app.js');
|
|
10
7
|
var types_appManager = require('./app-manager.js');
|
|
11
|
-
var
|
|
8
|
+
var types_lifecycleEvents = require('./lifecycle-events.js');
|
|
12
9
|
var types_networkClient = require('./network-client.js');
|
|
13
10
|
|
|
14
11
|
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
@@ -16,10 +13,10 @@ var isTransactionWithSigner = algosdk.isTransactionWithSigner;
|
|
|
16
13
|
var encodeAddress = algosdk.encodeAddress;
|
|
17
14
|
var modelsv2 = algosdk.modelsv2;
|
|
18
15
|
const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
19
|
-
/**
|
|
20
|
-
class
|
|
16
|
+
/** TransactionComposer helps you compose and execute transactions as a transaction group. */
|
|
17
|
+
class TransactionComposer {
|
|
21
18
|
/**
|
|
22
|
-
* Create
|
|
19
|
+
* Create a `TransactionComposer`.
|
|
23
20
|
* @param params The configuration for this composer
|
|
24
21
|
*/
|
|
25
22
|
constructor(params) {
|
|
@@ -226,6 +223,15 @@ class AlgoKitComposer {
|
|
|
226
223
|
this.txns.push({ ...params, type: 'keyReg' });
|
|
227
224
|
return this;
|
|
228
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Add an offline key registration transaction to the transaction group.
|
|
228
|
+
* @param params The offline key registration transaction parameters
|
|
229
|
+
* @returns The composer so you can chain method calls
|
|
230
|
+
*/
|
|
231
|
+
addOfflineKeyRegistration(params) {
|
|
232
|
+
this.txns.push({ ...params, type: 'keyReg' });
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
229
235
|
/**
|
|
230
236
|
* Add the transactions within an `AtomicTransactionComposer` to the transaction group.
|
|
231
237
|
* @param atc The `AtomicTransactionComposer` to build transactions from and add to the group
|
|
@@ -239,7 +245,7 @@ class AlgoKitComposer {
|
|
|
239
245
|
buildAtc(atc, processTransaction) {
|
|
240
246
|
const group = atc.buildGroup();
|
|
241
247
|
const txnWithSigners = group.map((ts, idx) => {
|
|
242
|
-
// Remove underlying group ID from the transaction since it will be re-grouped when this
|
|
248
|
+
// Remove underlying group ID from the transaction since it will be re-grouped when this TransactionComposer is built
|
|
243
249
|
ts.txn.group = undefined;
|
|
244
250
|
// Process transaction if a function is provided
|
|
245
251
|
ts.txn = processTransaction?.(ts.txn, idx) ?? ts.txn;
|
|
@@ -296,14 +302,22 @@ class AlgoKitComposer {
|
|
|
296
302
|
*/
|
|
297
303
|
async buildMethodCall(params, suggestedParams, includeSigner) {
|
|
298
304
|
const methodArgs = [];
|
|
305
|
+
const transactionsForGroup = [];
|
|
299
306
|
const isAbiValue = (x) => {
|
|
300
307
|
if (Array.isArray(x))
|
|
301
308
|
return x.length == 0 || x.every(isAbiValue);
|
|
302
309
|
return typeof x === 'bigint' || typeof x === 'boolean' || typeof x === 'number' || typeof x === 'string' || x instanceof Uint8Array;
|
|
303
310
|
};
|
|
304
|
-
for (let i =
|
|
311
|
+
for (let i = (params.args ?? []).length - 1; i >= 0; i--) {
|
|
305
312
|
const arg = params.args[i];
|
|
306
313
|
if (arg === undefined) {
|
|
314
|
+
// An undefined transaction argument signals that the value will be supplied by a method call argument
|
|
315
|
+
if (algosdk.abiTypeIsTransaction(params.method.args[i].type) && transactionsForGroup.length > 0) {
|
|
316
|
+
// Move the last transaction from the group to the method call arguments to appease algosdk
|
|
317
|
+
const placeholderTransaction = transactionsForGroup.splice(-1, 1)[0];
|
|
318
|
+
methodArgs.push(placeholderTransaction);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
307
321
|
throw Error(`No value provided for argument ${i + 1} within call to ${params.method.name}`);
|
|
308
322
|
}
|
|
309
323
|
if (isAbiValue(arg)) {
|
|
@@ -316,7 +330,10 @@ class AlgoKitComposer {
|
|
|
316
330
|
}
|
|
317
331
|
if ('method' in arg) {
|
|
318
332
|
const tempTxnWithSigners = await this.buildMethodCall(arg, suggestedParams, includeSigner);
|
|
319
|
-
|
|
333
|
+
// If there is any transaction args, add to the atc
|
|
334
|
+
// Everything else should be added as method args
|
|
335
|
+
methodArgs.push(...tempTxnWithSigners.slice(-1)); // Add the method call itself as a method arg
|
|
336
|
+
transactionsForGroup.push(...tempTxnWithSigners.slice(0, -1).reverse()); // Add any transaction arguments to the atc
|
|
320
337
|
continue;
|
|
321
338
|
}
|
|
322
339
|
const txn = await arg;
|
|
@@ -328,10 +345,11 @@ class AlgoKitComposer {
|
|
|
328
345
|
? params.signer.signer
|
|
329
346
|
: params.signer
|
|
330
347
|
: this.getSigner(encodeAddress(txn.from.publicKey))
|
|
331
|
-
:
|
|
348
|
+
: TransactionComposer.NULL_SIGNER,
|
|
332
349
|
});
|
|
333
350
|
}
|
|
334
351
|
const methodAtc = new algosdk.AtomicTransactionComposer();
|
|
352
|
+
transactionsForGroup.reverse().forEach((txn) => methodAtc.addTransaction(txn));
|
|
335
353
|
const appId = Number('appId' in params ? params.appId : 0n);
|
|
336
354
|
const approvalProgram = 'approvalProgram' in params
|
|
337
355
|
? typeof params.approvalProgram === 'string'
|
|
@@ -361,10 +379,10 @@ class AlgoKitComposer {
|
|
|
361
379
|
? Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0)) / types_app.APP_PAGE_MAX_SIZE)
|
|
362
380
|
: 0
|
|
363
381
|
: undefined,
|
|
364
|
-
numLocalInts: appId === 0 ? ('schema' in params ? params.schema?.localInts ?? 0 : 0) : undefined,
|
|
365
|
-
numLocalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.localByteSlices ?? 0 : 0) : undefined,
|
|
366
|
-
numGlobalInts: appId === 0 ? ('schema' in params ? params.schema?.globalInts ?? 0 : 0) : undefined,
|
|
367
|
-
numGlobalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.globalByteSlices ?? 0 : 0) : undefined,
|
|
382
|
+
numLocalInts: appId === 0 ? ('schema' in params ? (params.schema?.localInts ?? 0) : 0) : undefined,
|
|
383
|
+
numLocalByteSlices: appId === 0 ? ('schema' in params ? (params.schema?.localByteSlices ?? 0) : 0) : undefined,
|
|
384
|
+
numGlobalInts: appId === 0 ? ('schema' in params ? (params.schema?.globalInts ?? 0) : 0) : undefined,
|
|
385
|
+
numGlobalByteSlices: appId === 0 ? ('schema' in params ? (params.schema?.globalByteSlices ?? 0) : 0) : undefined,
|
|
368
386
|
method: params.method,
|
|
369
387
|
signer: includeSigner
|
|
370
388
|
? params.signer
|
|
@@ -372,8 +390,8 @@ class AlgoKitComposer {
|
|
|
372
390
|
? params.signer.signer
|
|
373
391
|
: params.signer
|
|
374
392
|
: this.getSigner(params.sender)
|
|
375
|
-
:
|
|
376
|
-
methodArgs: methodArgs,
|
|
393
|
+
: TransactionComposer.NULL_SIGNER,
|
|
394
|
+
methodArgs: methodArgs.reverse(),
|
|
377
395
|
// note, lease, and rekeyTo are set in the common build step
|
|
378
396
|
note: undefined,
|
|
379
397
|
lease: undefined,
|
|
@@ -486,12 +504,12 @@ class AlgoKitComposer {
|
|
|
486
504
|
txn = algosdk.makeApplicationCreateTxnFromObject({
|
|
487
505
|
...sdkParams,
|
|
488
506
|
extraPages: 'extraProgramPages' in params
|
|
489
|
-
? params.extraProgramPages ?? Math.floor((approvalProgram.length + clearStateProgram.length) / types_app.APP_PAGE_MAX_SIZE)
|
|
507
|
+
? (params.extraProgramPages ?? Math.floor((approvalProgram.length + clearStateProgram.length) / types_app.APP_PAGE_MAX_SIZE))
|
|
490
508
|
: 0,
|
|
491
|
-
numLocalInts: 'schema' in params ? params.schema?.localInts ?? 0 : 0,
|
|
492
|
-
numLocalByteSlices: 'schema' in params ? params.schema?.localByteSlices ?? 0 : 0,
|
|
493
|
-
numGlobalInts: 'schema' in params ? params.schema?.globalInts ?? 0 : 0,
|
|
494
|
-
numGlobalByteSlices: 'schema' in params ? params.schema?.globalByteSlices ?? 0 : 0,
|
|
509
|
+
numLocalInts: 'schema' in params ? (params.schema?.localInts ?? 0) : 0,
|
|
510
|
+
numLocalByteSlices: 'schema' in params ? (params.schema?.localByteSlices ?? 0) : 0,
|
|
511
|
+
numGlobalInts: 'schema' in params ? (params.schema?.globalInts ?? 0) : 0,
|
|
512
|
+
numGlobalByteSlices: 'schema' in params ? (params.schema?.globalByteSlices ?? 0) : 0,
|
|
495
513
|
approvalProgram: approvalProgram,
|
|
496
514
|
clearProgram: clearStateProgram,
|
|
497
515
|
});
|
|
@@ -502,7 +520,32 @@ class AlgoKitComposer {
|
|
|
502
520
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
503
521
|
}
|
|
504
522
|
buildKeyReg(params, suggestedParams) {
|
|
505
|
-
|
|
523
|
+
let txn;
|
|
524
|
+
if ('voteKey' in params) {
|
|
525
|
+
// algosdk throws when voteFirst is 0, so we need to set it to 1, then switch back to 0 after creating the transaction
|
|
526
|
+
const voteFirst = params.voteFirst === 0n ? 1n : params.voteFirst;
|
|
527
|
+
txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({
|
|
528
|
+
from: params.sender,
|
|
529
|
+
voteKey: params.voteKey,
|
|
530
|
+
selectionKey: params.selectionKey,
|
|
531
|
+
voteFirst: Number(voteFirst),
|
|
532
|
+
voteLast: Number(params.voteLast),
|
|
533
|
+
voteKeyDilution: Number(params.voteKeyDilution),
|
|
534
|
+
suggestedParams,
|
|
535
|
+
nonParticipation: false,
|
|
536
|
+
stateProofKey: params.stateProofKey,
|
|
537
|
+
});
|
|
538
|
+
if (params.voteFirst === 0n) {
|
|
539
|
+
txn.voteFirst = 0;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({
|
|
544
|
+
from: params.sender,
|
|
545
|
+
suggestedParams,
|
|
546
|
+
nonParticipation: params.preventAccountFromEverParticipatingAgain,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
506
549
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
507
550
|
}
|
|
508
551
|
/** Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` since those ones can have custom signers that need to be retrieved. */
|
|
@@ -569,7 +612,7 @@ class AlgoKitComposer {
|
|
|
569
612
|
: [];
|
|
570
613
|
transactions.push(...transactionsWithSigner.map((ts) => ts.txn));
|
|
571
614
|
transactionsWithSigner.forEach((ts, idx) => {
|
|
572
|
-
if (ts.signer && ts.signer !==
|
|
615
|
+
if (ts.signer && ts.signer !== TransactionComposer.NULL_SIGNER) {
|
|
573
616
|
signers.set(idx, ts.signer);
|
|
574
617
|
}
|
|
575
618
|
});
|
|
@@ -659,19 +702,17 @@ class AlgoKitComposer {
|
|
|
659
702
|
async execute(params) {
|
|
660
703
|
return this.send(params);
|
|
661
704
|
}
|
|
662
|
-
/**
|
|
663
|
-
* Compose the atomic transaction group and simulate sending it to the network
|
|
664
|
-
* @returns The simulation result
|
|
665
|
-
*/
|
|
666
705
|
async simulate(options) {
|
|
667
|
-
const
|
|
706
|
+
const { skipSignatures = false, ...rawOptions } = options ?? {};
|
|
707
|
+
const atc = skipSignatures ? new AtomicTransactionComposer() : this.atc;
|
|
668
708
|
// Build the transactions
|
|
669
|
-
if (
|
|
670
|
-
|
|
709
|
+
if (skipSignatures) {
|
|
710
|
+
rawOptions.allowEmptySignatures = true;
|
|
711
|
+
rawOptions.fixSigners = true;
|
|
671
712
|
// Build transactions uses empty signers
|
|
672
713
|
const transactions = await this.buildTransactions();
|
|
673
714
|
for (const txn of transactions.transactions) {
|
|
674
|
-
atc.addTransaction({ txn, signer:
|
|
715
|
+
atc.addTransaction({ txn, signer: TransactionComposer.NULL_SIGNER });
|
|
675
716
|
}
|
|
676
717
|
atc['methodCalls'] = transactions.methodCalls;
|
|
677
718
|
}
|
|
@@ -679,21 +720,36 @@ class AlgoKitComposer {
|
|
|
679
720
|
// Build creates real signatures
|
|
680
721
|
await this.build();
|
|
681
722
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
723
|
+
const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({
|
|
724
|
+
txnGroups: [],
|
|
725
|
+
...rawOptions,
|
|
726
|
+
...(config.Config.debug
|
|
727
|
+
? {
|
|
728
|
+
allowEmptySignatures: true,
|
|
729
|
+
fixSigners: true,
|
|
730
|
+
allowMoreLogging: true,
|
|
731
|
+
execTraceConfig: new modelsv2.SimulateTraceConfig({
|
|
732
|
+
enable: true,
|
|
733
|
+
scratchChange: true,
|
|
734
|
+
stackChange: true,
|
|
735
|
+
stateChange: true,
|
|
736
|
+
}),
|
|
737
|
+
}
|
|
738
|
+
: undefined),
|
|
739
|
+
}));
|
|
740
|
+
const failedGroup = simulateResponse?.txnGroups[0];
|
|
741
|
+
if (failedGroup?.failureMessage) {
|
|
742
|
+
const errorMessage = `Transaction failed at transaction(s) ${failedGroup.failedAt?.join(', ') || 'unknown'} in the group. ${failedGroup.failureMessage}`;
|
|
743
|
+
const error = new Error(errorMessage);
|
|
744
|
+
if (config.Config.debug) {
|
|
745
|
+
await config.Config.events.emitAsync(types_lifecycleEvents.EventType.TxnGroupSimulated, { simulateResponse });
|
|
746
|
+
}
|
|
694
747
|
error.simulateResponse = simulateResponse;
|
|
695
748
|
throw error;
|
|
696
749
|
}
|
|
750
|
+
if (config.Config.debug && config.Config.traceAll) {
|
|
751
|
+
await config.Config.events.emitAsync(types_lifecycleEvents.EventType.TxnGroupSimulated, { simulateResponse });
|
|
752
|
+
}
|
|
697
753
|
const transactions = atc.buildGroup().map((t) => t.txn);
|
|
698
754
|
return {
|
|
699
755
|
confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
|
|
@@ -701,7 +757,7 @@ class AlgoKitComposer {
|
|
|
701
757
|
txIds: transactions.map((t) => t.txID()),
|
|
702
758
|
groupId: Buffer.from(transactions[0].group ?? new Uint8Array()).toString('base64'),
|
|
703
759
|
simulateResponse,
|
|
704
|
-
returns: methodResults.map(
|
|
760
|
+
returns: methodResults.map(transaction.getABIReturnValue),
|
|
705
761
|
};
|
|
706
762
|
}
|
|
707
763
|
/**
|
|
@@ -718,8 +774,8 @@ class AlgoKitComposer {
|
|
|
718
774
|
}
|
|
719
775
|
}
|
|
720
776
|
/** Signer used to represent a lack of signer */
|
|
721
|
-
|
|
777
|
+
TransactionComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
|
|
722
778
|
|
|
723
779
|
exports.MAX_TRANSACTION_GROUP_SIZE = MAX_TRANSACTION_GROUP_SIZE;
|
|
724
|
-
exports.
|
|
780
|
+
exports.TransactionComposer = TransactionComposer;
|
|
725
781
|
//# sourceMappingURL=composer.js.map
|