@algorandfoundation/algokit-utils 1.0.0-beta.8 → 1.0.0-beta.9
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/account.d.ts +87 -0
- package/account.d.ts.map +1 -0
- package/account.js +144 -0
- package/account.js.map +1 -0
- package/algo-amount.d.ts +18 -0
- package/algo-amount.d.ts.map +1 -0
- package/algo-amount.js +31 -0
- package/algo-amount.js.map +1 -0
- package/algo-http-client-with-retry.d.ts +14 -0
- package/algo-http-client-with-retry.d.ts.map +1 -0
- package/algo-http-client-with-retry.js +62 -0
- package/algo-http-client-with-retry.js.map +1 -0
- package/app.d.ts +189 -0
- package/app.d.ts.map +1 -0
- package/app.js +265 -0
- package/app.js.map +1 -0
- package/application-client.d.ts +113 -0
- package/application-client.d.ts.map +1 -0
- package/application-client.js +258 -0
- package/application-client.js.map +1 -0
- package/config.d.ts +27 -0
- package/config.d.ts.map +1 -0
- package/config.js +46 -0
- package/config.js.map +1 -0
- package/deploy-app.d.ts +164 -0
- package/deploy-app.d.ts.map +1 -0
- package/deploy-app.js +419 -0
- package/deploy-app.js.map +1 -0
- package/index.d.ts +12 -0
- package/index.d.ts.map +1 -0
- package/index.js.map +1 -0
- package/indexer-lookup.d.ts +31 -0
- package/indexer-lookup.d.ts.map +1 -0
- package/indexer-lookup.js +96 -0
- package/indexer-lookup.js.map +1 -0
- package/localnet.d.ts +54 -0
- package/localnet.d.ts.map +1 -0
- package/localnet.js +121 -0
- package/localnet.js.map +1 -0
- package/network-client.d.ts +102 -0
- package/network-client.d.ts.map +1 -0
- package/network-client.js +182 -0
- package/network-client.js.map +1 -0
- package/package.json +2 -2
- package/transaction.d.ts +157 -0
- package/transaction.d.ts.map +1 -0
- package/transaction.js +306 -0
- package/transaction.js.map +1 -0
- package/transfer.d.ts +24 -0
- package/transfer.d.ts.map +1 -0
- package/transfer.js +33 -0
- package/transfer.js.map +1 -0
- package/types/algod.d.ts +124 -0
- package/types/algod.d.ts.map +1 -0
- package/types/algod.js +3 -0
- package/types/algod.js.map +1 -0
- package/types/appspec.d.ts +78 -0
- package/types/appspec.d.ts.map +1 -0
- package/types/appspec.js +15 -0
- package/types/appspec.js.map +1 -0
- package/types/indexer.d.ts +314 -0
- package/types/indexer.d.ts.map +1 -0
- package/types/indexer.js +25 -0
- package/types/indexer.js.map +1 -0
- package/urlTokenBaseHTTPClient.d.ts +41 -0
- package/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/urlTokenBaseHTTPClient.js +151 -0
- package/urlTokenBaseHTTPClient.js.map +1 -0
package/deploy-app.js
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.performTemplateSubstitutionAndCompile = exports.performTemplateSubstitution = exports.replaceDeployTimeControlParams = exports.getAppDeploymentTransactionNote = exports.getCreatorAppsByName = exports.schemaIsBroken = exports.deployApp = exports.OnSchemaBreak = exports.OnUpdate = exports.APP_DEPLOY_NOTE_PREFIX = exports.DELETABLE_TEMPLATE_NAME = exports.UPDATABLE_TEMPLATE_NAME = void 0;
|
|
4
|
+
const algosdk_1 = require("algosdk");
|
|
5
|
+
const app_1 = require("./app");
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
const indexer_lookup_1 = require("./indexer-lookup");
|
|
8
|
+
const transaction_1 = require("./transaction");
|
|
9
|
+
exports.UPDATABLE_TEMPLATE_NAME = 'TMPL_UPDATABLE';
|
|
10
|
+
exports.DELETABLE_TEMPLATE_NAME = 'TMPL_DELETABLE';
|
|
11
|
+
exports.APP_DEPLOY_NOTE_PREFIX = 'APP_DEPLOY::';
|
|
12
|
+
/** What action to perform when deploying an app and an update is detected in the TEAL code */
|
|
13
|
+
var OnUpdate;
|
|
14
|
+
(function (OnUpdate) {
|
|
15
|
+
/** Fail the deployment */
|
|
16
|
+
OnUpdate[OnUpdate["Fail"] = 0] = "Fail";
|
|
17
|
+
/** Update the app */
|
|
18
|
+
OnUpdate[OnUpdate["UpdateApp"] = 1] = "UpdateApp";
|
|
19
|
+
/** Delete the app and create a new one in its place */
|
|
20
|
+
OnUpdate[OnUpdate["ReplaceApp"] = 2] = "ReplaceApp";
|
|
21
|
+
})(OnUpdate = exports.OnUpdate || (exports.OnUpdate = {}));
|
|
22
|
+
/** What action to perform when deploying an app and a breaking schema change is detected */
|
|
23
|
+
var OnSchemaBreak;
|
|
24
|
+
(function (OnSchemaBreak) {
|
|
25
|
+
/** Fail the deployment */
|
|
26
|
+
OnSchemaBreak[OnSchemaBreak["Fail"] = 0] = "Fail";
|
|
27
|
+
/** Delete the app and create a new one in its place */
|
|
28
|
+
OnSchemaBreak[OnSchemaBreak["ReplaceApp"] = 1] = "ReplaceApp";
|
|
29
|
+
})(OnSchemaBreak = exports.OnSchemaBreak || (exports.OnSchemaBreak = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
|
|
32
|
+
*
|
|
33
|
+
* 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
|
|
34
|
+
*
|
|
35
|
+
* **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.
|
|
36
|
+
*
|
|
37
|
+
* **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.
|
|
38
|
+
* @param deployment The arguments to control the app deployment
|
|
39
|
+
* @param algod An algod client
|
|
40
|
+
* @param indexer An indexer client
|
|
41
|
+
* @returns The app reference of the new/existing app
|
|
42
|
+
*/
|
|
43
|
+
async function deployApp(deployment, algod, indexer) {
|
|
44
|
+
const { metadata, deployTimeParameters, onSchemaBreak, onUpdate, existingDeployments, createArgs, updateArgs, deleteArgs, ...appParams } = deployment;
|
|
45
|
+
if (existingDeployments && existingDeployments.creator !== (0, transaction_1.getSenderAddress)(appParams.from)) {
|
|
46
|
+
throw new Error(`Received invalid existingDeployments value for creator ${existingDeployments.creator} when attempting to deploy for creator ${appParams.from}`);
|
|
47
|
+
}
|
|
48
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`Idempotently deploying app "${metadata.name}" from creator ${(0, transaction_1.getSenderAddress)(appParams.from)} using ${appParams.approvalProgram.length} bytes of teal code and ${appParams.clearStateProgram.length} bytes of teal code`);
|
|
49
|
+
appParams.approvalProgram =
|
|
50
|
+
typeof appParams.approvalProgram === 'string'
|
|
51
|
+
? (await performTemplateSubstitutionAndCompile(appParams.approvalProgram, algod, deployTimeParameters, metadata))
|
|
52
|
+
.compiledBase64ToBytes
|
|
53
|
+
: appParams.approvalProgram;
|
|
54
|
+
appParams.clearStateProgram =
|
|
55
|
+
typeof appParams.clearStateProgram === 'string'
|
|
56
|
+
? (await performTemplateSubstitutionAndCompile(appParams.clearStateProgram, algod, deployTimeParameters)).compiledBase64ToBytes
|
|
57
|
+
: appParams.clearStateProgram;
|
|
58
|
+
const apps = existingDeployments ?? (await getCreatorAppsByName(appParams.from, indexer));
|
|
59
|
+
const create = async (skipSending) => {
|
|
60
|
+
const result = await (0, app_1.createApp)({
|
|
61
|
+
...appParams,
|
|
62
|
+
args: createArgs,
|
|
63
|
+
note: getAppDeploymentTransactionNote(metadata),
|
|
64
|
+
skipSending: skipSending ?? false,
|
|
65
|
+
skipWaiting: false,
|
|
66
|
+
}, algod);
|
|
67
|
+
return {
|
|
68
|
+
transaction: result.transaction,
|
|
69
|
+
confirmation: result.confirmation,
|
|
70
|
+
appIndex: result.appIndex,
|
|
71
|
+
appAddress: result.appAddress,
|
|
72
|
+
createdMetadata: metadata,
|
|
73
|
+
createdRound: Number(result.confirmation?.['confirmed-round']),
|
|
74
|
+
updatedRound: Number(result.confirmation?.['confirmed-round']),
|
|
75
|
+
...metadata,
|
|
76
|
+
deleted: false,
|
|
77
|
+
operationPerformed: 'create',
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const existingApp = apps.apps[metadata.name];
|
|
81
|
+
if (!existingApp) {
|
|
82
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`App ${metadata.name} not found in apps created by ${(0, transaction_1.getSenderAddress)(appParams.from)}; deploying app with version ${metadata.version}.`);
|
|
83
|
+
return await create();
|
|
84
|
+
}
|
|
85
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`Existing app ${metadata.name} found by creator ${(0, transaction_1.getSenderAddress)(appParams.from)}, with app index ${existingApp.appIndex} and version ${existingApp.version}.`);
|
|
86
|
+
const existingAppRecord = await (0, app_1.getAppByIndex)(existingApp.appIndex, algod);
|
|
87
|
+
const existingApproval = existingAppRecord.params['approval-program'];
|
|
88
|
+
const existingClear = existingAppRecord.params['clear-state-program'];
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
+
const existingGlobalSchema = existingAppRecord.params['global-state-schema'];
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
92
|
+
const existingLocalSchema = existingAppRecord.params['local-state-schema'];
|
|
93
|
+
const newGlobalSchema = {
|
|
94
|
+
'num-byte-slice': appParams.schema.globalByteSlices,
|
|
95
|
+
'num-uint': appParams.schema.globalInts,
|
|
96
|
+
};
|
|
97
|
+
const newLocalSchema = {
|
|
98
|
+
'num-byte-slice': appParams.schema.localByteSlices,
|
|
99
|
+
'num-uint': appParams.schema.localInts,
|
|
100
|
+
};
|
|
101
|
+
const newApproval = Buffer.from(appParams.approvalProgram).toString('base64');
|
|
102
|
+
const newClear = Buffer.from(appParams.clearStateProgram).toString('base64');
|
|
103
|
+
const isUpdate = newApproval !== existingApproval || newClear !== existingClear;
|
|
104
|
+
const isSchemaBreak = schemaIsBroken(existingGlobalSchema, newGlobalSchema) || schemaIsBroken(existingLocalSchema, newLocalSchema);
|
|
105
|
+
const replace = async () => {
|
|
106
|
+
// Create
|
|
107
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`Deploying a new ${metadata.name} app for ${(0, transaction_1.getSenderAddress)(appParams.from)}; deploying app with version ${metadata.version}.`);
|
|
108
|
+
const { transaction: createTransaction } = await create(true);
|
|
109
|
+
// Delete
|
|
110
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).warn(`Deleting existing ${metadata.name} app with index ${existingApp.appIndex} from ${(0, transaction_1.getSenderAddress)(appParams.from)} account.`);
|
|
111
|
+
const { transaction: deleteTransaction } = await (0, app_1.callApp)({
|
|
112
|
+
appIndex: existingApp.appIndex,
|
|
113
|
+
callType: 'delete',
|
|
114
|
+
from: appParams.from,
|
|
115
|
+
args: deleteArgs,
|
|
116
|
+
transactionParams: appParams.transactionParams,
|
|
117
|
+
suppressLog: appParams.suppressLog,
|
|
118
|
+
skipSending: true,
|
|
119
|
+
}, algod);
|
|
120
|
+
// Ensure create and delete happen atomically
|
|
121
|
+
const { confirmations } = await (0, transaction_1.sendGroupOfTransactions)({
|
|
122
|
+
transactions: [
|
|
123
|
+
{
|
|
124
|
+
transaction: createTransaction,
|
|
125
|
+
signer: appParams.from,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
transaction: deleteTransaction,
|
|
129
|
+
signer: appParams.from,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
sendParams: {
|
|
133
|
+
maxRoundsToWaitForConfirmation: appParams.maxRoundsToWaitForConfirmation,
|
|
134
|
+
skipWaiting: false,
|
|
135
|
+
suppressLog: true,
|
|
136
|
+
},
|
|
137
|
+
}, algod);
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
139
|
+
const createConfirmation = confirmations[0];
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
141
|
+
const deleteConfirmation = confirmations[1];
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
143
|
+
const newAppIndex = createConfirmation['application-index'];
|
|
144
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).warn(`Sent transactions ${createTransaction.txID()} to create app with index ${newAppIndex} and ${deleteTransaction.txID()} to delete app with index ${existingApp.appIndex} from ${(0, transaction_1.getSenderAddress)(appParams.from)} account.`);
|
|
145
|
+
return {
|
|
146
|
+
transaction: createTransaction,
|
|
147
|
+
confirmation: createConfirmation,
|
|
148
|
+
appIndex: newAppIndex,
|
|
149
|
+
appAddress: (0, algosdk_1.getApplicationAddress)(newAppIndex),
|
|
150
|
+
createdMetadata: metadata,
|
|
151
|
+
createdRound: Number(createConfirmation['confirmed-round']),
|
|
152
|
+
updatedRound: Number(createConfirmation['confirmed-round']),
|
|
153
|
+
...metadata,
|
|
154
|
+
deleted: false,
|
|
155
|
+
deleteResult: { transaction: deleteTransaction, confirmation: deleteConfirmation },
|
|
156
|
+
operationPerformed: 'replace',
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const update = async () => {
|
|
160
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`Updating existing ${metadata.name} app for ${(0, transaction_1.getSenderAddress)(appParams.from)} to version ${metadata.version}.`);
|
|
161
|
+
const result = await (0, app_1.updateApp)({
|
|
162
|
+
appIndex: existingApp.appIndex,
|
|
163
|
+
from: appParams.from,
|
|
164
|
+
args: updateArgs,
|
|
165
|
+
note: getAppDeploymentTransactionNote(metadata),
|
|
166
|
+
approvalProgram: appParams.approvalProgram,
|
|
167
|
+
clearStateProgram: appParams.clearStateProgram,
|
|
168
|
+
transactionParams: appParams.transactionParams,
|
|
169
|
+
suppressLog: appParams.suppressLog,
|
|
170
|
+
skipSending: false,
|
|
171
|
+
skipWaiting: false,
|
|
172
|
+
}, algod);
|
|
173
|
+
return {
|
|
174
|
+
transaction: result.transaction,
|
|
175
|
+
confirmation: result.confirmation,
|
|
176
|
+
appIndex: existingApp.appIndex,
|
|
177
|
+
appAddress: existingApp.appAddress,
|
|
178
|
+
createdMetadata: existingApp.createdMetadata,
|
|
179
|
+
createdRound: existingApp.createdRound,
|
|
180
|
+
updatedRound: Number(result.confirmation?.['confirmed-round']),
|
|
181
|
+
...metadata,
|
|
182
|
+
deleted: false,
|
|
183
|
+
operationPerformed: 'update',
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
if (isSchemaBreak) {
|
|
187
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).warn(`Detected a breaking app schema change in app ${existingApp.appIndex}:`, {
|
|
188
|
+
from: {
|
|
189
|
+
global: existingGlobalSchema,
|
|
190
|
+
local: existingLocalSchema,
|
|
191
|
+
},
|
|
192
|
+
to: {
|
|
193
|
+
global: newGlobalSchema,
|
|
194
|
+
local: newLocalSchema,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
if (onSchemaBreak === undefined || onSchemaBreak === 'fail' || onSchemaBreak === OnSchemaBreak.Fail) {
|
|
198
|
+
throw new Error('Schema break detected and onSchemaBreak=OnSchemaBreak.Fail, stopping deployment. ' +
|
|
199
|
+
'If you want to try deleting and recreating the app then ' +
|
|
200
|
+
're-run with onSchemaBreak=OnSchemaBreak.ReplaceApp');
|
|
201
|
+
}
|
|
202
|
+
if (existingApp.deletable) {
|
|
203
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info('App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app');
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info('App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail');
|
|
207
|
+
}
|
|
208
|
+
return await replace();
|
|
209
|
+
}
|
|
210
|
+
if (isUpdate) {
|
|
211
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`Detected a TEAL update in app ${existingApp.appIndex} for creator ${(0, transaction_1.getSenderAddress)(appParams.from)}`);
|
|
212
|
+
if (onUpdate === undefined || onUpdate === 'fail' || onUpdate === OnUpdate.Fail) {
|
|
213
|
+
throw new Error('Update detected and onUpdate=Fail, stopping deployment. ' +
|
|
214
|
+
'If you want to try deleting and recreating the app then ' +
|
|
215
|
+
're-run with onUpdate=UpdateApp');
|
|
216
|
+
}
|
|
217
|
+
if (onUpdate === 'update' || onUpdate === OnUpdate.UpdateApp) {
|
|
218
|
+
if (existingApp.updatable) {
|
|
219
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).info(`App is updatable and onUpdate=UpdateApp, updating app...`);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).warn(`App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail`);
|
|
223
|
+
}
|
|
224
|
+
return await update();
|
|
225
|
+
}
|
|
226
|
+
if (onUpdate === 'replace' || onUpdate === OnUpdate.ReplaceApp) {
|
|
227
|
+
if (existingApp.deletable) {
|
|
228
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).warn('App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app...');
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).warn('App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail');
|
|
232
|
+
}
|
|
233
|
+
return await replace();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
config_1.AlgoKitConfig.getLogger(appParams.suppressLog).debug('No detected changes in app, nothing to do.');
|
|
237
|
+
return { ...existingApp, operationPerformed: 'none' };
|
|
238
|
+
}
|
|
239
|
+
exports.deployApp = deployApp;
|
|
240
|
+
/** Returns true is there is a breaking change in the application state schema from before to after.
|
|
241
|
+
* i.e. if the schema becomes larger, since applications can't ask for more schema after creation.
|
|
242
|
+
* Otherwise, there is no error, the app just doesn't store data in the extra schema :(
|
|
243
|
+
*
|
|
244
|
+
* @param before The existing schema
|
|
245
|
+
* @param after The new schema
|
|
246
|
+
* @returns Whether or not there is a breaking change
|
|
247
|
+
*/
|
|
248
|
+
function schemaIsBroken(before, after) {
|
|
249
|
+
return before['num-byte-slice'] < after['num-byte-slice'] || before['num-uint'] < after['num-uint'];
|
|
250
|
+
}
|
|
251
|
+
exports.schemaIsBroken = schemaIsBroken;
|
|
252
|
+
/**
|
|
253
|
+
* Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have an @see {AppDeployNote} in the transaction note of the creation transaction.
|
|
254
|
+
*
|
|
255
|
+
* **Note:** It's recommended this is only called once and then stored since it's a somewhat expensive operation (multiple indexer calls).
|
|
256
|
+
*
|
|
257
|
+
* @param creatorAccount The account (with private key loaded) or string address of an account that is the creator of the apps you want to search for
|
|
258
|
+
* @param indexer An indexer client
|
|
259
|
+
* @returns A name-based lookup of the app information (id, address)
|
|
260
|
+
*/
|
|
261
|
+
async function getCreatorAppsByName(creatorAccount, indexer) {
|
|
262
|
+
const appLookup = {};
|
|
263
|
+
const creatorAddress = typeof creatorAccount !== 'string' ? (0, transaction_1.getSenderAddress)(creatorAccount) : creatorAccount;
|
|
264
|
+
// Extract all apps that account created
|
|
265
|
+
const createdApps = (await (0, indexer_lookup_1.lookupAccountCreatedApplicationByAddress)(indexer, creatorAddress)).map((a) => {
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
267
|
+
return { id: a.id, createdAtRound: a['created-at-round'], deleted: a.deleted };
|
|
268
|
+
});
|
|
269
|
+
// For each app that account created (in parallel)...
|
|
270
|
+
await Promise.all(createdApps.map(async (createdApp) => {
|
|
271
|
+
// Find any app transactions for that app in the round it was created (should always just be a single creation transaction)
|
|
272
|
+
const appTransactions = await (0, indexer_lookup_1.searchTransactions)(indexer, (s) => s
|
|
273
|
+
.minRound(createdApp.createdAtRound)
|
|
274
|
+
.txType(algosdk_1.TransactionType.appl)
|
|
275
|
+
.applicationID(createdApp.id)
|
|
276
|
+
.address(creatorAddress)
|
|
277
|
+
.addressRole('sender')
|
|
278
|
+
.notePrefix(Buffer.from(exports.APP_DEPLOY_NOTE_PREFIX).toString('base64')));
|
|
279
|
+
// Triple check the transaction is intact by filtering for the one we want:
|
|
280
|
+
// * application-id is 0 when the app is first created
|
|
281
|
+
// * also verify the sender to prevent a potential security risk
|
|
282
|
+
const appCreationTransaction = appTransactions.transactions.filter(
|
|
283
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
284
|
+
(t) => t['application-transaction']['application-id'] === 0 && t.sender === creatorAddress)[0];
|
|
285
|
+
const latestAppUpdateTransaction = appTransactions.transactions
|
|
286
|
+
.filter((t) => t.sender === creatorAddress)
|
|
287
|
+
.sort((a, b) => a['confirmed-round'] === b['confirmed-round']
|
|
288
|
+
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
289
|
+
(b['intra-round-offset'] - a['intra-round-offset']) / 10
|
|
290
|
+
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
291
|
+
b['confirmed-round'] - a['confirmed-round'])[0];
|
|
292
|
+
if (!appCreationTransaction?.note)
|
|
293
|
+
// No note; ignoring
|
|
294
|
+
return;
|
|
295
|
+
const parseNote = (note) => {
|
|
296
|
+
if (!note) {
|
|
297
|
+
// No note; ignoring...
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const decoder = new TextDecoder();
|
|
301
|
+
const noteAsBase64 = decoder.decode(Buffer.from(note));
|
|
302
|
+
const noteAsString = Buffer.from(noteAsBase64, 'base64').toString('utf-8');
|
|
303
|
+
if (!noteAsString.startsWith(`${exports.APP_DEPLOY_NOTE_PREFIX}{`))
|
|
304
|
+
// Clearly not APP_DEPLOY JSON; ignoring...
|
|
305
|
+
return;
|
|
306
|
+
return JSON.parse(noteAsString.substring(exports.APP_DEPLOY_NOTE_PREFIX.length));
|
|
307
|
+
};
|
|
308
|
+
try {
|
|
309
|
+
const creationNote = parseNote(appCreationTransaction.note);
|
|
310
|
+
const updateNote = parseNote(latestAppUpdateTransaction.note);
|
|
311
|
+
if (creationNote?.name) {
|
|
312
|
+
appLookup[creationNote.name] = {
|
|
313
|
+
appIndex: createdApp.id,
|
|
314
|
+
appAddress: (0, algosdk_1.getApplicationAddress)(createdApp.id),
|
|
315
|
+
createdMetadata: creationNote,
|
|
316
|
+
createdRound: Number(appCreationTransaction['confirmed-round']),
|
|
317
|
+
...(updateNote ?? creationNote),
|
|
318
|
+
updatedRound: Number(latestAppUpdateTransaction?.['confirmed-round']),
|
|
319
|
+
deleted: createdApp.deleted ?? false,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
config_1.AlgoKitConfig.logger.warn(`Received error trying to retrieve app with ${createdApp.id} for creator ${creatorAddress}; failing silently`, e);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
}));
|
|
328
|
+
return {
|
|
329
|
+
creator: creatorAddress,
|
|
330
|
+
apps: appLookup,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
exports.getCreatorAppsByName = getCreatorAppsByName;
|
|
334
|
+
/**
|
|
335
|
+
* Return the transaction note for an app deployment.
|
|
336
|
+
* @param metadata The metadata of the deployment
|
|
337
|
+
* @returns The transaction note as a utf-8 string
|
|
338
|
+
*/
|
|
339
|
+
function getAppDeploymentTransactionNote(metadata) {
|
|
340
|
+
return `${exports.APP_DEPLOY_NOTE_PREFIX}${JSON.stringify(metadata)}`;
|
|
341
|
+
}
|
|
342
|
+
exports.getAppDeploymentTransactionNote = getAppDeploymentTransactionNote;
|
|
343
|
+
/**
|
|
344
|
+
* Replaces deploy-time deployment control parameters within the given teal code.
|
|
345
|
+
*
|
|
346
|
+
* @see {UPDATABLE_TEMPLATE_NAME}
|
|
347
|
+
* @see {DELETABLE_TEMPLATE_NAME}
|
|
348
|
+
*
|
|
349
|
+
* @param tealCode The TEAL code to substitute
|
|
350
|
+
* @param params The deploy-time deployment control parameter value to replace
|
|
351
|
+
* @returns The replaced TEAL code
|
|
352
|
+
*/
|
|
353
|
+
function replaceDeployTimeControlParams(tealCode, params) {
|
|
354
|
+
if (params.updatable !== undefined) {
|
|
355
|
+
if (!tealCode.includes(exports.UPDATABLE_TEMPLATE_NAME)) {
|
|
356
|
+
throw new Error(`Deploy-time updatability control requested for app deployment, but ${exports.UPDATABLE_TEMPLATE_NAME} not present in TEAL code`);
|
|
357
|
+
}
|
|
358
|
+
tealCode = tealCode.replace(new RegExp(exports.UPDATABLE_TEMPLATE_NAME, 'g'), (params.updatable ? 1 : 0).toString());
|
|
359
|
+
}
|
|
360
|
+
if (params.deletable !== undefined) {
|
|
361
|
+
if (!tealCode.includes(exports.DELETABLE_TEMPLATE_NAME)) {
|
|
362
|
+
throw new Error(`Deploy-time deletability control requested for app deployment, but ${exports.DELETABLE_TEMPLATE_NAME} not present in TEAL code`);
|
|
363
|
+
}
|
|
364
|
+
tealCode = tealCode.replace(new RegExp(exports.DELETABLE_TEMPLATE_NAME, 'g'), (params.deletable ? 1 : 0).toString());
|
|
365
|
+
}
|
|
366
|
+
return tealCode;
|
|
367
|
+
}
|
|
368
|
+
exports.replaceDeployTimeControlParams = replaceDeployTimeControlParams;
|
|
369
|
+
/**
|
|
370
|
+
* Performs template substitution of a teal file.
|
|
371
|
+
*
|
|
372
|
+
* Looks for `TMPL_{parameter}` for template replacements.
|
|
373
|
+
*
|
|
374
|
+
* @param tealCode The TEAL logic to compile
|
|
375
|
+
* @param templateParameters Any parameters to replace in the .teal file before compiling
|
|
376
|
+
* @returns The TEAL code with replacements
|
|
377
|
+
*/
|
|
378
|
+
function performTemplateSubstitution(tealCode, templateParameters) {
|
|
379
|
+
if (templateParameters !== undefined) {
|
|
380
|
+
for (const key in templateParameters) {
|
|
381
|
+
const value = templateParameters[key];
|
|
382
|
+
const token = `TMPL_${key.replace(/^TMPL_/, '')}`;
|
|
383
|
+
// todo: handle uint8array
|
|
384
|
+
tealCode = tealCode.replace(new RegExp(token, 'g'), typeof value === 'string'
|
|
385
|
+
? `0x${Buffer.from(value, 'utf-8').toString('hex')}`
|
|
386
|
+
: ArrayBuffer.isView(value)
|
|
387
|
+
? `0x${Buffer.from(value).toString('hex')}`
|
|
388
|
+
: value.toString());
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return tealCode;
|
|
392
|
+
}
|
|
393
|
+
exports.performTemplateSubstitution = performTemplateSubstitution;
|
|
394
|
+
/**
|
|
395
|
+
* Performs template substitution of a teal file and compiles it, returning the compiled result.
|
|
396
|
+
*
|
|
397
|
+
* Looks for `TMPL_{parameter}` for template replacements.
|
|
398
|
+
*
|
|
399
|
+
* @param tealCode The TEAL logic to compile
|
|
400
|
+
* @param algod An algod client
|
|
401
|
+
* @param templateParameters Any parameters to replace in the .teal file before compiling
|
|
402
|
+
* @param deploymentMetadata The deployment metadata the app will be deployed with
|
|
403
|
+
* @returns The information about the compiled code
|
|
404
|
+
*/
|
|
405
|
+
async function performTemplateSubstitutionAndCompile(tealCode, algod, templateParameters, deploymentMetadata) {
|
|
406
|
+
tealCode = performTemplateSubstitution(tealCode, templateParameters);
|
|
407
|
+
if (deploymentMetadata) {
|
|
408
|
+
tealCode = replaceDeployTimeControlParams(tealCode, deploymentMetadata);
|
|
409
|
+
}
|
|
410
|
+
const compiled = await algod.compile(tealCode).do();
|
|
411
|
+
return {
|
|
412
|
+
teal: tealCode,
|
|
413
|
+
compiled: compiled.result,
|
|
414
|
+
compiledHash: compiled.hash,
|
|
415
|
+
compiledBase64ToBytes: new Uint8Array(Buffer.from(compiled.result, 'base64')),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
exports.performTemplateSubstitutionAndCompile = performTemplateSubstitutionAndCompile;
|
|
419
|
+
//# sourceMappingURL=deploy-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-app.js","sourceRoot":"","sources":["../src/deploy-app.ts"],"names":[],"mappings":";;;AAAA,qCAAkF;AAClF,+BAA8H;AAC9H,qCAAwC;AACxC,qDAA+F;AAC/F,+CAAqH;AA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,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACpD,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;oBAC3B,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;oBAC3C,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CACrB,CAAA;SACF;KACF;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAlBD,kEAkBC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,qCAAqC,CACzD,QAAgB,EAChB,KAAc,EACd,kBAA2C,EAC3C,kBAAsC;IAEtC,QAAQ,GAAG,2BAA2B,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAA;IAEpE,IAAI,kBAAkB,EAAE;QACtB,QAAQ,GAAG,8BAA8B,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAA;KACxE;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAA;IACnD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,YAAY,EAAE,QAAQ,CAAC,IAAI;QAC3B,qBAAqB,EAAE,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;KAC9E,CAAA;AACH,CAAC;AAnBD,sFAmBC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './account';
|
|
2
|
+
export * from './algo-amount';
|
|
3
|
+
export * from './app';
|
|
4
|
+
export * from './application-client';
|
|
5
|
+
export * from './config';
|
|
6
|
+
export * from './deploy-app';
|
|
7
|
+
export * from './indexer-lookup';
|
|
8
|
+
export * from './localnet';
|
|
9
|
+
export * from './network-client';
|
|
10
|
+
export * from './transaction';
|
|
11
|
+
export * from './transfer';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA"}
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,gDAA6B;AAC7B,wCAAqB;AACrB,uDAAoC;AACpC,2CAAwB;AACxB,+CAA4B;AAC5B,mDAAgC;AAChC,6CAA0B;AAC1B,mDAAgC;AAChC,gDAA6B;AAC7B,6CAA0B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Indexer } from 'algosdk';
|
|
2
|
+
import SearchForTransactions from 'algosdk/dist/types/client/v2/indexer/searchForTransactions';
|
|
3
|
+
import { ApplicationResult, TransactionLookupResult, TransactionSearchResults } from './types/indexer';
|
|
4
|
+
/**
|
|
5
|
+
* Looks up a transaction by ID using Indexer.
|
|
6
|
+
* @param indexer An indexer client
|
|
7
|
+
* @param transactionId The ID of the transaction to look up
|
|
8
|
+
* @returns The result of the look-up
|
|
9
|
+
*/
|
|
10
|
+
export declare function lookupTransactionById(transactionId: string, indexer: Indexer): Promise<TransactionLookupResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Looks up applications that were created by the given address.
|
|
13
|
+
* @param indexer An indexer instance
|
|
14
|
+
* @param address The address of the creator to look up
|
|
15
|
+
* @param getAll Whether or not to include deleted applications
|
|
16
|
+
* @param paginationLimit The number of records to return per paginated request, default @see {DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT}
|
|
17
|
+
* @returns The list of application results
|
|
18
|
+
*/
|
|
19
|
+
export declare function lookupAccountCreatedApplicationByAddress(indexer: Indexer, address: string, getAll?: boolean | undefined, paginationLimit?: number): Promise<ApplicationResult[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Allows transactions to be searched for the given criteria.
|
|
22
|
+
* @param indexer An indexer client
|
|
23
|
+
* @param searchCriteria The criteria to search for
|
|
24
|
+
* @param paginationLimit The number of records to return per paginated request, default @see {DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT}
|
|
25
|
+
* @returns The search results
|
|
26
|
+
*/
|
|
27
|
+
export declare function searchTransactions(indexer: Indexer, searchCriteria: (s: SearchForTransactions) => SearchForTransactions, paginationLimit?: number): Promise<TransactionSearchResults>;
|
|
28
|
+
export declare function executePaginatedRequest<TResult, TRequest extends {
|
|
29
|
+
do: () => Promise<any>;
|
|
30
|
+
}>(extractItems: (response: any) => TResult[], buildRequest: (nextToken?: string) => TRequest): Promise<TResult[]>;
|
|
31
|
+
//# sourceMappingURL=indexer-lookup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer-lookup.d.ts","sourceRoot":"","sources":["../src/indexer-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,qBAAqB,MAAM,4DAA4D,CAAA;AAC9F,OAAO,EAAkC,iBAAiB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAItI;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAErH;AAED;;;;;;;GAOG;AACH,wBAAsB,wCAAwC,CAC5D,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,OAAO,GAAG,SAAqB,EACvC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAmB9B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,qBAAqB,EACnE,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,wBAAwB,CAAC,CA0BnC;AAID,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,QAAQ,SAAS;IAAE,EAAE,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;CAAE,EAEhG,YAAY,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,EAAE,EAC1C,YAAY,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,QAAQ,GAC7C,OAAO,CAAC,OAAO,EAAE,CAAC,CAoBpB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executePaginatedRequest = exports.searchTransactions = exports.lookupAccountCreatedApplicationByAddress = exports.lookupTransactionById = void 0;
|
|
4
|
+
const DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT = 1000; //MaxAPIResourcesPerAccount: This is the default maximum, though may be provider specific
|
|
5
|
+
/**
|
|
6
|
+
* Looks up a transaction by ID using Indexer.
|
|
7
|
+
* @param indexer An indexer client
|
|
8
|
+
* @param transactionId The ID of the transaction to look up
|
|
9
|
+
* @returns The result of the look-up
|
|
10
|
+
*/
|
|
11
|
+
async function lookupTransactionById(transactionId, indexer) {
|
|
12
|
+
return (await indexer.lookupTransactionByID(transactionId).do());
|
|
13
|
+
}
|
|
14
|
+
exports.lookupTransactionById = lookupTransactionById;
|
|
15
|
+
/**
|
|
16
|
+
* Looks up applications that were created by the given address.
|
|
17
|
+
* @param indexer An indexer instance
|
|
18
|
+
* @param address The address of the creator to look up
|
|
19
|
+
* @param getAll Whether or not to include deleted applications
|
|
20
|
+
* @param paginationLimit The number of records to return per paginated request, default @see {DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT}
|
|
21
|
+
* @returns The list of application results
|
|
22
|
+
*/
|
|
23
|
+
async function lookupAccountCreatedApplicationByAddress(indexer, address, getAll = undefined, paginationLimit) {
|
|
24
|
+
return await executePaginatedRequest((response) => {
|
|
25
|
+
if ('message' in response) {
|
|
26
|
+
throw { status: 404, ...response };
|
|
27
|
+
}
|
|
28
|
+
return response.applications;
|
|
29
|
+
}, (nextToken) => {
|
|
30
|
+
let s = indexer
|
|
31
|
+
.lookupAccountCreatedApplications(address)
|
|
32
|
+
.includeAll(getAll)
|
|
33
|
+
.limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
34
|
+
if (nextToken) {
|
|
35
|
+
s = s.nextToken(nextToken);
|
|
36
|
+
}
|
|
37
|
+
return s;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.lookupAccountCreatedApplicationByAddress = lookupAccountCreatedApplicationByAddress;
|
|
41
|
+
/**
|
|
42
|
+
* Allows transactions to be searched for the given criteria.
|
|
43
|
+
* @param indexer An indexer client
|
|
44
|
+
* @param searchCriteria The criteria to search for
|
|
45
|
+
* @param paginationLimit The number of records to return per paginated request, default @see {DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT}
|
|
46
|
+
* @returns The search results
|
|
47
|
+
*/
|
|
48
|
+
async function searchTransactions(indexer, searchCriteria, paginationLimit) {
|
|
49
|
+
let currentRound = 0;
|
|
50
|
+
const txns = await executePaginatedRequest((response) => {
|
|
51
|
+
if ('message' in response) {
|
|
52
|
+
throw { status: 404, ...response };
|
|
53
|
+
}
|
|
54
|
+
if (Number(response['current-round']) > currentRound) {
|
|
55
|
+
currentRound = Number(response['current-round']);
|
|
56
|
+
}
|
|
57
|
+
return response.transactions;
|
|
58
|
+
}, (nextToken) => {
|
|
59
|
+
let s = searchCriteria(indexer.searchForTransactions()).limit(paginationLimit ?? DEFAULT_INDEXER_MAX_API_RESOURCES_PER_ACCOUNT);
|
|
60
|
+
if (nextToken) {
|
|
61
|
+
s = s.nextToken(nextToken);
|
|
62
|
+
}
|
|
63
|
+
return s;
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
'current-round': currentRound.toString(),
|
|
67
|
+
'next-token': '',
|
|
68
|
+
transactions: txns,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.searchTransactions = searchTransactions;
|
|
72
|
+
// https://developer.algorand.org/docs/get-details/indexer/#paginated-results
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
async function executePaginatedRequest(
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
extractItems, buildRequest) {
|
|
77
|
+
const results = [];
|
|
78
|
+
let nextToken = undefined;
|
|
79
|
+
// eslint-disable-next-line no-constant-condition
|
|
80
|
+
while (true) {
|
|
81
|
+
const request = buildRequest(nextToken);
|
|
82
|
+
const response = await request.do();
|
|
83
|
+
const items = extractItems(response);
|
|
84
|
+
if (items == null || items.length === 0) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
results.push(...items);
|
|
88
|
+
nextToken = response['next-token'];
|
|
89
|
+
if (!nextToken) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return results;
|
|
94
|
+
}
|
|
95
|
+
exports.executePaginatedRequest = executePaginatedRequest;
|
|
96
|
+
//# sourceMappingURL=indexer-lookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer-lookup.js","sourceRoot":"","sources":["../src/indexer-lookup.ts"],"names":[],"mappings":";;;AAIA,MAAM,6CAA6C,GAAG,IAAI,CAAA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