@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-deployer.mjs
CHANGED
|
@@ -1,384 +1,343 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { Config } from "../config.mjs";
|
|
2
|
+
import { APP_DEPLOY_NOTE_DAPP } from "./app.mjs";
|
|
3
|
+
import { calculateExtraProgramPages } from "../util.mjs";
|
|
4
|
+
import { TransactionComposer } from "./composer.mjs";
|
|
5
|
+
import { lookupAccountCreatedApplicationByAddress, searchTransactions } from "../indexer-lookup.mjs";
|
|
6
|
+
import algosdk, { Address } from "algosdk";
|
|
7
|
+
//#region src/types/app-deployer.ts
|
|
8
8
|
/** Allows management of deployment and deployment metadata of applications. */
|
|
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
|
-
.filter((a) => a !== null)
|
|
342
|
-
.forEach((a) => {
|
|
343
|
-
const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a;
|
|
344
|
-
const parseNote = (note) => {
|
|
345
|
-
if (!note) {
|
|
346
|
-
// No note; ignoring...
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
if (!note.startsWith(`${APP_DEPLOY_NOTE_DAPP}:j{`))
|
|
350
|
-
// Clearly not APP_DEPLOY JSON; ignoring...
|
|
351
|
-
return;
|
|
352
|
-
return JSON.parse(note.substring(APP_DEPLOY_NOTE_DAPP.length + 2));
|
|
353
|
-
};
|
|
354
|
-
try {
|
|
355
|
-
const creationNote = parseNote(appCreationTransaction.note ? Buffer.from(appCreationTransaction.note).toString('utf-8') : undefined);
|
|
356
|
-
const updateNote = parseNote(latestAppUpdateTransaction.note ? Buffer.from(latestAppUpdateTransaction.note).toString('utf-8') : undefined);
|
|
357
|
-
if (creationNote?.name) {
|
|
358
|
-
appLookup[creationNote.name] = {
|
|
359
|
-
appId: createdApp.id,
|
|
360
|
-
appAddress: algosdk.getApplicationAddress(createdApp.id),
|
|
361
|
-
createdMetadata: creationNote,
|
|
362
|
-
createdRound: appCreationTransaction.confirmedRound ?? 0n,
|
|
363
|
-
...(updateNote ?? creationNote),
|
|
364
|
-
updatedRound: latestAppUpdateTransaction?.confirmedRound ?? 0n,
|
|
365
|
-
deleted: createdApp.deleted ?? false,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
catch (e) {
|
|
370
|
-
Config.logger.warn(`Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`, e);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
const lookup = {
|
|
375
|
-
creator: typeof creatorAddress === 'string' ? Address.fromString(creatorAddress) : creatorAddress,
|
|
376
|
-
apps: appLookup,
|
|
377
|
-
};
|
|
378
|
-
this._appLookups.set(creatorAddress.toString(), lookup);
|
|
379
|
-
return lookup;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
9
|
+
var AppDeployer = class {
|
|
10
|
+
_appManager;
|
|
11
|
+
_transactionSender;
|
|
12
|
+
_indexer;
|
|
13
|
+
_appLookups = /* @__PURE__ */ new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Creates an `AppManager`
|
|
16
|
+
* @param appManager An `AppManager` instance
|
|
17
|
+
* @param transactionSender An `AlgorandClientTransactionSender` instance
|
|
18
|
+
* @param indexer An optional indexer instance; supply if you want to indexer to look up app metadata
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const deployer = new AppDeployer(appManager, transactionSender, indexer)
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
constructor(appManager, transactionSender, indexer) {
|
|
25
|
+
this._appManager = appManager;
|
|
26
|
+
this._transactionSender = transactionSender;
|
|
27
|
+
this._indexer = indexer;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 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).
|
|
31
|
+
*
|
|
32
|
+
* To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/src/content/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
|
|
33
|
+
*
|
|
34
|
+
* **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`.
|
|
35
|
+
*
|
|
36
|
+
* **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.
|
|
37
|
+
*
|
|
38
|
+
* **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.
|
|
39
|
+
* @param deployment The arguments to control the app deployment
|
|
40
|
+
* @returns The result of the deployment
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const deployResult = await deployer.deploy({
|
|
44
|
+
* createParams: {
|
|
45
|
+
* sender: 'SENDER_ADDRESS',
|
|
46
|
+
* approvalProgram: 'APPROVAL PROGRAM',
|
|
47
|
+
* clearStateProgram: 'CLEAR PROGRAM',
|
|
48
|
+
* schema: {
|
|
49
|
+
* globalByteSlices: 0,
|
|
50
|
+
* globalInts: 0,
|
|
51
|
+
* localByteSlices: 0,
|
|
52
|
+
* localInts: 0
|
|
53
|
+
* }
|
|
54
|
+
* },
|
|
55
|
+
* updateParams: {
|
|
56
|
+
* sender: 'SENDER_ADDRESS'
|
|
57
|
+
* },
|
|
58
|
+
* deleteParams: {
|
|
59
|
+
* sender: 'SENDER_ADDRESS'
|
|
60
|
+
* },
|
|
61
|
+
* metadata: { name: 'my_app', version: '2.0', updatable: false, deletable: false },
|
|
62
|
+
* onSchemaBreak: 'append',
|
|
63
|
+
* onUpdate: 'append'
|
|
64
|
+
* })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
async deploy(deployment) {
|
|
68
|
+
const { metadata, deployTimeParams, onSchemaBreak, onUpdate, createParams, updateParams, deleteParams, existingDeployments, ignoreCache, ...sendParams } = deployment;
|
|
69
|
+
createParams.note = updateParams.note = TransactionComposer.arc2Note({
|
|
70
|
+
dAppName: APP_DEPLOY_NOTE_DAPP,
|
|
71
|
+
data: metadata,
|
|
72
|
+
format: "j"
|
|
73
|
+
});
|
|
74
|
+
if (existingDeployments && existingDeployments.creator.toString() !== createParams.sender.toString()) throw new Error(`Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${createParams.sender}`);
|
|
75
|
+
if (!existingDeployments && !this._indexer) throw new Error(`Didn't receive an indexer client when this AppManager was created, but also didn't receive an existingDeployments cache - one of them must be provided`);
|
|
76
|
+
Config.getLogger(sendParams?.suppressLog).info(`Idempotently deploying app "${metadata.name}" from creator ${createParams.sender} using ${createParams.approvalProgram.length} bytes of ${typeof createParams.approvalProgram === "string" ? "teal code" : "AVM bytecode"} and ${createParams.clearStateProgram.length} bytes of ${typeof createParams.approvalProgram === "string" ? "teal code" : "AVM bytecode"}`);
|
|
77
|
+
const compiledApproval = typeof createParams.approvalProgram === "string" ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata) : void 0;
|
|
78
|
+
const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : createParams.approvalProgram;
|
|
79
|
+
const compiledClear = typeof createParams.clearStateProgram === "string" ? await this._appManager.compileTealTemplate(createParams.clearStateProgram, deployTimeParams) : void 0;
|
|
80
|
+
const clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : createParams.clearStateProgram;
|
|
81
|
+
const createApp = async () => {
|
|
82
|
+
const result = await ("method" in createParams ? this._transactionSender.appCreateMethodCall({
|
|
83
|
+
...createParams,
|
|
84
|
+
approvalProgram,
|
|
85
|
+
clearStateProgram,
|
|
86
|
+
...sendParams
|
|
87
|
+
}) : this._transactionSender.appCreate({
|
|
88
|
+
...createParams,
|
|
89
|
+
approvalProgram,
|
|
90
|
+
clearStateProgram,
|
|
91
|
+
...sendParams
|
|
92
|
+
}));
|
|
93
|
+
const appMetadata = {
|
|
94
|
+
appId: result.appId,
|
|
95
|
+
appAddress: result.appAddress,
|
|
96
|
+
...metadata,
|
|
97
|
+
createdMetadata: metadata,
|
|
98
|
+
createdRound: BigInt(result.confirmation.confirmedRound),
|
|
99
|
+
updatedRound: BigInt(result.confirmation.confirmedRound),
|
|
100
|
+
deleted: false
|
|
101
|
+
};
|
|
102
|
+
this.updateAppLookup(createParams.sender, appMetadata);
|
|
103
|
+
return {
|
|
104
|
+
operationPerformed: "create",
|
|
105
|
+
compiledApproval,
|
|
106
|
+
compiledClear,
|
|
107
|
+
...result,
|
|
108
|
+
...appMetadata
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const updateApp = async (existingApp) => {
|
|
112
|
+
Config.getLogger(sendParams?.suppressLog).info(`Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`);
|
|
113
|
+
const result = await ("method" in updateParams ? this._transactionSender.appUpdateMethodCall({
|
|
114
|
+
appId: existingApp.appId,
|
|
115
|
+
approvalProgram,
|
|
116
|
+
clearStateProgram,
|
|
117
|
+
...updateParams,
|
|
118
|
+
...sendParams
|
|
119
|
+
}) : this._transactionSender.appUpdate({
|
|
120
|
+
appId: existingApp.appId,
|
|
121
|
+
approvalProgram,
|
|
122
|
+
clearStateProgram,
|
|
123
|
+
...updateParams,
|
|
124
|
+
...sendParams
|
|
125
|
+
}));
|
|
126
|
+
const appMetadata = {
|
|
127
|
+
appId: existingApp.appId,
|
|
128
|
+
appAddress: existingApp.appAddress,
|
|
129
|
+
createdMetadata: existingApp.createdMetadata,
|
|
130
|
+
createdRound: existingApp.createdRound,
|
|
131
|
+
updatedRound: BigInt(result.confirmation.confirmedRound),
|
|
132
|
+
...metadata,
|
|
133
|
+
deleted: false
|
|
134
|
+
};
|
|
135
|
+
this.updateAppLookup(createParams.sender, appMetadata);
|
|
136
|
+
return {
|
|
137
|
+
operationPerformed: "update",
|
|
138
|
+
compiledApproval,
|
|
139
|
+
compiledClear,
|
|
140
|
+
...result,
|
|
141
|
+
...appMetadata
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
const replaceApp = async (existingApp) => {
|
|
145
|
+
Config.getLogger(sendParams?.suppressLog).info(`Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`);
|
|
146
|
+
Config.getLogger(sendParams?.suppressLog).warn(`Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`);
|
|
147
|
+
const composer = this._transactionSender.newGroup();
|
|
148
|
+
if ("method" in createParams) composer.addAppCreateMethodCall({
|
|
149
|
+
...createParams,
|
|
150
|
+
approvalProgram,
|
|
151
|
+
clearStateProgram
|
|
152
|
+
});
|
|
153
|
+
else composer.addAppCreate({
|
|
154
|
+
...createParams,
|
|
155
|
+
approvalProgram,
|
|
156
|
+
clearStateProgram
|
|
157
|
+
});
|
|
158
|
+
const createIndex = await composer.count();
|
|
159
|
+
if ("method" in deleteParams) composer.addAppDeleteMethodCall({
|
|
160
|
+
appId: existingApp.appId,
|
|
161
|
+
...deleteParams
|
|
162
|
+
});
|
|
163
|
+
else composer.addAppDelete({
|
|
164
|
+
appId: existingApp.appId,
|
|
165
|
+
...deleteParams
|
|
166
|
+
});
|
|
167
|
+
const result = await composer.send({ ...sendParams });
|
|
168
|
+
const confirmation = result.confirmations.at(createIndex - 1);
|
|
169
|
+
const transaction = result.transactions.at(createIndex - 1);
|
|
170
|
+
const deleteTransaction = result.transactions.at(-1);
|
|
171
|
+
Config.getLogger(sendParams?.suppressLog).warn(`Sent transactions ${transaction.txID()} to create app with id ${confirmation.applicationIndex} and ${deleteTransaction.txID()} to delete app with id ${existingApp.appId} from ${createParams.sender} account.`);
|
|
172
|
+
const appMetadata = {
|
|
173
|
+
appId: BigInt(confirmation.applicationIndex),
|
|
174
|
+
appAddress: algosdk.getApplicationAddress(confirmation.applicationIndex),
|
|
175
|
+
...metadata,
|
|
176
|
+
createdMetadata: metadata,
|
|
177
|
+
createdRound: BigInt(confirmation.confirmedRound),
|
|
178
|
+
updatedRound: BigInt(confirmation.confirmedRound),
|
|
179
|
+
deleted: false
|
|
180
|
+
};
|
|
181
|
+
this.updateAppLookup(createParams.sender, appMetadata);
|
|
182
|
+
return {
|
|
183
|
+
operationPerformed: "replace",
|
|
184
|
+
...result,
|
|
185
|
+
compiledApproval,
|
|
186
|
+
compiledClear,
|
|
187
|
+
transaction,
|
|
188
|
+
confirmation,
|
|
189
|
+
return: "method" in createParams ? result.returns?.[0] : void 0,
|
|
190
|
+
deleteReturn: "method" in deleteParams ? result.returns?.at(-1) : void 0,
|
|
191
|
+
...appMetadata,
|
|
192
|
+
deleteResult: {
|
|
193
|
+
transaction: deleteTransaction,
|
|
194
|
+
confirmation: result.confirmations.at(-1)
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
const existingApp = (existingDeployments ?? await this.getCreatorAppsByName(createParams.sender, ignoreCache)).apps[metadata.name];
|
|
199
|
+
if (!existingApp || existingApp.deleted) {
|
|
200
|
+
Config.getLogger(sendParams?.suppressLog).info(`App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`);
|
|
201
|
+
return await createApp();
|
|
202
|
+
}
|
|
203
|
+
Config.getLogger(sendParams?.suppressLog).info(`Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
|
|
204
|
+
const existingAppRecord = await this._appManager.getById(existingApp.appId);
|
|
205
|
+
const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString("base64");
|
|
206
|
+
const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString("base64");
|
|
207
|
+
const extraPages = existingAppRecord.extraProgramPages ?? 0;
|
|
208
|
+
const newApprovalBytes = Buffer.from(approvalProgram);
|
|
209
|
+
const newClearBytes = Buffer.from(clearStateProgram);
|
|
210
|
+
const newApproval = newApprovalBytes.toString("base64");
|
|
211
|
+
const newClear = newClearBytes.toString("base64");
|
|
212
|
+
const newExtraPages = calculateExtraProgramPages(newApprovalBytes, newClearBytes);
|
|
213
|
+
const isUpdate = newApproval !== existingApproval || newClear !== existingClear;
|
|
214
|
+
if (existingAppRecord.localInts < (createParams.schema?.localInts ?? 0) || existingAppRecord.globalInts < (createParams.schema?.globalInts ?? 0) || existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) || existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0) || extraPages < newExtraPages) {
|
|
215
|
+
Config.getLogger(sendParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {
|
|
216
|
+
from: {
|
|
217
|
+
globalInts: existingAppRecord.globalInts,
|
|
218
|
+
globalByteSlices: existingAppRecord.globalByteSlices,
|
|
219
|
+
localInts: existingAppRecord.localInts,
|
|
220
|
+
localByteSlices: existingAppRecord.localByteSlices,
|
|
221
|
+
extraProgramPages: extraPages
|
|
222
|
+
},
|
|
223
|
+
to: {
|
|
224
|
+
...createParams.schema,
|
|
225
|
+
extraProgramPages: newExtraPages
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
if (onSchemaBreak === void 0 || onSchemaBreak === "fail" || onSchemaBreak === 0) throw new Error("Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. If you want to try deleting and recreating the app then re-run with onSchemaBreak=OnSchemaBreak.ReplaceApp");
|
|
229
|
+
if (onSchemaBreak === "append" || onSchemaBreak === 2) {
|
|
230
|
+
Config.getLogger(sendParams?.suppressLog).info("onSchemaBreak=AppendApp, will attempt to create a new app");
|
|
231
|
+
return await createApp();
|
|
232
|
+
}
|
|
233
|
+
if (existingApp.deletable) Config.getLogger(sendParams?.suppressLog).info("App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app");
|
|
234
|
+
else Config.getLogger(sendParams?.suppressLog).info("App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail");
|
|
235
|
+
return await replaceApp(existingApp);
|
|
236
|
+
}
|
|
237
|
+
if (isUpdate) {
|
|
238
|
+
Config.getLogger(sendParams?.suppressLog).info(`Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`);
|
|
239
|
+
if (onUpdate === void 0 || onUpdate === "fail" || onUpdate === 0) throw new Error("Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.");
|
|
240
|
+
if (onUpdate === "append" || onUpdate === 3) {
|
|
241
|
+
Config.getLogger(sendParams?.suppressLog).info("onUpdate=AppendApp, will attempt to create a new app");
|
|
242
|
+
return await createApp();
|
|
243
|
+
}
|
|
244
|
+
if (onUpdate === "update" || onUpdate === 1) {
|
|
245
|
+
if (existingApp.updatable) Config.getLogger(sendParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
|
|
246
|
+
else Config.getLogger(sendParams?.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
|
|
247
|
+
return await updateApp(existingApp);
|
|
248
|
+
}
|
|
249
|
+
if (onUpdate === "replace" || onUpdate === 2) {
|
|
250
|
+
if (existingApp.deletable) Config.getLogger(sendParams?.suppressLog).warn("App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...");
|
|
251
|
+
else Config.getLogger(sendParams?.suppressLog).warn("App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail");
|
|
252
|
+
return await replaceApp(existingApp);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
Config.getLogger(sendParams?.suppressLog).debug("No detected changes in app, nothing to do.");
|
|
256
|
+
return {
|
|
257
|
+
...existingApp,
|
|
258
|
+
operationPerformed: "nothing"
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
updateAppLookup(sender, appMetadata) {
|
|
262
|
+
const s = typeof sender === "string" ? sender : sender.toString();
|
|
263
|
+
const lookup = this._appLookups.get(s);
|
|
264
|
+
if (!lookup) this._appLookups.set(s, {
|
|
265
|
+
creator: Address.fromString(s),
|
|
266
|
+
apps: { [appMetadata.name]: appMetadata }
|
|
267
|
+
});
|
|
268
|
+
else lookup.apps[appMetadata.name] = appMetadata;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have
|
|
272
|
+
* an [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) `AppDeployNote` as the transaction
|
|
273
|
+
* note of the app creation transaction.
|
|
274
|
+
*
|
|
275
|
+
* This function caches the result for the given creator account so that subsequent calls will not require an indexer lookup.
|
|
276
|
+
*
|
|
277
|
+
* If the `AppManager` instance wasn't created with an indexer client, this function will throw an error.
|
|
278
|
+
*
|
|
279
|
+
* @param creatorAddress The address of the account that is the creator of the apps you want to search for
|
|
280
|
+
* @param ignoreCache Whether or not to ignore the cache and force a lookup, default: use the cache
|
|
281
|
+
* @returns A name-based lookup of the app metadata
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* const result = await deployer.getCreatorAppsByName(creator)
|
|
285
|
+
*/
|
|
286
|
+
async getCreatorAppsByName(creatorAddress, ignoreCache) {
|
|
287
|
+
const appLookup = {};
|
|
288
|
+
const address = typeof creatorAddress === "string" ? creatorAddress : creatorAddress.toString();
|
|
289
|
+
if (!ignoreCache && this._appLookups.has(address)) return this._appLookups.get(address);
|
|
290
|
+
if (!this._indexer) throw new Error(`Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps`);
|
|
291
|
+
const createdApps = (await lookupAccountCreatedApplicationByAddress(this._indexer, creatorAddress)).map((a) => {
|
|
292
|
+
return {
|
|
293
|
+
id: a.id,
|
|
294
|
+
createdAtRound: a.createdAtRound,
|
|
295
|
+
deleted: a.deleted
|
|
296
|
+
};
|
|
297
|
+
}).sort((a, b) => Number(a.createdAtRound - b.createdAtRound));
|
|
298
|
+
(await Promise.all(createdApps.map(async (createdApp) => {
|
|
299
|
+
const appTransactions = await searchTransactions(this._indexer, (s) => s.minRound(createdApp.createdAtRound).txType(algosdk.TransactionType.appl).applicationID(Number(createdApp.id)).address(creatorAddress).addressRole("sender").notePrefix(Buffer.from(APP_DEPLOY_NOTE_DAPP).toString("base64")));
|
|
300
|
+
const appCreationTransaction = appTransactions.transactions.filter((t) => t.applicationTransaction?.applicationId === 0n && t.sender.toString() === creatorAddress.toString())[0];
|
|
301
|
+
const latestAppUpdateTransaction = appTransactions.transactions.filter((t) => t.sender.toString() === creatorAddress.toString()).sort((a, b) => a.confirmedRound === b.confirmedRound ? (b.intraRoundOffset - a.intraRoundOffset) / 10 : Number(b.confirmedRound - a.confirmedRound))[0];
|
|
302
|
+
if (!appCreationTransaction?.note) return null;
|
|
303
|
+
return {
|
|
304
|
+
createdApp,
|
|
305
|
+
appCreationTransaction,
|
|
306
|
+
latestAppUpdateTransaction
|
|
307
|
+
};
|
|
308
|
+
}))).filter((a) => a !== null).forEach((a) => {
|
|
309
|
+
const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a;
|
|
310
|
+
const parseNote = (note) => {
|
|
311
|
+
if (!note) return;
|
|
312
|
+
if (!note.startsWith(`ALGOKIT_DEPLOYER:j{`)) return;
|
|
313
|
+
return JSON.parse(note.substring(APP_DEPLOY_NOTE_DAPP.length + 2));
|
|
314
|
+
};
|
|
315
|
+
try {
|
|
316
|
+
const creationNote = parseNote(appCreationTransaction.note ? Buffer.from(appCreationTransaction.note).toString("utf-8") : void 0);
|
|
317
|
+
const updateNote = parseNote(latestAppUpdateTransaction.note ? Buffer.from(latestAppUpdateTransaction.note).toString("utf-8") : void 0);
|
|
318
|
+
if (creationNote?.name) appLookup[creationNote.name] = {
|
|
319
|
+
appId: createdApp.id,
|
|
320
|
+
appAddress: algosdk.getApplicationAddress(createdApp.id),
|
|
321
|
+
createdMetadata: creationNote,
|
|
322
|
+
createdRound: appCreationTransaction.confirmedRound ?? 0n,
|
|
323
|
+
...updateNote ?? creationNote,
|
|
324
|
+
updatedRound: latestAppUpdateTransaction?.confirmedRound ?? 0n,
|
|
325
|
+
deleted: createdApp.deleted ?? false
|
|
326
|
+
};
|
|
327
|
+
} catch (e) {
|
|
328
|
+
Config.logger.warn(`Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`, e);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
const lookup = {
|
|
333
|
+
creator: typeof creatorAddress === "string" ? Address.fromString(creatorAddress) : creatorAddress,
|
|
334
|
+
apps: appLookup
|
|
335
|
+
};
|
|
336
|
+
this._appLookups.set(creatorAddress.toString(), lookup);
|
|
337
|
+
return lookup;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
//#endregion
|
|
383
341
|
export { AppDeployer };
|
|
384
|
-
|
|
342
|
+
|
|
343
|
+
//# sourceMappingURL=app-deployer.mjs.map
|