@algorandfoundation/algokit-utils 1.0.0-beta.8 → 1.0.0

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 (141) hide show
  1. package/account.d.ts +91 -0
  2. package/account.d.ts.map +1 -0
  3. package/account.js +158 -0
  4. package/account.js.map +1 -0
  5. package/amount.d.ts +8 -0
  6. package/amount.d.ts.map +1 -0
  7. package/amount.js +24 -0
  8. package/amount.js.map +1 -0
  9. package/app.d.ts +108 -0
  10. package/app.d.ts.map +1 -0
  11. package/app.js +423 -0
  12. package/app.js.map +1 -0
  13. package/application-client.d.ts +10 -0
  14. package/application-client.d.ts.map +1 -0
  15. package/application-client.js +15 -0
  16. package/application-client.js.map +1 -0
  17. package/deploy-app.d.ts +93 -0
  18. package/deploy-app.d.ts.map +1 -0
  19. package/deploy-app.js +410 -0
  20. package/deploy-app.js.map +1 -0
  21. package/index.d.ts +14 -0
  22. package/index.d.ts.map +1 -0
  23. package/index.js +5 -2
  24. package/index.js.map +1 -0
  25. package/indexer-lookup.d.ts +31 -0
  26. package/indexer-lookup.d.ts.map +1 -0
  27. package/indexer-lookup.js +96 -0
  28. package/indexer-lookup.js.map +1 -0
  29. package/localnet.d.ts +54 -0
  30. package/localnet.d.ts.map +1 -0
  31. package/localnet.js +121 -0
  32. package/localnet.js.map +1 -0
  33. package/network-client.d.ts +93 -0
  34. package/network-client.d.ts.map +1 -0
  35. package/network-client.js +182 -0
  36. package/network-client.js.map +1 -0
  37. package/package.json +3 -3
  38. package/testing/account.d.ts +14 -0
  39. package/testing/account.d.ts.map +1 -0
  40. package/testing/account.js +31 -0
  41. package/testing/account.js.map +1 -0
  42. package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
  43. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
  44. package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
  45. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
  46. package/testing/fixtures/algorand-fixture.d.ts +20 -0
  47. package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
  48. package/testing/fixtures/algorand-fixture.js +49 -0
  49. package/testing/fixtures/algorand-fixture.js.map +1 -0
  50. package/testing/fixtures/index.d.ts +3 -0
  51. package/testing/fixtures/index.d.ts.map +1 -0
  52. package/testing/fixtures/index.js +19 -0
  53. package/testing/fixtures/index.js.map +1 -0
  54. package/testing/index.d.ts +6 -0
  55. package/testing/index.d.ts.map +1 -0
  56. package/testing/index.js +22 -0
  57. package/testing/index.js.map +1 -0
  58. package/testing/indexer.d.ts +12 -0
  59. package/testing/indexer.d.ts.map +1 -0
  60. package/testing/indexer.js +39 -0
  61. package/testing/indexer.js.map +1 -0
  62. package/testing/test-logger.d.ts +39 -0
  63. package/testing/test-logger.d.ts.map +1 -0
  64. package/testing/test-logger.js +69 -0
  65. package/testing/test-logger.js.map +1 -0
  66. package/testing/transaction-logger.d.ts +29 -0
  67. package/testing/transaction-logger.d.ts.map +1 -0
  68. package/testing/transaction-logger.js +71 -0
  69. package/testing/transaction-logger.js.map +1 -0
  70. package/transaction.d.ts +80 -0
  71. package/transaction.d.ts.map +1 -0
  72. package/transaction.js +256 -0
  73. package/transaction.js.map +1 -0
  74. package/transfer.d.ts +21 -0
  75. package/transfer.d.ts.map +1 -0
  76. package/transfer.js +65 -0
  77. package/transfer.js.map +1 -0
  78. package/types/account.d.ts +52 -0
  79. package/types/account.d.ts.map +1 -0
  80. package/types/account.js +86 -0
  81. package/types/account.js.map +1 -0
  82. package/types/algo-http-client-with-retry.d.ts +14 -0
  83. package/types/algo-http-client-with-retry.d.ts.map +1 -0
  84. package/types/algo-http-client-with-retry.js +62 -0
  85. package/types/algo-http-client-with-retry.js.map +1 -0
  86. package/types/algod.d.ts +137 -0
  87. package/types/algod.d.ts.map +1 -0
  88. package/types/algod.js +3 -0
  89. package/types/algod.js.map +1 -0
  90. package/types/amount.d.ts +20 -0
  91. package/types/amount.d.ts.map +1 -0
  92. package/types/amount.js +37 -0
  93. package/types/amount.js.map +1 -0
  94. package/types/app.d.ts +279 -0
  95. package/types/app.d.ts.map +1 -0
  96. package/types/app.js +32 -0
  97. package/types/app.js.map +1 -0
  98. package/types/application-client.d.ts +229 -0
  99. package/types/application-client.d.ts.map +1 -0
  100. package/types/application-client.js +470 -0
  101. package/types/application-client.js.map +1 -0
  102. package/types/appspec.d.ts +77 -0
  103. package/types/appspec.d.ts.map +1 -0
  104. package/types/appspec.js +15 -0
  105. package/types/appspec.js.map +1 -0
  106. package/types/config.d.ts +15 -0
  107. package/types/config.d.ts.map +1 -0
  108. package/types/config.js +27 -0
  109. package/types/config.js.map +1 -0
  110. package/types/indexer.d.ts +313 -0
  111. package/types/indexer.d.ts.map +1 -0
  112. package/types/indexer.js +25 -0
  113. package/types/indexer.js.map +1 -0
  114. package/types/logging.d.ts +13 -0
  115. package/types/logging.d.ts.map +1 -0
  116. package/types/logging.js +27 -0
  117. package/types/logging.js.map +1 -0
  118. package/types/logic-error.d.ts +33 -0
  119. package/types/logic-error.d.ts.map +1 -0
  120. package/types/logic-error.js +46 -0
  121. package/types/logic-error.js.map +1 -0
  122. package/types/network-client.d.ts +11 -0
  123. package/types/network-client.d.ts.map +1 -0
  124. package/types/network-client.js +3 -0
  125. package/types/network-client.js.map +1 -0
  126. package/types/testing.d.ts +89 -0
  127. package/types/testing.d.ts.map +1 -0
  128. package/types/testing.js +3 -0
  129. package/types/testing.js.map +1 -0
  130. package/types/transaction.d.ts +67 -0
  131. package/types/transaction.d.ts.map +1 -0
  132. package/types/transaction.js +3 -0
  133. package/types/transaction.js.map +1 -0
  134. package/types/transfer.d.ts +32 -0
  135. package/types/transfer.d.ts.map +1 -0
  136. package/types/transfer.js +3 -0
  137. package/types/transfer.js.map +1 -0
  138. package/types/urlTokenBaseHTTPClient.d.ts +41 -0
  139. package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  140. package/types/urlTokenBaseHTTPClient.js +151 -0
  141. package/types/urlTokenBaseHTTPClient.js.map +1 -0
