@algorandfoundation/algokit-utils 6.3.0-beta.1 → 7.0.0-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.
Files changed (132) hide show
  1. package/account/account.d.ts +7 -7
  2. package/account/account.js +7 -7
  3. package/account/account.mjs +7 -7
  4. package/account/get-account.d.ts +2 -2
  5. package/account/get-account.js +1 -1
  6. package/account/get-account.mjs +1 -1
  7. package/account/get-dispenser-account.d.ts +1 -1
  8. package/account/get-dispenser-account.js +1 -1
  9. package/account/get-dispenser-account.mjs +1 -1
  10. package/account/mnemonic-account.d.ts +1 -1
  11. package/account/mnemonic-account.js +1 -1
  12. package/account/mnemonic-account.mjs +1 -1
  13. package/app-deploy.d.ts +18 -1
  14. package/app-deploy.d.ts.map +1 -1
  15. package/app-deploy.js +142 -333
  16. package/app-deploy.js.map +1 -1
  17. package/app-deploy.mjs +145 -336
  18. package/app-deploy.mjs.map +1 -1
  19. package/app.d.ts +38 -1
  20. package/app.d.ts.map +1 -1
  21. package/app.js +113 -370
  22. package/app.js.map +1 -1
  23. package/app.mjs +114 -371
  24. package/app.mjs.map +1 -1
  25. package/asset.d.ts +5 -5
  26. package/asset.js +5 -5
  27. package/asset.mjs +5 -5
  28. package/debugging/debugging.js +2 -2
  29. package/debugging/debugging.js.map +1 -1
  30. package/debugging/debugging.mjs +2 -2
  31. package/debugging/debugging.mjs.map +1 -1
  32. package/index.d.ts +1 -1
  33. package/index.d.ts.map +1 -1
  34. package/index.js +12 -12
  35. package/index.mjs +1 -1
  36. package/localnet/get-kmd-wallet-account.d.ts +1 -1
  37. package/localnet/get-kmd-wallet-account.js +1 -1
  38. package/localnet/get-kmd-wallet-account.mjs +1 -1
  39. package/localnet/get-localnet-dispenser-account.d.ts +1 -1
  40. package/localnet/get-localnet-dispenser-account.js +1 -1
  41. package/localnet/get-localnet-dispenser-account.mjs +1 -1
  42. package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -1
  43. package/localnet/get-or-create-kmd-wallet-account.js +1 -1
  44. package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
  45. package/localnet/is-localnet.d.ts +1 -1
  46. package/localnet/is-localnet.js +1 -1
  47. package/localnet/is-localnet.mjs +1 -1
  48. package/network-client.d.ts +2 -2
  49. package/network-client.d.ts.map +1 -1
  50. package/network-client.js +2 -2
  51. package/network-client.mjs +2 -2
  52. package/package.json +1 -1
  53. package/testing/fixtures/algorand-fixture.js +12 -12
  54. package/testing/fixtures/algorand-fixture.js.map +1 -1
  55. package/testing/fixtures/algorand-fixture.mjs +12 -12
  56. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  57. package/transaction/legacy-bridge.d.ts +31 -5
  58. package/transaction/legacy-bridge.d.ts.map +1 -1
  59. package/transaction/legacy-bridge.js +99 -5
  60. package/transaction/legacy-bridge.js.map +1 -1
  61. package/transaction/legacy-bridge.mjs +98 -7
  62. package/transaction/legacy-bridge.mjs.map +1 -1
  63. package/transfer/transfer-algos.d.ts +1 -1
  64. package/transfer/transfer-algos.js +1 -1
  65. package/transfer/transfer-algos.mjs +1 -1
  66. package/transfer/transfer.d.ts +1 -1
  67. package/transfer/transfer.js +1 -1
  68. package/transfer/transfer.mjs +1 -1
  69. package/types/account-manager.d.ts +1 -1
  70. package/types/account-manager.d.ts.map +1 -1
  71. package/types/algorand-client-transaction-creator.d.ts +450 -20
  72. package/types/algorand-client-transaction-creator.d.ts.map +1 -1
  73. package/types/algorand-client-transaction-creator.js +406 -22
  74. package/types/algorand-client-transaction-creator.js.map +1 -1
  75. package/types/algorand-client-transaction-creator.mjs +406 -22
  76. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  77. package/types/algorand-client-transaction-sender.d.ts +750 -24
  78. package/types/algorand-client-transaction-sender.d.ts.map +1 -1
  79. package/types/algorand-client-transaction-sender.js +426 -12
  80. package/types/algorand-client-transaction-sender.js.map +1 -1
  81. package/types/algorand-client-transaction-sender.mjs +426 -12
  82. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  83. package/types/algorand-client.d.ts +8 -0
  84. package/types/algorand-client.d.ts.map +1 -1
  85. package/types/algorand-client.js +14 -1
  86. package/types/algorand-client.js.map +1 -1
  87. package/types/algorand-client.mjs +14 -1
  88. package/types/algorand-client.mjs.map +1 -1
  89. package/types/app-client.d.ts +13 -1
  90. package/types/app-client.d.ts.map +1 -1
  91. package/types/app-client.js +8 -5
  92. package/types/app-client.js.map +1 -1
  93. package/types/app-client.mjs +9 -6
  94. package/types/app-client.mjs.map +1 -1
  95. package/types/app-deployer.d.ts +121 -0
  96. package/types/app-deployer.d.ts.map +1 -0
  97. package/types/app-deployer.js +354 -0
  98. package/types/app-deployer.js.map +1 -0
  99. package/types/app-deployer.mjs +352 -0
  100. package/types/app-deployer.mjs.map +1 -0
  101. package/types/app-manager.d.ts +235 -0
  102. package/types/app-manager.d.ts.map +1 -0
  103. package/types/app-manager.js +336 -0
  104. package/types/app-manager.js.map +1 -0
  105. package/types/app-manager.mjs +334 -0
  106. package/types/app-manager.mjs.map +1 -0
  107. package/types/app.d.ts +42 -7
  108. package/types/app.d.ts.map +1 -1
  109. package/types/app.js +1 -1
  110. package/types/app.js.map +1 -1
  111. package/types/app.mjs +1 -1
  112. package/types/app.mjs.map +1 -1
  113. package/types/client-manager.d.ts +2 -0
  114. package/types/client-manager.d.ts.map +1 -1
  115. package/types/client-manager.js +4 -0
  116. package/types/client-manager.js.map +1 -1
  117. package/types/client-manager.mjs +4 -0
  118. package/types/client-manager.mjs.map +1 -1
  119. package/types/composer.d.ts +150 -39
  120. package/types/composer.d.ts.map +1 -1
  121. package/types/composer.js +218 -62
  122. package/types/composer.js.map +1 -1
  123. package/types/composer.mjs +218 -62
  124. package/types/composer.mjs.map +1 -1
  125. package/types/expand.d.ts +8 -0
  126. package/types/expand.d.ts.map +1 -0
  127. package/types/expand.js +3 -0
  128. package/types/expand.js.map +1 -0
  129. package/types/expand.mjs +2 -0
  130. package/types/expand.mjs.map +1 -0
  131. package/types/transaction.d.ts +3 -0
  132. package/types/transaction.d.ts.map +1 -1
