@algorandfoundation/algokit-utils 6.3.0-beta.1 → 7.0.0-beta.10
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 +3 -25
- package/account/account.d.ts +8 -9
- package/account/account.js +7 -7
- package/account/account.js.map +1 -1
- package/account/account.mjs +7 -7
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +0 -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.d.ts +2 -3
- package/account/get-account.js +1 -1
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +1 -1
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +1 -2
- package/account/get-dispenser-account.js +1 -1
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +1 -1
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/index.d.ts +0 -1
- package/account/mnemonic-account.d.ts +1 -2
- package/account/mnemonic-account.js +1 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +1 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +14 -5
- package/amount.js +6 -0
- package/amount.js.map +1 -1
- package/amount.mjs +6 -0
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +15 -1
- package/app-client.js +15 -0
- package/app-client.js.map +1 -1
- package/app-client.mjs +15 -0
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +18 -2
- package/app-deploy.js +140 -333
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +143 -336
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +39 -3
- package/app.js +116 -369
- package/app.js.map +1 -1
- package/app.mjs +117 -370
- package/app.mjs.map +1 -1
- package/asset.d.ts +5 -6
- package/asset.js +5 -8
- package/asset.js.map +1 -1
- package/asset.mjs +5 -8
- package/asset.mjs.map +1 -1
- package/config.d.ts +0 -1
- package/config.js.map +1 -1
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +3 -5
- package/debugging/debugging.js +4 -128
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +4 -109
- package/debugging/debugging.mjs.map +1 -1
- package/debugging/index.d.ts +0 -2
- package/dispenser-client.d.ts +0 -1
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +4 -4
- package/index.js +31 -26
- package/index.js.map +1 -1
- package/index.mjs +4 -4
- package/indexer-lookup.d.ts +0 -1
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-kmd-wallet-account.js +1 -1
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +1 -1
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +1 -2
- package/localnet/get-localnet-dispenser-account.js +1 -1
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +1 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-or-create-kmd-wallet-account.js +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/index.d.ts +0 -1
- package/localnet/is-localnet.d.ts +1 -2
- package/localnet/is-localnet.js +1 -1
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +1 -1
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +2 -3
- package/network-client.js +2 -2
- package/network-client.js.map +1 -1
- package/network-client.mjs +2 -2
- package/network-client.mjs.map +1 -1
- package/package.json +1 -1
- package/testing/_asset.d.ts +0 -1
- package/testing/account.d.ts +0 -1
- package/testing/account.js.map +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -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.d.ts +0 -1
- package/testing/fixtures/algorand-fixture.js +12 -12
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +12 -12
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/fixtures/index.d.ts +0 -1
- package/testing/index.d.ts +0 -1
- package/testing/indexer.d.ts +0 -1
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +0 -1
- package/testing/test-logger.js +1 -3
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +1 -3
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +0 -1
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/index.d.ts +0 -1
- package/transaction/legacy-bridge.d.ts +31 -6
- package/transaction/legacy-bridge.js +100 -6
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +99 -8
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +41 -6
- package/transaction/transaction.js +107 -45
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +107 -46
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/index.d.ts +0 -1
- package/transfer/transfer-algos.d.ts +1 -2
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -2
- package/transfer/transfer.js +3 -3
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +3 -3
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +14 -6
- package/types/account-manager.js +18 -4
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +18 -4
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +0 -1
- package/types/account.js.map +1 -1
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +0 -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 +28 -0
- package/types/algorand-client-interface.js +3 -0
- package/types/algorand-client-interface.js.map +1 -0
- package/types/algorand-client-interface.mjs +2 -0
- package/types/algorand-client-interface.mjs.map +1 -0
- package/types/algorand-client-transaction-creator.d.ts +450 -21
- package/types/algorand-client-transaction-creator.js +406 -22
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +406 -22
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +758 -33
- package/types/algorand-client-transaction-sender.js +444 -14
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +444 -14
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +18 -10
- package/types/algorand-client.js +23 -10
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +23 -10
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +10 -11
- package/types/amount.js +7 -7
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +7 -7
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +348 -0
- package/types/app-arc56.js +184 -0
- package/types/app-arc56.js.map +1 -0
- package/types/app-arc56.mjs +175 -0
- package/types/app-arc56.mjs.map +1 -0
- package/types/app-client.d.ts +1496 -9
- package/types/app-client.js +903 -21
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +904 -23
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +126 -0
- package/types/app-deployer.js +354 -0
- package/types/app-deployer.js.map +1 -0
- package/types/app-deployer.mjs +352 -0
- package/types/app-deployer.mjs.map +1 -0
- package/types/app-factory.d.ts +846 -0
- package/types/app-factory.js +411 -0
- package/types/app-factory.js.map +1 -0
- package/types/app-factory.mjs +409 -0
- package/types/app-factory.mjs.map +1 -0
- package/types/app-manager.d.ts +244 -0
- package/types/app-manager.js +334 -0
- package/types/app-manager.js.map +1 -0
- package/types/app-manager.mjs +332 -0
- package/types/app-manager.mjs.map +1 -0
- package/types/app-spec.d.ts +2 -1
- package/types/app-spec.js +121 -0
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +120 -0
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +53 -13
- package/types/app.js +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +4 -4
- package/types/asset-manager.js +3 -4
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +3 -4
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +0 -1
- package/types/async-event-emitter.d.ts +23 -0
- package/types/async-event-emitter.js +55 -0
- package/types/async-event-emitter.js.map +1 -0
- package/types/async-event-emitter.mjs +53 -0
- package/types/async-event-emitter.mjs.map +1 -0
- package/types/client-manager.d.ts +133 -51
- package/types/client-manager.js +147 -23
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +148 -24
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +232 -49
- package/types/composer.js +307 -65
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +308 -66
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +3 -6
- package/types/config.js +5 -44
- package/types/config.js.map +1 -1
- package/types/config.mjs +5 -27
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +29 -101
- package/types/debugging.js +16 -109
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -107
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +1 -2
- package/types/dispenser-client.js +6 -5
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +6 -5
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +7 -0
- package/types/expand.js +3 -0
- package/types/expand.js.map +1 -0
- package/types/expand.mjs +2 -0
- package/types/expand.mjs.map +1 -0
- package/types/indexer.d.ts +0 -1
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +0 -1
- package/types/kmd-account-manager.js +2 -2
- 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/logging.d.ts +0 -1
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +0 -1
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +13 -1
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +3 -4
- package/types/transaction.d.ts +17 -4
- package/types/transfer.d.ts +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -1
- package/types/urlTokenBaseHTTPClient.js +1 -1
- package/types/urlTokenBaseHTTPClient.js.map +1 -1
- package/types/urlTokenBaseHTTPClient.mjs +1 -1
- package/types/urlTokenBaseHTTPClient.mjs.map +1 -1
- package/util.d.ts +2 -2
- package/util.js +11 -10
- package/util.js.map +1 -1
- package/util.mjs +11 -10
- package/util.mjs.map +1 -1
- package/account/account.d.ts.map +0 -1
- package/account/get-account-config-from-environment.d.ts.map +0 -1
- package/account/get-account.d.ts.map +0 -1
- package/account/get-dispenser-account.d.ts.map +0 -1
- package/account/index.d.ts.map +0 -1
- package/account/mnemonic-account.d.ts.map +0 -1
- package/amount.d.ts.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app.d.ts.map +0 -1
- package/asset.d.ts.map +0 -1
- package/config.d.ts.map +0 -1
- package/debugging/debugging.d.ts.map +0 -1
- package/debugging/index.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.d.ts +0 -20
- package/debugging/simulate-and-persist-response.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.js +0 -108
- package/debugging/simulate-and-persist-response.js.map +0 -1
- package/debugging/simulate-and-persist-response.mjs +0 -89
- package/debugging/simulate-and-persist-response.mjs.map +0 -1
- package/dispenser-client.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/index.d.ts.map +0 -1
- package/localnet/is-localnet.d.ts.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/testing/_asset.d.ts.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/transaction/index.d.ts.map +0 -1
- package/transaction/legacy-bridge.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
- package/transaction/transaction.d.ts.map +0 -1
- package/transfer/index.d.ts.map +0 -1
- package/transfer/transfer-algos.d.ts.map +0 -1
- package/transfer/transfer.d.ts.map +0 -1
- package/types/account-manager.d.ts.map +0 -1
- package/types/account.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algorand-client-transaction-creator.d.ts.map +0 -1
- package/types/algorand-client-transaction-sender.d.ts.map +0 -1
- package/types/algorand-client.d.ts.map +0 -1
- package/types/amount.d.ts.map +0 -1
- package/types/app-client.d.ts.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.d.ts.map +0 -1
- package/types/asset-manager.d.ts.map +0 -1
- package/types/asset.d.ts.map +0 -1
- package/types/client-manager.d.ts.map +0 -1
- package/types/composer.d.ts.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/debugging.d.ts.map +0 -1
- package/types/dispenser-client.d.ts.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/kmd-account-manager.d.ts.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/network-client.d.ts.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/transaction.d.ts.map +0 -1
- package/types/transfer.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/util.d.ts.map +0 -1
package/types/composer.mjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
|
-
import {
|
|
2
|
+
import { Config } from '../config.mjs';
|
|
3
|
+
import { performAtomicTransactionComposerSimulate } from '../transaction/perform-atomic-transaction-composer-simulate.mjs';
|
|
4
|
+
import { encodeLease, sendAtomicTransactionComposer, getABIReturnValue } from '../transaction/transaction.mjs';
|
|
5
|
+
import { APP_PAGE_MAX_SIZE } from './app.mjs';
|
|
6
|
+
import { AppManager } from './app-manager.mjs';
|
|
7
|
+
import { EventType } from './async-event-emitter.mjs';
|
|
3
8
|
import { genesisIdIsLocalNet } from './network-client.mjs';
|
|
4
9
|
|
|
10
|
+
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
5
11
|
var isTransactionWithSigner = algosdk.isTransactionWithSigner;
|
|
6
12
|
var encodeAddress = algosdk.encodeAddress;
|
|
13
|
+
var modelsv2 = algosdk.modelsv2;
|
|
7
14
|
const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
8
15
|
/** AlgoKit Composer helps you compose and execute transactions as a transaction group. */
|
|
9
16
|
class AlgoKitComposer {
|
|
@@ -28,6 +35,21 @@ class AlgoKitComposer {
|
|
|
28
35
|
this.getSigner = params.getSigner;
|
|
29
36
|
this.defaultValidityWindow = params.defaultValidityWindow ?? this.defaultValidityWindow;
|
|
30
37
|
this.defaultValidityWindowIsExplicit = params.defaultValidityWindow !== undefined;
|
|
38
|
+
this.appManager = params.appManager ?? new AppManager(params.algod);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Add a pre-built transaction to the transaction group.
|
|
42
|
+
* @param transaction The pre-built transaction
|
|
43
|
+
* @param signer Optional signer override for the transaction
|
|
44
|
+
* @returns The composer so you can chain method calls
|
|
45
|
+
*/
|
|
46
|
+
addTransaction(transaction, signer) {
|
|
47
|
+
this.txns.push({
|
|
48
|
+
txn: transaction,
|
|
49
|
+
signer: signer ?? this.getSigner(algosdk.encodeAddress(transaction.from.publicKey)),
|
|
50
|
+
type: 'txnWithSigner',
|
|
51
|
+
});
|
|
52
|
+
return this;
|
|
31
53
|
}
|
|
32
54
|
/**
|
|
33
55
|
* Add a payment transaction to the transaction group.
|
|
@@ -101,9 +123,44 @@ class AlgoKitComposer {
|
|
|
101
123
|
this.txns.push({ ...params, type: 'assetOptOut' });
|
|
102
124
|
return this;
|
|
103
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Add an application create transaction to the transaction group.
|
|
128
|
+
*
|
|
129
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
130
|
+
* @param params The application create transaction parameters
|
|
131
|
+
* @returns The composer so you can chain method calls
|
|
132
|
+
*/
|
|
133
|
+
addAppCreate(params) {
|
|
134
|
+
this.txns.push({ ...params, type: 'appCall' });
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Add an application update transaction to the transaction group.
|
|
139
|
+
*
|
|
140
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
141
|
+
* @param params The application update transaction parameters
|
|
142
|
+
* @returns The composer so you can chain method calls
|
|
143
|
+
*/
|
|
144
|
+
addAppUpdate(params) {
|
|
145
|
+
this.txns.push({ ...params, type: 'appCall', onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC });
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Add an application delete transaction to the transaction group.
|
|
150
|
+
*
|
|
151
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
152
|
+
* @param params The application delete transaction parameters
|
|
153
|
+
* @returns The composer so you can chain method calls
|
|
154
|
+
*/
|
|
155
|
+
addAppDelete(params) {
|
|
156
|
+
this.txns.push({ ...params, type: 'appCall', onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC });
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
104
159
|
/**
|
|
105
160
|
* Add an application call transaction to the transaction group.
|
|
106
161
|
*
|
|
162
|
+
* If you want to create or update an app use `addAppCreate` or `addAppUpdate`.
|
|
163
|
+
*
|
|
107
164
|
* Note: we recommend using app clients to make it easier to make app calls.
|
|
108
165
|
* @param params The application call transaction parameters
|
|
109
166
|
* @returns The composer so you can chain method calls
|
|
@@ -113,13 +170,46 @@ class AlgoKitComposer {
|
|
|
113
170
|
return this;
|
|
114
171
|
}
|
|
115
172
|
/**
|
|
116
|
-
* Add an ABI method application call transaction to the transaction group.
|
|
173
|
+
* Add an ABI method create application call transaction to the transaction group.
|
|
174
|
+
*
|
|
175
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
176
|
+
* @param params The ABI create method application call transaction parameters
|
|
177
|
+
* @returns The composer so you can chain method calls
|
|
178
|
+
*/
|
|
179
|
+
addAppCreateMethodCall(params) {
|
|
180
|
+
this.txns.push({ ...params, type: 'methodCall' });
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Add an ABI method update application call transaction to the transaction group.
|
|
185
|
+
*
|
|
186
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
187
|
+
* @param params The ABI update method application call transaction parameters
|
|
188
|
+
* @returns The composer so you can chain method calls
|
|
189
|
+
*/
|
|
190
|
+
addAppUpdateMethodCall(params) {
|
|
191
|
+
this.txns.push({ ...params, type: 'methodCall', onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC });
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Add an ABI method delete application call transaction to the transaction group.
|
|
196
|
+
*
|
|
197
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
198
|
+
* @param params The ABI delete method application call transaction parameters
|
|
199
|
+
* @returns The composer so you can chain method calls
|
|
200
|
+
*/
|
|
201
|
+
addAppDeleteMethodCall(params) {
|
|
202
|
+
this.txns.push({ ...params, type: 'methodCall', onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC });
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Add a non-create/non-update ABI method application call transaction to the transaction group.
|
|
117
207
|
*
|
|
118
208
|
* Note: we recommend using app clients to make it easier to make app calls.
|
|
119
209
|
* @param params The ABI method application call transaction parameters
|
|
120
210
|
* @returns The composer so you can chain method calls
|
|
121
211
|
*/
|
|
122
|
-
|
|
212
|
+
addAppCallMethodCall(params) {
|
|
123
213
|
this.txns.push({ ...params, type: 'methodCall' });
|
|
124
214
|
return this;
|
|
125
215
|
}
|
|
@@ -141,15 +231,20 @@ class AlgoKitComposer {
|
|
|
141
231
|
this.txns.push({ atc, type: 'atc' });
|
|
142
232
|
return this;
|
|
143
233
|
}
|
|
144
|
-
|
|
234
|
+
/** Build an ATC and return transactions ready to be incorporated into a broader set of transactions this composer is composing */
|
|
235
|
+
buildAtc(atc, processTransaction) {
|
|
145
236
|
const group = atc.buildGroup();
|
|
146
|
-
const txnWithSigners = group.map((ts) => {
|
|
237
|
+
const txnWithSigners = group.map((ts, idx) => {
|
|
238
|
+
// Remove underlying group ID from the transaction since it will be re-grouped when this AlgoKitComposer is built
|
|
147
239
|
ts.txn.group = undefined;
|
|
240
|
+
// Process transaction if a function is provided
|
|
241
|
+
ts.txn = processTransaction?.(ts.txn, idx) ?? ts.txn;
|
|
242
|
+
// If this was a method call stash the ABIMethod for later
|
|
243
|
+
if (atc['methodCalls'].get(idx)) {
|
|
244
|
+
this.txnMethodMap.set(ts.txn.txID(), atc['methodCalls'].get(idx));
|
|
245
|
+
}
|
|
148
246
|
return ts;
|
|
149
247
|
});
|
|
150
|
-
const method = atc['methodCalls'].get(group.length - 1);
|
|
151
|
-
if (method)
|
|
152
|
-
this.txnMethodMap.set(txnWithSigners.at(-1).txn.txID(), method);
|
|
153
248
|
return txnWithSigners;
|
|
154
249
|
}
|
|
155
250
|
commonTxnBuildStep(params, txn, suggestedParams) {
|
|
@@ -157,8 +252,9 @@ class AlgoKitComposer {
|
|
|
157
252
|
txn.addLease(encodeLease(params.lease));
|
|
158
253
|
if (params.rekeyTo)
|
|
159
254
|
txn.addRekey(params.rekeyTo);
|
|
255
|
+
const encoder = new TextEncoder();
|
|
160
256
|
if (params.note)
|
|
161
|
-
txn.note =
|
|
257
|
+
txn.note = typeof params.note === 'string' ? encoder.encode(params.note) : params.note;
|
|
162
258
|
if (params.firstValidRound) {
|
|
163
259
|
txn.firstRound = Number(params.firstValidRound);
|
|
164
260
|
}
|
|
@@ -176,27 +272,36 @@ class AlgoKitComposer {
|
|
|
176
272
|
throw Error('Cannot set both staticFee and extraFee');
|
|
177
273
|
}
|
|
178
274
|
if (params.staticFee !== undefined) {
|
|
179
|
-
txn.fee = params.staticFee.microAlgo;
|
|
275
|
+
txn.fee = Number(params.staticFee.microAlgo);
|
|
180
276
|
}
|
|
181
277
|
else {
|
|
182
278
|
txn.fee = txn.estimateSize() * suggestedParams.fee || algosdk.ALGORAND_MIN_TX_FEE;
|
|
183
279
|
if (params.extraFee)
|
|
184
|
-
txn.fee += params.extraFee.microAlgo;
|
|
280
|
+
txn.fee += Number(params.extraFee.microAlgo);
|
|
185
281
|
}
|
|
186
282
|
txn.flatFee = true;
|
|
187
283
|
if (params.maxFee !== undefined && txn.fee > params.maxFee.microAlgo) {
|
|
188
|
-
throw Error(`Transaction fee ${txn.fee} is greater than maxFee ${params.maxFee}`);
|
|
284
|
+
throw Error(`Transaction fee ${txn.fee} µALGO is greater than maxFee ${params.maxFee}`);
|
|
189
285
|
}
|
|
190
286
|
return txn;
|
|
191
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Builds an ABI method call transaction and any other associated transactions represented in the ABI args.
|
|
290
|
+
* @param includeSigner Whether to include the actual signer for the transactions.
|
|
291
|
+
* If you are just building transactions without signers yet then set this to `false`.
|
|
292
|
+
*/
|
|
192
293
|
async buildMethodCall(params, suggestedParams, includeSigner) {
|
|
193
294
|
const methodArgs = [];
|
|
194
295
|
const isAbiValue = (x) => {
|
|
195
296
|
if (Array.isArray(x))
|
|
196
297
|
return x.length == 0 || x.every(isAbiValue);
|
|
197
|
-
return
|
|
298
|
+
return typeof x === 'bigint' || typeof x === 'boolean' || typeof x === 'number' || typeof x === 'string' || x instanceof Uint8Array;
|
|
198
299
|
};
|
|
199
|
-
for (
|
|
300
|
+
for (let i = 0; i < (params.args ?? []).length; i++) {
|
|
301
|
+
const arg = params.args[i];
|
|
302
|
+
if (arg === undefined) {
|
|
303
|
+
throw Error(`No value provided for argument ${i + 1} within call to ${params.method.name}`);
|
|
304
|
+
}
|
|
200
305
|
if (isAbiValue(arg)) {
|
|
201
306
|
methodArgs.push(arg);
|
|
202
307
|
continue;
|
|
@@ -219,39 +324,60 @@ class AlgoKitComposer {
|
|
|
219
324
|
? params.signer.signer
|
|
220
325
|
: params.signer
|
|
221
326
|
: this.getSigner(encodeAddress(txn.from.publicKey))
|
|
222
|
-
:
|
|
327
|
+
: AlgoKitComposer.NULL_SIGNER,
|
|
223
328
|
});
|
|
224
329
|
}
|
|
225
330
|
const methodAtc = new algosdk.AtomicTransactionComposer();
|
|
226
|
-
const
|
|
331
|
+
const appId = Number('appId' in params ? params.appId : 0n);
|
|
332
|
+
const approvalProgram = 'approvalProgram' in params
|
|
333
|
+
? typeof params.approvalProgram === 'string'
|
|
334
|
+
? (await this.appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes
|
|
335
|
+
: params.approvalProgram
|
|
336
|
+
: undefined;
|
|
337
|
+
const clearStateProgram = 'clearStateProgram' in params
|
|
338
|
+
? typeof params.clearStateProgram === 'string'
|
|
339
|
+
? (await this.appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes
|
|
340
|
+
: params.clearStateProgram
|
|
341
|
+
: undefined;
|
|
227
342
|
methodAtc.addMethodCall({
|
|
228
|
-
appID,
|
|
343
|
+
appID: appId,
|
|
229
344
|
sender: params.sender,
|
|
230
345
|
suggestedParams,
|
|
231
|
-
onComplete: params.onComplete,
|
|
346
|
+
onComplete: params.onComplete ?? algosdk.OnApplicationComplete.NoOpOC,
|
|
232
347
|
appAccounts: params.accountReferences,
|
|
233
348
|
appForeignApps: params.appReferences?.map((x) => Number(x)),
|
|
234
349
|
appForeignAssets: params.assetReferences?.map((x) => Number(x)),
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
350
|
+
boxes: params.boxReferences?.map(AppManager.getBoxReference),
|
|
351
|
+
approvalProgram,
|
|
352
|
+
clearProgram: clearStateProgram,
|
|
353
|
+
extraPages: appId === 0
|
|
354
|
+
? 'extraProgramPages' in params && params.extraProgramPages !== undefined
|
|
355
|
+
? params.extraProgramPages
|
|
356
|
+
: approvalProgram
|
|
357
|
+
? Math.floor((approvalProgram.length + (clearStateProgram?.length ?? 0)) / APP_PAGE_MAX_SIZE)
|
|
358
|
+
: 0
|
|
359
|
+
: undefined,
|
|
360
|
+
numLocalInts: appId === 0 ? ('schema' in params ? params.schema?.localInts ?? 0 : 0) : undefined,
|
|
361
|
+
numLocalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.localByteSlices ?? 0 : 0) : undefined,
|
|
362
|
+
numGlobalInts: appId === 0 ? ('schema' in params ? params.schema?.globalInts ?? 0 : 0) : undefined,
|
|
363
|
+
numGlobalByteSlices: appId === 0 ? ('schema' in params ? params.schema?.globalByteSlices ?? 0 : 0) : undefined,
|
|
242
364
|
method: params.method,
|
|
243
|
-
signer:
|
|
365
|
+
signer: includeSigner
|
|
366
|
+
? params.signer
|
|
367
|
+
? 'signer' in params.signer
|
|
368
|
+
? params.signer.signer
|
|
369
|
+
: params.signer
|
|
370
|
+
: this.getSigner(params.sender)
|
|
371
|
+
: AlgoKitComposer.NULL_SIGNER,
|
|
244
372
|
methodArgs: methodArgs,
|
|
245
373
|
// note, lease, and rekeyTo are set in the common build step
|
|
246
374
|
note: undefined,
|
|
247
375
|
lease: undefined,
|
|
248
376
|
rekeyTo: undefined,
|
|
249
377
|
});
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
group[methodIdx].txn = this.commonTxnBuildStep(params, group[methodIdx].txn, suggestedParams);
|
|
254
|
-
return this.buildAtc(methodAtc);
|
|
378
|
+
// Process the ATC to get a set of transactions ready for broader grouping
|
|
379
|
+
// and with the common build step to set fees and validity rounds
|
|
380
|
+
return this.buildAtc(methodAtc, (txn, idx) => idx === methodAtc.count() - 1 ? this.commonTxnBuildStep(params, txn, suggestedParams) : txn);
|
|
255
381
|
}
|
|
256
382
|
buildPayment(params, suggestedParams) {
|
|
257
383
|
const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
|
|
@@ -324,57 +450,66 @@ class AlgoKitComposer {
|
|
|
324
450
|
});
|
|
325
451
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
326
452
|
}
|
|
327
|
-
buildAppCall(params, suggestedParams) {
|
|
453
|
+
async buildAppCall(params, suggestedParams) {
|
|
454
|
+
const appId = Number('appId' in params ? params.appId : 0n);
|
|
455
|
+
const approvalProgram = 'approvalProgram' in params
|
|
456
|
+
? typeof params.approvalProgram === 'string'
|
|
457
|
+
? (await this.appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes
|
|
458
|
+
: params.approvalProgram
|
|
459
|
+
: undefined;
|
|
460
|
+
const clearStateProgram = 'clearStateProgram' in params
|
|
461
|
+
? typeof params.clearStateProgram === 'string'
|
|
462
|
+
? (await this.appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes
|
|
463
|
+
: params.clearStateProgram
|
|
464
|
+
: undefined;
|
|
328
465
|
const sdkParams = {
|
|
329
466
|
from: params.sender,
|
|
330
467
|
suggestedParams,
|
|
331
|
-
onComplete: params.onComplete,
|
|
332
|
-
approvalProgram: params.approvalProgram,
|
|
333
|
-
clearProgram: params.clearProgram,
|
|
334
468
|
appArgs: params.args,
|
|
469
|
+
onComplete: params.onComplete ?? algosdk.OnApplicationComplete.NoOpOC,
|
|
335
470
|
accounts: params.accountReferences,
|
|
336
471
|
foreignApps: params.appReferences?.map((x) => Number(x)),
|
|
337
472
|
foreignAssets: params.assetReferences?.map((x) => Number(x)),
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
numGlobalInts: params.schema?.globalUints || 0,
|
|
342
|
-
numGlobalByteSlices: params.schema?.globalByteSlices || 0,
|
|
473
|
+
boxes: params.boxReferences?.map(AppManager.getBoxReference),
|
|
474
|
+
approvalProgram,
|
|
475
|
+
clearProgram: clearStateProgram,
|
|
343
476
|
};
|
|
344
477
|
let txn;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
throw new Error('approvalProgram and clearProgram are required for application creation');
|
|
478
|
+
if (appId === 0) {
|
|
479
|
+
if (sdkParams.approvalProgram === undefined || sdkParams.clearProgram === undefined) {
|
|
480
|
+
throw new Error('approvalProgram and clearStateProgram are required for application creation');
|
|
349
481
|
}
|
|
350
482
|
txn = algosdk.makeApplicationCreateTxnFromObject({
|
|
351
483
|
...sdkParams,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
484
|
+
extraPages: 'extraProgramPages' in params
|
|
485
|
+
? params.extraProgramPages ?? Math.floor((approvalProgram.length + clearStateProgram.length) / APP_PAGE_MAX_SIZE)
|
|
486
|
+
: 0,
|
|
487
|
+
numLocalInts: 'schema' in params ? params.schema?.localInts ?? 0 : 0,
|
|
488
|
+
numLocalByteSlices: 'schema' in params ? params.schema?.localByteSlices ?? 0 : 0,
|
|
489
|
+
numGlobalInts: 'schema' in params ? params.schema?.globalInts ?? 0 : 0,
|
|
490
|
+
numGlobalByteSlices: 'schema' in params ? params.schema?.globalByteSlices ?? 0 : 0,
|
|
491
|
+
approvalProgram: approvalProgram,
|
|
492
|
+
clearProgram: clearStateProgram,
|
|
355
493
|
});
|
|
356
494
|
}
|
|
357
|
-
|
|
495
|
+
else {
|
|
496
|
+
txn = algosdk.makeApplicationCallTxnFromObject({ ...sdkParams, appIndex: appId });
|
|
497
|
+
}
|
|
358
498
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
359
499
|
}
|
|
360
500
|
buildKeyReg(params, suggestedParams) {
|
|
361
501
|
const txn = algosdk.makeKeyRegistrationTxnWithSuggestedParams(params.sender, undefined, params.voteKey, params.selectionKey, Number(params.voteFirst), Number(params.voteLast), Number(params.voteKeyDilution), suggestedParams, undefined, false, params.stateProofKey);
|
|
362
502
|
return this.commonTxnBuildStep(params, txn, suggestedParams);
|
|
363
503
|
}
|
|
504
|
+
/** Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` since those ones can have custom signers that need to be retrieved. */
|
|
364
505
|
async buildTxn(txn, suggestedParams) {
|
|
365
506
|
switch (txn.type) {
|
|
366
|
-
case 'txnWithSigner':
|
|
367
|
-
return [txn.txn];
|
|
368
|
-
case 'atc':
|
|
369
|
-
return txn.atc.buildGroup().map((ts) => ts.txn);
|
|
370
|
-
case 'methodCall':
|
|
371
|
-
return (await this.buildMethodCall(txn, suggestedParams, false)).map((ts) => ts.txn);
|
|
372
507
|
case 'pay':
|
|
373
508
|
return [this.buildPayment(txn, suggestedParams)];
|
|
374
509
|
case 'assetCreate':
|
|
375
510
|
return [this.buildAssetCreate(txn, suggestedParams)];
|
|
376
511
|
case 'appCall':
|
|
377
|
-
return [this.buildAppCall(txn, suggestedParams)];
|
|
512
|
+
return [await this.buildAppCall(txn, suggestedParams)];
|
|
378
513
|
case 'assetConfig':
|
|
379
514
|
return [this.buildAssetConfig(txn, suggestedParams)];
|
|
380
515
|
case 'assetDestroy':
|
|
@@ -407,43 +542,77 @@ class AlgoKitComposer {
|
|
|
407
542
|
return (await this.buildTxn(txn, suggestedParams)).map((txn) => ({ txn, signer }));
|
|
408
543
|
}
|
|
409
544
|
/**
|
|
410
|
-
* Compose all of the transactions without signers and return the transaction objects directly.
|
|
545
|
+
* Compose all of the transactions without signers and return the transaction objects directly along with any ABI method calls.
|
|
411
546
|
*
|
|
412
|
-
* @returns The array of built transactions
|
|
547
|
+
* @returns The array of built transactions and any corresponding method calls
|
|
413
548
|
*/
|
|
414
549
|
async buildTransactions() {
|
|
415
550
|
const suggestedParams = await this.getSuggestedParams();
|
|
416
551
|
const transactions = [];
|
|
552
|
+
const methodCalls = new Map();
|
|
553
|
+
const signers = new Map();
|
|
417
554
|
for (const txn of this.txns) {
|
|
418
|
-
|
|
555
|
+
if (!['txnWithSigner', 'atc', 'methodCall'].includes(txn.type)) {
|
|
556
|
+
transactions.push(...(await this.buildTxn(txn, suggestedParams)));
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
const transactionsWithSigner = txn.type === 'txnWithSigner'
|
|
560
|
+
? [txn]
|
|
561
|
+
: txn.type === 'atc'
|
|
562
|
+
? this.buildAtc(txn.atc)
|
|
563
|
+
: txn.type === 'methodCall'
|
|
564
|
+
? await this.buildMethodCall(txn, suggestedParams, false)
|
|
565
|
+
: [];
|
|
566
|
+
transactions.push(...transactionsWithSigner.map((ts) => ts.txn));
|
|
567
|
+
transactionsWithSigner.forEach((ts, idx) => {
|
|
568
|
+
if (ts.signer && ts.signer !== AlgoKitComposer.NULL_SIGNER) {
|
|
569
|
+
signers.set(idx, ts.signer);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
419
573
|
}
|
|
420
|
-
|
|
574
|
+
for (let i = 0; i < transactions.length; i++) {
|
|
575
|
+
const method = this.txnMethodMap.get(transactions[i].txID());
|
|
576
|
+
if (method)
|
|
577
|
+
methodCalls.set(i, method);
|
|
578
|
+
}
|
|
579
|
+
return { transactions, methodCalls, signers };
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Get the number of transactions currently added to this composer.
|
|
583
|
+
*/
|
|
584
|
+
async count() {
|
|
585
|
+
return (await this.buildTransactions()).transactions.length;
|
|
421
586
|
}
|
|
422
587
|
/**
|
|
423
588
|
* Compose all of the transactions in a single atomic transaction group and an atomic transaction composer.
|
|
424
589
|
*
|
|
425
590
|
* You can then use the transactions standalone, or use the composer to execute or simulate the transactions.
|
|
591
|
+
*
|
|
592
|
+
* Once this method is called, no further transactions will be able to be added.
|
|
593
|
+
* You can safely call this method multiple times to get the same result.
|
|
426
594
|
* @returns The built atomic transaction composer and the transactions
|
|
427
595
|
*/
|
|
428
596
|
async build() {
|
|
429
597
|
if (this.atc.getStatus() === algosdk.AtomicTransactionComposerStatus.BUILDING) {
|
|
430
598
|
const suggestedParams = await this.getSuggestedParams();
|
|
599
|
+
// Build all of the transactions
|
|
431
600
|
const txnWithSigners = [];
|
|
432
601
|
for (const txn of this.txns) {
|
|
433
602
|
txnWithSigners.push(...(await this.buildTxnWithSigner(txn, suggestedParams)));
|
|
434
603
|
}
|
|
435
|
-
|
|
436
|
-
this.atc.addTransaction(ts);
|
|
437
|
-
});
|
|
604
|
+
// Add all of the transactions to the underlying ATC
|
|
438
605
|
const methodCalls = new Map();
|
|
439
606
|
txnWithSigners.forEach((ts, idx) => {
|
|
607
|
+
this.atc.addTransaction(ts);
|
|
608
|
+
// Populate consolidated set of all ABI method calls
|
|
440
609
|
const method = this.txnMethodMap.get(ts.txn.txID());
|
|
441
610
|
if (method)
|
|
442
611
|
methodCalls.set(idx, method);
|
|
443
612
|
});
|
|
444
613
|
this.atc['methodCalls'] = methodCalls;
|
|
445
614
|
}
|
|
446
|
-
return { atc: this.atc, transactions: this.atc.buildGroup() };
|
|
615
|
+
return { atc: this.atc, transactions: this.atc.buildGroup(), methodCalls: this.atc['methodCalls'] };
|
|
447
616
|
}
|
|
448
617
|
/**
|
|
449
618
|
* Rebuild the group, discarding any previously built transactions.
|
|
@@ -455,11 +624,11 @@ class AlgoKitComposer {
|
|
|
455
624
|
return await this.build();
|
|
456
625
|
}
|
|
457
626
|
/**
|
|
458
|
-
* Compose the atomic transaction group and send it to the network
|
|
627
|
+
* Compose the atomic transaction group and send it to the network.
|
|
459
628
|
* @param params The parameters to control execution with
|
|
460
629
|
* @returns The execution result
|
|
461
630
|
*/
|
|
462
|
-
async
|
|
631
|
+
async send(params) {
|
|
463
632
|
const group = (await this.build()).transactions;
|
|
464
633
|
let waitRounds = params?.maxRoundsToWaitForConfirmation;
|
|
465
634
|
if (waitRounds === undefined) {
|
|
@@ -469,10 +638,83 @@ class AlgoKitComposer {
|
|
|
469
638
|
}
|
|
470
639
|
return await sendAtomicTransactionComposer({
|
|
471
640
|
atc: this.atc,
|
|
472
|
-
|
|
641
|
+
suppressLog: params?.suppressLog,
|
|
642
|
+
maxRoundsToWaitForConfirmation: waitRounds,
|
|
643
|
+
populateAppCallResources: params?.populateAppCallResources,
|
|
473
644
|
}, this.algod);
|
|
474
645
|
}
|
|
646
|
+
/**
|
|
647
|
+
* @deprecated Use `send` instead.
|
|
648
|
+
*
|
|
649
|
+
* Compose the atomic transaction group and send it to the network
|
|
650
|
+
*
|
|
651
|
+
* An alias for `composer.send(params)`.
|
|
652
|
+
* @param params The parameters to control execution with
|
|
653
|
+
* @returns The execution result
|
|
654
|
+
*/
|
|
655
|
+
async execute(params) {
|
|
656
|
+
return this.send(params);
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Compose the atomic transaction group and simulate sending it to the network
|
|
660
|
+
* @returns The simulation result
|
|
661
|
+
*/
|
|
662
|
+
async simulate(options) {
|
|
663
|
+
const atc = options?.skipSignatures ? new AtomicTransactionComposer() : this.atc;
|
|
664
|
+
// Build the transactions
|
|
665
|
+
if (options?.skipSignatures) {
|
|
666
|
+
options.allowEmptySignatures = true;
|
|
667
|
+
// Build transactions uses empty signers
|
|
668
|
+
const transactions = await this.buildTransactions();
|
|
669
|
+
for (const txn of transactions.transactions) {
|
|
670
|
+
atc.addTransaction({ txn, signer: AlgoKitComposer.NULL_SIGNER });
|
|
671
|
+
}
|
|
672
|
+
atc['methodCalls'] = transactions.methodCalls;
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
// Build creates real signatures
|
|
676
|
+
await this.build();
|
|
677
|
+
}
|
|
678
|
+
if (Config.debug && !Config.traceAll) {
|
|
679
|
+
// Dump the traces to a file for use with AlgoKit AVM debugger
|
|
680
|
+
// Checks for false on traceAll because it should have been already
|
|
681
|
+
// executed above
|
|
682
|
+
const simulateResponse = await performAtomicTransactionComposerSimulate(atc, this.algod);
|
|
683
|
+
await Config.events.emitAsync(EventType.TxnGroupSimulated, {
|
|
684
|
+
simulateResponse,
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({ txnGroups: [], ...options }));
|
|
688
|
+
if (simulateResponse && simulateResponse.txnGroups[0].failedAt) {
|
|
689
|
+
const error = new Error(`Transaction failed at transaction(s) ${simulateResponse.txnGroups[0].failedAt.join(', ')} in the group. ${simulateResponse.txnGroups.find((x) => x.failureMessage)?.failureMessage}`);
|
|
690
|
+
error.simulateResponse = simulateResponse;
|
|
691
|
+
throw error;
|
|
692
|
+
}
|
|
693
|
+
const transactions = atc.buildGroup().map((t) => t.txn);
|
|
694
|
+
return {
|
|
695
|
+
confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
|
|
696
|
+
transactions: transactions,
|
|
697
|
+
txIds: transactions.map((t) => t.txID()),
|
|
698
|
+
groupId: Buffer.from(transactions[0].group ?? new Uint8Array()).toString('base64'),
|
|
699
|
+
simulateResponse,
|
|
700
|
+
returns: methodResults.map(getABIReturnValue),
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Create an encoded transaction note that follows the ARC-2 spec.
|
|
705
|
+
*
|
|
706
|
+
* https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md
|
|
707
|
+
* @param note The ARC-2 transaction note data
|
|
708
|
+
* @returns The binary encoded transaction note
|
|
709
|
+
*/
|
|
710
|
+
static arc2Note(note) {
|
|
711
|
+
const arc2Payload = `${note.dAppName}:${note.format}${typeof note.data === 'string' ? note.data : JSON.stringify(note.data)}`;
|
|
712
|
+
const encoder = new TextEncoder();
|
|
713
|
+
return encoder.encode(arc2Payload);
|
|
714
|
+
}
|
|
475
715
|
}
|
|
716
|
+
/** Signer used to represent a lack of signer */
|
|
717
|
+
AlgoKitComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
|
|
476
718
|
|
|
477
719
|
export { MAX_TRANSACTION_GROUP_SIZE, AlgoKitComposer as default };
|
|
478
720
|
//# sourceMappingURL=composer.mjs.map
|