package/app.js ADDED
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.compileTeal = exports.getAppByIndex = exports.getAppArgsForTransaction = exports.decodeAppState = exports.getAppBoxValuesFromABIType = exports.getAppBoxValueFromABIType = exports.getAppBoxValues = exports.getAppBoxValue = exports.getAppBoxNames = exports.getAppLocalState = exports.getAppGlobalState = exports.getABIReturn = exports.callApp = exports.updateApp = exports.createApp = void 0;
27
+ const algosdk_1 = __importStar(require("algosdk"));
28
+ const buffer_1 = require("buffer");
29
+ const _1 = require("./");
30
+ const transaction_1 = require("./transaction");
31
+ const app_1 = require("./types/app");
32
+ /**
33
+ * Creates a smart contract app, returns the details of the created app.
34
+ * @param create The parameters to create the app with
35
+ * @param algod An algod client
36
+ * @returns The details of the created app, or the transaction to create it if `skipSending`
37
+ */
38
+ async function createApp(create, algod) {
39
+ const { from, approvalProgram: approval, clearStateProgram: clear, schema, note, transactionParams, args, ...sendParams } = create;
40
+ const compiledApproval = typeof approval === 'string' ? await compileTeal(approval, algod) : undefined;
41
+ const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : approval;
42
+ const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined;
43
+ const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear;
44
+ const transaction = algosdk_1.default.makeApplicationCreateTxnFromObject({
45
+ approvalProgram: approvalProgram,
46
+ clearProgram: clearProgram,
47
+ numLocalInts: schema.localInts,
48
+ numLocalByteSlices: schema.localByteSlices,
49
+ numGlobalInts: schema.globalInts,
50
+ numGlobalByteSlices: schema.globalByteSlices,
51
+ extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / app_1.APP_PAGE_MAX_SIZE),
52
+ onComplete: algosdk_1.default.OnApplicationComplete.NoOpOC,
53
+ suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
54
+ from: (0, transaction_1.getSenderAddress)(from),
55
+ note: (0, transaction_1.encodeTransactionNote)(note),
56
+ ...getAppArgsForTransaction(args),
57
+ rekeyTo: undefined,
58
+ });
59
+ const { confirmation } = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
60
+ if (confirmation) {
61
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
+ const appId = confirmation['application-index'];
63
+ _1.Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${(0, transaction_1.getSenderAddress)(from)}`);
64
+ return {
65
+ transaction,
66
+ confirmation,
67
+ appId,
68
+ appAddress: algosdk_1.default.getApplicationAddress(appId),
69
+ return: getABIReturn(args, confirmation),
70
+ compiledApproval,
71
+ compiledClear,
72
+ };
73
+ }
74
+ else {
75
+ return { transaction, appId: 0, appAddress: '', compiledApproval, compiledClear };
76
+ }
77
+ }
78
+ exports.createApp = createApp;
79
+ /**
80
+ * Updates a smart contract app.
81
+ * @param update The parameters to update the app with
82
+ * @param algod An algod client
83
+ * @returns The transaction
84
+ */
85
+ async function updateApp(update, algod) {
86
+ const { appId, from, approvalProgram: approval, clearStateProgram: clear, note, transactionParams, args, ...sendParams } = update;
87
+ const compiledApproval = typeof approval === 'string' ? await compileTeal(approval, algod) : undefined;
88
+ const approvalProgram = compiledApproval ? compiledApproval.compiledBase64ToBytes : approval;
89
+ const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined;
90
+ const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear;
91
+ const transaction = algosdk_1.default.makeApplicationUpdateTxnFromObject({
92
+ appIndex: appId,
93
+ approvalProgram: approvalProgram,
94
+ clearProgram: clearProgram,
95
+ suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
96
+ from: (0, transaction_1.getSenderAddress)(from),
97
+ note: (0, transaction_1.encodeTransactionNote)(note),
98
+ ...getAppArgsForTransaction(args),
99
+ rekeyTo: undefined,
100
+ });
101
+ _1.Config.getLogger(sendParams.suppressLog).debug(`Updating app ${appId}`);
102
+ const result = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
103
+ return {
104
+ ...result,
105
+ return: getABIReturn(args, result.confirmation),
106
+ compiledApproval,
107
+ compiledClear,
108
+ };
109
+ }
110
+ exports.updateApp = updateApp;
111
+ /**
112
+ * Issues a call to a given app.
113
+ * @param call The call details.
114
+ * @param algod An algod client
115
+ * @returns The result of the call
116
+ */
117
+ async function callApp(call, algod) {
118
+ const { appId, callType, from, args, note, transactionParams, ...sendParams } = call;
119
+ const appCallParams = {
120
+ appIndex: appId,
121
+ from: (0, transaction_1.getSenderAddress)(from),
122
+ suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
123
+ ...getAppArgsForTransaction(args),
124
+ note: (0, transaction_1.encodeTransactionNote)(note),
125
+ rekeyTo: undefined,
126
+ };
127
+ let transaction;
128
+ switch (callType) {
129
+ case 'optin':
130
+ transaction = algosdk_1.default.makeApplicationOptInTxnFromObject(appCallParams);
131
+ break;
132
+ case 'clearstate':
133
+ transaction = algosdk_1.default.makeApplicationClearStateTxnFromObject(appCallParams);
134
+ break;
135
+ case 'closeout':
136
+ transaction = algosdk_1.default.makeApplicationCloseOutTxnFromObject(appCallParams);
137
+ break;
138
+ case 'delete':
139
+ transaction = algosdk_1.default.makeApplicationDeleteTxnFromObject(appCallParams);
140
+ break;
141
+ case 'normal':
142
+ transaction = algosdk_1.default.makeApplicationNoOpTxnFromObject(appCallParams);
143
+ break;
144
+ }
145
+ const result = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
146
+ return {
147
+ ...result,
148
+ return: getABIReturn(args, result.confirmation),
149
+ };
150
+ }
151
+ exports.callApp = callApp;
152
+ function getABIReturn(args, confirmation) {
153
+ try {
154
+ if (!args || !('method' in args)) {
155
+ return undefined;
156
+ }
157
+ const method = 'txnCount' in args.method ? args.method : new algosdk_1.ABIMethod(args.method);
158
+ if (method.returns.type !== 'void' && confirmation) {
159
+ const logs = confirmation.logs || [];
160
+ if (logs.length === 0) {
161
+ throw new Error('App call transaction did not log a return value');
162
+ }
163
+ const lastLog = logs[logs.length - 1];
164
+ if (lastLog.byteLength < 4 || lastLog.slice(0, 4).toString() !== app_1.ABI_RETURN_PREFIX.toString()) {
165
+ throw new Error('App call transaction did not log a return value (ABI_RETURN_PREFIX not found)');
166
+ }
167
+ return {
168
+ rawReturnValue: new Uint8Array(lastLog.slice(4)),
169
+ returnValue: method.returns.type.decode(new Uint8Array(lastLog.slice(4))),
170
+ decodeError: undefined,
171
+ };
172
+ }
173
+ }
174
+ catch (e) {
175
+ return {
176
+ rawReturnValue: undefined,
177
+ returnValue: undefined,
178
+ decodeError: e,
179
+ };
180
+ }
181
+ return undefined;
182
+ }
183
+ exports.getABIReturn = getABIReturn;
184
+ /**
185
+ * Returns the current global state values for the given app ID
186
+ * @param appId The ID of the app return global state for
187
+ * @param algod An algod client instance
188
+ * @returns The current global state
189
+ */
190
+ async function getAppGlobalState(appId, algod) {
191
+ const appInfo = await getAppByIndex(appId, algod);
192
+ if (!appInfo.params || !appInfo.params['global-state']) {
193
+ throw new Error("Couldn't find global state");
194
+ }
195
+ return decodeAppState(appInfo.params['global-state']);
196
+ }
197
+ exports.getAppGlobalState = getAppGlobalState;
198
+ /**
199
+ * Returns the current global state values for the given app ID and account
200
+ * @param appId The ID of the app return global state for
201
+ * @param account Either the string address of an account or an account object for the account to get local state for the given app
202
+ * @param algod An algod client instance
203
+ * @returns The current local state for the given (app, account) combination
204
+ */
205
+ async function getAppLocalState(appId, account, algod) {
206
+ const accountAddress = typeof account === 'string' ? account : (0, transaction_1.getSenderAddress)(account);
207
+ const appInfo = await algod.accountApplicationInformation(accountAddress, appId).do();
208
+ if (!appInfo['app-local-state'] || !appInfo['app-local-state']['key-value']) {
209
+ throw new Error("Couldn't find local state");
210
+ }
211
+ return decodeAppState(appInfo['app-local-state']['key-value']);
212
+ }
213
+ exports.getAppLocalState = getAppLocalState;
214
+ /**
215
+ * Returns the names of the boxes for the given app.
216
+ * @param appId The ID of the app return box names for
217
+ * @param algod An algod client instance
218
+ * @returns The current box names
219
+ */
220
+ async function getAppBoxNames(appId, algod) {
221
+ const boxResult = await algod.getApplicationBoxes(appId).do();
222
+ return boxResult.boxes.map((b) => {
223
+ return {
224
+ nameRaw: b.name,
225
+ nameBase64: buffer_1.Buffer.from(b.name).toString('base64'),
226
+ name: buffer_1.Buffer.from(b.name).toString('utf-8'),
227
+ };
228
+ });
229
+ }
230
+ exports.getAppBoxNames = getAppBoxNames;
231
+ /**
232
+ * Returns the value of the given box name for the given app.
233
+ * @param appId The ID of the app return box names for
234
+ * @param boxName The name of the box to return either as a string, binary array or @see BoxName
235
+ * @param algod An algod client instance
236
+ * @returns The current box value as a byte array
237
+ */
238
+ async function getAppBoxValue(appId, boxName, algod) {
239
+ const name = typeof boxName === 'string' ? new Uint8Array(buffer_1.Buffer.from(boxName, 'utf-8')) : 'name' in boxName ? boxName.nameRaw : boxName;
240
+ const boxResult = await algod.getApplicationBoxByName(appId, name).do();
241
+ return boxResult.value;
242
+ }
243
+ exports.getAppBoxValue = getAppBoxValue;
244
+ /**
245
+ * Returns the value of the given box names for the given app.
246
+ * @param appId The ID of the app return box names for
247
+ * @param boxNames The names of the boxes to return either as a string, binary array or @see BoxName
248
+ * @param algod An algod client instance
249
+ * @returns The current box values as a byte array in the same order as the passed in box names
250
+ */
251
+ async function getAppBoxValues(appId, boxNames, algod) {
252
+ return await Promise.all(boxNames.map(async (boxName) => await getAppBoxValue(appId, boxName, algod)));
253
+ }
254
+ exports.getAppBoxValues = getAppBoxValues;
255
+ /**
256
+ * Returns the value of the given box name for the given app decoded based on the given ABI type.
257
+ * @param request The parameters for the box value request
258
+ * @param algod An algod client instance
259
+ * @returns The current box value as an ABI value
260
+ */
261
+ async function getAppBoxValueFromABIType(request, algod) {
262
+ const { appId, boxName, type } = request;
263
+ const value = await getAppBoxValue(appId, boxName, algod);
264
+ return type.decode(value);
265
+ }
266
+ exports.getAppBoxValueFromABIType = getAppBoxValueFromABIType;
267
+ /**
268
+ * Returns the value of the given box names for the given app decoded based on the given ABI type.
269
+ * @param request The parameters for the box value request
270
+ * @param algod An algod client instance
271
+ * @returns The current box values as an ABI value in the same order as the passed in box names
272
+ */
273
+ async function getAppBoxValuesFromABIType(request, algod) {
274
+ const { appId, boxNames, type } = request;
275
+ return await Promise.all(boxNames.map(async (boxName) => await getAppBoxValueFromABIType({ appId, boxName, type }, algod)));
276
+ }
277
+ exports.getAppBoxValuesFromABIType = getAppBoxValuesFromABIType;
278
+ // Converts an array of global-state or global-state-deltas to a more
279
+ // friendly generic object
280
+ function decodeAppState(state) {
281
+ const stateValues = {};
282
+ // Start with empty set
283
+ for (const stateVal of state) {
284
+ const keyBase64 = stateVal.key;
285
+ const keyRaw = buffer_1.Buffer.from(keyBase64, 'base64');
286
+ const key = keyRaw.toString('utf-8');
287
+ const tealValue = stateVal.value;
288
+ const dataTypeFlag = 'action' in tealValue ? tealValue.action : tealValue.type;
289
+ let valueBase64;
290
+ let valueRaw;
291
+ switch (dataTypeFlag) {
292
+ case 1:
293
+ valueBase64 = 'bytes' in tealValue ? tealValue.bytes : '';
294
+ valueRaw = buffer_1.Buffer.from(valueBase64, 'base64');
295
+ stateValues[key] = {
296
+ keyRaw,
297
+ keyBase64,
298
+ valueRaw: new Uint8Array(valueRaw),
299
+ valueBase64: valueBase64,
300
+ value: valueRaw.toString('utf-8'),
301
+ };
302
+ break;
303
+ case 2:
304
+ // eslint-disable-next-line no-case-declarations
305
+ const value = 'uint' in tealValue ? tealValue.uint : 0;
306
+ stateValues[key] = {
307
+ keyRaw,
308
+ keyBase64,
309
+ value,
310
+ };
311
+ break;
312
+ default:
313
+ throw new Error(`Received unknown state data type of ${dataTypeFlag}`);
314
+ }
315
+ }
316
+ return stateValues;
317
+ }
318
+ exports.decodeAppState = decodeAppState;
319
+ /** Returns the app args ready to load onto an app @see {Transaction} object */
320
+ function getAppArgsForTransaction(args) {
321
+ if (!args)
322
+ return undefined;
323
+ let actualArgs;
324
+ if ('method' in args) {
325
+ // todo: Land a change to algosdk that extracts the logic from ATC, because (fair warning) this is a HACK
326
+ // I don't want to have to rewrite all of the ABI resolution logic so using an ATC temporarily here
327
+ // and passing stuff in to keep it happy like a randomly generated account :O
328
+ // Most of these values aren't being used since the transaction is discarded
329
+ const dummyAtc = new algosdk_1.AtomicTransactionComposer();
330
+ const dummyAccount = algosdk_1.default.generateAccount();
331
+ const dummySigner = (0, algosdk_1.makeBasicAccountTransactionSigner)(dummyAccount);
332
+ const dummyAppId = 1;
333
+ const dummyParams = {
334
+ fee: 1,
335
+ firstRound: 1,
336
+ genesisHash: buffer_1.Buffer.from('abcd', 'utf-8').toString('base64'),
337
+ genesisID: 'a',
338
+ lastRound: 1,
339
+ };
340
+ const methodArgs = args.args?.map((a) => {
341
+ if (typeof a !== 'object') {
342
+ return a;
343
+ }
344
+ // Handle the various forms of transactions to wrangle them for ATC
345
+ return 'txn' in a
346
+ ? a
347
+ : 'transaction' in a
348
+ ? { txn: a.transaction, signer: dummySigner }
349
+ : 'txID' in a
350
+ ? { txn: a, signer: dummySigner }
351
+ : a;
352
+ });
353
+ const dummyOnComplete = algosdk_1.OnApplicationComplete.NoOpOC;
354
+ dummyAtc.addMethodCall({
355
+ method: 'txnCount' in args.method ? args.method : new algosdk_1.ABIMethod(args.method),
356
+ methodArgs,
357
+ // Rest are dummy values
358
+ appID: dummyAppId,
359
+ sender: dummyAccount.addr,
360
+ signer: dummySigner,
361
+ suggestedParams: dummyParams,
362
+ onComplete: dummyOnComplete,
363
+ });
364
+ const txns = dummyAtc.buildGroup();
365
+ const txn = txns[txns.length - 1];
366
+ actualArgs = {
367
+ accounts: txn.txn.appAccounts,
368
+ appArgs: txn.txn.appArgs,
369
+ apps: txn.txn.appForeignApps,
370
+ assets: txn.txn.appForeignAssets,
371
+ boxes: args.boxes?.map((b) => (typeof b === 'object' && 'appId' in b ? b : { appId: 0, name: b })),
372
+ lease: args.lease,
373
+ };
374
+ }
375
+ else {
376
+ actualArgs = args;
377
+ }
378
+ const encoder = new TextEncoder();
379
+ return {
380
+ accounts: actualArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk_1.default.encodeAddress(a.publicKey))),
381
+ appArgs: actualArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a)),
382
+ boxes: actualArgs?.boxes
383
+ ?.map((b) => (typeof b === 'object' && 'appId' in b ? b : { appId: 0, name: b }))
384
+ ?.map((ref) => ({
385
+ appIndex: ref.appId,
386
+ name: typeof ref.name === 'string' ? encoder.encode(ref.name) : ref.name,
387
+ })),
388
+ foreignApps: actualArgs?.apps,
389
+ foreignAssets: actualArgs?.assets,
390
+ lease: typeof actualArgs?.lease === 'string' ? encoder.encode(actualArgs?.lease) : actualArgs?.lease,
391
+ };
392
+ }
393
+ exports.getAppArgsForTransaction = getAppArgsForTransaction;
394
+ /**
395
+ * Gets the current data for the given app from algod.
396
+ *
397
+ * @param appId The id of the app
398
+ * @param algod An algod client
399
+ * @returns The data about the app
400
+ */
401
+ async function getAppByIndex(appId, algod) {
402
+ return (await algod.getApplicationByID(appId).do());
403
+ }
404
+ exports.getAppByIndex = getAppByIndex;
405
+ /**
406
+ * Compiles the given TEAL using algod and returns the result.
407
+ *
408
+ * @param algod An algod client
409
+ * @param tealCode The TEAL code
410
+ * @returns The information about the compiled file
411
+ */
412
+ async function compileTeal(tealCode, algod) {
413
+ const compiled = await algod.compile(tealCode).sourcemap(true).do();
414
+ return {
415
+ teal: tealCode,
416
+ compiled: compiled.result,
417
+ compiledHash: compiled.hash,
418
+ compiledBase64ToBytes: new Uint8Array(buffer_1.Buffer.from(compiled.result, 'base64')),
419
+ sourceMap: new algosdk_1.SourceMap(compiled['sourcemap']),
420
+ };
421
+ }
422
+ exports.compileTeal = compileTeal;
423
+ //# sourceMappingURL=app.js.map
package/app.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDASgB;AAChB,mCAA+B;AAC/B,yBAA2B;AAC3B,+CAA8G;AAE9G,qCAgBoB;AAGpB;;;;;GAKG;AACI,KAAK,UAAU,SAAS,CAC7B,MAAuB,EACvB,KAAc;IAEd,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAA;IAElI,MAAM,gBAAgB,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACtG,MAAM,eAAe,GAAG,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC5F,MAAM,a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AED;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAAC,KAAa,EAAE,KAAc;IAC/D,OAAO,CAAC,MAAM,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAwB,CAAA;AAC5E,CAAC;AAFD,sCAEC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,KAAc;IAChE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAA;IACnE,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,YAAY,EAAE,QAAQ,CAAC,IAAI;QAC3B,qBAAqB,EAAE,IAAI,UAAU,CAAC,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC7E,SAAS,EAAE,IAAI,mBAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;KAChD,CAAA;AACH,CAAC;AATD,kCASC"}
@@ -0,0 +1,10 @@
1
+ import { Algodv2 } from 'algosdk';
2
+ import { ApplicationClient, AppSpecAppDetails } from './types/application-client';
3
+ /**
4
+ * Create a new ApplicationClient instance
5
+ * @param appDetails The details of the app
6
+ * @param algod An algod instance
7
+ * @returns The application client
8
+ */
9
+ export declare function getApplicationClient(appDetails: AppSpecAppDetails, algod: Algodv2): ApplicationClient;
10
+ //# sourceMappingURL=application-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-client.d.ts","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAEjF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,qBAEjF"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApplicationClient = void 0;
4
+ const application_client_1 = require("./types/application-client");
5
+ /**
6
+ * Create a new ApplicationClient instance
7
+ * @param appDetails The details of the app
8
+ * @param algod An algod instance
9
+ * @returns The application client
10
+ */
11
+ function getApplicationClient(appDetails, algod) {
12
+ return new application_client_1.ApplicationClient(appDetails, algod);
13
+ }
14
+ exports.getApplicationClient = getApplicationClient;
15
+ //# sourceMappingURL=application-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-client.js","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":";;;AACA,mEAAiF;AAEjF;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,UAA6B,EAAE,KAAc;IAChF,OAAO,IAAI,sCAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AACjD,CAAC;AAFD,oDAEC"}
@@ -0,0 +1,93 @@
1
+ import { Algodv2, Indexer } from 'algosdk';
2
+ import { ApplicationStateSchema } from './types/algod';
3
+ import { AppCompilationResult, AppDeploymentParams, AppDeployMetadata, AppLookup, AppMetadata, CompiledTeal, TealTemplateParams } from './types/app';
4
+ import { ConfirmedTransactionResult, SendTransactionFrom } from './types/transaction';
5
+ /**
6
+ * Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
7
+ *
8
+ * 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
9
+ *
10
+ * **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`.
11
+ *
12
+ * **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.
13
+ *
14
+ * **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.
15
+ * @param deployment The arguments to control the app deployment
16
+ * @param algod An algod client
17
+ * @param indexer An indexer client, needed if `existingDeployments` not passed in
18
+ * @returns The app reference of the new/existing app
19
+ */
20
+ export declare function deployApp(deployment: AppDeploymentParams, algod: Algodv2, indexer?: Indexer): Promise<Partial<AppCompilationResult> & ((ConfirmedTransactionResult & AppMetadata & {
21
+ operationPerformed: 'create' | 'update';
22
+ }) | (ConfirmedTransactionResult & AppMetadata & {
23
+ deleteResult: ConfirmedTransactionResult;
24
+ operationPerformed: 'replace';
25
+ }) | (AppMetadata & {
26
+ operationPerformed: 'nothing';
27
+ }))>;
28
+ /** Returns true is there is a breaking change in the application state schema from before to after.
29
+ * i.e. if the schema becomes larger, since applications can't ask for more schema after creation.
30
+ * Otherwise, there is no error, the app just doesn't store data in the extra schema :(
31
+ *
32
+ * @param before The existing schema
33
+ * @param after The new schema
34
+ * @returns Whether or not there is a breaking change
35
+ */
36
+ export declare function isSchemaIsBroken(before: ApplicationStateSchema, after: ApplicationStateSchema): boolean;
37
+ /**
38
+ * 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.
39
+ *
40
+ * **Note:** It's recommended this is only called once and then stored since it's a somewhat expensive operation (multiple indexer calls).
41
+ *
42
+ * @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
43
+ * @param indexer An indexer client
44
+ * @returns A name-based lookup of the app information (id, address)
45
+ */
46
+ export declare function getCreatorAppsByName(creatorAccount: SendTransactionFrom | string, indexer: Indexer): Promise<AppLookup>;
47
+ /**
48
+ * Return the transaction note for an app deployment.
49
+ * @param metadata The metadata of the deployment
50
+ * @returns The transaction note as a utf-8 string
51
+ */
52
+ export declare function getAppDeploymentTransactionNote(metadata: AppDeployMetadata): {
53
+ dAppName: string;
54
+ data: AppDeployMetadata;
55
+ format: string;
56
+ };
57
+ /**
58
+ * Replaces deploy-time deployment control parameters within the given teal code.
59
+ *
60
+ * @see {UPDATABLE_TEMPLATE_NAME}
61
+ * @see {DELETABLE_TEMPLATE_NAME}
62
+ *
63
+ * @param tealCode The TEAL code to substitute
64
+ * @param params The deploy-time deployment control parameter value to replace
65
+ * @returns The replaced TEAL code
66
+ */
67
+ export declare function replaceDeployTimeControlParams(tealCode: string, params: {
68
+ updatable?: boolean;
69
+ deletable?: boolean;
70
+ }): string;
71
+ /**
72
+ * Performs template substitution of a teal file.
73
+ *
74
+ * Looks for `TMPL_{parameter}` for template replacements.
75
+ *
76
+ * @param tealCode The TEAL logic to compile
77
+ * @param templateParams Any parameters to replace in the .teal file before compiling
78
+ * @returns The TEAL code with replacements
79
+ */
80
+ export declare function performTemplateSubstitution(tealCode: string, templateParams?: TealTemplateParams): string;
81
+ /**
82
+ * Performs template substitution of a teal file and compiles it, returning the compiled result.
83
+ *
84
+ * Looks for `TMPL_{parameter}` for template replacements.
85
+ *
86
+ * @param tealCode The TEAL logic to compile
87
+ * @param algod An algod client
88
+ * @param templateParams Any parameters to replace in the .teal file before compiling
89
+ * @param deploymentMetadata The deployment metadata the app will be deployed with
90
+ * @returns The information about the compiled code
91
+ */
92
+ export declare function performTemplateSubstitutionAndCompile(tealCode: string, algod: Algodv2, templateParams?: TealTemplateParams, deploymentMetadata?: AppDeployMetadata): Promise<CompiledTeal>;
93
+ //# sourceMappingURL=deploy-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-app.d.ts","sourceRoot":"","sources":["../src/deploy-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyB,OAAO,EAAmB,MAAM,SAAS,CAAA;AAKlF,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,WAAW,EAEX,YAAY,EAIZ,kBAAkB,EAEnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,0BAA0B,EAAE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