@@ -0,0 +1,354 @@
1
+ 'use strict';
2
+
3
+ var algosdk = require('algosdk');
4
+ var config = require('../config.js');
5
+ var indexerLookup = require('../indexer-lookup.js');
6
+ var types_app = require('./app.js');
7
+ var types_composer = require('./composer.js');
8
+
9
+ /** Allows management of deployment and deployment metadata of applications. */
10
+ class AppDeployer {
11
+ /**
12
+ * Creates an `AppManager`
13
+ * @param appManager An `AppManager` instance
14
+ * @param transactionSender An `AlgorandClientTransactionSender` instance
15
+ * @param indexer An optional indexer instance; supply if you want to indexer to look up app metadata
16
+ */
17
+ constructor(appManager, transactionSender, indexer) {
18
+ this._appLookups = new Map();
19
+ this._appManager = appManager;
20
+ this._transactionSender = transactionSender;
21
+ this._indexer = indexer;
22
+ }
23
+ /**
24
+ * 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).
25
+ *
26
+ * To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
27
+ *
28
+ * **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`.
29
+ *
30
+ * **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.
31
+ *
32
+ * **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.
33
+ * @param deployment The arguments to control the app deployment
34
+ * @returns The app reference of the new/existing app
35
+ */
36
+ async deploy(deployment) {
37
+ const { metadata, deployTimeParams, onSchemaBreak, onUpdate, createParams, updateParams, deleteParams, executeParams, existingDeployments, ignoreCache, } = deployment;
38
+ // Set creation note
39
+ createParams.note = updateParams.note = types_composer.default.arc2Note({
40
+ dAppName: types_app.APP_DEPLOY_NOTE_DAPP,
41
+ data: metadata,
42
+ format: 'j',
43
+ });
44
+ // Check for required fields
45
+ if (existingDeployments && existingDeployments.creator !== createParams.sender) {
46
+ throw new Error(`Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${createParams.sender}`);
47
+ }
48
+ if (!existingDeployments && !this._indexer) {
49
+ 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`);
50
+ }
51
+ config.Config.getLogger(executeParams?.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'}`);
52
+ // Compile code if required
53
+ const compiledApproval = typeof createParams.approvalProgram === 'string'
54
+ ? await this._appManager.compileTealTemplate(createParams.approvalProgram, deployTimeParams, metadata)
55
+ : undefined;
56
+ const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : createParams.approvalProgram;
57
+ const compiledClear = typeof createParams.clearStateProgram === 'string'
58
+ ? await this._appManager.compileTealTemplate(createParams.clearStateProgram, deployTimeParams)
59
+ : undefined;
60
+ const clearStateProgram = compiledClear ? compiledClear.compiledBase64ToBytes : createParams.clearStateProgram;
61
+ // Define routines for create, update, and replace
62
+ const createApp = async () => {
63
+ const result = await ('method' in createParams
64
+ ? this._transactionSender.appCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram, ...executeParams })
65
+ : this._transactionSender.appCreate({ ...createParams, approvalProgram, clearStateProgram, ...executeParams }));
66
+ const appMetadata = {
67
+ appId: result.appId,
68
+ appAddress: result.appAddress,
69
+ ...metadata,
70
+ createdMetadata: metadata,
71
+ createdRound: BigInt(result.confirmation.confirmedRound),
72
+ updatedRound: BigInt(result.confirmation.confirmedRound),
73
+ deleted: false,
74
+ };
75
+ this.updateAppLookup(createParams.sender, appMetadata);
76
+ return {
77
+ operationPerformed: 'create',
78
+ compiledApproval,
79
+ compiledClear,
80
+ ...result,
81
+ ...appMetadata,
82
+ };
83
+ };
84
+ const updateApp = async (existingApp) => {
85
+ config.Config.getLogger(executeParams?.suppressLog).info(`Updating existing ${metadata.name} app for ${createParams.sender} to version ${metadata.version}.`);
86
+ const result = await ('method' in updateParams
87
+ ? this._transactionSender.appUpdateMethodCall({
88
+ appId: existingApp.appId,
89
+ approvalProgram,
90
+ clearStateProgram,
91
+ ...updateParams,
92
+ ...executeParams,
93
+ })
94
+ : this._transactionSender.appUpdate({
95
+ appId: existingApp.appId,
96
+ approvalProgram,
97
+ clearStateProgram,
98
+ ...updateParams,
99
+ ...executeParams,
100
+ }));
101
+ const appMetadata = {
102
+ appId: existingApp.appId,
103
+ appAddress: existingApp.appAddress,
104
+ createdMetadata: existingApp.createdMetadata,
105
+ createdRound: existingApp.createdRound,
106
+ updatedRound: BigInt(result.confirmation.confirmedRound),
107
+ ...metadata,
108
+ deleted: false,
109
+ };
110
+ this.updateAppLookup(createParams.sender, appMetadata);
111
+ return {
112
+ operationPerformed: 'update',
113
+ compiledApproval,
114
+ compiledClear,
115
+ ...result,
116
+ ...appMetadata,
117
+ };
118
+ };
119
+ const replaceApp = async (existingApp) => {
120
+ config.Config.getLogger(executeParams?.suppressLog).info(`Deploying a new ${metadata.name} app for ${createParams.sender}; deploying app with version ${metadata.version}.`);
121
+ config.Config.getLogger(executeParams?.suppressLog).warn(`Deleting existing ${metadata.name} app with id ${existingApp.appId} from ${deleteParams.sender} account.`);
122
+ const composer = this._transactionSender.newGroup();
123
+ if ('method' in createParams) {
124
+ composer.addAppCreateMethodCall({ ...createParams, approvalProgram, clearStateProgram });
125
+ }
126
+ else {
127
+ composer.addAppCreate({ ...createParams, approvalProgram, clearStateProgram });
128
+ }
129
+ const createIndex = await composer.count();
130
+ if ('method' in deleteParams) {
131
+ composer.addAppDeleteMethodCall({ appId: existingApp.appId, ...deleteParams });
132
+ }
133
+ else {
134
+ composer.addAppDelete({ appId: existingApp.appId, ...deleteParams });
135
+ }
136
+ const result = await composer.execute({ ...executeParams, suppressLog: true });
137
+ const confirmation = result.confirmations.at(createIndex - 1);
138
+ const transaction = result.transactions.at(createIndex - 1);
139
+ const deleteTransaction = result.transactions.at(-1);
140
+ config.Config.getLogger(executeParams?.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.`);
141
+ const appMetadata = {
142
+ appId: BigInt(confirmation.applicationIndex),
143
+ appAddress: algosdk.getApplicationAddress(confirmation.applicationIndex),
144
+ ...metadata,
145
+ createdMetadata: metadata,
146
+ createdRound: BigInt(confirmation.confirmedRound),
147
+ updatedRound: BigInt(confirmation.confirmedRound),
148
+ deleted: false,
149
+ };
150
+ this.updateAppLookup(createParams.sender, appMetadata);
151
+ return {
152
+ operationPerformed: 'replace',
153
+ ...result,
154
+ compiledApproval,
155
+ compiledClear,
156
+ transaction,
157
+ confirmation,
158
+ return: 'method' in createParams ? result.returns?.[0] : undefined,
159
+ deleteReturn: 'method' in deleteParams ? result.returns?.at(-1) : undefined,
160
+ ...appMetadata,
161
+ deleteResult: { transaction: deleteTransaction, confirmation: result.confirmations.at(-1) },
162
+ };
163
+ };
164
+ // Lookup existing app metadata
165
+ const apps = existingDeployments ?? (await this.getCreatorAppsByName(createParams.sender, ignoreCache));
166
+ const existingApp = apps.apps[metadata.name];
167
+ if (!existingApp || existingApp.deleted) {
168
+ config.Config.getLogger(executeParams?.suppressLog).info(`App ${metadata.name} not found in apps created by ${createParams.sender}; deploying app with version ${metadata.version}.`);
169
+ return await createApp();
170
+ }
171
+ config.Config.getLogger(executeParams?.suppressLog).info(`Existing app ${metadata.name} found by creator ${createParams.sender}, with app id ${existingApp.appId} and version ${existingApp.version}.`);
172
+ const existingAppRecord = await this._appManager.getById(existingApp.appId);
173
+ const existingApproval = Buffer.from(existingAppRecord.approvalProgram).toString('base64');
174
+ const existingClear = Buffer.from(existingAppRecord.clearStateProgram).toString('base64');
175
+ const newApproval = Buffer.from(approvalProgram).toString('base64');
176
+ const newClear = Buffer.from(clearStateProgram).toString('base64');
177
+ // Check for changes
178
+ const isUpdate = newApproval !== existingApproval || newClear !== existingClear;
179
+ const isSchemaBreak = existingAppRecord.localInts < (createParams.schema?.localInts ?? 0) ||
180
+ existingAppRecord.globalInts < (createParams.schema?.globalInts ?? 0) ||
181
+ existingAppRecord.localByteSlices < (createParams.schema?.localByteSlices ?? 0) ||
182
+ existingAppRecord.globalByteSlices < (createParams.schema?.globalByteSlices ?? 0);
183
+ if (isSchemaBreak) {
184
+ config.Config.getLogger(executeParams?.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appId}:`, {
185
+ from: {
186
+ globalInts: existingAppRecord.globalInts,
187
+ globalByteSlices: existingAppRecord.globalByteSlices,
188
+ localInts: existingAppRecord.localInts,
189
+ localByteSlices: existingAppRecord.localByteSlices,
190
+ },
191
+ to: createParams.schema,
192
+ });
193
+ if (onSchemaBreak === undefined || onSchemaBreak === 'fail' || onSchemaBreak === types_app.OnSchemaBreak.Fail) {
194
+ throw new Error('Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. ' +
195
+ 'If you want to try deleting and recreating the app then ' +
196
+ 're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp');
197
+ }
198
+ if (onSchemaBreak === 'append' || onSchemaBreak === types_app.OnSchemaBreak.AppendApp) {
199
+ config.Config.getLogger(executeParams?.suppressLog).info('onSchemaBreak=AppendApp, will attempt to create a new app');
200
+ return await createApp();
201
+ }
202
+ if (existingApp.deletable) {
203
+ config.Config.getLogger(executeParams?.suppressLog).info('App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app');
204
+ }
205
+ else {
206
+ config.Config.getLogger(executeParams?.suppressLog).info('App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail');
207
+ }
208
+ return await replaceApp(existingApp);
209
+ }
210
+ if (isUpdate) {
211
+ config.Config.getLogger(executeParams?.suppressLog).info(`Detected a TEAL update in app ${existingApp.appId} for creator ${createParams.sender}`);
212
+ if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === types_app.OnUpdate.Fail) {
213
+ throw new Error('Update detected and onUpdate=Fail, stopping deployment. Try a different onUpdate value to not fail.');
214
+ }
215
+ if (onUpdate === 'append' || onUpdate === types_app.OnUpdate.AppendApp) {
216
+ config.Config.getLogger(executeParams?.suppressLog).info('onUpdate=AppendApp, will attempt to create a new app');
217
+ return await createApp();
218
+ }
219
+ if (onUpdate === 'update' || onUpdate === types_app.OnUpdate.UpdateApp) {
220
+ if (existingApp.updatable) {
221
+ config.Config.getLogger(executeParams?.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
222
+ }
223
+ else {
224
+ config.Config.getLogger(executeParams?.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
225
+ }
226
+ return await updateApp(existingApp);
227
+ }
228
+ if (onUpdate === 'replace' || onUpdate === types_app.OnUpdate.ReplaceApp) {
229
+ if (existingApp.deletable) {
230
+ config.Config.getLogger(executeParams?.suppressLog).warn('App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...');
231
+ }
232
+ else {
233
+ config.Config.getLogger(executeParams?.suppressLog).warn('App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail');
234
+ }
235
+ return await replaceApp(existingApp);
236
+ }
237
+ }
238
+ config.Config.getLogger(executeParams?.suppressLog).debug('No detected changes in app, nothing to do.');
239
+ return { ...existingApp, operationPerformed: 'nothing' };
240
+ }
241
+ updateAppLookup(sender, appMetadata) {
242
+ const lookup = this._appLookups.get(sender);
243
+ if (!lookup) {
244
+ this._appLookups.set(sender, { creator: sender, apps: { [appMetadata.name]: appMetadata } });
245
+ }
246
+ else {
247
+ lookup.apps[appMetadata.name] = appMetadata;
248
+ }
249
+ }
250
+ /**
251
+ * Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have
252
+ * an [ARC-2](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md) `AppDeployNote` as the transaction
253
+ * note of the app creation transaction.
254
+ *
255
+ * This function caches the result for the given creator account so that subsequent calls will not require an indexer lookup.
256
+ *
257
+ * If the `AppManager` instance wasn't created with an indexer client, this function will throw an error.
258
+ *
259
+ * @param creatorAddress The address of the account that is the creator of the apps you want to search for
260
+ * @param ignoreCache Whether ot not to ignore the cache and force a lookup, default: use the cache
261
+ * @returns A name-based lookup of the app metadata
262
+ */
263
+ async getCreatorAppsByName(creatorAddress, ignoreCache) {
264
+ const appLookup = {};
265
+ if (!ignoreCache && this._appLookups.has(creatorAddress)) {
266
+ return this._appLookups.get(creatorAddress);
267
+ }
268
+ if (!this._indexer) {
269
+ throw new Error(`Didn't receive an indexer client when this AppManager was created, but received a call to getCreatorApps`);
270
+ }
271
+ // Extract all apps that account created
272
+ const createdApps = (await indexerLookup.lookupAccountCreatedApplicationByAddress(this._indexer, creatorAddress))
273
+ .map((a) => {
274
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
275
+ return { id: BigInt(a.id), createdAtRound: a['created-at-round'], deleted: a.deleted };
276
+ })
277
+ .sort((a, b) => a.createdAtRound - b.createdAtRound);
278
+ // For each app that account created (in parallel)...
279
+ const apps = await Promise.all(createdApps.map(async (createdApp) => {
280
+ // Find any app transactions for that app in the round it was created (should always just be a single creation transaction)
281
+ const appTransactions = await indexerLookup.searchTransactions(this._indexer, (s) => s
282
+ .minRound(createdApp.createdAtRound)
283
+ .txType(algosdk.TransactionType.appl)
284
+ .applicationID(Number(createdApp.id))
285
+ .address(creatorAddress)
286
+ .addressRole('sender')
287
+ .notePrefix(Buffer.from(types_app.APP_DEPLOY_NOTE_DAPP).toString('base64')));
288
+ // Triple check the transaction is intact by filtering for the one we want:
289
+ // * application-id is 0 when the app is first created
290
+ // * also verify the sender to prevent a potential security risk
291
+ const appCreationTransaction = appTransactions.transactions.filter(
292
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
293
+ (t) => t['application-transaction']['application-id'] === 0 && t.sender === creatorAddress)[0];
294
+ const latestAppUpdateTransaction = appTransactions.transactions
295
+ .filter((t) => t.sender === creatorAddress)
296
+ .sort((a, b) => a['confirmed-round'] === b['confirmed-round']
297
+ ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
298
+ (b['intra-round-offset'] - a['intra-round-offset']) / 10
299
+ : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
300
+ b['confirmed-round'] - a['confirmed-round'])[0];
301
+ if (!appCreationTransaction?.note)
302
+ // No note; ignoring
303
+ return null;
304
+ return { createdApp, appCreationTransaction, latestAppUpdateTransaction };
305
+ }));
306
+ apps
307
+ .filter((a) => a !== null)
308
+ .forEach((a) => {
309
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
310
+ const { createdApp, appCreationTransaction, latestAppUpdateTransaction } = a;
311
+ const parseNote = (note) => {
312
+ if (!note) {
313
+ // No note; ignoring...
314
+ return;
315
+ }
316
+ const decoder = new TextDecoder();
317
+ const noteAsBase64 = decoder.decode(Buffer.from(note));
318
+ const noteAsString = Buffer.from(noteAsBase64, 'base64').toString('utf-8');
319
+ if (!noteAsString.startsWith(`${types_app.APP_DEPLOY_NOTE_DAPP}:j{`))
320
+ // Clearly not APP_DEPLOY JSON; ignoring...
321
+ return;
322
+ return JSON.parse(noteAsString.substring(types_app.APP_DEPLOY_NOTE_DAPP.length + 2));
323
+ };
324
+ try {
325
+ const creationNote = parseNote(appCreationTransaction.note);
326
+ const updateNote = parseNote(latestAppUpdateTransaction.note);
327
+ if (creationNote?.name) {
328
+ appLookup[creationNote.name] = {
329
+ appId: createdApp.id,
330
+ appAddress: algosdk.getApplicationAddress(createdApp.id),
331
+ createdMetadata: creationNote,
332
+ createdRound: BigInt(appCreationTransaction['confirmed-round'] ?? 0),
333
+ ...(updateNote ?? creationNote),
334
+ updatedRound: BigInt(latestAppUpdateTransaction?.['confirmed-round'] ?? 0),
335
+ deleted: createdApp.deleted ?? false,
336
+ };
337
+ }
338
+ }
339
+ catch (e) {
340
+ config.Config.logger.warn(`Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`, e);
341
+ return;
342
+ }
343
+ });
344
+ const lookup = {
345
+ creator: creatorAddress,
346
+ apps: appLookup,
347
+ };
348
+ this._appLookups.set(creatorAddress, lookup);
349
+ return lookup;
350
+ }
351
+ }
352
+
353
+ exports.AppDeployer = AppDeployer;
354
+ //# sourceMappingURL=app-deployer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-deployer.js","sources":["../../src/types/app-deployer.ts"],"sourcesContent":[null],"names":["AlgoKitComposer","APP_DEPLOY_NOTE_DAPP","Config","OnSchemaBreak","OnUpdate","indexer.lookupAccountCreatedApplicationByAddress","indexer.searchTransactions"],"mappings":";;;;;;;;AAsGA;MACa,WAAW,CAAA;AAMtB;;;;;AAKG;AACH,IAAA,WAAA,CAAY,UAAsB,EAAE,iBAAkD,EAAE,OAAyB,EAAA;AARzG,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,GAAG,EAAqB,CAAA;AAShD,QAAA,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;AAC7B,QAAA,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAA;AAC3C,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;KACxB;AAED;;;;;;;;;;;;AAYG;IACH,MAAM,MAAM,CAAC,UAA2B,EAAA;QACtC,MAAM,EACJ,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,WAAW,GACZ,GAAG,UAAU,CAAA;;QAId,YAAY,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,GAAGA,sBAAe,CAAC,QAAQ,CAAC;AAC/D,YAAA,QAAQ,EAAEC,8BAAoB;AAC9B,YAAA,IAAI,EAAE,QAAQ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