@algorandfoundation/algokit-utils 7.0.0-beta.8 → 7.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/LICENSE +21 -0
- package/README.md +7 -0
- 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 +97 -78
- package/types/app-client.js +171 -54
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +169 -52
- 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 +30 -10
- package/types/app-factory.js +26 -20
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +26 -20
- 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 +40 -25
- package/types/composer.js +114 -40
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +115 -39
- package/types/composer.mjs.map +1 -1
- 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/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.d.ts
CHANGED
|
@@ -11,7 +11,10 @@ import SimulateResponse = algosdk.modelsv2.SimulateResponse;
|
|
|
11
11
|
import modelsv2 = algosdk.modelsv2;
|
|
12
12
|
export declare const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
13
13
|
/** Options to control a simulate request */
|
|
14
|
-
export type SimulateOptions = Expand<Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'
|
|
14
|
+
export type SimulateOptions = Expand<Omit<ConstructorParameters<typeof modelsv2.SimulateRequest>[0], 'txnGroups'>> & {
|
|
15
|
+
/** Whether or not to skip signatures for all built transactions and use an empty signer instead. */
|
|
16
|
+
skipSignatures?: boolean;
|
|
17
|
+
};
|
|
15
18
|
/** Common parameters for defining a transaction. */
|
|
16
19
|
export type CommonTransactionParams = {
|
|
17
20
|
/** The address of the account sending the transaction. */
|
|
@@ -284,6 +287,11 @@ export type OnlineKeyRegistrationParams = CommonTransactionParams & {
|
|
|
284
287
|
/** The 64 byte state proof public key commitment */
|
|
285
288
|
stateProofKey?: Uint8Array;
|
|
286
289
|
};
|
|
290
|
+
/** Parameters to define an offline key registration transaction. */
|
|
291
|
+
export type OfflineKeyRegistrationParams = CommonTransactionParams & {
|
|
292
|
+
/** Prevent this account from ever participating again. The account will also no longer earn rewards */
|
|
293
|
+
preventAccountFromEverParticipatingAgain?: boolean;
|
|
294
|
+
};
|
|
287
295
|
/** Common parameters for defining an application call transaction. */
|
|
288
296
|
export type CommonAppCallParams = CommonTransactionParams & {
|
|
289
297
|
/** ID of the application; 0 if the application is being created. */
|
|
@@ -368,8 +376,9 @@ export type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {
|
|
|
368
376
|
* * A transaction (where the signer will be automatically assigned)
|
|
369
377
|
* * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())
|
|
370
378
|
* * Another method call (via method call params object)
|
|
379
|
+
* * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)
|
|
371
380
|
*/
|
|
372
|
-
args?: (algosdk.ABIValue | TransactionWithSigner | Transaction | Promise<Transaction> | AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams>)[];
|
|
381
|
+
args?: (algosdk.ABIValue | TransactionWithSigner | Transaction | Promise<Transaction> | AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> | undefined)[];
|
|
373
382
|
};
|
|
374
383
|
export type Txn = (PaymentParams & {
|
|
375
384
|
type: 'pay';
|
|
@@ -389,7 +398,7 @@ export type Txn = (PaymentParams & {
|
|
|
389
398
|
type: 'assetOptOut';
|
|
390
399
|
}) | ((AppCallParams | AppCreateParams | AppUpdateParams) & {
|
|
391
400
|
type: 'appCall';
|
|
392
|
-
}) | (OnlineKeyRegistrationParams & {
|
|
401
|
+
}) | ((OnlineKeyRegistrationParams | OfflineKeyRegistrationParams) & {
|
|
393
402
|
type: 'keyReg';
|
|
394
403
|
}) | (algosdk.TransactionWithSigner & {
|
|
395
404
|
type: 'txnWithSigner';
|
|
@@ -399,8 +408,8 @@ export type Txn = (PaymentParams & {
|
|
|
399
408
|
} | ((AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall) & {
|
|
400
409
|
type: 'methodCall';
|
|
401
410
|
});
|
|
402
|
-
/** Parameters to create an `
|
|
403
|
-
export type
|
|
411
|
+
/** Parameters to create an `TransactionComposer`. */
|
|
412
|
+
export type TransactionComposerParams = {
|
|
404
413
|
/** The algod client to use to get suggestedParams and send the transaction group */
|
|
405
414
|
algod: algosdk.Algodv2;
|
|
406
415
|
/** The function used to get the TransactionSigner for a given address */
|
|
@@ -417,7 +426,7 @@ export type AlgoKitComposerParams = {
|
|
|
417
426
|
*/
|
|
418
427
|
appManager?: AppManager;
|
|
419
428
|
};
|
|
420
|
-
/** Set of transactions built by `
|
|
429
|
+
/** Set of transactions built by `TransactionComposer`. */
|
|
421
430
|
export interface BuiltTransactions {
|
|
422
431
|
/** The built transactions */
|
|
423
432
|
transactions: algosdk.Transaction[];
|
|
@@ -426,8 +435,8 @@ export interface BuiltTransactions {
|
|
|
426
435
|
/** Any `TransactionSigner` objects associated with any of the transactions in a map keyed by transaction index. */
|
|
427
436
|
signers: Map<number, algosdk.TransactionSigner>;
|
|
428
437
|
}
|
|
429
|
-
/**
|
|
430
|
-
export
|
|
438
|
+
/** TransactionComposer helps you compose and execute transactions as a transaction group. */
|
|
439
|
+
export declare class TransactionComposer {
|
|
431
440
|
/** Signer used to represent a lack of signer */
|
|
432
441
|
private static NULL_SIGNER;
|
|
433
442
|
/** The ATC used to compose the group */
|
|
@@ -448,65 +457,65 @@ export default class AlgoKitComposer {
|
|
|
448
457
|
private defaultValidityWindowIsExplicit;
|
|
449
458
|
private appManager;
|
|
450
459
|
/**
|
|
451
|
-
* Create
|
|
460
|
+
* Create a `TransactionComposer`.
|
|
452
461
|
* @param params The configuration for this composer
|
|
453
462
|
*/
|
|
454
|
-
constructor(params:
|
|
463
|
+
constructor(params: TransactionComposerParams);
|
|
455
464
|
/**
|
|
456
465
|
* Add a pre-built transaction to the transaction group.
|
|
457
466
|
* @param transaction The pre-built transaction
|
|
458
467
|
* @param signer Optional signer override for the transaction
|
|
459
468
|
* @returns The composer so you can chain method calls
|
|
460
469
|
*/
|
|
461
|
-
addTransaction(transaction: Transaction, signer?: TransactionSigner):
|
|
470
|
+
addTransaction(transaction: Transaction, signer?: TransactionSigner): TransactionComposer;
|
|
462
471
|
/**
|
|
463
472
|
* Add a payment transaction to the transaction group.
|
|
464
473
|
* @param params The payment transaction parameters
|
|
465
474
|
* @returns The composer so you can chain method calls
|
|
466
475
|
*/
|
|
467
|
-
addPayment(params: PaymentParams):
|
|
476
|
+
addPayment(params: PaymentParams): TransactionComposer;
|
|
468
477
|
/**
|
|
469
478
|
* Add an asset create transaction to the transaction group.
|
|
470
479
|
* @param params The asset create transaction parameters
|
|
471
480
|
* @returns The composer so you can chain method calls
|
|
472
481
|
*/
|
|
473
|
-
addAssetCreate(params: AssetCreateParams):
|
|
482
|
+
addAssetCreate(params: AssetCreateParams): TransactionComposer;
|
|
474
483
|
/**
|
|
475
484
|
* Add an asset config transaction to the transaction group.
|
|
476
485
|
* @param params The asset config transaction parameters
|
|
477
486
|
* @returns The composer so you can chain method calls
|
|
478
487
|
*/
|
|
479
|
-
addAssetConfig(params: AssetConfigParams):
|
|
488
|
+
addAssetConfig(params: AssetConfigParams): TransactionComposer;
|
|
480
489
|
/**
|
|
481
490
|
* Add an asset freeze transaction to the transaction group.
|
|
482
491
|
* @param params The asset freeze transaction parameters
|
|
483
492
|
* @returns The composer so you can chain method calls
|
|
484
493
|
*/
|
|
485
|
-
addAssetFreeze(params: AssetFreezeParams):
|
|
494
|
+
addAssetFreeze(params: AssetFreezeParams): TransactionComposer;
|
|
486
495
|
/**
|
|
487
496
|
* Add an asset destroy transaction to the transaction group.
|
|
488
497
|
* @param params The asset destroy transaction parameters
|
|
489
498
|
* @returns The composer so you can chain method calls
|
|
490
499
|
*/
|
|
491
|
-
addAssetDestroy(params: AssetDestroyParams):
|
|
500
|
+
addAssetDestroy(params: AssetDestroyParams): TransactionComposer;
|
|
492
501
|
/**
|
|
493
502
|
* Add an asset transfer transaction to the transaction group.
|
|
494
503
|
* @param params The asset transfer transaction parameters
|
|
495
504
|
* @returns The composer so you can chain method calls
|
|
496
505
|
*/
|
|
497
|
-
addAssetTransfer(params: AssetTransferParams):
|
|
506
|
+
addAssetTransfer(params: AssetTransferParams): TransactionComposer;
|
|
498
507
|
/**
|
|
499
508
|
* Add an asset opt-in transaction to the transaction group.
|
|
500
509
|
* @param params The asset opt-in transaction parameters
|
|
501
510
|
* @returns The composer so you can chain method calls
|
|
502
511
|
*/
|
|
503
|
-
addAssetOptIn(params: AssetOptInParams):
|
|
512
|
+
addAssetOptIn(params: AssetOptInParams): TransactionComposer;
|
|
504
513
|
/**
|
|
505
514
|
* Add an asset opt-out transaction to the transaction group.
|
|
506
515
|
* @param params The asset opt-out transaction parameters
|
|
507
516
|
* @returns The composer so you can chain method calls
|
|
508
517
|
*/
|
|
509
|
-
addAssetOptOut(params: AssetOptOutParams):
|
|
518
|
+
addAssetOptOut(params: AssetOptOutParams): TransactionComposer;
|
|
510
519
|
/**
|
|
511
520
|
* Add an application create transaction to the transaction group.
|
|
512
521
|
*
|
|
@@ -514,7 +523,7 @@ export default class AlgoKitComposer {
|
|
|
514
523
|
* @param params The application create transaction parameters
|
|
515
524
|
* @returns The composer so you can chain method calls
|
|
516
525
|
*/
|
|
517
|
-
addAppCreate(params: AppCreateParams):
|
|
526
|
+
addAppCreate(params: AppCreateParams): TransactionComposer;
|
|
518
527
|
/**
|
|
519
528
|
* Add an application update transaction to the transaction group.
|
|
520
529
|
*
|
|
@@ -522,7 +531,7 @@ export default class AlgoKitComposer {
|
|
|
522
531
|
* @param params The application update transaction parameters
|
|
523
532
|
* @returns The composer so you can chain method calls
|
|
524
533
|
*/
|
|
525
|
-
addAppUpdate(params: AppUpdateParams):
|
|
534
|
+
addAppUpdate(params: AppUpdateParams): TransactionComposer;
|
|
526
535
|
/**
|
|
527
536
|
* Add an application delete transaction to the transaction group.
|
|
528
537
|
*
|
|
@@ -530,7 +539,7 @@ export default class AlgoKitComposer {
|
|
|
530
539
|
* @param params The application delete transaction parameters
|
|
531
540
|
* @returns The composer so you can chain method calls
|
|
532
541
|
*/
|
|
533
|
-
addAppDelete(params: AppDeleteParams):
|
|
542
|
+
addAppDelete(params: AppDeleteParams): TransactionComposer;
|
|
534
543
|
/**
|
|
535
544
|
* Add an application call transaction to the transaction group.
|
|
536
545
|
*
|
|
@@ -540,7 +549,7 @@ export default class AlgoKitComposer {
|
|
|
540
549
|
* @param params The application call transaction parameters
|
|
541
550
|
* @returns The composer so you can chain method calls
|
|
542
551
|
*/
|
|
543
|
-
addAppCall(params: AppCallParams):
|
|
552
|
+
addAppCall(params: AppCallParams): TransactionComposer;
|
|
544
553
|
/**
|
|
545
554
|
* Add an ABI method create application call transaction to the transaction group.
|
|
546
555
|
*
|
|
@@ -578,13 +587,19 @@ export default class AlgoKitComposer {
|
|
|
578
587
|
* @param params The online key registration transaction parameters
|
|
579
588
|
* @returns The composer so you can chain method calls
|
|
580
589
|
*/
|
|
581
|
-
addOnlineKeyRegistration(params: OnlineKeyRegistrationParams):
|
|
590
|
+
addOnlineKeyRegistration(params: OnlineKeyRegistrationParams): TransactionComposer;
|
|
591
|
+
/**
|
|
592
|
+
* Add an offline key registration transaction to the transaction group.
|
|
593
|
+
* @param params The offline key registration transaction parameters
|
|
594
|
+
* @returns The composer so you can chain method calls
|
|
595
|
+
*/
|
|
596
|
+
addOfflineKeyRegistration(params: OfflineKeyRegistrationParams): TransactionComposer;
|
|
582
597
|
/**
|
|
583
598
|
* Add the transactions within an `AtomicTransactionComposer` to the transaction group.
|
|
584
599
|
* @param atc The `AtomicTransactionComposer` to build transactions from and add to the group
|
|
585
600
|
* @returns The composer so you can chain method calls
|
|
586
601
|
*/
|
|
587
|
-
addAtc(atc: algosdk.AtomicTransactionComposer):
|
|
602
|
+
addAtc(atc: algosdk.AtomicTransactionComposer): TransactionComposer;
|
|
588
603
|
/** Build an ATC and return transactions ready to be incorporated into a broader set of transactions this composer is composing */
|
|
589
604
|
private buildAtc;
|
|
590
605
|
private commonTxnBuildStep;
|
package/types/composer.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
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
|
|
|
11
|
+
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
14
12
|
var isTransactionWithSigner = algosdk.isTransactionWithSigner;
|
|
15
13
|
var encodeAddress = algosdk.encodeAddress;
|
|
16
14
|
var modelsv2 = algosdk.modelsv2;
|
|
17
15
|
const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
18
|
-
/**
|
|
19
|
-
class
|
|
16
|
+
/** TransactionComposer helps you compose and execute transactions as a transaction group. */
|
|
17
|
+
class TransactionComposer {
|
|
20
18
|
/**
|
|
21
|
-
* Create
|
|
19
|
+
* Create a `TransactionComposer`.
|
|
22
20
|
* @param params The configuration for this composer
|
|
23
21
|
*/
|
|
24
22
|
constructor(params) {
|
|
@@ -225,6 +223,15 @@ class AlgoKitComposer {
|
|
|
225
223
|
this.txns.push({ ...params, type: 'keyReg' });
|
|
226
224
|
return this;
|
|
227
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
|
+
}
|
|
228
235
|
/**
|
|
229
236
|
* Add the transactions within an `AtomicTransactionComposer` to the transaction group.
|
|
230
237
|
* @param atc The `AtomicTransactionComposer` to build transactions from and add to the group
|
|
@@ -238,7 +245,7 @@ class AlgoKitComposer {
|
|
|
238
245
|
buildAtc(atc, processTransaction) {
|
|
239
246
|
const group = atc.buildGroup();
|
|
240
247
|
const txnWithSigners = group.map((ts, idx) => {
|
|
241
|
-
// 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
|
|
242
249
|
ts.txn.group = undefined;
|
|
243
250
|
// Process transaction if a function is provided
|
|
244
251
|
ts.txn = processTransaction?.(ts.txn, idx) ?? ts.txn;
|
|
@@ -295,14 +302,22 @@ class AlgoKitComposer {
|
|
|
295
302
|
*/
|
|
296
303
|
async buildMethodCall(params, suggestedParams, includeSigner) {
|
|
297
304
|
const methodArgs = [];
|
|
305
|
+
const transactionsForGroup = [];
|
|
298
306
|
const isAbiValue = (x) => {
|
|
299
307
|
if (Array.isArray(x))
|
|
300
308
|
return x.length == 0 || x.every(isAbiValue);
|
|
301
309
|
return typeof x === 'bigint' || typeof x === 'boolean' || typeof x === 'number' || typeof x === 'string' || x instanceof Uint8Array;
|
|
302
310
|
};
|
|
303
|
-
for (let i =
|
|
311
|
+
for (let i = (params.args ?? []).length - 1; i >= 0; i--) {
|
|
304
312
|
const arg = params.args[i];
|
|
305
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
|
+
}
|
|
306
321
|
throw Error(`No value provided for argument ${i + 1} within call to ${params.method.name}`);
|
|
307
322
|
}
|
|
308
323
|
if (isAbiValue(arg)) {
|
|
@@ -315,7 +330,10 @@ class AlgoKitComposer {
|
|
|
315
330
|
}
|
|
316
331
|
if ('method' in arg) {
|
|
317
332
|
const tempTxnWithSigners = await this.buildMethodCall(arg, suggestedParams, includeSigner);
|
|
318
|
-
|
|
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
|
|
319
337
|
continue;
|
|
320
338
|
}
|
|
321
339
|
const txn = await arg;
|
|
@@ -327,10 +345,11 @@ class AlgoKitComposer {
|
|
|
327
345
|
? params.signer.signer
|
|
328
346
|
: params.signer
|
|
329
347
|
: this.getSigner(encodeAddress(txn.from.publicKey))
|
|
330
|
-
:
|
|
348
|
+
: TransactionComposer.NULL_SIGNER,
|
|
331
349
|
});
|
|
332
350
|
}
|
|
333
351
|
const methodAtc = new algosdk.AtomicTransactionComposer();
|
|
352
|
+
transactionsForGroup.reverse().forEach((txn) => methodAtc.addTransaction(txn));
|
|
334
353
|
const appId = Number('appId' in params ? params.appId : 0n);
|
|
335
354
|
const approvalProgram = 'approvalProgram' in params
|
|
336
355
|
? typeof params.approvalProgram === 'string'
|
|
@@ -360,10 +379,10 @@ class AlgoKitComposer {
|
|
|
360
379
|
? Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0)) / types_app.APP_PAGE_MAX_SIZE)
|
|
361
380
|
: 0
|
|
362
381
|
: undefined,
|
|
363
|
-
numLocalInts: appId === 0 ? ('schema' in params ? params.schema?.localInts ?? 0 : 0) : undefined,
|
|
364
|
-
numLocalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.localByteSlices ?? 0 : 0) : undefined,
|
|
365
|
-
numGlobalInts: appId === 0 ? ('schema' in params ? params.schema?.globalInts ?? 0 : 0) : undefined,
|
|
366
|
-
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,
|
|
367
386
|
method: params.method,
|
|
368
387
|
signer: includeSigner
|
|
369
388
|
? params.signer
|
|
@@ -371,8 +390,8 @@ class AlgoKitComposer {
|
|
|
371
390
|
? params.signer.signer
|
|
372
391
|
: params.signer
|
|
373
392
|
: this.getSigner(params.sender)
|
|
374
|
-
:
|
|
375
|
-
methodArgs: methodArgs,
|
|
393
|
+
: TransactionComposer.NULL_SIGNER,
|
|
394
|
+
methodArgs: methodArgs.reverse(),
|
|
376
395
|
// note, lease, and rekeyTo are set in the common build step
|
|
377
396
|
note: undefined,
|
|
378
397
|
lease: undefined,
|
|
@@ -485,12 +504,12 @@ class AlgoKitComposer {
|
|
|
485
504
|
txn = algosdk.makeApplicationCreateTxnFromObject({
|
|
486
505
|
...sdkParams,
|
|
487
506
|
extraPages: 'extraProgramPages' in params
|
|
488
|
-
? 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))
|
|
489
508
|
: 0,
|
|
490
|
-
numLocalInts: 'schema' in params ? params.schema?.localInts ?? 0 : 0,
|
|
491
|
-
numLocalByteSlices: 'schema' in params ? params.schema?.localByteSlices ?? 0 : 0,
|
|
492
|
-
numGlobalInts: 'schema' in params ? params.schema?.globalInts ?? 0 : 0,
|
|
493
|
-
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,
|
|
494
513
|
approvalProgram: approvalProgram,
|
|
495
514
|
clearProgram: clearStateProgram,
|
|
496
515
|
});
|
|
@@ -501,7 +520,32 @@ class AlgoKitComposer {
|
|
|
501
520
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
502
521
|
}
|
|
503
522
|
buildKeyReg(params, suggestedParams) {
|
|
504
|
-
|
|
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
|
+
}
|
|
505
549
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
506
550
|
}
|
|
507
551
|
/** Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` since those ones can have custom signers that need to be retrieved. */
|
|
@@ -568,7 +612,7 @@ class AlgoKitComposer {
|
|
|
568
612
|
: [];
|
|
569
613
|
transactions.push(...transactionsWithSigner.map((ts) => ts.txn));
|
|
570
614
|
transactionsWithSigner.forEach((ts, idx) => {
|
|
571
|
-
if (ts.signer && ts.signer !==
|
|
615
|
+
if (ts.signer && ts.signer !== TransactionComposer.NULL_SIGNER) {
|
|
572
616
|
signers.set(idx, ts.signer);
|
|
573
617
|
}
|
|
574
618
|
});
|
|
@@ -663,30 +707,60 @@ class AlgoKitComposer {
|
|
|
663
707
|
* @returns The simulation result
|
|
664
708
|
*/
|
|
665
709
|
async simulate(options) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
await
|
|
673
|
-
|
|
674
|
-
|
|
710
|
+
const atc = options?.skipSignatures ? new AtomicTransactionComposer() : this.atc;
|
|
711
|
+
// Build the transactions
|
|
712
|
+
if (options?.skipSignatures) {
|
|
713
|
+
options.allowEmptySignatures = true;
|
|
714
|
+
options.fixSigners = true;
|
|
715
|
+
// Build transactions uses empty signers
|
|
716
|
+
const transactions = await this.buildTransactions();
|
|
717
|
+
for (const txn of transactions.transactions) {
|
|
718
|
+
atc.addTransaction({ txn, signer: TransactionComposer.NULL_SIGNER });
|
|
719
|
+
}
|
|
720
|
+
atc['methodCalls'] = transactions.methodCalls;
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
// Build creates real signatures
|
|
724
|
+
await this.build();
|
|
675
725
|
}
|
|
676
|
-
const { methodResults, simulateResponse } = await
|
|
677
|
-
|
|
678
|
-
|
|
726
|
+
const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({
|
|
727
|
+
txnGroups: [],
|
|
728
|
+
...options,
|
|
729
|
+
...(config.Config.debug
|
|
730
|
+
? {
|
|
731
|
+
allowEmptySignatures: true,
|
|
732
|
+
fixSigners: true,
|
|
733
|
+
allowMoreLogging: true,
|
|
734
|
+
execTraceConfig: new modelsv2.SimulateTraceConfig({
|
|
735
|
+
enable: true,
|
|
736
|
+
scratchChange: true,
|
|
737
|
+
stackChange: true,
|
|
738
|
+
stateChange: true,
|
|
739
|
+
}),
|
|
740
|
+
}
|
|
741
|
+
: undefined),
|
|
742
|
+
}));
|
|
743
|
+
const failedGroup = simulateResponse?.txnGroups[0];
|
|
744
|
+
if (failedGroup?.failureMessage) {
|
|
745
|
+
const errorMessage = `Transaction failed at transaction(s) ${failedGroup.failedAt?.join(', ') || 'unknown'} in the group. ${failedGroup.failureMessage}`;
|
|
746
|
+
const error = new Error(errorMessage);
|
|
747
|
+
if (config.Config.debug) {
|
|
748
|
+
await config.Config.events.emitAsync(types_lifecycleEvents.EventType.TxnGroupSimulated, { simulateResponse });
|
|
749
|
+
}
|
|
679
750
|
error.simulateResponse = simulateResponse;
|
|
680
751
|
throw error;
|
|
681
752
|
}
|
|
682
|
-
|
|
753
|
+
if (config.Config.debug && config.Config.traceAll) {
|
|
754
|
+
await config.Config.events.emitAsync(types_lifecycleEvents.EventType.TxnGroupSimulated, { simulateResponse });
|
|
755
|
+
}
|
|
756
|
+
const transactions = atc.buildGroup().map((t) => t.txn);
|
|
683
757
|
return {
|
|
684
758
|
confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
|
|
685
759
|
transactions: transactions,
|
|
686
760
|
txIds: transactions.map((t) => t.txID()),
|
|
687
761
|
groupId: Buffer.from(transactions[0].group ?? new Uint8Array()).toString('base64'),
|
|
688
762
|
simulateResponse,
|
|
689
|
-
returns: methodResults.map(
|
|
763
|
+
returns: methodResults.map(transaction.getABIReturnValue),
|
|
690
764
|
};
|
|
691
765
|
}
|
|
692
766
|
/**
|
|
@@ -703,8 +777,8 @@ class AlgoKitComposer {
|
|
|
703
777
|
}
|
|
704
778
|
}
|
|
705
779
|
/** Signer used to represent a lack of signer */
|
|
706
|
-
|
|
780
|
+
TransactionComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
|
|
707
781
|
|
|
708
782
|
exports.MAX_TRANSACTION_GROUP_SIZE = MAX_TRANSACTION_GROUP_SIZE;
|
|
709
|
-
exports.
|
|
783
|
+
exports.TransactionComposer = TransactionComposer;
|
|
710
784
|
//# sourceMappingURL=composer.js.map
|