@algorandfoundation/algokit-utils 9.2.0 → 9.2.1-beta.2
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/app-factory.mjs
CHANGED
|
@@ -1,488 +1,495 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import "./app.mjs";
|
|
2
|
+
import { getABIDecodedValue, getABITupleFromABIStruct, getArc56Method, getArc56ReturnValue } from "./app-arc56.mjs";
|
|
3
|
+
import { AppClient } from "./app-client.mjs";
|
|
4
|
+
import algosdk, { Address } from "algosdk";
|
|
5
|
+
//#region src/types/app-factory.ts
|
|
6
6
|
var SourceMap = algosdk.ProgramSourceMap;
|
|
7
7
|
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
9
|
+
* ARC-56/ARC-32 app factory that, for a given app spec, allows you to create
|
|
10
|
+
* and deploy one or more app instances and to create one or more app clients
|
|
11
|
+
* to interact with those (or other) app instances.
|
|
12
|
+
*/
|
|
13
|
+
var AppFactory = class {
|
|
14
|
+
_appSpec;
|
|
15
|
+
_appName;
|
|
16
|
+
_algorand;
|
|
17
|
+
_version;
|
|
18
|
+
_defaultSender;
|
|
19
|
+
_defaultSigner;
|
|
20
|
+
_deployTimeParams;
|
|
21
|
+
_updatable;
|
|
22
|
+
_deletable;
|
|
23
|
+
_approvalSourceMap;
|
|
24
|
+
_clearSourceMap;
|
|
25
|
+
_paramsMethods;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new app factory.
|
|
28
|
+
* @param params The parameters to create the app factory
|
|
29
|
+
* @returns The `AppFactory` instance
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const appFactory = new AppFactory({
|
|
33
|
+
* appSpec: appSpec,
|
|
34
|
+
* algorand: AlgorandClient.mainNet(),
|
|
35
|
+
* })
|
|
36
|
+
*/
|
|
37
|
+
constructor(params) {
|
|
38
|
+
this._appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
39
|
+
this._appName = params.appName ?? this._appSpec.name;
|
|
40
|
+
this._algorand = params.algorand;
|
|
41
|
+
this._version = params.version ?? "1.0";
|
|
42
|
+
this._defaultSender = typeof params.defaultSender === "string" ? Address.fromString(params.defaultSender) : params.defaultSender;
|
|
43
|
+
this._defaultSigner = params.defaultSigner;
|
|
44
|
+
this._deployTimeParams = params.deployTimeParams;
|
|
45
|
+
this._updatable = params.updatable;
|
|
46
|
+
this._deletable = params.deletable;
|
|
47
|
+
this._paramsMethods = this.getParamsMethods();
|
|
48
|
+
}
|
|
49
|
+
/** The name of the app (from the ARC-32 / ARC-56 app spec or override). */
|
|
50
|
+
get appName() {
|
|
51
|
+
return this._appName;
|
|
52
|
+
}
|
|
53
|
+
/** The ARC-56 app spec being used */
|
|
54
|
+
get appSpec() {
|
|
55
|
+
return this._appSpec;
|
|
56
|
+
}
|
|
57
|
+
/** Return the algorand client this factory is using. */
|
|
58
|
+
get algorand() {
|
|
59
|
+
return this._algorand;
|
|
60
|
+
}
|
|
61
|
+
/** Get parameters to create transactions (create and deploy related calls) for the current app.
|
|
62
|
+
*
|
|
63
|
+
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
64
|
+
* @example Create a transaction in the future using Algorand Client
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})
|
|
67
|
+
* // ...
|
|
68
|
+
* await algorand.send.AppCreateMethodCall(createAppParams)
|
|
69
|
+
* ```
|
|
70
|
+
* @example Define a nested transaction as an ABI argument
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const createAppParams = appFactory.params.create({method: 'create_method', args: [123, 'hello']})
|
|
73
|
+
* await appClient.send.call({method: 'my_method', args: [createAppParams]})
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
get params() {
|
|
77
|
+
return this._paramsMethods;
|
|
78
|
+
}
|
|
79
|
+
/** Create transactions for the current app */
|
|
80
|
+
createTransaction = {
|
|
81
|
+
/** Create bare (raw) transactions for the current app */
|
|
82
|
+
bare: {
|
|
83
|
+
/**
|
|
84
|
+
* Create a create app call transaction using a bare (raw) create call.
|
|
85
|
+
*
|
|
86
|
+
* Performs deploy-time TEAL template placeholder substitutions (if specified).
|
|
87
|
+
* @param params The parameters to create the create call transaction
|
|
88
|
+
* @returns The create call transaction
|
|
89
|
+
*/
|
|
90
|
+
create: async (params) => {
|
|
91
|
+
return this._algorand.createTransaction.appCreate(await this.params.bare.create(params));
|
|
92
|
+
} },
|
|
93
|
+
/**
|
|
94
|
+
* Create a create app call transaction using an ABI create call.
|
|
95
|
+
*
|
|
96
|
+
* Performs deploy-time TEAL template placeholder substitutions (if specified).
|
|
97
|
+
* @param params The parameters to create the create call transaction
|
|
98
|
+
* @returns The create call transaction
|
|
99
|
+
*/
|
|
100
|
+
create: async (params) => {
|
|
101
|
+
return this._algorand.createTransaction.appCreateMethodCall(await this.params.create(params));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** Send transactions to the current app */
|
|
105
|
+
send = {
|
|
106
|
+
/** Send bare (raw) transactions for the current app */
|
|
107
|
+
bare: {
|
|
108
|
+
/**
|
|
109
|
+
* Creates an instance of the app using a bare (raw) create call and returns the result
|
|
110
|
+
* of the creation transaction and an app client to interact with that app instance.
|
|
111
|
+
*
|
|
112
|
+
* Performs deploy-time TEAL template placeholder substitutions (if specified).
|
|
113
|
+
* @param params The parameters to create the app
|
|
114
|
+
* @returns The app client and the result of the creation transaction
|
|
115
|
+
*/
|
|
116
|
+
create: async (params) => {
|
|
117
|
+
const updatable = params?.updatable ?? this._updatable;
|
|
118
|
+
const deletable = params?.deletable ?? this._deletable;
|
|
119
|
+
const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams;
|
|
120
|
+
const compiled = await this.compile({
|
|
121
|
+
deployTimeParams,
|
|
122
|
+
updatable,
|
|
123
|
+
deletable
|
|
124
|
+
});
|
|
125
|
+
const result = await this.handleCallErrors(async () => ({
|
|
126
|
+
...await this._algorand.send.appCreate(await this.params.bare.create({
|
|
127
|
+
...params,
|
|
128
|
+
updatable,
|
|
129
|
+
deletable,
|
|
130
|
+
deployTimeParams
|
|
131
|
+
})),
|
|
132
|
+
return: void 0
|
|
133
|
+
}));
|
|
134
|
+
return {
|
|
135
|
+
appClient: this.getAppClientById({ appId: result.appId }),
|
|
136
|
+
result: {
|
|
137
|
+
...result,
|
|
138
|
+
...compiled
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
} },
|
|
142
|
+
/**
|
|
143
|
+
* Creates an instance of the app and returns the result of the creation
|
|
144
|
+
* transaction and an app client to interact with that app instance.
|
|
145
|
+
*
|
|
146
|
+
* Performs deploy-time TEAL template placeholder substitutions (if specified).
|
|
147
|
+
* @param params The parameters to create the app
|
|
148
|
+
* @returns The app client and the result of the creation transaction
|
|
149
|
+
*/
|
|
150
|
+
create: async (params) => {
|
|
151
|
+
const updatable = params?.updatable ?? this._updatable;
|
|
152
|
+
const deletable = params?.deletable ?? this._deletable;
|
|
153
|
+
const deployTimeParams = params?.deployTimeParams ?? this._deployTimeParams;
|
|
154
|
+
const compiled = await this.compile({
|
|
155
|
+
deployTimeParams,
|
|
156
|
+
updatable,
|
|
157
|
+
deletable
|
|
158
|
+
});
|
|
159
|
+
const result = await this.handleCallErrors(async () => this.parseMethodCallReturn(this._algorand.send.appCreateMethodCall(await this.params.create({
|
|
160
|
+
...params,
|
|
161
|
+
updatable,
|
|
162
|
+
deletable,
|
|
163
|
+
deployTimeParams
|
|
164
|
+
})), getArc56Method(params.method, this._appSpec)));
|
|
165
|
+
return {
|
|
166
|
+
appClient: this.getAppClientById({ appId: result.appId }),
|
|
167
|
+
result: {
|
|
168
|
+
...result,
|
|
169
|
+
...compiled
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Idempotently deploy (create if not exists, update if changed) an app against the given name for the given creator account, including deploy-time TEAL template placeholder substitutions (if specified).
|
|
176
|
+
*
|
|
177
|
+
* **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.
|
|
178
|
+
*
|
|
179
|
+
* **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.
|
|
180
|
+
*
|
|
181
|
+
* **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.
|
|
182
|
+
* @param params The arguments to control the app deployment
|
|
183
|
+
* @returns The app client and the result of the deployment
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const { appClient, result } = await factory.deploy({
|
|
187
|
+
* createParams: {
|
|
188
|
+
* sender: 'SENDER_ADDRESS',
|
|
189
|
+
* approvalProgram: 'APPROVAL PROGRAM',
|
|
190
|
+
* clearStateProgram: 'CLEAR PROGRAM',
|
|
191
|
+
* schema: {
|
|
192
|
+
* globalByteSlices: 0,
|
|
193
|
+
* globalInts: 0,
|
|
194
|
+
* localByteSlices: 0,
|
|
195
|
+
* localInts: 0
|
|
196
|
+
* }
|
|
197
|
+
* },
|
|
198
|
+
* updateParams: {
|
|
199
|
+
* sender: 'SENDER_ADDRESS'
|
|
200
|
+
* },
|
|
201
|
+
* deleteParams: {
|
|
202
|
+
* sender: 'SENDER_ADDRESS'
|
|
203
|
+
* },
|
|
204
|
+
* metadata: { name: 'my_app', version: '2.0', updatable: false, deletable: false },
|
|
205
|
+
* onSchemaBreak: 'append',
|
|
206
|
+
* onUpdate: 'append'
|
|
207
|
+
* })
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
async deploy(params) {
|
|
211
|
+
const updatable = params.updatable ?? this._updatable ?? this.getDeployTimeControl("updatable");
|
|
212
|
+
const deletable = params.deletable ?? this._deletable ?? this.getDeployTimeControl("deletable");
|
|
213
|
+
const deployTimeParams = params.deployTimeParams ?? this._deployTimeParams;
|
|
214
|
+
const compiled = await this.getAppClientById({ appId: 0n }).compile({
|
|
215
|
+
deployTimeParams,
|
|
216
|
+
updatable,
|
|
217
|
+
deletable
|
|
218
|
+
});
|
|
219
|
+
const deployResult = await this._algorand.appDeployer.deploy({
|
|
220
|
+
...params,
|
|
221
|
+
createParams: await (params.createParams && "method" in params.createParams ? this.params.create({
|
|
222
|
+
...params.createParams,
|
|
223
|
+
updatable,
|
|
224
|
+
deletable,
|
|
225
|
+
deployTimeParams
|
|
226
|
+
}) : this.params.bare.create({
|
|
227
|
+
...params.createParams,
|
|
228
|
+
updatable,
|
|
229
|
+
deletable,
|
|
230
|
+
deployTimeParams
|
|
231
|
+
})),
|
|
232
|
+
updateParams: params.updateParams && "method" in params.updateParams ? this.params.deployUpdate(params.updateParams) : this.params.bare.deployUpdate(params.updateParams),
|
|
233
|
+
deleteParams: params.deleteParams && "method" in params.deleteParams ? this.params.deployDelete(params.deleteParams) : this.params.bare.deployDelete(params.deleteParams),
|
|
234
|
+
metadata: {
|
|
235
|
+
name: params.appName ?? this._appName,
|
|
236
|
+
version: this._version,
|
|
237
|
+
updatable,
|
|
238
|
+
deletable
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
const appClient = this.getAppClientById({
|
|
242
|
+
appId: deployResult.appId,
|
|
243
|
+
appName: params.appName
|
|
244
|
+
});
|
|
245
|
+
const result = {
|
|
246
|
+
...deployResult,
|
|
247
|
+
...compiled
|
|
248
|
+
};
|
|
249
|
+
return {
|
|
250
|
+
appClient,
|
|
251
|
+
result: {
|
|
252
|
+
...result,
|
|
253
|
+
return: "return" in result ? result.operationPerformed === "update" ? params.updateParams && "method" in params.updateParams ? getArc56ReturnValue(result.return, getArc56Method(params.updateParams.method, this._appSpec), this._appSpec.structs) : void 0 : params.createParams && "method" in params.createParams ? getArc56ReturnValue(result.return, getArc56Method(params.createParams.method, this._appSpec), this._appSpec.structs) : void 0 : void 0,
|
|
254
|
+
deleteReturn: "deleteReturn" in result && params.deleteParams && "method" in params.deleteParams ? getArc56ReturnValue(result.deleteReturn, getArc56Method(params.deleteParams.method, this._appSpec), this._appSpec.structs) : void 0
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Returns a new `AppClient` client for an app instance of the given ID.
|
|
260
|
+
*
|
|
261
|
+
* Automatically populates appName, defaultSender and source maps from the factory
|
|
262
|
+
* if not specified in the params.
|
|
263
|
+
* @param params The parameters to create the app client
|
|
264
|
+
* @returns The `AppClient` instance
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const appClient = factory.getAppClientById({ appId: 12345n })
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
getAppClientById(params) {
|
|
271
|
+
return new AppClient({
|
|
272
|
+
...params,
|
|
273
|
+
algorand: this._algorand,
|
|
274
|
+
appSpec: this._appSpec,
|
|
275
|
+
appName: params.appName ?? this._appName,
|
|
276
|
+
defaultSender: params.defaultSender ?? this._defaultSender,
|
|
277
|
+
defaultSigner: params.defaultSigner ?? this._defaultSigner,
|
|
278
|
+
approvalSourceMap: params.approvalSourceMap ?? this._approvalSourceMap,
|
|
279
|
+
clearSourceMap: params.clearSourceMap ?? this._clearSourceMap
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Returns a new `AppClient` client, resolving the app by creator address and name
|
|
284
|
+
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
285
|
+
*
|
|
286
|
+
* Automatically populates appName, defaultSender and source maps from the factory
|
|
287
|
+
* if not specified in the params.
|
|
288
|
+
* @param params The parameters to create the app client
|
|
289
|
+
* @returns The `AppClient` instance
|
|
290
|
+
* @example
|
|
291
|
+
* ```typescript
|
|
292
|
+
* const appClient = factory.getAppClientByCreatorAndName({ creatorAddress: 'CREATOR_ADDRESS', appName: 'my_app' })
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
getAppClientByCreatorAndName(params) {
|
|
296
|
+
return AppClient.fromCreatorAndName({
|
|
297
|
+
...params,
|
|
298
|
+
algorand: this._algorand,
|
|
299
|
+
appSpec: this._appSpec,
|
|
300
|
+
appName: params.appName ?? this._appName,
|
|
301
|
+
defaultSender: params.defaultSender ?? this._defaultSender,
|
|
302
|
+
approvalSourceMap: params.approvalSourceMap ?? this._approvalSourceMap,
|
|
303
|
+
clearSourceMap: params.clearSourceMap ?? this._clearSourceMap
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
308
|
+
* error to include source code information via the source map and ARC-56 spec.
|
|
309
|
+
* @param e The error to parse
|
|
310
|
+
* @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)
|
|
311
|
+
* @returns The new error, or if there was no logic error or source map then the wrapped error with source details
|
|
312
|
+
*/
|
|
313
|
+
exposeLogicError(e, isClearStateProgram) {
|
|
314
|
+
return AppClient.exposeLogicError(e, this._appSpec, {
|
|
315
|
+
isClearStateProgram,
|
|
316
|
+
approvalSourceMap: this._approvalSourceMap,
|
|
317
|
+
clearSourceMap: this._clearSourceMap
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Export the current source maps for the app.
|
|
322
|
+
* @returns The source maps
|
|
323
|
+
*/
|
|
324
|
+
exportSourceMaps() {
|
|
325
|
+
if (!this._approvalSourceMap || !this._clearSourceMap) throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");
|
|
326
|
+
return {
|
|
327
|
+
approvalSourceMap: this._approvalSourceMap,
|
|
328
|
+
clearSourceMap: this._clearSourceMap
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Import source maps for the app.
|
|
333
|
+
* @param sourceMaps The source maps to import
|
|
334
|
+
*/
|
|
335
|
+
importSourceMaps(sourceMaps) {
|
|
336
|
+
this._approvalSourceMap = new SourceMap(sourceMaps.approvalSourceMap);
|
|
337
|
+
this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
|
|
338
|
+
}
|
|
339
|
+
getDeployTimeControl(control) {
|
|
340
|
+
const approval = this._appSpec.source?.approval ? Buffer.from(this._appSpec.source.approval, "base64").toString("utf-8") : void 0;
|
|
341
|
+
if (!approval || !approval.includes(control === "updatable" ? "TMPL_UPDATABLE" : "TMPL_DELETABLE")) return void 0;
|
|
342
|
+
return this._appSpec.bareActions.call.includes(control === "updatable" ? "UpdateApplication" : "DeleteApplication") || Object.values(this._appSpec.methods).some((c) => c.actions.call.includes(control === "updatable" ? "UpdateApplication" : "DeleteApplication"));
|
|
343
|
+
}
|
|
344
|
+
getParamsMethods() {
|
|
345
|
+
return {
|
|
346
|
+
/** Return params for a create ABI call, including deploy-time TEAL template replacements and compilation if provided */
|
|
347
|
+
create: async (params) => {
|
|
348
|
+
const compiled = await this.compile({
|
|
349
|
+
...params,
|
|
350
|
+
deployTimeParams: params.deployTimeParams ?? this._deployTimeParams
|
|
351
|
+
});
|
|
352
|
+
return this.getABIParams({
|
|
353
|
+
...params,
|
|
354
|
+
deployTimeParams: params.deployTimeParams ?? this._deployTimeParams,
|
|
355
|
+
schema: params.schema ?? {
|
|
356
|
+
globalByteSlices: this._appSpec.state.schema.global.bytes,
|
|
357
|
+
globalInts: this._appSpec.state.schema.global.ints,
|
|
358
|
+
localByteSlices: this._appSpec.state.schema.local.bytes,
|
|
359
|
+
localInts: this._appSpec.state.schema.local.ints
|
|
360
|
+
},
|
|
361
|
+
approvalProgram: compiled.approvalProgram,
|
|
362
|
+
clearStateProgram: compiled.clearStateProgram
|
|
363
|
+
}, params.onComplete ?? OnApplicationComplete.NoOpOC);
|
|
364
|
+
},
|
|
365
|
+
/** Return params for a deployment update ABI call */
|
|
366
|
+
deployUpdate: (params) => {
|
|
367
|
+
return this.getABIParams(params, OnApplicationComplete.UpdateApplicationOC);
|
|
368
|
+
},
|
|
369
|
+
/** Return params for a deployment delete ABI call */
|
|
370
|
+
deployDelete: (params) => {
|
|
371
|
+
return this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC);
|
|
372
|
+
},
|
|
373
|
+
bare: {
|
|
374
|
+
/** Return params for a create bare call, including deploy-time TEAL template replacements and compilation if provided */
|
|
375
|
+
create: async (params) => {
|
|
376
|
+
return this.getBareParams({
|
|
377
|
+
...params,
|
|
378
|
+
deployTimeParams: params?.deployTimeParams ?? this._deployTimeParams,
|
|
379
|
+
schema: params?.schema ?? {
|
|
380
|
+
globalByteSlices: this._appSpec.state.schema.global.bytes,
|
|
381
|
+
globalInts: this._appSpec.state.schema.global.ints,
|
|
382
|
+
localByteSlices: this._appSpec.state.schema.local.bytes,
|
|
383
|
+
localInts: this._appSpec.state.schema.local.ints
|
|
384
|
+
},
|
|
385
|
+
...await this.compile({
|
|
386
|
+
...params,
|
|
387
|
+
deployTimeParams: params?.deployTimeParams ?? this._deployTimeParams
|
|
388
|
+
})
|
|
389
|
+
}, params?.onComplete ?? OnApplicationComplete.NoOpOC);
|
|
390
|
+
},
|
|
391
|
+
/** Return params for a deployment update bare call */
|
|
392
|
+
deployUpdate: (params) => {
|
|
393
|
+
return this.getBareParams(params, OnApplicationComplete.UpdateApplicationOC);
|
|
394
|
+
},
|
|
395
|
+
/** Return params for a deployment delete bare call */
|
|
396
|
+
deployDelete: (params) => {
|
|
397
|
+
return this.getBareParams(params, OnApplicationComplete.DeleteApplicationOC);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
/** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */
|
|
403
|
+
async handleCallErrors(call) {
|
|
404
|
+
try {
|
|
405
|
+
return await call();
|
|
406
|
+
} catch (e) {
|
|
407
|
+
throw this.exposeLogicError(e);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
412
|
+
* performing any provided deploy-time parameter replacement and stores
|
|
413
|
+
* the source maps.
|
|
414
|
+
*
|
|
415
|
+
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
416
|
+
*
|
|
417
|
+
* Will store any generated source maps for later use in debugging.
|
|
418
|
+
* @param compilation Optional compilation parameters to use for the compilation
|
|
419
|
+
* @returns The compilation result
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const result = await factory.compile()
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
async compile(compilation) {
|
|
426
|
+
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
427
|
+
if (result.compiledApproval) this._approvalSourceMap = result.compiledApproval.sourceMap;
|
|
428
|
+
if (result.compiledClear) this._clearSourceMap = result.compiledClear.sourceMap;
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
431
|
+
getBareParams(params, onComplete) {
|
|
432
|
+
return {
|
|
433
|
+
...params,
|
|
434
|
+
sender: this.getSender(params?.sender),
|
|
435
|
+
signer: this.getSigner(params?.sender, params?.signer),
|
|
436
|
+
onComplete
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
getABIParams(params, onComplete) {
|
|
440
|
+
return {
|
|
441
|
+
...params,
|
|
442
|
+
sender: this.getSender(params.sender),
|
|
443
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
444
|
+
method: getArc56Method(params.method, this._appSpec),
|
|
445
|
+
args: this.getCreateABIArgsWithDefaultValues(params.method, params.args),
|
|
446
|
+
onComplete
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
getCreateABIArgsWithDefaultValues(methodNameOrSignature, args) {
|
|
450
|
+
const m = getArc56Method(methodNameOrSignature, this._appSpec);
|
|
451
|
+
return args?.map((a, i) => {
|
|
452
|
+
const arg = m.args[i];
|
|
453
|
+
if (a !== void 0) return arg.struct && typeof a === "object" && !Array.isArray(a) ? getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs) : a;
|
|
454
|
+
const defaultValue = arg.defaultValue;
|
|
455
|
+
if (defaultValue) switch (defaultValue.source) {
|
|
456
|
+
case "literal": return getABIDecodedValue(Buffer.from(defaultValue.data, "base64"), m.method.args[i].type, this._appSpec.structs);
|
|
457
|
+
default: throw new Error(`Can't provide default value for ${defaultValue.source} for a contract creation call`);
|
|
458
|
+
}
|
|
459
|
+
throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
/** Returns the sender for a call, using the `defaultSender`
|
|
463
|
+
* if none provided and throws an error if neither provided */
|
|
464
|
+
getSender(sender) {
|
|
465
|
+
if (!sender && !this._defaultSender) throw new Error(`No sender provided and no default sender present in app factory for call to app ${this._appName}`);
|
|
466
|
+
return typeof sender === "string" ? Address.fromString(sender) : sender ?? this._defaultSender;
|
|
467
|
+
}
|
|
468
|
+
/** Returns the signer for a call, using the provided signer or the `defaultSigner`
|
|
469
|
+
* if no signer was provided and the sender resolves to the default sender, the call will use default signer
|
|
470
|
+
* or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */
|
|
471
|
+
getSigner(sender, signer) {
|
|
472
|
+
return signer ?? (!sender || sender === this._defaultSender ? this._defaultSigner : void 0);
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
|
|
476
|
+
* on the ARC-56 method.
|
|
477
|
+
*
|
|
478
|
+
* If the return type is a struct then the struct will be returned.
|
|
479
|
+
*
|
|
480
|
+
* @param result The SendAppTransactionResult to be mapped
|
|
481
|
+
* @param method The method that was called
|
|
482
|
+
* @returns The smart contract response with an updated return value
|
|
483
|
+
*/
|
|
484
|
+
async parseMethodCallReturn(result, method) {
|
|
485
|
+
const resultValue = await result;
|
|
486
|
+
return {
|
|
487
|
+
...resultValue,
|
|
488
|
+
return: getArc56ReturnValue(resultValue.return, method, this._appSpec.structs)
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
//#endregion
|
|
487
493
|
export { AppFactory };
|
|
488
|
-
|
|
494
|
+
|
|
495
|
+
//# sourceMappingURL=app-factory.mjs.map
|