@algorandfoundation/algokit-utils 9.2.0 → 9.2.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/_rolldown/runtime.js +33 -0
- package/_virtual/_rolldown/runtime.mjs +13 -0
- package/account/account.d.ts +25 -30
- package/account/account.js +151 -146
- package/account/account.js.map +1 -1
- package/account/account.mjs +149 -144
- package/account/account.mjs.map +1 -1
- package/account/get-account-config-from-environment.d.ts +7 -2
- package/account/get-account-config-from-environment.js +19 -21
- package/account/get-account-config-from-environment.js.map +1 -1
- package/account/get-account-config-from-environment.mjs +19 -19
- package/account/get-account-config-from-environment.mjs.map +1 -1
- package/account/get-account.d.ts +14 -12
- package/account/get-account.js +56 -59
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +56 -57
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +9 -5
- package/account/get-dispenser-account.js +20 -18
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +20 -16
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.d.ts +7 -3
- package/account/mnemonic-account.js +17 -17
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +15 -15
- package/account/mnemonic-account.mjs.map +1 -1
- package/amount.d.ts +40 -35
- package/amount.js +33 -34
- package/amount.js.map +1 -1
- package/amount.mjs +33 -32
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +10 -6
- package/app-client.js +91 -86
- package/app-client.js.map +1 -1
- package/app-client.mjs +91 -84
- package/app-client.mjs.map +1 -1
- package/app-deploy.d.ts +26 -24
- package/app-deploy.js +235 -253
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +233 -251
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +45 -46
- package/app.js +253 -271
- package/app.js.map +1 -1
- package/app.mjs +249 -267
- package/app.mjs.map +1 -1
- package/asset.d.ts +16 -12
- package/asset.js +116 -122
- package/asset.js.map +1 -1
- package/asset.mjs +116 -120
- package/asset.mjs.map +1 -1
- package/config.d.ts +7 -2
- package/config.js +5 -7
- package/config.js.map +1 -1
- package/config.mjs +5 -4
- package/config.mjs.map +1 -1
- package/debugging/debugging.d.ts +5 -1
- package/debugging/debugging.js +11 -11
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +11 -9
- package/debugging/debugging.mjs.map +1 -1
- package/dispenser-client.d.ts +7 -2
- package/dispenser-client.js +23 -24
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs +23 -22
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +27 -18
- package/index.js +140 -143
- package/index.mjs +27 -29
- package/indexer-lookup.d.ts +18 -11
- package/indexer-lookup.js +112 -120
- package/indexer-lookup.js.map +1 -1
- package/indexer-lookup.mjs +105 -118
- package/indexer-lookup.mjs.map +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +9 -7
- package/localnet/get-kmd-wallet-account.js +28 -26
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +28 -24
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +7 -5
- package/localnet/get-localnet-dispenser-account.js +17 -15
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +17 -13
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +10 -8
- package/localnet/get-or-create-kmd-wallet-account.js +28 -26
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +28 -24
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/is-localnet.d.ts +7 -3
- package/localnet/is-localnet.js +9 -10
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +9 -8
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +17 -15
- package/network-client.js +115 -116
- package/network-client.js.map +1 -1
- package/network-client.mjs +115 -114
- package/network-client.mjs.map +1 -1
- package/package.json +12 -3
- package/testing/account.d.ts +11 -9
- package/testing/account.js +31 -33
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +29 -31
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +7 -2
- package/testing/fixtures/algokit-log-capture-fixture.js +36 -41
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs +36 -39
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +9 -4
- package/testing/fixtures/algorand-fixture.js +67 -62
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +66 -59
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +7 -5
- package/testing/index.js +13 -18
- package/testing/index.mjs +7 -7
- package/testing/indexer.d.ts +5 -1
- package/testing/indexer.js +28 -37
- package/testing/indexer.js.map +1 -1
- package/testing/indexer.mjs +28 -35
- package/testing/indexer.mjs.map +1 -1
- package/testing/test-logger.d.ts +41 -36
- package/testing/test-logger.js +71 -76
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs +71 -74
- package/testing/test-logger.mjs.map +1 -1
- package/testing/transaction-logger.d.ts +30 -27
- package/testing/transaction-logger.js +77 -93
- package/testing/transaction-logger.js.map +1 -1
- package/testing/transaction-logger.mjs +74 -90
- package/testing/transaction-logger.mjs.map +1 -1
- package/transaction/legacy-bridge.js +100 -111
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +97 -108
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +7 -5
- package/transaction/perform-atomic-transaction-composer-simulate.js +31 -36
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +28 -33
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +34 -35
- package/transaction/transaction.js +716 -914
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +713 -911
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.d.ts +9 -5
- package/transfer/transfer-algos.js +26 -27
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +26 -25
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +11 -8
- package/transfer/transfer.js +94 -100
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +94 -98
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +432 -429
- package/types/account-manager.js +591 -602
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +587 -599
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +192 -202
- package/types/account.js +91 -88
- package/types/account.js.map +1 -1
- package/types/account.mjs +88 -86
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +15 -10
- package/types/algo-http-client-with-retry.js +70 -92
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +69 -90
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +778 -771
- package/types/algorand-client-transaction-creator.js +733 -732
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +732 -730
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +1090 -1360
- package/types/algorand-client-transaction-sender.js +930 -961
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +927 -959
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +239 -236
- package/types/algorand-client.js +322 -320
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +321 -318
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +47 -43
- package/types/amount.js +66 -70
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +63 -68
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +235 -272
- package/types/app-arc56.js +124 -170
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs +121 -168
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +1128 -2009
- package/types/app-client.js +1633 -1791
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1624 -1783
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +139 -141
- package/types/app-deployer.js +344 -384
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +341 -382
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +762 -932
- package/types/app-factory.js +496 -488
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +491 -484
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +304 -310
- package/types/app-manager.js +422 -475
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +419 -473
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +118 -117
- package/types/app-spec.js +125 -135
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +121 -132
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +229 -241
- package/types/app.js +36 -28
- package/types/app.js.map +1 -1
- package/types/app.mjs +33 -26
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +204 -199
- package/types/asset-manager.js +165 -174
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +164 -172
- package/types/asset-manager.mjs.map +1 -1
- package/types/asset.d.ts +95 -91
- package/types/asset.js +0 -3
- package/types/asset.mjs +0 -2
- package/types/async-event-emitter.d.ts +18 -13
- package/types/async-event-emitter.js +37 -49
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +36 -47
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +453 -451
- package/types/client-manager.js +602 -598
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +597 -594
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +1211 -1258
- package/types/composer.js +1436 -1498
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +1430 -1493
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +53 -48
- package/types/config.js +78 -77
- package/types/config.js.map +1 -1
- package/types/config.mjs +77 -75
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +25 -23
- package/types/debugging.js +9 -11
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +8 -9
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +57 -52
- package/types/dispenser-client.js +120 -141
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +119 -139
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +5 -3
- package/types/expand.js +0 -3
- package/types/expand.mjs +0 -2
- package/types/indexer.d.ts +104 -100
- package/types/indexer.js +36 -31
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +32 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +5 -3
- package/types/instance-of.js +0 -3
- package/types/instance-of.mjs +0 -2
- package/types/kmd-account-manager.d.ts +75 -70
- package/types/kmd-account-manager.js +150 -184
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +147 -182
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +13 -8
- package/types/lifecycle-events.js +10 -7
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +9 -7
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +15 -11
- package/types/logging.js +30 -31
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +29 -29
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +33 -29
- package/types/logic-error.js +50 -49
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +49 -47
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +32 -27
- package/types/network-client.js +10 -9
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +9 -7
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +131 -132
- package/types/testing.js +0 -3
- package/types/testing.mjs +0 -2
- package/types/transaction.d.ts +110 -110
- package/types/transaction.js +0 -3
- package/types/transaction.mjs +0 -2
- package/types/transfer.d.ts +70 -66
- package/types/transfer.js +0 -3
- package/types/transfer.mjs +0 -2
- package/util.js +73 -118
- package/util.js.map +1 -1
- package/util.mjs +73 -116
- package/util.mjs.map +1 -1
- package/account/index.d.ts +0 -5
- package/debugging/index.d.ts +0 -1
- package/index.js.map +0 -1
- package/index.mjs.map +0 -1
- package/localnet/index.d.ts +0 -4
- package/testing/_asset.d.ts +0 -3
- package/testing/fixtures/index.d.ts +0 -2
- package/testing/index.js.map +0 -1
- package/testing/index.mjs.map +0 -1
- package/transaction/index.d.ts +0 -2
- package/transaction/legacy-bridge.d.ts +0 -35
- package/transfer/index.d.ts +0 -2
- package/types/asset.js.map +0 -1
- package/types/asset.mjs.map +0 -1
- package/types/expand.js.map +0 -1
- package/types/expand.mjs.map +0 -1
- package/types/instance-of.js.map +0 -1
- package/types/instance-of.mjs.map +0 -1
- package/types/testing.js.map +0 -1
- package/types/testing.mjs.map +0 -1
- package/types/transaction.js.map +0 -1
- package/types/transaction.mjs.map +0 -1
- package/types/transfer.js.map +0 -1
- package/types/transfer.mjs.map +0 -1
- package/util.d.ts +0 -48
package/types/composer.mjs
CHANGED
|
@@ -1,1508 +1,1445 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AppManager } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { Config } from "../config.mjs";
|
|
2
|
+
import "./lifecycle-events.mjs";
|
|
3
|
+
import { asJson, calculateExtraProgramPages } from "../util.mjs";
|
|
4
|
+
import { encodeLease, getABIReturnValue, sendAtomicTransactionComposer } from "../transaction/transaction.mjs";
|
|
5
|
+
import { AppManager } from "./app-manager.mjs";
|
|
6
|
+
import { genesisIdIsLocalNet } from "./network-client.mjs";
|
|
7
|
+
import algosdk, { Address } from "algosdk";
|
|
8
|
+
//#region src/types/composer.ts
|
|
9
9
|
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
10
10
|
var isTransactionWithSigner = algosdk.isTransactionWithSigner;
|
|
11
11
|
var modelsv2 = algosdk.modelsv2;
|
|
12
12
|
const address = (address) => {
|
|
13
|
-
|
|
13
|
+
return typeof address === "string" ? Address.fromString(address) : address;
|
|
14
14
|
};
|
|
15
15
|
const MAX_TRANSACTION_GROUP_SIZE = 16;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
16
|
+
var InvalidErrorTransformerValue = class extends Error {
|
|
17
|
+
constructor(originalError, value) {
|
|
18
|
+
super(`An error transformer returned a non-error value: ${value}. The original error before any transformation: ${originalError}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var ErrorTransformerError = class extends Error {
|
|
22
|
+
constructor(originalError, cause) {
|
|
23
|
+
super(`An error transformer threw an error: ${cause}. The original error before any transformation: ${originalError} `, { cause });
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
26
|
/** TransactionComposer helps you compose and execute transactions as a transaction group. */
|
|
27
|
-
class TransactionComposer {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
for (const txn of transactions.transactions) {
|
|
1418
|
-
atc.addTransaction({ txn, signer: TransactionComposer.NULL_SIGNER });
|
|
1419
|
-
}
|
|
1420
|
-
atc['methodCalls'] = transactions.methodCalls;
|
|
1421
|
-
}
|
|
1422
|
-
else {
|
|
1423
|
-
// Build creates real signatures
|
|
1424
|
-
await this.build();
|
|
1425
|
-
}
|
|
1426
|
-
const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({
|
|
1427
|
-
txnGroups: [],
|
|
1428
|
-
...rawOptions,
|
|
1429
|
-
...(Config.debug
|
|
1430
|
-
? {
|
|
1431
|
-
allowEmptySignatures: true,
|
|
1432
|
-
fixSigners: true,
|
|
1433
|
-
allowMoreLogging: true,
|
|
1434
|
-
execTraceConfig: new modelsv2.SimulateTraceConfig({
|
|
1435
|
-
enable: true,
|
|
1436
|
-
scratchChange: true,
|
|
1437
|
-
stackChange: true,
|
|
1438
|
-
stateChange: true,
|
|
1439
|
-
}),
|
|
1440
|
-
}
|
|
1441
|
-
: undefined),
|
|
1442
|
-
}));
|
|
1443
|
-
const failedGroup = simulateResponse?.txnGroups[0];
|
|
1444
|
-
if (failedGroup?.failureMessage) {
|
|
1445
|
-
const errorMessage = `Transaction failed at transaction(s) ${failedGroup.failedAt?.join(', ') || 'unknown'} in the group. ${failedGroup.failureMessage}`;
|
|
1446
|
-
const error = new Error(errorMessage);
|
|
1447
|
-
if (Config.debug) {
|
|
1448
|
-
await Config.events.emitAsync(EventType.TxnGroupSimulated, { simulateResponse });
|
|
1449
|
-
}
|
|
1450
|
-
throw await this.transformError(error);
|
|
1451
|
-
}
|
|
1452
|
-
if (Config.debug && Config.traceAll) {
|
|
1453
|
-
await Config.events.emitAsync(EventType.TxnGroupSimulated, { simulateResponse });
|
|
1454
|
-
}
|
|
1455
|
-
const transactions = atc.buildGroup().map((t) => t.txn);
|
|
1456
|
-
const methodCalls = [...atc['methodCalls'].values()];
|
|
1457
|
-
return {
|
|
1458
|
-
confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
|
|
1459
|
-
transactions: transactions,
|
|
1460
|
-
txIds: transactions.map((t) => t.txID()),
|
|
1461
|
-
groupId: Buffer.from(transactions[0].group ?? new Uint8Array()).toString('base64'),
|
|
1462
|
-
simulateResponse,
|
|
1463
|
-
returns: methodResults.map((r, i) => getABIReturnValue(r, methodCalls[i].returns.type)),
|
|
1464
|
-
};
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* Create an encoded transaction note that follows the ARC-2 spec.
|
|
1468
|
-
*
|
|
1469
|
-
* https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md
|
|
1470
|
-
* @param note The ARC-2 transaction note data
|
|
1471
|
-
* @returns The binary encoded transaction note
|
|
1472
|
-
*/
|
|
1473
|
-
static arc2Note(note) {
|
|
1474
|
-
const arc2Payload = `${note.dAppName}:${note.format}${typeof note.data === 'string' ? note.data : asJson(note.data)}`;
|
|
1475
|
-
const encoder = new TextEncoder();
|
|
1476
|
-
return encoder.encode(arc2Payload);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
/** Signer used to represent a lack of signer */
|
|
1480
|
-
TransactionComposer.NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
|
|
27
|
+
var TransactionComposer = class TransactionComposer {
|
|
28
|
+
/** Signer used to represent a lack of signer */
|
|
29
|
+
static NULL_SIGNER = algosdk.makeEmptyTransactionSigner();
|
|
30
|
+
/** The ATC used to compose the group */
|
|
31
|
+
atc = new algosdk.AtomicTransactionComposer();
|
|
32
|
+
/** Map of transaction index in the atc to a max logical fee.
|
|
33
|
+
* This is set using the value of either maxFee or staticFee.
|
|
34
|
+
*/
|
|
35
|
+
txnMaxFees = /* @__PURE__ */ new Map();
|
|
36
|
+
/** Transactions that have not yet been composed */
|
|
37
|
+
txns = [];
|
|
38
|
+
/** The algod client used by the composer. */
|
|
39
|
+
algod;
|
|
40
|
+
/** An async function that will return suggested params for the transaction. */
|
|
41
|
+
getSuggestedParams;
|
|
42
|
+
/** A function that takes in an address and return a signer function for that address. */
|
|
43
|
+
getSigner;
|
|
44
|
+
/** The default transaction validity window */
|
|
45
|
+
defaultValidityWindow = 10n;
|
|
46
|
+
/** Whether the validity window was explicitly set on construction */
|
|
47
|
+
defaultValidityWindowIsExplicit = false;
|
|
48
|
+
appManager;
|
|
49
|
+
errorTransformers;
|
|
50
|
+
async transformError(originalError) {
|
|
51
|
+
if (!(originalError instanceof Error)) return originalError;
|
|
52
|
+
let transformedError = originalError;
|
|
53
|
+
for (const transformer of this.errorTransformers) try {
|
|
54
|
+
transformedError = await transformer(transformedError);
|
|
55
|
+
if (!(transformedError instanceof Error)) return new InvalidErrorTransformerValue(originalError, transformedError);
|
|
56
|
+
} catch (errorFromTransformer) {
|
|
57
|
+
return new ErrorTransformerError(originalError, errorFromTransformer);
|
|
58
|
+
}
|
|
59
|
+
return transformedError;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a `TransactionComposer`.
|
|
63
|
+
* @param params The configuration for this composer
|
|
64
|
+
* @returns The `TransactionComposer` instance
|
|
65
|
+
*/
|
|
66
|
+
constructor(params) {
|
|
67
|
+
this.algod = params.algod;
|
|
68
|
+
const defaultGetSuggestedParams = () => params.algod.getTransactionParams().do();
|
|
69
|
+
this.getSuggestedParams = params.getSuggestedParams ?? defaultGetSuggestedParams;
|
|
70
|
+
this.getSigner = params.getSigner;
|
|
71
|
+
this.defaultValidityWindow = params.defaultValidityWindow ?? this.defaultValidityWindow;
|
|
72
|
+
this.defaultValidityWindowIsExplicit = params.defaultValidityWindow !== void 0;
|
|
73
|
+
this.appManager = params.appManager ?? new AppManager(params.algod);
|
|
74
|
+
this.errorTransformers = params.errorTransformers ?? [];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Register a function that will be used to transform an error caught when simulating or executing
|
|
78
|
+
*
|
|
79
|
+
* @returns The composer so you can chain method calls
|
|
80
|
+
*/
|
|
81
|
+
registerErrorTransformer(transformer) {
|
|
82
|
+
this.errorTransformers.push(transformer);
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Add a pre-built transaction to the transaction group.
|
|
87
|
+
* @param transaction The pre-built transaction
|
|
88
|
+
* @param signer Optional signer override for the transaction
|
|
89
|
+
* @returns The composer so you can chain method calls
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* composer.addTransaction(txn)
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
addTransaction(transaction, signer) {
|
|
96
|
+
this.txns.push({
|
|
97
|
+
txn: transaction,
|
|
98
|
+
signer: signer ?? this.getSigner(transaction.sender),
|
|
99
|
+
type: "txnWithSigner"
|
|
100
|
+
});
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Add a payment transaction to the transaction group.
|
|
105
|
+
* @param params The payment transaction parameters
|
|
106
|
+
* @returns The composer so you can chain method calls
|
|
107
|
+
* @example Basic example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* composer.addPayment({
|
|
110
|
+
* sender: 'SENDERADDRESS',
|
|
111
|
+
* receiver: 'RECEIVERADDRESS',
|
|
112
|
+
* amount: (4).algo(),
|
|
113
|
+
* })
|
|
114
|
+
* ```
|
|
115
|
+
* @example Advanced example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* composer.addPayment({
|
|
118
|
+
* amount: (4).algo(),
|
|
119
|
+
* receiver: 'RECEIVERADDRESS',
|
|
120
|
+
* sender: 'SENDERADDRESS',
|
|
121
|
+
* closeRemainderTo: 'CLOSEREMAINDERTOADDRESS',
|
|
122
|
+
* lease: 'lease',
|
|
123
|
+
* note: 'note',
|
|
124
|
+
* // Use this with caution, it's generally better to use algorand.account.rekeyAccount
|
|
125
|
+
* rekeyTo: 'REKEYTOADDRESS',
|
|
126
|
+
* // You wouldn't normally set this field
|
|
127
|
+
* firstValidRound: 1000n,
|
|
128
|
+
* validityWindow: 10,
|
|
129
|
+
* extraFee: (1000).microAlgo(),
|
|
130
|
+
* staticFee: (1000).microAlgo(),
|
|
131
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
132
|
+
* // already specified, but here for completeness
|
|
133
|
+
* maxFee: (3000).microAlgo(),
|
|
134
|
+
* })
|
|
135
|
+
*/
|
|
136
|
+
addPayment(params) {
|
|
137
|
+
this.txns.push({
|
|
138
|
+
...params,
|
|
139
|
+
type: "pay"
|
|
140
|
+
});
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Add an asset create transaction to the transaction group.
|
|
145
|
+
* @param params The asset create transaction parameters
|
|
146
|
+
* @returns The composer so you can chain method calls
|
|
147
|
+
* @example Basic example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* composer.addAssetCreate({ sender: "CREATORADDRESS", total: 100n})
|
|
150
|
+
* ```
|
|
151
|
+
* @example Advanced example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* composer.addAssetCreate({
|
|
154
|
+
* sender: 'CREATORADDRESS',
|
|
155
|
+
* total: 100n,
|
|
156
|
+
* decimals: 2,
|
|
157
|
+
* assetName: 'asset',
|
|
158
|
+
* unitName: 'unit',
|
|
159
|
+
* url: 'url',
|
|
160
|
+
* metadataHash: 'metadataHash',
|
|
161
|
+
* defaultFrozen: false,
|
|
162
|
+
* manager: 'MANAGERADDRESS',
|
|
163
|
+
* reserve: 'RESERVEADDRESS',
|
|
164
|
+
* freeze: 'FREEZEADDRESS',
|
|
165
|
+
* clawback: 'CLAWBACKADDRESS',
|
|
166
|
+
* lease: 'lease',
|
|
167
|
+
* note: 'note',
|
|
168
|
+
* // You wouldn't normally set this field
|
|
169
|
+
* firstValidRound: 1000n,
|
|
170
|
+
* validityWindow: 10,
|
|
171
|
+
* extraFee: (1000).microAlgo(),
|
|
172
|
+
* staticFee: (1000).microAlgo(),
|
|
173
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
174
|
+
* // already specified, but here for completeness
|
|
175
|
+
* maxFee: (3000).microAlgo(),
|
|
176
|
+
* })
|
|
177
|
+
*/
|
|
178
|
+
addAssetCreate(params) {
|
|
179
|
+
this.txns.push({
|
|
180
|
+
...params,
|
|
181
|
+
type: "assetCreate"
|
|
182
|
+
});
|
|
183
|
+
return this;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Add an asset config transaction to the transaction group.
|
|
187
|
+
* @param params The asset config transaction parameters
|
|
188
|
+
* @returns The composer so you can chain method calls
|
|
189
|
+
* @example Basic example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* composer.addAssetConfig({ sender: "MANAGERADDRESS", assetId: 123456n, manager: "MANAGERADDRESS" })
|
|
192
|
+
* ```
|
|
193
|
+
* @example Advanced example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* composer.addAssetConfig({
|
|
196
|
+
* sender: 'MANAGERADDRESS',
|
|
197
|
+
* assetId: 123456n,
|
|
198
|
+
* manager: 'MANAGERADDRESS',
|
|
199
|
+
* reserve: 'RESERVEADDRESS',
|
|
200
|
+
* freeze: 'FREEZEADDRESS',
|
|
201
|
+
* clawback: 'CLAWBACKADDRESS',
|
|
202
|
+
* lease: 'lease',
|
|
203
|
+
* note: 'note',
|
|
204
|
+
* // You wouldn't normally set this field
|
|
205
|
+
* firstValidRound: 1000n,
|
|
206
|
+
* validityWindow: 10,
|
|
207
|
+
* extraFee: (1000).microAlgo(),
|
|
208
|
+
* staticFee: (1000).microAlgo(),
|
|
209
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
210
|
+
* // already specified, but here for completeness
|
|
211
|
+
* maxFee: (3000).microAlgo(),
|
|
212
|
+
* })
|
|
213
|
+
*/
|
|
214
|
+
addAssetConfig(params) {
|
|
215
|
+
this.txns.push({
|
|
216
|
+
...params,
|
|
217
|
+
type: "assetConfig"
|
|
218
|
+
});
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Add an asset freeze transaction to the transaction group.
|
|
223
|
+
* @param params The asset freeze transaction parameters
|
|
224
|
+
* @returns The composer so you can chain method calls
|
|
225
|
+
* @example Basic example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* composer.addAssetFreeze({ sender: "MANAGERADDRESS", assetId: 123456n, account: "ACCOUNTADDRESS", frozen: true })
|
|
228
|
+
* ```
|
|
229
|
+
* @example Advanced example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* composer.addAssetFreeze({
|
|
232
|
+
* sender: 'MANAGERADDRESS',
|
|
233
|
+
* assetId: 123456n,
|
|
234
|
+
* account: 'ACCOUNTADDRESS',
|
|
235
|
+
* frozen: true,
|
|
236
|
+
* lease: 'lease',
|
|
237
|
+
* note: 'note',
|
|
238
|
+
* // You wouldn't normally set this field
|
|
239
|
+
* firstValidRound: 1000n,
|
|
240
|
+
* validityWindow: 10,
|
|
241
|
+
* extraFee: (1000).microAlgo(),
|
|
242
|
+
* staticFee: (1000).microAlgo(),
|
|
243
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
244
|
+
* // already specified, but here for completeness
|
|
245
|
+
* maxFee: (3000).microAlgo(),
|
|
246
|
+
* })
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
addAssetFreeze(params) {
|
|
250
|
+
this.txns.push({
|
|
251
|
+
...params,
|
|
252
|
+
type: "assetFreeze"
|
|
253
|
+
});
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Add an asset destroy transaction to the transaction group.
|
|
258
|
+
* @param params The asset destroy transaction parameters
|
|
259
|
+
* @returns The composer so you can chain method calls
|
|
260
|
+
* @example Basic example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* composer.addAssetDestroy({ sender: "MANAGERADDRESS", assetId: 123456n })
|
|
263
|
+
* ```
|
|
264
|
+
* @example Advanced example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* composer.addAssetDestroy({
|
|
267
|
+
* sender: 'MANAGERADDRESS',
|
|
268
|
+
* assetId: 123456n,
|
|
269
|
+
* lease: 'lease',
|
|
270
|
+
* note: 'note',
|
|
271
|
+
* // You wouldn't normally set this field
|
|
272
|
+
* firstValidRound: 1000n,
|
|
273
|
+
* validityWindow: 10,
|
|
274
|
+
* extraFee: (1000).microAlgo(),
|
|
275
|
+
* staticFee: (1000).microAlgo(),
|
|
276
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
277
|
+
* // already specified, but here for completeness
|
|
278
|
+
* maxFee: (3000).microAlgo(),
|
|
279
|
+
* })
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
addAssetDestroy(params) {
|
|
283
|
+
this.txns.push({
|
|
284
|
+
...params,
|
|
285
|
+
type: "assetDestroy"
|
|
286
|
+
});
|
|
287
|
+
return this;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Add an asset transfer transaction to the transaction group.
|
|
291
|
+
* @param params The asset transfer transaction parameters
|
|
292
|
+
* @returns The composer so you can chain method calls
|
|
293
|
+
* @example Basic example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* composer.addAssetTransfer({ sender: "HOLDERADDRESS", assetId: 123456n, amount: 1n, receiver: "RECEIVERADDRESS" })
|
|
296
|
+
* ```
|
|
297
|
+
* @example Advanced example (with clawback)
|
|
298
|
+
* ```typescript
|
|
299
|
+
* composer.addAssetTransfer({
|
|
300
|
+
* sender: 'CLAWBACKADDRESS',
|
|
301
|
+
* assetId: 123456n,
|
|
302
|
+
* amount: 1n,
|
|
303
|
+
* receiver: 'RECEIVERADDRESS',
|
|
304
|
+
* clawbackTarget: 'HOLDERADDRESS',
|
|
305
|
+
* // This field needs to be used with caution
|
|
306
|
+
* closeAssetTo: 'ADDRESSTOCLOSETO'
|
|
307
|
+
* lease: 'lease',
|
|
308
|
+
* note: 'note',
|
|
309
|
+
* // You wouldn't normally set this field
|
|
310
|
+
* firstValidRound: 1000n,
|
|
311
|
+
* validityWindow: 10,
|
|
312
|
+
* extraFee: (1000).microAlgo(),
|
|
313
|
+
* staticFee: (1000).microAlgo(),
|
|
314
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
315
|
+
* // already specified, but here for completeness
|
|
316
|
+
* maxFee: (3000).microAlgo(),
|
|
317
|
+
* })
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
addAssetTransfer(params) {
|
|
321
|
+
this.txns.push({
|
|
322
|
+
...params,
|
|
323
|
+
type: "assetTransfer"
|
|
324
|
+
});
|
|
325
|
+
return this;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Add an asset opt-in transaction to the transaction group.
|
|
329
|
+
* @param params The asset opt-in transaction parameters
|
|
330
|
+
* @returns The composer so you can chain method calls
|
|
331
|
+
* @example Basic example
|
|
332
|
+
* ```typescript
|
|
333
|
+
* composer.addAssetOptIn({ sender: "SENDERADDRESS", assetId: 123456n })
|
|
334
|
+
* ```
|
|
335
|
+
* @example Advanced example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* composer.addAssetOptIn({
|
|
338
|
+
* sender: 'SENDERADDRESS',
|
|
339
|
+
* assetId: 123456n,
|
|
340
|
+
* lease: 'lease',
|
|
341
|
+
* note: 'note',
|
|
342
|
+
* // You wouldn't normally set this field
|
|
343
|
+
* firstValidRound: 1000n,
|
|
344
|
+
* validityWindow: 10,
|
|
345
|
+
* extraFee: (1000).microAlgo(),
|
|
346
|
+
* staticFee: (1000).microAlgo(),
|
|
347
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
348
|
+
* // already specified, but here for completeness
|
|
349
|
+
* maxFee: (3000).microAlgo(),
|
|
350
|
+
* })
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
addAssetOptIn(params) {
|
|
354
|
+
this.txns.push({
|
|
355
|
+
...params,
|
|
356
|
+
type: "assetOptIn"
|
|
357
|
+
});
|
|
358
|
+
return this;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Add an asset opt-out transaction to the transaction group.
|
|
362
|
+
* @param params The asset opt-out transaction parameters
|
|
363
|
+
* @returns The composer so you can chain method calls
|
|
364
|
+
* @example Basic example (without creator, will be retrieved from algod)
|
|
365
|
+
* ```typescript
|
|
366
|
+
* composer.addAssetOptOut({ sender: "SENDERADDRESS", assetId: 123456n, ensureZeroBalance: true })
|
|
367
|
+
* ```
|
|
368
|
+
* @example Basic example (with creator)
|
|
369
|
+
* ```typescript
|
|
370
|
+
* composer.addAssetOptOut({ sender: "SENDERADDRESS", creator: "CREATORADDRESS", assetId: 123456n, ensureZeroBalance: true })
|
|
371
|
+
* ```
|
|
372
|
+
* @example Advanced example
|
|
373
|
+
* ```typescript
|
|
374
|
+
* composer.addAssetOptOut({
|
|
375
|
+
* sender: 'SENDERADDRESS',
|
|
376
|
+
* assetId: 123456n,
|
|
377
|
+
* creator: 'CREATORADDRESS',
|
|
378
|
+
* ensureZeroBalance: true,
|
|
379
|
+
* lease: 'lease',
|
|
380
|
+
* note: 'note',
|
|
381
|
+
* // You wouldn't normally set this field
|
|
382
|
+
* firstValidRound: 1000n,
|
|
383
|
+
* validityWindow: 10,
|
|
384
|
+
* extraFee: (1000).microAlgo(),
|
|
385
|
+
* staticFee: (1000).microAlgo(),
|
|
386
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
387
|
+
* // already specified, but here for completeness
|
|
388
|
+
* maxFee: (3000).microAlgo(),
|
|
389
|
+
* })
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
addAssetOptOut(params) {
|
|
393
|
+
this.txns.push({
|
|
394
|
+
...params,
|
|
395
|
+
type: "assetOptOut"
|
|
396
|
+
});
|
|
397
|
+
return this;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Add an application create transaction to the transaction group.
|
|
401
|
+
*
|
|
402
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
403
|
+
* @param params The application create transaction parameters
|
|
404
|
+
* @returns The composer so you can chain method calls
|
|
405
|
+
* @example Basic example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* composer.addAppCreate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
|
|
408
|
+
* ```
|
|
409
|
+
* @example Advanced example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* composer.addAppCreate({
|
|
412
|
+
* sender: 'CREATORADDRESS',
|
|
413
|
+
* approvalProgram: "TEALCODE",
|
|
414
|
+
* clearStateProgram: "TEALCODE",
|
|
415
|
+
* schema: {
|
|
416
|
+
* globalInts: 1,
|
|
417
|
+
* globalByteSlices: 2,
|
|
418
|
+
* localInts: 3,
|
|
419
|
+
* localByteSlices: 4
|
|
420
|
+
* },
|
|
421
|
+
* extraProgramPages: 1,
|
|
422
|
+
* onComplete: algosdk.OnApplicationComplete.OptInOC,
|
|
423
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
424
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
425
|
+
* appReferences: [123n, 1234n]
|
|
426
|
+
* assetReferences: [12345n]
|
|
427
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
428
|
+
* accessReferences: [{ appId: 1234n }]
|
|
429
|
+
* lease: 'lease',
|
|
430
|
+
* note: 'note',
|
|
431
|
+
* // You wouldn't normally set this field
|
|
432
|
+
* firstValidRound: 1000n,
|
|
433
|
+
* validityWindow: 10,
|
|
434
|
+
* extraFee: (1000).microAlgo(),
|
|
435
|
+
* staticFee: (1000).microAlgo(),
|
|
436
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
437
|
+
* // already specified, but here for completeness
|
|
438
|
+
* maxFee: (3000).microAlgo(),
|
|
439
|
+
* rejectVersion: 1,
|
|
440
|
+
* // Signer only needed if you want to provide one,
|
|
441
|
+
* // generally you'd register it with AlgorandClient
|
|
442
|
+
* // against the sender and not need to pass it in
|
|
443
|
+
* signer: transactionSigner,
|
|
444
|
+
* maxRoundsToWaitForConfirmation: 5,
|
|
445
|
+
* suppressLog: true,
|
|
446
|
+
*})
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
addAppCreate(params) {
|
|
450
|
+
this.txns.push({
|
|
451
|
+
...params,
|
|
452
|
+
type: "appCall"
|
|
453
|
+
});
|
|
454
|
+
return this;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Add an application update transaction to the transaction group.
|
|
458
|
+
*
|
|
459
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
460
|
+
* @param params The application update transaction parameters
|
|
461
|
+
* @returns The composer so you can chain method calls
|
|
462
|
+
* @example Basic example
|
|
463
|
+
* ```typescript
|
|
464
|
+
* composer.addAppUpdate({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE' })
|
|
465
|
+
* ```
|
|
466
|
+
* @example Advanced example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* composer.addAppUpdate({
|
|
469
|
+
* sender: 'CREATORADDRESS',
|
|
470
|
+
* approvalProgram: "TEALCODE",
|
|
471
|
+
* clearStateProgram: "TEALCODE",
|
|
472
|
+
* onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
473
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
474
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
475
|
+
* appReferences: [123n, 1234n]
|
|
476
|
+
* assetReferences: [12345n]
|
|
477
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
478
|
+
* accessReferences: [{ appId: 1234n }]
|
|
479
|
+
* lease: 'lease',
|
|
480
|
+
* note: 'note',
|
|
481
|
+
* // You wouldn't normally set this field
|
|
482
|
+
* firstValidRound: 1000n,
|
|
483
|
+
* validityWindow: 10,
|
|
484
|
+
* extraFee: (1000).microAlgo(),
|
|
485
|
+
* staticFee: (1000).microAlgo(),
|
|
486
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
487
|
+
* // already specified, but here for completeness
|
|
488
|
+
* maxFee: (3000).microAlgo(),
|
|
489
|
+
* rejectVersion: 1,
|
|
490
|
+
*})
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
addAppUpdate(params) {
|
|
494
|
+
this.txns.push({
|
|
495
|
+
...params,
|
|
496
|
+
type: "appCall",
|
|
497
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC
|
|
498
|
+
});
|
|
499
|
+
return this;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Add an application delete transaction to the transaction group.
|
|
503
|
+
*
|
|
504
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
505
|
+
* @param params The application delete transaction parameters
|
|
506
|
+
* @returns The composer so you can chain method calls
|
|
507
|
+
* @example Basic example
|
|
508
|
+
* ```typescript
|
|
509
|
+
* composer.addAppDelete({ sender: 'CREATORADDRESS' })
|
|
510
|
+
* ```
|
|
511
|
+
* @example Advanced example
|
|
512
|
+
* ```typescript
|
|
513
|
+
* composer.addAppDelete({
|
|
514
|
+
* sender: 'CREATORADDRESS',
|
|
515
|
+
* onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
|
|
516
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
517
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
518
|
+
* appReferences: [123n, 1234n]
|
|
519
|
+
* assetReferences: [12345n]
|
|
520
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
521
|
+
* accessReferences: [{ appId: 1234n }]
|
|
522
|
+
* lease: 'lease',
|
|
523
|
+
* note: 'note',
|
|
524
|
+
* // You wouldn't normally set this field
|
|
525
|
+
* firstValidRound: 1000n,
|
|
526
|
+
* validityWindow: 10,
|
|
527
|
+
* extraFee: (1000).microAlgo(),
|
|
528
|
+
* staticFee: (1000).microAlgo(),
|
|
529
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
530
|
+
* // already specified, but here for completeness
|
|
531
|
+
* maxFee: (3000).microAlgo(),
|
|
532
|
+
* rejectVersion: 1,
|
|
533
|
+
*})
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
addAppDelete(params) {
|
|
537
|
+
this.txns.push({
|
|
538
|
+
...params,
|
|
539
|
+
type: "appCall",
|
|
540
|
+
onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC
|
|
541
|
+
});
|
|
542
|
+
return this;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Add an application call transaction to the transaction group.
|
|
546
|
+
*
|
|
547
|
+
* If you want to create or update an app use `addAppCreate` or `addAppUpdate`.
|
|
548
|
+
*
|
|
549
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
550
|
+
* @param params The application call transaction parameters
|
|
551
|
+
* @returns The composer so you can chain method calls
|
|
552
|
+
* @example Basic example
|
|
553
|
+
* ```typescript
|
|
554
|
+
* composer.addAppCall({ sender: 'CREATORADDRESS' })
|
|
555
|
+
* ```
|
|
556
|
+
* @example Advanced example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* composer.addAppCall({
|
|
559
|
+
* sender: 'CREATORADDRESS',
|
|
560
|
+
* onComplete: algosdk.OnApplicationComplete.OptInOC,
|
|
561
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
562
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
563
|
+
* appReferences: [123n, 1234n]
|
|
564
|
+
* assetReferences: [12345n]
|
|
565
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
566
|
+
* accessReferences: [{ appId: 1234n }]
|
|
567
|
+
* lease: 'lease',
|
|
568
|
+
* note: 'note',
|
|
569
|
+
* // You wouldn't normally set this field
|
|
570
|
+
* firstValidRound: 1000n,
|
|
571
|
+
* validityWindow: 10,
|
|
572
|
+
* extraFee: (1000).microAlgo(),
|
|
573
|
+
* staticFee: (1000).microAlgo(),
|
|
574
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
575
|
+
* // already specified, but here for completeness
|
|
576
|
+
* maxFee: (3000).microAlgo(),
|
|
577
|
+
* rejectVersion: 1,
|
|
578
|
+
*})
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
addAppCall(params) {
|
|
582
|
+
this.txns.push({
|
|
583
|
+
...params,
|
|
584
|
+
type: "appCall"
|
|
585
|
+
});
|
|
586
|
+
return this;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Add an ABI method create application call transaction to the transaction group.
|
|
590
|
+
*
|
|
591
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
592
|
+
* @param params The ABI create method application call transaction parameters
|
|
593
|
+
* @returns The composer so you can chain method calls
|
|
594
|
+
* @example Basic example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* const method = new ABIMethod({
|
|
597
|
+
* name: 'method',
|
|
598
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
599
|
+
* returns: { type: 'string' },
|
|
600
|
+
* })
|
|
601
|
+
* composer.addAppCreateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
|
|
602
|
+
* ```
|
|
603
|
+
* @example Advanced example
|
|
604
|
+
* ```typescript
|
|
605
|
+
* const method = new ABIMethod({
|
|
606
|
+
* name: 'method',
|
|
607
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
608
|
+
* returns: { type: 'string' },
|
|
609
|
+
* })
|
|
610
|
+
* composer.addAppCreateMethodCall({
|
|
611
|
+
* sender: 'CREATORADDRESS',
|
|
612
|
+
* method: method,
|
|
613
|
+
* args: ["arg1_value"],
|
|
614
|
+
* approvalProgram: "TEALCODE",
|
|
615
|
+
* clearStateProgram: "TEALCODE",
|
|
616
|
+
* schema: {
|
|
617
|
+
* globalInts: 1,
|
|
618
|
+
* globalByteSlices: 2,
|
|
619
|
+
* localInts: 3,
|
|
620
|
+
* localByteSlices: 4
|
|
621
|
+
* },
|
|
622
|
+
* extraProgramPages: 1,
|
|
623
|
+
* onComplete: algosdk.OnApplicationComplete.OptInOC,
|
|
624
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
625
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
626
|
+
* appReferences: [123n, 1234n]
|
|
627
|
+
* assetReferences: [12345n]
|
|
628
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
629
|
+
* accessReferences: [{ appId: 1234n }]
|
|
630
|
+
* lease: 'lease',
|
|
631
|
+
* note: 'note',
|
|
632
|
+
* // You wouldn't normally set this field
|
|
633
|
+
* firstValidRound: 1000n,
|
|
634
|
+
* validityWindow: 10,
|
|
635
|
+
* extraFee: (1000).microAlgo(),
|
|
636
|
+
* staticFee: (1000).microAlgo(),
|
|
637
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
638
|
+
* // already specified, but here for completeness
|
|
639
|
+
* maxFee: (3000).microAlgo(),
|
|
640
|
+
* rejectVersion: 1,
|
|
641
|
+
*})
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
addAppCreateMethodCall(params) {
|
|
645
|
+
this.txns.push({
|
|
646
|
+
...params,
|
|
647
|
+
type: "methodCall"
|
|
648
|
+
});
|
|
649
|
+
return this;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Add an ABI method update application call transaction to the transaction group.
|
|
653
|
+
*
|
|
654
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
655
|
+
* @param params The ABI update method application call transaction parameters
|
|
656
|
+
* @returns The composer so you can chain method calls
|
|
657
|
+
* @example Basic example
|
|
658
|
+
* ```typescript
|
|
659
|
+
* const method = new ABIMethod({
|
|
660
|
+
* name: 'method',
|
|
661
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
662
|
+
* returns: { type: 'string' },
|
|
663
|
+
* })
|
|
664
|
+
* composer.addAppUpdateMethodCall({ sender: 'CREATORADDRESS', approvalProgram: 'TEALCODE', clearStateProgram: 'TEALCODE', method: method, args: ["arg1_value"] })
|
|
665
|
+
* ```
|
|
666
|
+
* @example Advanced example
|
|
667
|
+
* ```typescript
|
|
668
|
+
* const method = new ABIMethod({
|
|
669
|
+
* name: 'method',
|
|
670
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
671
|
+
* returns: { type: 'string' },
|
|
672
|
+
* })
|
|
673
|
+
* composer.addAppUpdateMethodCall({
|
|
674
|
+
* sender: 'CREATORADDRESS',
|
|
675
|
+
* method: method,
|
|
676
|
+
* args: ["arg1_value"],
|
|
677
|
+
* approvalProgram: "TEALCODE",
|
|
678
|
+
* clearStateProgram: "TEALCODE",
|
|
679
|
+
* onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
680
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
681
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
682
|
+
* appReferences: [123n, 1234n]
|
|
683
|
+
* assetReferences: [12345n]
|
|
684
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
685
|
+
* accessReferences: [{ appId: 1234n }]
|
|
686
|
+
* lease: 'lease',
|
|
687
|
+
* note: 'note',
|
|
688
|
+
* // You wouldn't normally set this field
|
|
689
|
+
* firstValidRound: 1000n,
|
|
690
|
+
* validityWindow: 10,
|
|
691
|
+
* extraFee: (1000).microAlgo(),
|
|
692
|
+
* staticFee: (1000).microAlgo(),
|
|
693
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
694
|
+
* // already specified, but here for completeness
|
|
695
|
+
* maxFee: (3000).microAlgo(),
|
|
696
|
+
* rejectVersion: 1,
|
|
697
|
+
*})
|
|
698
|
+
* ```
|
|
699
|
+
*/
|
|
700
|
+
addAppUpdateMethodCall(params) {
|
|
701
|
+
this.txns.push({
|
|
702
|
+
...params,
|
|
703
|
+
type: "methodCall",
|
|
704
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC
|
|
705
|
+
});
|
|
706
|
+
return this;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Add an ABI method delete application call transaction to the transaction group.
|
|
710
|
+
*
|
|
711
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
712
|
+
* @param params The ABI delete method application call transaction parameters
|
|
713
|
+
* @returns The composer so you can chain method calls
|
|
714
|
+
* @example Basic example
|
|
715
|
+
* ```typescript
|
|
716
|
+
* const method = new ABIMethod({
|
|
717
|
+
* name: 'method',
|
|
718
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
719
|
+
* returns: { type: 'string' },
|
|
720
|
+
* })
|
|
721
|
+
* composer.addAppDeleteMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
|
|
722
|
+
* ```
|
|
723
|
+
* @example Advanced example
|
|
724
|
+
* ```typescript
|
|
725
|
+
* const method = new ABIMethod({
|
|
726
|
+
* name: 'method',
|
|
727
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
728
|
+
* returns: { type: 'string' },
|
|
729
|
+
* })
|
|
730
|
+
* composer.addAppDeleteMethodCall({
|
|
731
|
+
* sender: 'CREATORADDRESS',
|
|
732
|
+
* method: method,
|
|
733
|
+
* args: ["arg1_value"],
|
|
734
|
+
* onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
|
|
735
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
736
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
737
|
+
* appReferences: [123n, 1234n]
|
|
738
|
+
* assetReferences: [12345n]
|
|
739
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
740
|
+
* accessReferences: [{ appId: 1234n }]
|
|
741
|
+
* lease: 'lease',
|
|
742
|
+
* note: 'note',
|
|
743
|
+
* // You wouldn't normally set this field
|
|
744
|
+
* firstValidRound: 1000n,
|
|
745
|
+
* validityWindow: 10,
|
|
746
|
+
* extraFee: (1000).microAlgo(),
|
|
747
|
+
* staticFee: (1000).microAlgo(),
|
|
748
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
749
|
+
* // already specified, but here for completeness
|
|
750
|
+
* maxFee: (3000).microAlgo(),
|
|
751
|
+
* rejectVersion: 1,
|
|
752
|
+
*})
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
addAppDeleteMethodCall(params) {
|
|
756
|
+
this.txns.push({
|
|
757
|
+
...params,
|
|
758
|
+
type: "methodCall",
|
|
759
|
+
onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC
|
|
760
|
+
});
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Add a non-create/non-update ABI method application call transaction to the transaction group.
|
|
765
|
+
*
|
|
766
|
+
* Note: we recommend using app clients to make it easier to make app calls.
|
|
767
|
+
* @param params The ABI method application call transaction parameters
|
|
768
|
+
* @returns The composer so you can chain method calls
|
|
769
|
+
* @example Basic example
|
|
770
|
+
* ```typescript
|
|
771
|
+
* const method = new ABIMethod({
|
|
772
|
+
* name: 'method',
|
|
773
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
774
|
+
* returns: { type: 'string' },
|
|
775
|
+
* })
|
|
776
|
+
* composer.addAppCallMethodCall({ sender: 'CREATORADDRESS', method: method, args: ["arg1_value"] })
|
|
777
|
+
* ```
|
|
778
|
+
* @example Advanced example
|
|
779
|
+
* ```typescript
|
|
780
|
+
* const method = new ABIMethod({
|
|
781
|
+
* name: 'method',
|
|
782
|
+
* args: [{ name: 'arg1', type: 'string' }],
|
|
783
|
+
* returns: { type: 'string' },
|
|
784
|
+
* })
|
|
785
|
+
* composer.addAppCallMethodCall({
|
|
786
|
+
* sender: 'CREATORADDRESS',
|
|
787
|
+
* method: method,
|
|
788
|
+
* args: ["arg1_value"],
|
|
789
|
+
* onComplete: algosdk.OnApplicationComplete.OptInOC,
|
|
790
|
+
* args: [new Uint8Array(1, 2, 3, 4)]
|
|
791
|
+
* accountReferences: ["ACCOUNT_1"]
|
|
792
|
+
* appReferences: [123n, 1234n]
|
|
793
|
+
* assetReferences: [12345n]
|
|
794
|
+
* boxReferences: ["box1", {appId: 1234n, name: "box2"}]
|
|
795
|
+
* accessReferences: [{ appId: 1234n }]
|
|
796
|
+
* lease: 'lease',
|
|
797
|
+
* note: 'note',
|
|
798
|
+
* // You wouldn't normally set this field
|
|
799
|
+
* firstValidRound: 1000n,
|
|
800
|
+
* validityWindow: 10,
|
|
801
|
+
* extraFee: (1000).microAlgo(),
|
|
802
|
+
* staticFee: (1000).microAlgo(),
|
|
803
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
804
|
+
* // already specified, but here for completeness
|
|
805
|
+
* maxFee: (3000).microAlgo(),
|
|
806
|
+
* rejectVersion: 1,
|
|
807
|
+
*})
|
|
808
|
+
* ```
|
|
809
|
+
*/
|
|
810
|
+
addAppCallMethodCall(params) {
|
|
811
|
+
this.txns.push({
|
|
812
|
+
...params,
|
|
813
|
+
type: "methodCall"
|
|
814
|
+
});
|
|
815
|
+
return this;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Add an online key registration transaction to the transaction group.
|
|
819
|
+
* @param params The online key registration transaction parameters
|
|
820
|
+
* @returns The composer so you can chain method calls
|
|
821
|
+
* @example Basic example
|
|
822
|
+
* ```typescript
|
|
823
|
+
* composer.addOnlineKeyRegistration({
|
|
824
|
+
* sender: 'SENDERADDRESS',
|
|
825
|
+
* voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
|
|
826
|
+
* selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
|
|
827
|
+
* stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
|
|
828
|
+
* voteFirst: 1n,
|
|
829
|
+
* voteLast: 1000n,
|
|
830
|
+
* voteKeyDilution: 1n,
|
|
831
|
+
* })
|
|
832
|
+
* ```
|
|
833
|
+
* @example Advanced example
|
|
834
|
+
* ```typescript
|
|
835
|
+
* composer.addOnlineKeyRegistration({
|
|
836
|
+
* sender: 'SENDERADDRESS',
|
|
837
|
+
* voteKey: Uint8Array.from(Buffer.from("voteKeyBase64", 'base64')),
|
|
838
|
+
* selectionKey: Uint8Array.from(Buffer.from("selectionKeyBase64", 'base64')),
|
|
839
|
+
* stateProofKey: Uint8Array.from(Buffer.from("stateProofKeyBase64", 'base64')),
|
|
840
|
+
* voteFirst: 1n,
|
|
841
|
+
* voteLast: 1000n,
|
|
842
|
+
* voteKeyDilution: 1n,
|
|
843
|
+
* lease: 'lease',
|
|
844
|
+
* note: 'note',
|
|
845
|
+
* // Use this with caution, it's generally better to use algorand.account.rekeyAccount
|
|
846
|
+
* rekeyTo: 'REKEYTOADDRESS',
|
|
847
|
+
* // You wouldn't normally set this field
|
|
848
|
+
* firstValidRound: 1000n,
|
|
849
|
+
* validityWindow: 10,
|
|
850
|
+
* extraFee: (1000).microAlgo(),
|
|
851
|
+
* staticFee: (1000).microAlgo(),
|
|
852
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
853
|
+
* // already specified, but here for completeness
|
|
854
|
+
* maxFee: (3000).microAlgo(),
|
|
855
|
+
* })
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
858
|
+
addOnlineKeyRegistration(params) {
|
|
859
|
+
this.txns.push({
|
|
860
|
+
...params,
|
|
861
|
+
type: "keyReg"
|
|
862
|
+
});
|
|
863
|
+
return this;
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Add an offline key registration transaction to the transaction group.
|
|
867
|
+
* @param params The offline key registration transaction parameters
|
|
868
|
+
* @returns The composer so you can chain method calls
|
|
869
|
+
* @example Basic example
|
|
870
|
+
* ```typescript
|
|
871
|
+
* composer.addOfflineKeyRegistration({
|
|
872
|
+
* sender: 'SENDERADDRESS',
|
|
873
|
+
* })
|
|
874
|
+
* ```
|
|
875
|
+
* @example Advanced example
|
|
876
|
+
* ```typescript
|
|
877
|
+
* composer.addOfflineKeyRegistration({
|
|
878
|
+
* sender: 'SENDERADDRESS',
|
|
879
|
+
* lease: 'lease',
|
|
880
|
+
* note: 'note',
|
|
881
|
+
* // Use this with caution, it's generally better to use algorand.account.rekeyAccount
|
|
882
|
+
* rekeyTo: 'REKEYTOADDRESS',
|
|
883
|
+
* // You wouldn't normally set this field
|
|
884
|
+
* firstValidRound: 1000n,
|
|
885
|
+
* validityWindow: 10,
|
|
886
|
+
* extraFee: (1000).microAlgo(),
|
|
887
|
+
* staticFee: (1000).microAlgo(),
|
|
888
|
+
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
889
|
+
* // already specified, but here for completeness
|
|
890
|
+
* maxFee: (3000).microAlgo(),
|
|
891
|
+
* })
|
|
892
|
+
* ```
|
|
893
|
+
*/
|
|
894
|
+
addOfflineKeyRegistration(params) {
|
|
895
|
+
this.txns.push({
|
|
896
|
+
...params,
|
|
897
|
+
type: "keyReg"
|
|
898
|
+
});
|
|
899
|
+
return this;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Add the transactions within an `AtomicTransactionComposer` to the transaction group.
|
|
903
|
+
* @param atc The `AtomicTransactionComposer` to build transactions from and add to the group
|
|
904
|
+
* @returns The composer so you can chain method calls
|
|
905
|
+
* @example
|
|
906
|
+
* ```typescript
|
|
907
|
+
* const atc = new AtomicTransactionComposer()
|
|
908
|
+
* .addPayment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', amount: 1000n })
|
|
909
|
+
* composer.addAtc(atc)
|
|
910
|
+
* ```
|
|
911
|
+
*/
|
|
912
|
+
addAtc(atc) {
|
|
913
|
+
this.txns.push({
|
|
914
|
+
atc,
|
|
915
|
+
type: "atc"
|
|
916
|
+
});
|
|
917
|
+
return this;
|
|
918
|
+
}
|
|
919
|
+
/** Build an ATC and return transactions ready to be incorporated into a broader set of transactions this composer is composing */
|
|
920
|
+
buildAtc(atc) {
|
|
921
|
+
return atc.buildGroup().map((ts, idx) => {
|
|
922
|
+
ts.txn.group = void 0;
|
|
923
|
+
if (atc["methodCalls"].get(idx)) return {
|
|
924
|
+
...ts,
|
|
925
|
+
context: { abiMethod: atc["methodCalls"].get(idx) }
|
|
926
|
+
};
|
|
927
|
+
return {
|
|
928
|
+
...ts,
|
|
929
|
+
context: {}
|
|
930
|
+
};
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
commonTxnBuildStep(buildTxn, params, txnParams) {
|
|
934
|
+
txnParams.suggestedParams = { ...txnParams.suggestedParams };
|
|
935
|
+
if (params.lease) txnParams.lease = encodeLease(params.lease);
|
|
936
|
+
if (params.rekeyTo) txnParams.rekeyTo = address(params.rekeyTo);
|
|
937
|
+
const encoder = new TextEncoder();
|
|
938
|
+
if (params.note) txnParams.note = typeof params.note === "string" ? encoder.encode(params.note) : params.note;
|
|
939
|
+
if (params.firstValidRound) txnParams.suggestedParams.firstValid = params.firstValidRound;
|
|
940
|
+
if (params.lastValidRound) txnParams.suggestedParams.lastValid = params.lastValidRound;
|
|
941
|
+
else {
|
|
942
|
+
const window = params.validityWindow ? BigInt(params.validityWindow) : !this.defaultValidityWindowIsExplicit && genesisIdIsLocalNet(txnParams.suggestedParams.genesisID ?? "unknown") ? 1000n : this.defaultValidityWindow;
|
|
943
|
+
txnParams.suggestedParams.lastValid = BigInt(txnParams.suggestedParams.firstValid) + window;
|
|
944
|
+
}
|
|
945
|
+
if (params.staticFee !== void 0 && params.extraFee !== void 0) throw Error("Cannot set both staticFee and extraFee");
|
|
946
|
+
if (params.staticFee !== void 0) {
|
|
947
|
+
txnParams.suggestedParams.fee = params.staticFee.microAlgo;
|
|
948
|
+
txnParams.suggestedParams.flatFee = true;
|
|
949
|
+
}
|
|
950
|
+
const txn = buildTxn(txnParams);
|
|
951
|
+
if (params.extraFee) txn.fee += params.extraFee.microAlgo;
|
|
952
|
+
if (params.maxFee !== void 0 && txn.fee > params.maxFee.microAlgo) throw Error(`Transaction fee ${txn.fee} µALGO is greater than maxFee ${params.maxFee}`);
|
|
953
|
+
return {
|
|
954
|
+
txn,
|
|
955
|
+
context: { maxFee: params.maxFee !== void 0 && params.maxFee.microAlgo > (params.staticFee?.microAlgo ?? 0n) ? params.maxFee : params.staticFee }
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Builds an ABI method call transaction and any other associated transactions represented in the ABI args.
|
|
960
|
+
* @param includeSigner Whether to include the actual signer for the transactions.
|
|
961
|
+
* If you are just building transactions without signers yet then set this to `false`.
|
|
962
|
+
*/
|
|
963
|
+
async buildMethodCall(params, suggestedParams, includeSigner) {
|
|
964
|
+
const methodArgs = [];
|
|
965
|
+
const transactionsForGroup = [];
|
|
966
|
+
const isAbiValue = (x) => {
|
|
967
|
+
if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue);
|
|
968
|
+
return typeof x === "bigint" || typeof x === "boolean" || typeof x === "number" || typeof x === "string" || x instanceof Uint8Array || x instanceof algosdk.Address;
|
|
969
|
+
};
|
|
970
|
+
for (let i = (params.args ?? []).length - 1; i >= 0; i--) {
|
|
971
|
+
const arg = params.args[i];
|
|
972
|
+
if (arg === void 0) {
|
|
973
|
+
if (algosdk.abiTypeIsTransaction(params.method.args[i].type) && transactionsForGroup.length > 0) {
|
|
974
|
+
const placeholderTransaction = transactionsForGroup.splice(-1, 1)[0];
|
|
975
|
+
methodArgs.push(placeholderTransaction);
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
throw Error(`No value provided for argument ${i + 1} within call to ${params.method.name}`);
|
|
979
|
+
}
|
|
980
|
+
if (isAbiValue(arg)) {
|
|
981
|
+
methodArgs.push(arg);
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
if (isTransactionWithSigner(arg)) {
|
|
985
|
+
methodArgs.push(arg);
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
if ("method" in arg) {
|
|
989
|
+
const tempTxnWithSigners = await this.buildMethodCall(arg, suggestedParams, includeSigner);
|
|
990
|
+
methodArgs.push(...tempTxnWithSigners.slice(-1));
|
|
991
|
+
transactionsForGroup.push(...tempTxnWithSigners.slice(0, -1).reverse());
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
994
|
+
const txn = await arg;
|
|
995
|
+
methodArgs.push({
|
|
996
|
+
txn,
|
|
997
|
+
signer: includeSigner ? params.signer ? "signer" in params.signer ? params.signer.signer : params.signer : this.getSigner(txn.sender) : TransactionComposer.NULL_SIGNER
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
const methodAtc = new algosdk.AtomicTransactionComposer();
|
|
1001
|
+
const maxFees = /* @__PURE__ */ new Map();
|
|
1002
|
+
transactionsForGroup.reverse().forEach(({ context, ...txnWithSigner }) => {
|
|
1003
|
+
methodAtc.addTransaction(txnWithSigner);
|
|
1004
|
+
const atcIndex = methodAtc.count() - 1;
|
|
1005
|
+
if (context.abiMethod) methodAtc["methodCalls"].set(atcIndex, context.abiMethod);
|
|
1006
|
+
if (context.maxFee !== void 0) maxFees.set(atcIndex, context.maxFee);
|
|
1007
|
+
});
|
|
1008
|
+
methodArgs.filter((arg) => {
|
|
1009
|
+
if (typeof arg === "object" && "context" in arg) {
|
|
1010
|
+
const { context, ...txnWithSigner } = arg;
|
|
1011
|
+
return isTransactionWithSigner(txnWithSigner);
|
|
1012
|
+
}
|
|
1013
|
+
return isTransactionWithSigner(arg);
|
|
1014
|
+
}).reverse().forEach((arg, idx) => {
|
|
1015
|
+
if (typeof arg === "object" && "context" in arg && arg.context) {
|
|
1016
|
+
const atcIndex = methodAtc.count() + idx;
|
|
1017
|
+
if (arg.context.abiMethod) methodAtc["methodCalls"].set(atcIndex, arg.context.abiMethod);
|
|
1018
|
+
if (arg.context.maxFee !== void 0) maxFees.set(atcIndex, arg.context.maxFee);
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
const appId = Number("appId" in params ? params.appId : 0n);
|
|
1022
|
+
const approvalProgram = "approvalProgram" in params ? typeof params.approvalProgram === "string" ? (await this.appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes : params.approvalProgram : void 0;
|
|
1023
|
+
const clearStateProgram = "clearStateProgram" in params ? typeof params.clearStateProgram === "string" ? (await this.appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes : params.clearStateProgram : void 0;
|
|
1024
|
+
const txnParams = {
|
|
1025
|
+
appID: appId,
|
|
1026
|
+
sender: params.sender,
|
|
1027
|
+
suggestedParams,
|
|
1028
|
+
onComplete: params.onComplete ?? algosdk.OnApplicationComplete.NoOpOC,
|
|
1029
|
+
appAccounts: params.accountReferences,
|
|
1030
|
+
appForeignApps: params.appReferences?.map((x) => Number(x)),
|
|
1031
|
+
appForeignAssets: params.assetReferences?.map((x) => Number(x)),
|
|
1032
|
+
boxes: params.boxReferences?.map(AppManager.getBoxReference),
|
|
1033
|
+
access: params.accessReferences?.map(getResourceReference),
|
|
1034
|
+
approvalProgram,
|
|
1035
|
+
clearProgram: clearStateProgram,
|
|
1036
|
+
extraPages: appId === 0 ? "extraProgramPages" in params && params.extraProgramPages !== void 0 ? params.extraProgramPages : approvalProgram ? calculateExtraProgramPages(approvalProgram, clearStateProgram) : 0 : void 0,
|
|
1037
|
+
numLocalInts: appId === 0 ? "schema" in params ? params.schema?.localInts ?? 0 : 0 : void 0,
|
|
1038
|
+
numLocalByteSlices: appId === 0 ? "schema" in params ? params.schema?.localByteSlices ?? 0 : 0 : void 0,
|
|
1039
|
+
numGlobalInts: appId === 0 ? "schema" in params ? params.schema?.globalInts ?? 0 : 0 : void 0,
|
|
1040
|
+
numGlobalByteSlices: appId === 0 ? "schema" in params ? params.schema?.globalByteSlices ?? 0 : 0 : void 0,
|
|
1041
|
+
method: params.method,
|
|
1042
|
+
signer: includeSigner ? params.signer ? "signer" in params.signer ? params.signer.signer : params.signer : this.getSigner(params.sender) : TransactionComposer.NULL_SIGNER,
|
|
1043
|
+
methodArgs: methodArgs.map((arg) => {
|
|
1044
|
+
if (typeof arg === "object" && "context" in arg) {
|
|
1045
|
+
const { context, ...txnWithSigner } = arg;
|
|
1046
|
+
return txnWithSigner;
|
|
1047
|
+
}
|
|
1048
|
+
return arg;
|
|
1049
|
+
}).reverse(),
|
|
1050
|
+
rejectVersion: params.rejectVersion,
|
|
1051
|
+
note: void 0,
|
|
1052
|
+
lease: void 0,
|
|
1053
|
+
rekeyTo: void 0
|
|
1054
|
+
};
|
|
1055
|
+
const result = this.commonTxnBuildStep((txnParams) => {
|
|
1056
|
+
methodAtc.addMethodCall(txnParams);
|
|
1057
|
+
return methodAtc.buildGroup()[methodAtc.count() - 1].txn;
|
|
1058
|
+
}, params, txnParams);
|
|
1059
|
+
return this.buildAtc(methodAtc).map(({ context: _context, ...txnWithSigner }, idx) => {
|
|
1060
|
+
const maxFee = idx === methodAtc.count() - 1 ? result.context.maxFee : maxFees.get(idx);
|
|
1061
|
+
const context = {
|
|
1062
|
+
..._context,
|
|
1063
|
+
maxFee
|
|
1064
|
+
};
|
|
1065
|
+
return {
|
|
1066
|
+
...txnWithSigner,
|
|
1067
|
+
context
|
|
1068
|
+
};
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
buildPayment(params, suggestedParams) {
|
|
1072
|
+
return this.commonTxnBuildStep(algosdk.makePaymentTxnWithSuggestedParamsFromObject, params, {
|
|
1073
|
+
sender: params.sender,
|
|
1074
|
+
receiver: params.receiver,
|
|
1075
|
+
amount: params.amount.microAlgo,
|
|
1076
|
+
closeRemainderTo: params.closeRemainderTo,
|
|
1077
|
+
suggestedParams
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
buildAssetCreate(params, suggestedParams) {
|
|
1081
|
+
return this.commonTxnBuildStep(algosdk.makeAssetCreateTxnWithSuggestedParamsFromObject, params, {
|
|
1082
|
+
sender: params.sender,
|
|
1083
|
+
total: params.total,
|
|
1084
|
+
decimals: params.decimals ?? 0,
|
|
1085
|
+
assetName: params.assetName,
|
|
1086
|
+
unitName: params.unitName,
|
|
1087
|
+
assetURL: params.url,
|
|
1088
|
+
defaultFrozen: params.defaultFrozen ?? false,
|
|
1089
|
+
assetMetadataHash: typeof params.metadataHash === "string" ? Buffer.from(params.metadataHash, "utf-8") : params.metadataHash,
|
|
1090
|
+
manager: params.manager,
|
|
1091
|
+
reserve: params.reserve,
|
|
1092
|
+
freeze: params.freeze,
|
|
1093
|
+
clawback: params.clawback,
|
|
1094
|
+
suggestedParams
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
buildAssetConfig(params, suggestedParams) {
|
|
1098
|
+
return this.commonTxnBuildStep(algosdk.makeAssetConfigTxnWithSuggestedParamsFromObject, params, {
|
|
1099
|
+
sender: params.sender,
|
|
1100
|
+
assetIndex: params.assetId,
|
|
1101
|
+
suggestedParams,
|
|
1102
|
+
manager: params.manager,
|
|
1103
|
+
reserve: params.reserve,
|
|
1104
|
+
freeze: params.freeze,
|
|
1105
|
+
clawback: params.clawback,
|
|
1106
|
+
strictEmptyAddressChecking: false
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
buildAssetDestroy(params, suggestedParams) {
|
|
1110
|
+
return this.commonTxnBuildStep(algosdk.makeAssetDestroyTxnWithSuggestedParamsFromObject, params, {
|
|
1111
|
+
sender: params.sender,
|
|
1112
|
+
assetIndex: params.assetId,
|
|
1113
|
+
suggestedParams
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
buildAssetFreeze(params, suggestedParams) {
|
|
1117
|
+
return this.commonTxnBuildStep(algosdk.makeAssetFreezeTxnWithSuggestedParamsFromObject, params, {
|
|
1118
|
+
sender: params.sender,
|
|
1119
|
+
assetIndex: params.assetId,
|
|
1120
|
+
freezeTarget: params.account,
|
|
1121
|
+
frozen: params.frozen,
|
|
1122
|
+
suggestedParams
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
buildAssetTransfer(params, suggestedParams) {
|
|
1126
|
+
return this.commonTxnBuildStep(algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject, params, {
|
|
1127
|
+
sender: params.sender,
|
|
1128
|
+
receiver: params.receiver,
|
|
1129
|
+
assetIndex: params.assetId,
|
|
1130
|
+
amount: params.amount,
|
|
1131
|
+
suggestedParams,
|
|
1132
|
+
closeRemainderTo: params.closeAssetTo,
|
|
1133
|
+
assetSender: params.clawbackTarget
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
async buildAppCall(params, suggestedParams) {
|
|
1137
|
+
const appId = "appId" in params ? params.appId : 0n;
|
|
1138
|
+
const approvalProgram = "approvalProgram" in params ? typeof params.approvalProgram === "string" ? (await this.appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes : params.approvalProgram : void 0;
|
|
1139
|
+
const clearStateProgram = "clearStateProgram" in params ? typeof params.clearStateProgram === "string" ? (await this.appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes : params.clearStateProgram : void 0;
|
|
1140
|
+
const sdkParams = {
|
|
1141
|
+
sender: params.sender,
|
|
1142
|
+
suggestedParams,
|
|
1143
|
+
appArgs: params.args,
|
|
1144
|
+
onComplete: params.onComplete ?? algosdk.OnApplicationComplete.NoOpOC,
|
|
1145
|
+
accounts: params.accountReferences,
|
|
1146
|
+
foreignApps: params.appReferences?.map((x) => Number(x)),
|
|
1147
|
+
foreignAssets: params.assetReferences?.map((x) => Number(x)),
|
|
1148
|
+
boxes: params.boxReferences?.map(AppManager.getBoxReference),
|
|
1149
|
+
access: params.accessReferences?.map(getResourceReference),
|
|
1150
|
+
approvalProgram,
|
|
1151
|
+
clearProgram: clearStateProgram,
|
|
1152
|
+
rejectVersion: params.rejectVersion
|
|
1153
|
+
};
|
|
1154
|
+
if (appId === 0n) {
|
|
1155
|
+
if (sdkParams.approvalProgram === void 0 || sdkParams.clearProgram === void 0) throw new Error("approvalProgram and clearStateProgram are required for application creation");
|
|
1156
|
+
return this.commonTxnBuildStep(algosdk.makeApplicationCreateTxnFromObject, params, {
|
|
1157
|
+
...sdkParams,
|
|
1158
|
+
extraPages: "extraProgramPages" in params && params.extraProgramPages !== void 0 ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram, clearStateProgram),
|
|
1159
|
+
numLocalInts: "schema" in params ? params.schema?.localInts ?? 0 : 0,
|
|
1160
|
+
numLocalByteSlices: "schema" in params ? params.schema?.localByteSlices ?? 0 : 0,
|
|
1161
|
+
numGlobalInts: "schema" in params ? params.schema?.globalInts ?? 0 : 0,
|
|
1162
|
+
numGlobalByteSlices: "schema" in params ? params.schema?.globalByteSlices ?? 0 : 0,
|
|
1163
|
+
approvalProgram,
|
|
1164
|
+
clearProgram: clearStateProgram
|
|
1165
|
+
});
|
|
1166
|
+
} else return this.commonTxnBuildStep(algosdk.makeApplicationCallTxnFromObject, params, {
|
|
1167
|
+
...sdkParams,
|
|
1168
|
+
appIndex: appId
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
buildKeyReg(params, suggestedParams) {
|
|
1172
|
+
if ("voteKey" in params) return this.commonTxnBuildStep(algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject, params, {
|
|
1173
|
+
sender: params.sender,
|
|
1174
|
+
voteKey: params.voteKey,
|
|
1175
|
+
selectionKey: params.selectionKey,
|
|
1176
|
+
voteFirst: params.voteFirst,
|
|
1177
|
+
voteLast: params.voteLast,
|
|
1178
|
+
voteKeyDilution: params.voteKeyDilution,
|
|
1179
|
+
suggestedParams,
|
|
1180
|
+
nonParticipation: false,
|
|
1181
|
+
stateProofKey: params.stateProofKey
|
|
1182
|
+
});
|
|
1183
|
+
return this.commonTxnBuildStep(algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject, params, {
|
|
1184
|
+
sender: params.sender,
|
|
1185
|
+
suggestedParams,
|
|
1186
|
+
nonParticipation: params.preventAccountFromEverParticipatingAgain
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
/** Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` since those ones can have custom signers that need to be retrieved. */
|
|
1190
|
+
async buildTxn(txn, suggestedParams) {
|
|
1191
|
+
switch (txn.type) {
|
|
1192
|
+
case "pay": return [this.buildPayment(txn, suggestedParams)];
|
|
1193
|
+
case "assetCreate": return [this.buildAssetCreate(txn, suggestedParams)];
|
|
1194
|
+
case "appCall": return [await this.buildAppCall(txn, suggestedParams)];
|
|
1195
|
+
case "assetConfig": return [this.buildAssetConfig(txn, suggestedParams)];
|
|
1196
|
+
case "assetDestroy": return [this.buildAssetDestroy(txn, suggestedParams)];
|
|
1197
|
+
case "assetFreeze": return [this.buildAssetFreeze(txn, suggestedParams)];
|
|
1198
|
+
case "assetTransfer": return [this.buildAssetTransfer(txn, suggestedParams)];
|
|
1199
|
+
case "assetOptIn": return [this.buildAssetTransfer({
|
|
1200
|
+
...txn,
|
|
1201
|
+
receiver: txn.sender,
|
|
1202
|
+
amount: 0n
|
|
1203
|
+
}, suggestedParams)];
|
|
1204
|
+
case "assetOptOut": return [this.buildAssetTransfer({
|
|
1205
|
+
...txn,
|
|
1206
|
+
receiver: txn.sender,
|
|
1207
|
+
amount: 0n,
|
|
1208
|
+
closeAssetTo: txn.creator
|
|
1209
|
+
}, suggestedParams)];
|
|
1210
|
+
case "keyReg": return [this.buildKeyReg(txn, suggestedParams)];
|
|
1211
|
+
default: throw Error(`Unsupported txn type`);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
async buildTxnWithSigner(txn, suggestedParams) {
|
|
1215
|
+
if (txn.type === "txnWithSigner") return [{
|
|
1216
|
+
...txn,
|
|
1217
|
+
context: {}
|
|
1218
|
+
}];
|
|
1219
|
+
if (txn.type === "atc") return this.buildAtc(txn.atc);
|
|
1220
|
+
if (txn.type === "methodCall") return await this.buildMethodCall(txn, suggestedParams, true);
|
|
1221
|
+
const signer = txn.signer ? "signer" in txn.signer ? txn.signer.signer : txn.signer : this.getSigner(txn.sender);
|
|
1222
|
+
return (await this.buildTxn(txn, suggestedParams)).map(({ txn, context }) => ({
|
|
1223
|
+
txn,
|
|
1224
|
+
signer,
|
|
1225
|
+
context
|
|
1226
|
+
}));
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Compose all of the transactions without signers and return the transaction objects directly along with any ABI method calls.
|
|
1230
|
+
*
|
|
1231
|
+
* @returns The array of built transactions and any corresponding method calls
|
|
1232
|
+
* @example
|
|
1233
|
+
* ```typescript
|
|
1234
|
+
* const { transactions, methodCalls, signers } = await composer.buildTransactions()
|
|
1235
|
+
* ```
|
|
1236
|
+
*/
|
|
1237
|
+
async buildTransactions() {
|
|
1238
|
+
const suggestedParams = await this.getSuggestedParams();
|
|
1239
|
+
const transactions = [];
|
|
1240
|
+
const methodCalls = /* @__PURE__ */ new Map();
|
|
1241
|
+
const signers = /* @__PURE__ */ new Map();
|
|
1242
|
+
for (const txn of this.txns) if (![
|
|
1243
|
+
"txnWithSigner",
|
|
1244
|
+
"atc",
|
|
1245
|
+
"methodCall"
|
|
1246
|
+
].includes(txn.type)) transactions.push(...(await this.buildTxn(txn, suggestedParams)).map((txn) => txn.txn));
|
|
1247
|
+
else (txn.type === "txnWithSigner" ? [txn] : txn.type === "atc" ? this.buildAtc(txn.atc) : txn.type === "methodCall" ? await this.buildMethodCall(txn, suggestedParams, false) : []).forEach((ts) => {
|
|
1248
|
+
transactions.push(ts.txn);
|
|
1249
|
+
const groupIdx = transactions.length - 1;
|
|
1250
|
+
if (ts.signer && ts.signer !== TransactionComposer.NULL_SIGNER) signers.set(groupIdx, ts.signer);
|
|
1251
|
+
if ("context" in ts && ts.context.abiMethod) methodCalls.set(groupIdx, ts.context.abiMethod);
|
|
1252
|
+
});
|
|
1253
|
+
return {
|
|
1254
|
+
transactions,
|
|
1255
|
+
methodCalls,
|
|
1256
|
+
signers
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Get the number of transactions currently added to this composer.
|
|
1261
|
+
* @returns The number of transactions currently added to this composer
|
|
1262
|
+
*/
|
|
1263
|
+
async count() {
|
|
1264
|
+
return (await this.buildTransactions()).transactions.length;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Compose all of the transactions in a single atomic transaction group and an atomic transaction composer.
|
|
1268
|
+
*
|
|
1269
|
+
* You can then use the transactions standalone, or use the composer to execute or simulate the transactions.
|
|
1270
|
+
*
|
|
1271
|
+
* Once this method is called, no further transactions will be able to be added.
|
|
1272
|
+
* You can safely call this method multiple times to get the same result.
|
|
1273
|
+
* @returns The built atomic transaction composer, the transactions and any corresponding method calls
|
|
1274
|
+
* @example
|
|
1275
|
+
* ```typescript
|
|
1276
|
+
* const { atc, transactions, methodCalls } = await composer.build()
|
|
1277
|
+
* ```
|
|
1278
|
+
*/
|
|
1279
|
+
async build() {
|
|
1280
|
+
if (this.atc.getStatus() === algosdk.AtomicTransactionComposerStatus.BUILDING) {
|
|
1281
|
+
const suggestedParams = await this.getSuggestedParams();
|
|
1282
|
+
const txnWithSigners = [];
|
|
1283
|
+
for (const txn of this.txns) txnWithSigners.push(...await this.buildTxnWithSigner(txn, suggestedParams));
|
|
1284
|
+
const methodCalls = /* @__PURE__ */ new Map();
|
|
1285
|
+
txnWithSigners.forEach(({ context, ...ts }, idx) => {
|
|
1286
|
+
this.atc.addTransaction(ts);
|
|
1287
|
+
if (context.abiMethod) methodCalls.set(idx, context.abiMethod);
|
|
1288
|
+
if (context.maxFee !== void 0) this.txnMaxFees.set(idx, context.maxFee);
|
|
1289
|
+
});
|
|
1290
|
+
this.atc["methodCalls"] = methodCalls;
|
|
1291
|
+
}
|
|
1292
|
+
const transactions = this.atc.buildGroup();
|
|
1293
|
+
return {
|
|
1294
|
+
atc: this.atc,
|
|
1295
|
+
transactions,
|
|
1296
|
+
methodCalls: this.atc["methodCalls"]
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Rebuild the group, discarding any previously built transactions.
|
|
1301
|
+
* This will potentially cause new signers and suggested params to be used if the callbacks return a new value compared to the first build.
|
|
1302
|
+
* @returns The newly built atomic transaction composer and the transactions
|
|
1303
|
+
* @example
|
|
1304
|
+
* ```typescript
|
|
1305
|
+
* const { atc, transactions, methodCalls } = await composer.rebuild()
|
|
1306
|
+
* ```
|
|
1307
|
+
*/
|
|
1308
|
+
async rebuild() {
|
|
1309
|
+
this.atc = new algosdk.AtomicTransactionComposer();
|
|
1310
|
+
return await this.build();
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Compose the atomic transaction group and send it to the network.
|
|
1314
|
+
* @param params The parameters to control execution with
|
|
1315
|
+
* @returns The execution result
|
|
1316
|
+
* @example
|
|
1317
|
+
* ```typescript
|
|
1318
|
+
* const result = await composer.send()
|
|
1319
|
+
* ```
|
|
1320
|
+
*/
|
|
1321
|
+
async send(params) {
|
|
1322
|
+
const group = (await this.build()).transactions;
|
|
1323
|
+
let waitRounds = params?.maxRoundsToWaitForConfirmation;
|
|
1324
|
+
const suggestedParams = waitRounds === void 0 || params?.coverAppCallInnerTransactionFees ? await this.getSuggestedParams() : void 0;
|
|
1325
|
+
if (waitRounds === void 0) {
|
|
1326
|
+
const lastRound = group.reduce((max, txn) => txn.txn.lastValid > max ? txn.txn.lastValid : BigInt(max), 0n);
|
|
1327
|
+
const { firstValid: firstRound } = suggestedParams;
|
|
1328
|
+
waitRounds = Number(BigInt(lastRound) - BigInt(firstRound)) + 1;
|
|
1329
|
+
}
|
|
1330
|
+
try {
|
|
1331
|
+
return await sendAtomicTransactionComposer({
|
|
1332
|
+
atc: this.atc,
|
|
1333
|
+
suppressLog: params?.suppressLog,
|
|
1334
|
+
maxRoundsToWaitForConfirmation: waitRounds,
|
|
1335
|
+
populateAppCallResources: params?.populateAppCallResources,
|
|
1336
|
+
coverAppCallInnerTransactionFees: params?.coverAppCallInnerTransactionFees,
|
|
1337
|
+
additionalAtcContext: params?.coverAppCallInnerTransactionFees ? {
|
|
1338
|
+
maxFees: this.txnMaxFees,
|
|
1339
|
+
suggestedParams
|
|
1340
|
+
} : void 0
|
|
1341
|
+
}, this.algod);
|
|
1342
|
+
} catch (originalError) {
|
|
1343
|
+
throw await this.transformError(originalError);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* @deprecated Use `send` instead.
|
|
1348
|
+
*
|
|
1349
|
+
* Compose the atomic transaction group and send it to the network
|
|
1350
|
+
*
|
|
1351
|
+
* An alias for `composer.send(params)`.
|
|
1352
|
+
* @param params The parameters to control execution with
|
|
1353
|
+
* @returns The execution result
|
|
1354
|
+
*/
|
|
1355
|
+
async execute(params) {
|
|
1356
|
+
return this.send(params);
|
|
1357
|
+
}
|
|
1358
|
+
async simulate(options) {
|
|
1359
|
+
const { skipSignatures = false, ...rawOptions } = options ?? {};
|
|
1360
|
+
const atc = skipSignatures ? new AtomicTransactionComposer() : this.atc;
|
|
1361
|
+
if (skipSignatures) {
|
|
1362
|
+
rawOptions.allowEmptySignatures = true;
|
|
1363
|
+
rawOptions.fixSigners = true;
|
|
1364
|
+
const transactions = await this.buildTransactions();
|
|
1365
|
+
for (const txn of transactions.transactions) atc.addTransaction({
|
|
1366
|
+
txn,
|
|
1367
|
+
signer: TransactionComposer.NULL_SIGNER
|
|
1368
|
+
});
|
|
1369
|
+
atc["methodCalls"] = transactions.methodCalls;
|
|
1370
|
+
} else await this.build();
|
|
1371
|
+
const { methodResults, simulateResponse } = await atc.simulate(this.algod, new modelsv2.SimulateRequest({
|
|
1372
|
+
txnGroups: [],
|
|
1373
|
+
...rawOptions,
|
|
1374
|
+
...Config.debug ? {
|
|
1375
|
+
allowEmptySignatures: true,
|
|
1376
|
+
fixSigners: true,
|
|
1377
|
+
allowMoreLogging: true,
|
|
1378
|
+
execTraceConfig: new modelsv2.SimulateTraceConfig({
|
|
1379
|
+
enable: true,
|
|
1380
|
+
scratchChange: true,
|
|
1381
|
+
stackChange: true,
|
|
1382
|
+
stateChange: true
|
|
1383
|
+
})
|
|
1384
|
+
} : void 0
|
|
1385
|
+
}));
|
|
1386
|
+
const failedGroup = simulateResponse?.txnGroups[0];
|
|
1387
|
+
if (failedGroup?.failureMessage) {
|
|
1388
|
+
const errorMessage = `Transaction failed at transaction(s) ${failedGroup.failedAt?.join(", ") || "unknown"} in the group. ${failedGroup.failureMessage}`;
|
|
1389
|
+
const error = new Error(errorMessage);
|
|
1390
|
+
if (Config.debug) await Config.events.emitAsync("TxnGroupSimulated", { simulateResponse });
|
|
1391
|
+
throw await this.transformError(error);
|
|
1392
|
+
}
|
|
1393
|
+
if (Config.debug && Config.traceAll) await Config.events.emitAsync("TxnGroupSimulated", { simulateResponse });
|
|
1394
|
+
const transactions = atc.buildGroup().map((t) => t.txn);
|
|
1395
|
+
const methodCalls = [...atc["methodCalls"].values()];
|
|
1396
|
+
return {
|
|
1397
|
+
confirmations: simulateResponse.txnGroups[0].txnResults.map((t) => t.txnResult),
|
|
1398
|
+
transactions,
|
|
1399
|
+
txIds: transactions.map((t) => t.txID()),
|
|
1400
|
+
groupId: Buffer.from(transactions[0].group ?? /* @__PURE__ */ new Uint8Array()).toString("base64"),
|
|
1401
|
+
simulateResponse,
|
|
1402
|
+
returns: methodResults.map((r, i) => getABIReturnValue(r, methodCalls[i].returns.type))
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Create an encoded transaction note that follows the ARC-2 spec.
|
|
1407
|
+
*
|
|
1408
|
+
* https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md
|
|
1409
|
+
* @param note The ARC-2 transaction note data
|
|
1410
|
+
* @returns The binary encoded transaction note
|
|
1411
|
+
*/
|
|
1412
|
+
static arc2Note(note) {
|
|
1413
|
+
const arc2Payload = `${note.dAppName}:${note.format}${typeof note.data === "string" ? note.data : asJson(note.data)}`;
|
|
1414
|
+
return new TextEncoder().encode(arc2Payload);
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1481
1417
|
/**
|
|
1482
|
-
|
|
1483
|
-
|
|
1418
|
+
* Returns an `algosdk.TransactionResourceReference` given a `ResourceReference`.
|
|
1419
|
+
*/
|
|
1484
1420
|
function getResourceReference(accessReference) {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1421
|
+
return {
|
|
1422
|
+
address: typeof accessReference.address === "string" ? Address.fromString(accessReference.address) : accessReference.address,
|
|
1423
|
+
appIndex: accessReference.appId,
|
|
1424
|
+
assetIndex: accessReference.assetId,
|
|
1425
|
+
holding: accessReference.holding ? getHoldingReference(accessReference.holding) : void 0,
|
|
1426
|
+
locals: accessReference.locals ? getLocalsReference(accessReference.locals) : void 0,
|
|
1427
|
+
box: accessReference.box ? AppManager.getBoxReference(accessReference.box) : void 0
|
|
1428
|
+
};
|
|
1493
1429
|
}
|
|
1494
1430
|
function getHoldingReference(holdingReference) {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1431
|
+
return {
|
|
1432
|
+
assetIndex: holdingReference.assetId,
|
|
1433
|
+
address: typeof holdingReference.address === "string" ? Address.fromString(holdingReference.address) : holdingReference.address
|
|
1434
|
+
};
|
|
1499
1435
|
}
|
|
1500
1436
|
function getLocalsReference(localsReference) {
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1437
|
+
return {
|
|
1438
|
+
appIndex: localsReference.appId,
|
|
1439
|
+
address: typeof localsReference.address === "string" ? Address.fromString(localsReference.address) : localsReference.address
|
|
1440
|
+
};
|
|
1505
1441
|
}
|
|
1506
|
-
|
|
1442
|
+
//#endregion
|
|
1507
1443
|
export { MAX_TRANSACTION_GROUP_SIZE, TransactionComposer };
|
|
1508
|
-
|
|
1444
|
+
|
|
1445
|
+
//# sourceMappingURL=composer.mjs.map
|