@d13co/escreg-sdk 0.0.1

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.
@@ -0,0 +1,1182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EscregClient = exports.EscregParamsFactory = exports.APP_SPEC = void 0;
4
+ exports.AddressWithAuthFromTuple = AddressWithAuthFromTuple;
5
+ const app_arc56_1 = require("@algorandfoundation/algokit-utils/types/app-arc56");
6
+ const app_client_1 = require("@algorandfoundation/algokit-utils/types/app-client");
7
+ exports.APP_SPEC = { "name": "Escreg", "structs": { "AddressWithAuth": [{ "name": "appId", "type": "uint64" }, { "name": "authAppId", "type": "uint64" }] }, "methods": [{ "name": "deleteApplication", "args": [], "returns": { "type": "void" }, "actions": { "create": [], "call": ["DeleteApplication"] }, "readonly": false, "desc": "Delete the application.", "events": [], "recommendations": {} }, { "name": "updateApplication", "args": [], "returns": { "type": "void" }, "actions": { "create": [], "call": ["UpdateApplication"] }, "readonly": false, "desc": "Update the application.", "events": [], "recommendations": {} }, { "name": "withdraw", "args": [{ "type": "uint64", "name": "amount", "desc": "Amount of microAlgos to withdraw." }], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "Withdraw funds from the contract to the admin.", "events": [], "recommendations": {} }, { "name": "deleteBoxes", "args": [{ "type": "byte[4][]", "name": "boxKeys", "desc": "Array of 4-byte box keys to delete." }], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "Delete app registry boxes by their keys.", "events": [], "recommendations": {} }, { "name": "register", "args": [{ "type": "uint64", "name": "appId", "desc": "App ID of the application to register. The app address derived from this ID will be registered in the contract and can be retrieved later." }], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "Register a single application escrow account", "events": [], "recommendations": {} }, { "name": "registerList", "args": [{ "type": "uint64[]", "name": "appIds", "desc": "Array of App IDs to register. The app addresses derived from these IDs will be registered in the contract and can be retrieved later." }], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "Register multiple application escrow accounts in a single transaction. This is more efficient than calling register multiple times as the MBR cost can be paid for in a single payment and the app IDs can be stored more efficiently in the contract state.", "events": [], "recommendations": {} }, { "name": "exists", "args": [{ "type": "address", "name": "address", "desc": "App Escrow to check" }], "returns": { "type": "bool", "desc": "boolean indicating whether the given address is registered in the contract" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Return true if an app escrow account exists for the given address, false otherwise.", "events": [], "recommendations": {} }, { "name": "get", "args": [{ "type": "address", "name": "address", "desc": "App Escrow to get the app ID for" }], "returns": { "type": "uint64", "desc": "App ID for the given address, or 0 if not registered" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Get the app ID for the given app escrow address. Returns 0 if the app escrow is not registered in the contract.", "events": [], "recommendations": {} }, { "name": "mustGet", "args": [{ "type": "address", "name": "address", "desc": "App Escrow to get the app ID for" }], "returns": { "type": "uint64", "desc": "App ID for the given address" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Get the app ID for the given app escrow address. Throws an error if the app escrow is not registered in the contract.", "events": [], "recommendations": {} }, { "name": "getWithAuth", "args": [{ "type": "address", "name": "address", "desc": "App Escrow to get the app ID for, along with its auth address" }], "returns": { "type": "(uint64,uint64)", "struct": "AddressWithAuth", "desc": "[app ID for the given address, app ID for the auth address], or 0 for each if not registered" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Get the app ID for the given app escrow address and its auth address. Returns 0 for each if not registered in the contract.", "events": [], "recommendations": {} }, { "name": "getWithAuthList", "args": [{ "type": "address[]", "name": "addresses", "desc": "App Escrows to get the app IDs for, along with their auth addresses" }], "returns": { "type": "(uint64,uint64)[]", "desc": "Array of [app ID for the given address, app ID for the auth address] for each input address, or 0 for each if not registered" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Get the app ID for multiple app escrow addresses and their auth addresses. Returns 0 for each if not registered in the contract.", "events": [], "recommendations": {} }, { "name": "getList", "args": [{ "type": "address[]", "name": "addresses", "desc": "App Escrows to get the app IDs for" }], "returns": { "type": "uint64[]", "desc": "Array of app IDs for each input address, or 0 if not registered" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Get the app IDs for multiple app escrow addresses. Returns 0 for each if not registered in the contract.", "events": [], "recommendations": {} }, { "name": "mustGetList", "args": [{ "type": "address[]", "name": "addresses", "desc": "App Escrows to get the app IDs for" }], "returns": { "type": "uint64[]", "desc": "Array of app IDs for each input address" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": true, "desc": "Get the app IDs for multiple app escrow addresses. Throws an error if any of the app escrows are not registered in the contract.", "events": [], "recommendations": {} }, { "name": "increaseBudget", "args": [{ "type": "uint64", "name": "itxns", "desc": "Number of itxns to perform." }], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "Utility for explicitly increasing the budget of a transaction group by performing no-op inner transactions.", "events": [], "recommendations": {} }, { "name": "depositCredits", "args": [{ "type": "address", "name": "creditor", "desc": "account to credit" }, { "type": "pay", "name": "txn", "desc": "payment transaction to contract. amount is the credit received" }], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "public method to deposit MBR credits for an account", "events": [], "recommendations": {} }, { "name": "withdrawCredits", "args": [], "returns": { "type": "void" }, "actions": { "create": [], "call": ["NoOp"] }, "readonly": false, "desc": "Withdraw all remaining MBR credits for sender. This will delete the user credit box, so all credits are withdrawn including the MBR locked for the box itself.", "events": [], "recommendations": {} }], "arcs": [22, 28], "networks": {}, "state": { "schema": { "global": { "ints": 32, "bytes": 32 }, "local": { "ints": 0, "bytes": 0 } }, "keys": { "global": { "admin": { "keyType": "AVMString", "valueType": "address", "key": "YWRtaW4=", "desc": "Contract admin" }, "counter": { "keyType": "AVMString", "valueType": "AVMUint64", "key": "Y291bnRlcg==", "desc": "Counter for the number of registered applications" } }, "local": {}, "box": {} }, "maps": { "global": {}, "local": {}, "box": { "apps": { "keyType": "AVMBytes", "valueType": "uint64[]", "desc": "BoxMap from 4-byte prefix of escrow to app IDs", "prefix": "" }, "userCredits": { "keyType": "address", "valueType": "uint64", "prefix": "Yw==" } } } }, "bareActions": { "create": ["NoOp"], "call": [] }, "sourceInfo": { "approval": { "sourceInfo": [{ "pc": [557, 613, 664, 732, 790, 888, 946, 1103, 1223, 1390, 1439, 1518, 1715, 1783], "errorMessage": "Box must have value" }, { "pc": [242], "errorMessage": "OnCompletion must be DeleteApplication && can only call when not creating" }, { "pc": [113], "errorMessage": "OnCompletion must be NoOp" }, { "pc": [253], "errorMessage": "OnCompletion must be NoOp && can only call when creating" }, { "pc": [230], "errorMessage": "OnCompletion must be UpdateApplication && can only call when not creating" }, { "pc": [369, 428, 751, 907, 1396, 1419, 1451, 1677], "errorMessage": "account funded" }, { "pc": [330, 383, 465, 1479, 1602], "errorMessage": "check GlobalState exists" }, { "pc": [317, 846, 1028, 1180], "errorMessage": "index access is out of bounds" }, { "pc": [298, 430, 825, 1007, 1159, 1617], "errorMessage": "invalid array length header" }, { "pc": [1337], "errorMessage": "invalid number of bytes for arc4.static_array<arc4.uint8, 32>" }, { "pc": [967, 1076, 1121, 1253, 1577], "errorMessage": "max array length exceeded" }, { "pc": [1348], "errorMessage": "transaction type is pay" }], "pcOffsetMethod": "none" }, "clear": { "sourceInfo": [], "pcOffsetMethod": "none" } }, "events": [] };
8
+ class BinaryStateValue {
9
+ constructor(value) {
10
+ this.value = value;
11
+ }
12
+ asByteArray() {
13
+ return this.value;
14
+ }
15
+ asString() {
16
+ return this.value !== undefined ? Buffer.from(this.value).toString('utf-8') : undefined;
17
+ }
18
+ }
19
+ /**
20
+ * Converts the ABI tuple representation of a AddressWithAuth to the struct representation
21
+ */
22
+ function AddressWithAuthFromTuple(abiTuple) {
23
+ return (0, app_arc56_1.getABIStructFromABITuple)(abiTuple, exports.APP_SPEC.structs.AddressWithAuth, exports.APP_SPEC.structs);
24
+ }
25
+ /**
26
+ * Exposes methods for constructing `AppClient` params objects for ABI calls to the Escreg smart contract
27
+ */
28
+ class EscregParamsFactory {
29
+ /**
30
+ * Constructs a no op call for the withdraw(uint64)void ABI method
31
+ *
32
+ * Withdraw funds from the contract to the admin.
33
+ *
34
+ * @param params Parameters for the call
35
+ * @returns An `AppClientMethodCallParams` object for the call
36
+ */
37
+ static withdraw(params) {
38
+ return {
39
+ ...params,
40
+ method: 'withdraw(uint64)void',
41
+ args: Array.isArray(params.args) ? params.args : [params.args.amount],
42
+ };
43
+ }
44
+ /**
45
+ * Constructs a no op call for the deleteBoxes(byte[4][])void ABI method
46
+ *
47
+ * Delete app registry boxes by their keys.
48
+ *
49
+ * @param params Parameters for the call
50
+ * @returns An `AppClientMethodCallParams` object for the call
51
+ */
52
+ static deleteBoxes(params) {
53
+ return {
54
+ ...params,
55
+ method: 'deleteBoxes(byte[4][])void',
56
+ args: Array.isArray(params.args) ? params.args : [params.args.boxKeys],
57
+ };
58
+ }
59
+ /**
60
+ * Constructs a no op call for the register(uint64)void ABI method
61
+ *
62
+ * Register a single application escrow account
63
+ *
64
+ * @param params Parameters for the call
65
+ * @returns An `AppClientMethodCallParams` object for the call
66
+ */
67
+ static register(params) {
68
+ return {
69
+ ...params,
70
+ method: 'register(uint64)void',
71
+ args: Array.isArray(params.args) ? params.args : [params.args.appId],
72
+ };
73
+ }
74
+ /**
75
+ * Constructs a no op call for the registerList(uint64[])void ABI method
76
+ *
77
+ * Register multiple application escrow accounts in a single transaction. This is more efficient than calling register multiple times as the MBR cost can be paid for in a single payment and the app IDs can be stored more efficiently in the contract state.
78
+ *
79
+ * @param params Parameters for the call
80
+ * @returns An `AppClientMethodCallParams` object for the call
81
+ */
82
+ static registerList(params) {
83
+ return {
84
+ ...params,
85
+ method: 'registerList(uint64[])void',
86
+ args: Array.isArray(params.args) ? params.args : [params.args.appIds],
87
+ };
88
+ }
89
+ /**
90
+ * Constructs a no op call for the exists(address)bool ABI method
91
+ *
92
+ * Return true if an app escrow account exists for the given address, false otherwise.
93
+ *
94
+ * @param params Parameters for the call
95
+ * @returns An `AppClientMethodCallParams` object for the call
96
+ */
97
+ static exists(params) {
98
+ return {
99
+ ...params,
100
+ method: 'exists(address)bool',
101
+ args: Array.isArray(params.args) ? params.args : [params.args.address],
102
+ };
103
+ }
104
+ /**
105
+ * Constructs a no op call for the get(address)uint64 ABI method
106
+ *
107
+ * Get the app ID for the given app escrow address. Returns 0 if the app escrow is not registered in the contract.
108
+ *
109
+ * @param params Parameters for the call
110
+ * @returns An `AppClientMethodCallParams` object for the call
111
+ */
112
+ static get(params) {
113
+ return {
114
+ ...params,
115
+ method: 'get(address)uint64',
116
+ args: Array.isArray(params.args) ? params.args : [params.args.address],
117
+ };
118
+ }
119
+ /**
120
+ * Constructs a no op call for the mustGet(address)uint64 ABI method
121
+ *
122
+ * Get the app ID for the given app escrow address. Throws an error if the app escrow is not registered in the contract.
123
+ *
124
+ * @param params Parameters for the call
125
+ * @returns An `AppClientMethodCallParams` object for the call
126
+ */
127
+ static mustGet(params) {
128
+ return {
129
+ ...params,
130
+ method: 'mustGet(address)uint64',
131
+ args: Array.isArray(params.args) ? params.args : [params.args.address],
132
+ };
133
+ }
134
+ /**
135
+ * Constructs a no op call for the getWithAuth(address)(uint64,uint64) ABI method
136
+ *
137
+ * Get the app ID for the given app escrow address and its auth address. Returns 0 for each if not registered in the contract.
138
+ *
139
+ * @param params Parameters for the call
140
+ * @returns An `AppClientMethodCallParams` object for the call
141
+ */
142
+ static getWithAuth(params) {
143
+ return {
144
+ ...params,
145
+ method: 'getWithAuth(address)(uint64,uint64)',
146
+ args: Array.isArray(params.args) ? params.args : [params.args.address],
147
+ };
148
+ }
149
+ /**
150
+ * Constructs a no op call for the getWithAuthList(address[])(uint64,uint64)[] ABI method
151
+ *
152
+ * Get the app ID for multiple app escrow addresses and their auth addresses. Returns 0 for each if not registered in the contract.
153
+ *
154
+ * @param params Parameters for the call
155
+ * @returns An `AppClientMethodCallParams` object for the call
156
+ */
157
+ static getWithAuthList(params) {
158
+ return {
159
+ ...params,
160
+ method: 'getWithAuthList(address[])(uint64,uint64)[]',
161
+ args: Array.isArray(params.args) ? params.args : [params.args.addresses],
162
+ };
163
+ }
164
+ /**
165
+ * Constructs a no op call for the getList(address[])uint64[] ABI method
166
+ *
167
+ * Get the app IDs for multiple app escrow addresses. Returns 0 for each if not registered in the contract.
168
+ *
169
+ * @param params Parameters for the call
170
+ * @returns An `AppClientMethodCallParams` object for the call
171
+ */
172
+ static getList(params) {
173
+ return {
174
+ ...params,
175
+ method: 'getList(address[])uint64[]',
176
+ args: Array.isArray(params.args) ? params.args : [params.args.addresses],
177
+ };
178
+ }
179
+ /**
180
+ * Constructs a no op call for the mustGetList(address[])uint64[] ABI method
181
+ *
182
+ * Get the app IDs for multiple app escrow addresses. Throws an error if any of the app escrows are not registered in the contract.
183
+ *
184
+ * @param params Parameters for the call
185
+ * @returns An `AppClientMethodCallParams` object for the call
186
+ */
187
+ static mustGetList(params) {
188
+ return {
189
+ ...params,
190
+ method: 'mustGetList(address[])uint64[]',
191
+ args: Array.isArray(params.args) ? params.args : [params.args.addresses],
192
+ };
193
+ }
194
+ /**
195
+ * Constructs a no op call for the increaseBudget(uint64)void ABI method
196
+ *
197
+ * Utility for explicitly increasing the budget of a transaction group by performing no-op inner transactions.
198
+ *
199
+ * @param params Parameters for the call
200
+ * @returns An `AppClientMethodCallParams` object for the call
201
+ */
202
+ static increaseBudget(params) {
203
+ return {
204
+ ...params,
205
+ method: 'increaseBudget(uint64)void',
206
+ args: Array.isArray(params.args) ? params.args : [params.args.itxns],
207
+ };
208
+ }
209
+ /**
210
+ * Constructs a no op call for the depositCredits(address,pay)void ABI method
211
+ *
212
+ * public method to deposit MBR credits for an account
213
+ *
214
+ * @param params Parameters for the call
215
+ * @returns An `AppClientMethodCallParams` object for the call
216
+ */
217
+ static depositCredits(params) {
218
+ return {
219
+ ...params,
220
+ method: 'depositCredits(address,pay)void',
221
+ args: Array.isArray(params.args) ? params.args : [params.args.creditor, params.args.txn],
222
+ };
223
+ }
224
+ /**
225
+ * Constructs a no op call for the withdrawCredits()void ABI method
226
+ *
227
+ * Withdraw all remaining MBR credits for sender. This will delete the user credit box, so all credits are withdrawn including the MBR locked for the box itself.
228
+ *
229
+ * @param params Parameters for the call
230
+ * @returns An `AppClientMethodCallParams` object for the call
231
+ */
232
+ static withdrawCredits(params) {
233
+ return {
234
+ ...params,
235
+ method: 'withdrawCredits()void',
236
+ args: Array.isArray(params.args) ? params.args : [],
237
+ };
238
+ }
239
+ }
240
+ exports.EscregParamsFactory = EscregParamsFactory;
241
+ /**
242
+ * A client to make calls to the Escreg smart contract
243
+ */
244
+ class EscregClient {
245
+ constructor(appClientOrParams) {
246
+ /**
247
+ * Get parameters to create transactions for the current app. A good mental model for this is that these parameters represent a deferred transaction creation.
248
+ */
249
+ this.params = {
250
+ /**
251
+ * Makes a clear_state call to an existing instance of the Escreg smart contract.
252
+ *
253
+ * @param params The params for the bare (raw) call
254
+ * @returns The clearState result
255
+ */
256
+ clearState: (params) => {
257
+ return this.appClient.params.bare.clearState(params);
258
+ },
259
+ /**
260
+ * Makes a call to the Escreg smart contract using the `withdraw(uint64)void` ABI method.
261
+ *
262
+ * Withdraw funds from the contract to the admin.
263
+ *
264
+ * @param params The params for the smart contract call
265
+ * @returns The call params
266
+ */
267
+ withdraw: (params) => {
268
+ return this.appClient.params.call(EscregParamsFactory.withdraw(params));
269
+ },
270
+ /**
271
+ * Makes a call to the Escreg smart contract using the `deleteBoxes(byte[4][])void` ABI method.
272
+ *
273
+ * Delete app registry boxes by their keys.
274
+ *
275
+ * @param params The params for the smart contract call
276
+ * @returns The call params
277
+ */
278
+ deleteBoxes: (params) => {
279
+ return this.appClient.params.call(EscregParamsFactory.deleteBoxes(params));
280
+ },
281
+ /**
282
+ * Makes a call to the Escreg smart contract using the `register(uint64)void` ABI method.
283
+ *
284
+ * Register a single application escrow account
285
+ *
286
+ * @param params The params for the smart contract call
287
+ * @returns The call params
288
+ */
289
+ register: (params) => {
290
+ return this.appClient.params.call(EscregParamsFactory.register(params));
291
+ },
292
+ /**
293
+ * Makes a call to the Escreg smart contract using the `registerList(uint64[])void` ABI method.
294
+ *
295
+ * Register multiple application escrow accounts in a single transaction. This is more efficient than calling register multiple times as the MBR cost can be paid for in a single payment and the app IDs can be stored more efficiently in the contract state.
296
+ *
297
+ * @param params The params for the smart contract call
298
+ * @returns The call params
299
+ */
300
+ registerList: (params) => {
301
+ return this.appClient.params.call(EscregParamsFactory.registerList(params));
302
+ },
303
+ /**
304
+ * Makes a call to the Escreg smart contract using the `exists(address)bool` ABI method.
305
+ *
306
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
307
+ *
308
+ * Return true if an app escrow account exists for the given address, false otherwise.
309
+ *
310
+ * @param params The params for the smart contract call
311
+ * @returns The call params: boolean indicating whether the given address is registered in the contract
312
+ */
313
+ exists: (params) => {
314
+ return this.appClient.params.call(EscregParamsFactory.exists(params));
315
+ },
316
+ /**
317
+ * Makes a call to the Escreg smart contract using the `get(address)uint64` ABI method.
318
+ *
319
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
320
+ *
321
+ * Get the app ID for the given app escrow address. Returns 0 if the app escrow is not registered in the contract.
322
+ *
323
+ * @param params The params for the smart contract call
324
+ * @returns The call params: App ID for the given address, or 0 if not registered
325
+ */
326
+ get: (params) => {
327
+ return this.appClient.params.call(EscregParamsFactory.get(params));
328
+ },
329
+ /**
330
+ * Makes a call to the Escreg smart contract using the `mustGet(address)uint64` ABI method.
331
+ *
332
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
333
+ *
334
+ * Get the app ID for the given app escrow address. Throws an error if the app escrow is not registered in the contract.
335
+ *
336
+ * @param params The params for the smart contract call
337
+ * @returns The call params: App ID for the given address
338
+ */
339
+ mustGet: (params) => {
340
+ return this.appClient.params.call(EscregParamsFactory.mustGet(params));
341
+ },
342
+ /**
343
+ * Makes a call to the Escreg smart contract using the `getWithAuth(address)(uint64,uint64)` ABI method.
344
+ *
345
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
346
+ *
347
+ * Get the app ID for the given app escrow address and its auth address. Returns 0 for each if not registered in the contract.
348
+ *
349
+ * @param params The params for the smart contract call
350
+ * @returns The call params: [app ID for the given address, app ID for the auth address], or 0 for each if not registered
351
+ */
352
+ getWithAuth: (params) => {
353
+ return this.appClient.params.call(EscregParamsFactory.getWithAuth(params));
354
+ },
355
+ /**
356
+ * Makes a call to the Escreg smart contract using the `getWithAuthList(address[])(uint64,uint64)[]` ABI method.
357
+ *
358
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
359
+ *
360
+ * Get the app ID for multiple app escrow addresses and their auth addresses. Returns 0 for each if not registered in the contract.
361
+ *
362
+ * @param params The params for the smart contract call
363
+ * @returns The call params: Array of [app ID for the given address, app ID for the auth address] for each input address, or 0 for each if not registered
364
+ */
365
+ getWithAuthList: (params) => {
366
+ return this.appClient.params.call(EscregParamsFactory.getWithAuthList(params));
367
+ },
368
+ /**
369
+ * Makes a call to the Escreg smart contract using the `getList(address[])uint64[]` ABI method.
370
+ *
371
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
372
+ *
373
+ * Get the app IDs for multiple app escrow addresses. Returns 0 for each if not registered in the contract.
374
+ *
375
+ * @param params The params for the smart contract call
376
+ * @returns The call params: Array of app IDs for each input address, or 0 if not registered
377
+ */
378
+ getList: (params) => {
379
+ return this.appClient.params.call(EscregParamsFactory.getList(params));
380
+ },
381
+ /**
382
+ * Makes a call to the Escreg smart contract using the `mustGetList(address[])uint64[]` ABI method.
383
+ *
384
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
385
+ *
386
+ * Get the app IDs for multiple app escrow addresses. Throws an error if any of the app escrows are not registered in the contract.
387
+ *
388
+ * @param params The params for the smart contract call
389
+ * @returns The call params: Array of app IDs for each input address
390
+ */
391
+ mustGetList: (params) => {
392
+ return this.appClient.params.call(EscregParamsFactory.mustGetList(params));
393
+ },
394
+ /**
395
+ * Makes a call to the Escreg smart contract using the `increaseBudget(uint64)void` ABI method.
396
+ *
397
+ * Utility for explicitly increasing the budget of a transaction group by performing no-op inner transactions.
398
+ *
399
+ * @param params The params for the smart contract call
400
+ * @returns The call params
401
+ */
402
+ increaseBudget: (params) => {
403
+ return this.appClient.params.call(EscregParamsFactory.increaseBudget(params));
404
+ },
405
+ /**
406
+ * Makes a call to the Escreg smart contract using the `depositCredits(address,pay)void` ABI method.
407
+ *
408
+ * public method to deposit MBR credits for an account
409
+ *
410
+ * @param params The params for the smart contract call
411
+ * @returns The call params
412
+ */
413
+ depositCredits: (params) => {
414
+ return this.appClient.params.call(EscregParamsFactory.depositCredits(params));
415
+ },
416
+ /**
417
+ * Makes a call to the Escreg smart contract using the `withdrawCredits()void` ABI method.
418
+ *
419
+ * Withdraw all remaining MBR credits for sender. This will delete the user credit box, so all credits are withdrawn including the MBR locked for the box itself.
420
+ *
421
+ * @param params The params for the smart contract call
422
+ * @returns The call params
423
+ */
424
+ withdrawCredits: (params = { args: [] }) => {
425
+ return this.appClient.params.call(EscregParamsFactory.withdrawCredits(params));
426
+ },
427
+ };
428
+ /**
429
+ * Create transactions for the current app
430
+ */
431
+ this.createTransaction = {
432
+ /**
433
+ * Makes a clear_state call to an existing instance of the Escreg smart contract.
434
+ *
435
+ * @param params The params for the bare (raw) call
436
+ * @returns The clearState result
437
+ */
438
+ clearState: (params) => {
439
+ return this.appClient.createTransaction.bare.clearState(params);
440
+ },
441
+ /**
442
+ * Makes a call to the Escreg smart contract using the `withdraw(uint64)void` ABI method.
443
+ *
444
+ * Withdraw funds from the contract to the admin.
445
+ *
446
+ * @param params The params for the smart contract call
447
+ * @returns The call transaction
448
+ */
449
+ withdraw: (params) => {
450
+ return this.appClient.createTransaction.call(EscregParamsFactory.withdraw(params));
451
+ },
452
+ /**
453
+ * Makes a call to the Escreg smart contract using the `deleteBoxes(byte[4][])void` ABI method.
454
+ *
455
+ * Delete app registry boxes by their keys.
456
+ *
457
+ * @param params The params for the smart contract call
458
+ * @returns The call transaction
459
+ */
460
+ deleteBoxes: (params) => {
461
+ return this.appClient.createTransaction.call(EscregParamsFactory.deleteBoxes(params));
462
+ },
463
+ /**
464
+ * Makes a call to the Escreg smart contract using the `register(uint64)void` ABI method.
465
+ *
466
+ * Register a single application escrow account
467
+ *
468
+ * @param params The params for the smart contract call
469
+ * @returns The call transaction
470
+ */
471
+ register: (params) => {
472
+ return this.appClient.createTransaction.call(EscregParamsFactory.register(params));
473
+ },
474
+ /**
475
+ * Makes a call to the Escreg smart contract using the `registerList(uint64[])void` ABI method.
476
+ *
477
+ * Register multiple application escrow accounts in a single transaction. This is more efficient than calling register multiple times as the MBR cost can be paid for in a single payment and the app IDs can be stored more efficiently in the contract state.
478
+ *
479
+ * @param params The params for the smart contract call
480
+ * @returns The call transaction
481
+ */
482
+ registerList: (params) => {
483
+ return this.appClient.createTransaction.call(EscregParamsFactory.registerList(params));
484
+ },
485
+ /**
486
+ * Makes a call to the Escreg smart contract using the `exists(address)bool` ABI method.
487
+ *
488
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
489
+ *
490
+ * Return true if an app escrow account exists for the given address, false otherwise.
491
+ *
492
+ * @param params The params for the smart contract call
493
+ * @returns The call transaction: boolean indicating whether the given address is registered in the contract
494
+ */
495
+ exists: (params) => {
496
+ return this.appClient.createTransaction.call(EscregParamsFactory.exists(params));
497
+ },
498
+ /**
499
+ * Makes a call to the Escreg smart contract using the `get(address)uint64` ABI method.
500
+ *
501
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
502
+ *
503
+ * Get the app ID for the given app escrow address. Returns 0 if the app escrow is not registered in the contract.
504
+ *
505
+ * @param params The params for the smart contract call
506
+ * @returns The call transaction: App ID for the given address, or 0 if not registered
507
+ */
508
+ get: (params) => {
509
+ return this.appClient.createTransaction.call(EscregParamsFactory.get(params));
510
+ },
511
+ /**
512
+ * Makes a call to the Escreg smart contract using the `mustGet(address)uint64` ABI method.
513
+ *
514
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
515
+ *
516
+ * Get the app ID for the given app escrow address. Throws an error if the app escrow is not registered in the contract.
517
+ *
518
+ * @param params The params for the smart contract call
519
+ * @returns The call transaction: App ID for the given address
520
+ */
521
+ mustGet: (params) => {
522
+ return this.appClient.createTransaction.call(EscregParamsFactory.mustGet(params));
523
+ },
524
+ /**
525
+ * Makes a call to the Escreg smart contract using the `getWithAuth(address)(uint64,uint64)` ABI method.
526
+ *
527
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
528
+ *
529
+ * Get the app ID for the given app escrow address and its auth address. Returns 0 for each if not registered in the contract.
530
+ *
531
+ * @param params The params for the smart contract call
532
+ * @returns The call transaction: [app ID for the given address, app ID for the auth address], or 0 for each if not registered
533
+ */
534
+ getWithAuth: (params) => {
535
+ return this.appClient.createTransaction.call(EscregParamsFactory.getWithAuth(params));
536
+ },
537
+ /**
538
+ * Makes a call to the Escreg smart contract using the `getWithAuthList(address[])(uint64,uint64)[]` ABI method.
539
+ *
540
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
541
+ *
542
+ * Get the app ID for multiple app escrow addresses and their auth addresses. Returns 0 for each if not registered in the contract.
543
+ *
544
+ * @param params The params for the smart contract call
545
+ * @returns The call transaction: Array of [app ID for the given address, app ID for the auth address] for each input address, or 0 for each if not registered
546
+ */
547
+ getWithAuthList: (params) => {
548
+ return this.appClient.createTransaction.call(EscregParamsFactory.getWithAuthList(params));
549
+ },
550
+ /**
551
+ * Makes a call to the Escreg smart contract using the `getList(address[])uint64[]` ABI method.
552
+ *
553
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
554
+ *
555
+ * Get the app IDs for multiple app escrow addresses. Returns 0 for each if not registered in the contract.
556
+ *
557
+ * @param params The params for the smart contract call
558
+ * @returns The call transaction: Array of app IDs for each input address, or 0 if not registered
559
+ */
560
+ getList: (params) => {
561
+ return this.appClient.createTransaction.call(EscregParamsFactory.getList(params));
562
+ },
563
+ /**
564
+ * Makes a call to the Escreg smart contract using the `mustGetList(address[])uint64[]` ABI method.
565
+ *
566
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
567
+ *
568
+ * Get the app IDs for multiple app escrow addresses. Throws an error if any of the app escrows are not registered in the contract.
569
+ *
570
+ * @param params The params for the smart contract call
571
+ * @returns The call transaction: Array of app IDs for each input address
572
+ */
573
+ mustGetList: (params) => {
574
+ return this.appClient.createTransaction.call(EscregParamsFactory.mustGetList(params));
575
+ },
576
+ /**
577
+ * Makes a call to the Escreg smart contract using the `increaseBudget(uint64)void` ABI method.
578
+ *
579
+ * Utility for explicitly increasing the budget of a transaction group by performing no-op inner transactions.
580
+ *
581
+ * @param params The params for the smart contract call
582
+ * @returns The call transaction
583
+ */
584
+ increaseBudget: (params) => {
585
+ return this.appClient.createTransaction.call(EscregParamsFactory.increaseBudget(params));
586
+ },
587
+ /**
588
+ * Makes a call to the Escreg smart contract using the `depositCredits(address,pay)void` ABI method.
589
+ *
590
+ * public method to deposit MBR credits for an account
591
+ *
592
+ * @param params The params for the smart contract call
593
+ * @returns The call transaction
594
+ */
595
+ depositCredits: (params) => {
596
+ return this.appClient.createTransaction.call(EscregParamsFactory.depositCredits(params));
597
+ },
598
+ /**
599
+ * Makes a call to the Escreg smart contract using the `withdrawCredits()void` ABI method.
600
+ *
601
+ * Withdraw all remaining MBR credits for sender. This will delete the user credit box, so all credits are withdrawn including the MBR locked for the box itself.
602
+ *
603
+ * @param params The params for the smart contract call
604
+ * @returns The call transaction
605
+ */
606
+ withdrawCredits: (params = { args: [] }) => {
607
+ return this.appClient.createTransaction.call(EscregParamsFactory.withdrawCredits(params));
608
+ },
609
+ };
610
+ /**
611
+ * Send calls to the current app
612
+ */
613
+ this.send = {
614
+ /**
615
+ * Makes a clear_state call to an existing instance of the Escreg smart contract.
616
+ *
617
+ * @param params The params for the bare (raw) call
618
+ * @returns The clearState result
619
+ */
620
+ clearState: (params) => {
621
+ return this.appClient.send.bare.clearState(params);
622
+ },
623
+ /**
624
+ * Makes a call to the Escreg smart contract using the `withdraw(uint64)void` ABI method.
625
+ *
626
+ * Withdraw funds from the contract to the admin.
627
+ *
628
+ * @param params The params for the smart contract call
629
+ * @returns The call result
630
+ */
631
+ withdraw: async (params) => {
632
+ const result = await this.appClient.send.call(EscregParamsFactory.withdraw(params));
633
+ return { ...result, return: result.return };
634
+ },
635
+ /**
636
+ * Makes a call to the Escreg smart contract using the `deleteBoxes(byte[4][])void` ABI method.
637
+ *
638
+ * Delete app registry boxes by their keys.
639
+ *
640
+ * @param params The params for the smart contract call
641
+ * @returns The call result
642
+ */
643
+ deleteBoxes: async (params) => {
644
+ const result = await this.appClient.send.call(EscregParamsFactory.deleteBoxes(params));
645
+ return { ...result, return: result.return };
646
+ },
647
+ /**
648
+ * Makes a call to the Escreg smart contract using the `register(uint64)void` ABI method.
649
+ *
650
+ * Register a single application escrow account
651
+ *
652
+ * @param params The params for the smart contract call
653
+ * @returns The call result
654
+ */
655
+ register: async (params) => {
656
+ const result = await this.appClient.send.call(EscregParamsFactory.register(params));
657
+ return { ...result, return: result.return };
658
+ },
659
+ /**
660
+ * Makes a call to the Escreg smart contract using the `registerList(uint64[])void` ABI method.
661
+ *
662
+ * Register multiple application escrow accounts in a single transaction. This is more efficient than calling register multiple times as the MBR cost can be paid for in a single payment and the app IDs can be stored more efficiently in the contract state.
663
+ *
664
+ * @param params The params for the smart contract call
665
+ * @returns The call result
666
+ */
667
+ registerList: async (params) => {
668
+ const result = await this.appClient.send.call(EscregParamsFactory.registerList(params));
669
+ return { ...result, return: result.return };
670
+ },
671
+ /**
672
+ * Makes a call to the Escreg smart contract using the `exists(address)bool` ABI method.
673
+ *
674
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
675
+ *
676
+ * Return true if an app escrow account exists for the given address, false otherwise.
677
+ *
678
+ * @param params The params for the smart contract call
679
+ * @returns The call result: boolean indicating whether the given address is registered in the contract
680
+ */
681
+ exists: async (params) => {
682
+ const result = await this.appClient.send.call(EscregParamsFactory.exists(params));
683
+ return { ...result, return: result.return };
684
+ },
685
+ /**
686
+ * Makes a call to the Escreg smart contract using the `get(address)uint64` ABI method.
687
+ *
688
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
689
+ *
690
+ * Get the app ID for the given app escrow address. Returns 0 if the app escrow is not registered in the contract.
691
+ *
692
+ * @param params The params for the smart contract call
693
+ * @returns The call result: App ID for the given address, or 0 if not registered
694
+ */
695
+ get: async (params) => {
696
+ const result = await this.appClient.send.call(EscregParamsFactory.get(params));
697
+ return { ...result, return: result.return };
698
+ },
699
+ /**
700
+ * Makes a call to the Escreg smart contract using the `mustGet(address)uint64` ABI method.
701
+ *
702
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
703
+ *
704
+ * Get the app ID for the given app escrow address. Throws an error if the app escrow is not registered in the contract.
705
+ *
706
+ * @param params The params for the smart contract call
707
+ * @returns The call result: App ID for the given address
708
+ */
709
+ mustGet: async (params) => {
710
+ const result = await this.appClient.send.call(EscregParamsFactory.mustGet(params));
711
+ return { ...result, return: result.return };
712
+ },
713
+ /**
714
+ * Makes a call to the Escreg smart contract using the `getWithAuth(address)(uint64,uint64)` ABI method.
715
+ *
716
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
717
+ *
718
+ * Get the app ID for the given app escrow address and its auth address. Returns 0 for each if not registered in the contract.
719
+ *
720
+ * @param params The params for the smart contract call
721
+ * @returns The call result: [app ID for the given address, app ID for the auth address], or 0 for each if not registered
722
+ */
723
+ getWithAuth: async (params) => {
724
+ const result = await this.appClient.send.call(EscregParamsFactory.getWithAuth(params));
725
+ return { ...result, return: result.return };
726
+ },
727
+ /**
728
+ * Makes a call to the Escreg smart contract using the `getWithAuthList(address[])(uint64,uint64)[]` ABI method.
729
+ *
730
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
731
+ *
732
+ * Get the app ID for multiple app escrow addresses and their auth addresses. Returns 0 for each if not registered in the contract.
733
+ *
734
+ * @param params The params for the smart contract call
735
+ * @returns The call result: Array of [app ID for the given address, app ID for the auth address] for each input address, or 0 for each if not registered
736
+ */
737
+ getWithAuthList: async (params) => {
738
+ const result = await this.appClient.send.call(EscregParamsFactory.getWithAuthList(params));
739
+ return { ...result, return: result.return };
740
+ },
741
+ /**
742
+ * Makes a call to the Escreg smart contract using the `getList(address[])uint64[]` ABI method.
743
+ *
744
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
745
+ *
746
+ * Get the app IDs for multiple app escrow addresses. Returns 0 for each if not registered in the contract.
747
+ *
748
+ * @param params The params for the smart contract call
749
+ * @returns The call result: Array of app IDs for each input address, or 0 if not registered
750
+ */
751
+ getList: async (params) => {
752
+ const result = await this.appClient.send.call(EscregParamsFactory.getList(params));
753
+ return { ...result, return: result.return };
754
+ },
755
+ /**
756
+ * Makes a call to the Escreg smart contract using the `mustGetList(address[])uint64[]` ABI method.
757
+ *
758
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
759
+ *
760
+ * Get the app IDs for multiple app escrow addresses. Throws an error if any of the app escrows are not registered in the contract.
761
+ *
762
+ * @param params The params for the smart contract call
763
+ * @returns The call result: Array of app IDs for each input address
764
+ */
765
+ mustGetList: async (params) => {
766
+ const result = await this.appClient.send.call(EscregParamsFactory.mustGetList(params));
767
+ return { ...result, return: result.return };
768
+ },
769
+ /**
770
+ * Makes a call to the Escreg smart contract using the `increaseBudget(uint64)void` ABI method.
771
+ *
772
+ * Utility for explicitly increasing the budget of a transaction group by performing no-op inner transactions.
773
+ *
774
+ * @param params The params for the smart contract call
775
+ * @returns The call result
776
+ */
777
+ increaseBudget: async (params) => {
778
+ const result = await this.appClient.send.call(EscregParamsFactory.increaseBudget(params));
779
+ return { ...result, return: result.return };
780
+ },
781
+ /**
782
+ * Makes a call to the Escreg smart contract using the `depositCredits(address,pay)void` ABI method.
783
+ *
784
+ * public method to deposit MBR credits for an account
785
+ *
786
+ * @param params The params for the smart contract call
787
+ * @returns The call result
788
+ */
789
+ depositCredits: async (params) => {
790
+ const result = await this.appClient.send.call(EscregParamsFactory.depositCredits(params));
791
+ return { ...result, return: result.return };
792
+ },
793
+ /**
794
+ * Makes a call to the Escreg smart contract using the `withdrawCredits()void` ABI method.
795
+ *
796
+ * Withdraw all remaining MBR credits for sender. This will delete the user credit box, so all credits are withdrawn including the MBR locked for the box itself.
797
+ *
798
+ * @param params The params for the smart contract call
799
+ * @returns The call result
800
+ */
801
+ withdrawCredits: async (params = { args: [] }) => {
802
+ const result = await this.appClient.send.call(EscregParamsFactory.withdrawCredits(params));
803
+ return { ...result, return: result.return };
804
+ },
805
+ };
806
+ /**
807
+ * Methods to access state for the current Escreg app
808
+ */
809
+ this.state = {
810
+ /**
811
+ * Methods to access global state for the current Escreg app
812
+ */
813
+ global: {
814
+ /**
815
+ * Get all current keyed values from global state
816
+ */
817
+ getAll: async () => {
818
+ const result = await this.appClient.state.global.getAll();
819
+ return {
820
+ admin: result.admin,
821
+ counter: result.counter,
822
+ };
823
+ },
824
+ /**
825
+ * Get the current value of the admin key in global state
826
+ */
827
+ admin: async () => { return (await this.appClient.state.global.getValue("admin")); },
828
+ /**
829
+ * Get the current value of the counter key in global state
830
+ */
831
+ counter: async () => { return (await this.appClient.state.global.getValue("counter")); },
832
+ },
833
+ /**
834
+ * Methods to access box state for the current Escreg app
835
+ */
836
+ box: {
837
+ /**
838
+ * Get all current keyed values from box state
839
+ */
840
+ getAll: async () => {
841
+ const result = await this.appClient.state.box.getAll();
842
+ return {};
843
+ },
844
+ /**
845
+ * Get values from the apps map in box state
846
+ */
847
+ apps: {
848
+ /**
849
+ * Get all current values of the apps map in box state
850
+ */
851
+ getMap: async () => { return (await this.appClient.state.box.getMap("apps")); },
852
+ /**
853
+ * Get a current value of the apps map by key from box state
854
+ */
855
+ value: async (key) => { return await this.appClient.state.box.getMapValue("apps", key); },
856
+ },
857
+ /**
858
+ * Get values from the userCredits map in box state
859
+ */
860
+ userCredits: {
861
+ /**
862
+ * Get all current values of the userCredits map in box state
863
+ */
864
+ getMap: async () => { return (await this.appClient.state.box.getMap("userCredits")); },
865
+ /**
866
+ * Get a current value of the userCredits map by key from box state
867
+ */
868
+ value: async (key) => { return await this.appClient.state.box.getMapValue("userCredits", key); },
869
+ },
870
+ },
871
+ };
872
+ this.appClient = appClientOrParams instanceof app_client_1.AppClient ? appClientOrParams : new app_client_1.AppClient({
873
+ ...appClientOrParams,
874
+ appSpec: exports.APP_SPEC,
875
+ });
876
+ }
877
+ /**
878
+ * Checks for decode errors on the given return value and maps the return value to the return type for the given method
879
+ * @returns The typed return value or undefined if there was no value
880
+ */
881
+ decodeReturnValue(method, returnValue) {
882
+ return returnValue !== undefined ? (0, app_arc56_1.getArc56ReturnValue)(returnValue, this.appClient.getABIMethod(method), exports.APP_SPEC.structs) : undefined;
883
+ }
884
+ /**
885
+ * Returns a new `EscregClient` client, resolving the app by creator address and name
886
+ * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
887
+ * @param params The parameters to create the app client
888
+ */
889
+ static async fromCreatorAndName(params) {
890
+ return new EscregClient(await app_client_1.AppClient.fromCreatorAndName({ ...params, appSpec: exports.APP_SPEC }));
891
+ }
892
+ /**
893
+ * Returns an `EscregClient` instance for the current network based on
894
+ * pre-determined network-specific app IDs specified in the ARC-56 app spec.
895
+ *
896
+ * If no IDs are in the app spec or the network isn't recognised, an error is thrown.
897
+ * @param params The parameters to create the app client
898
+ */
899
+ static async fromNetwork(params) {
900
+ return new EscregClient(await app_client_1.AppClient.fromNetwork({ ...params, appSpec: exports.APP_SPEC }));
901
+ }
902
+ /** The ID of the app instance this client is linked to. */
903
+ get appId() {
904
+ return this.appClient.appId;
905
+ }
906
+ /** The app address of the app instance this client is linked to. */
907
+ get appAddress() {
908
+ return this.appClient.appAddress;
909
+ }
910
+ /** The name of the app. */
911
+ get appName() {
912
+ return this.appClient.appName;
913
+ }
914
+ /** The ARC-56 app spec being used */
915
+ get appSpec() {
916
+ return this.appClient.appSpec;
917
+ }
918
+ /** A reference to the underlying `AlgorandClient` this app client is using. */
919
+ get algorand() {
920
+ return this.appClient.algorand;
921
+ }
922
+ /**
923
+ * Clone this app client with different params
924
+ *
925
+ * @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.
926
+ * @returns A new app client with the altered params
927
+ */
928
+ clone(params) {
929
+ return new EscregClient(this.appClient.clone(params));
930
+ }
931
+ /**
932
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `exists(address)bool` ABI method.
933
+ *
934
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
935
+ *
936
+ * Return true if an app escrow account exists for the given address, false otherwise.
937
+ *
938
+ * @param params The params for the smart contract call
939
+ * @returns The call result: boolean indicating whether the given address is registered in the contract
940
+ */
941
+ async exists(params) {
942
+ const result = await this.appClient.send.call(EscregParamsFactory.exists(params));
943
+ return result.return;
944
+ }
945
+ /**
946
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `get(address)uint64` ABI method.
947
+ *
948
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
949
+ *
950
+ * Get the app ID for the given app escrow address. Returns 0 if the app escrow is not registered in the contract.
951
+ *
952
+ * @param params The params for the smart contract call
953
+ * @returns The call result: App ID for the given address, or 0 if not registered
954
+ */
955
+ async get(params) {
956
+ const result = await this.appClient.send.call(EscregParamsFactory.get(params));
957
+ return result.return;
958
+ }
959
+ /**
960
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `mustGet(address)uint64` ABI method.
961
+ *
962
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
963
+ *
964
+ * Get the app ID for the given app escrow address. Throws an error if the app escrow is not registered in the contract.
965
+ *
966
+ * @param params The params for the smart contract call
967
+ * @returns The call result: App ID for the given address
968
+ */
969
+ async mustGet(params) {
970
+ const result = await this.appClient.send.call(EscregParamsFactory.mustGet(params));
971
+ return result.return;
972
+ }
973
+ /**
974
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `getWithAuth(address)(uint64,uint64)` ABI method.
975
+ *
976
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
977
+ *
978
+ * Get the app ID for the given app escrow address and its auth address. Returns 0 for each if not registered in the contract.
979
+ *
980
+ * @param params The params for the smart contract call
981
+ * @returns The call result: [app ID for the given address, app ID for the auth address], or 0 for each if not registered
982
+ */
983
+ async getWithAuth(params) {
984
+ const result = await this.appClient.send.call(EscregParamsFactory.getWithAuth(params));
985
+ return result.return;
986
+ }
987
+ /**
988
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `getWithAuthList(address[])(uint64,uint64)[]` ABI method.
989
+ *
990
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
991
+ *
992
+ * Get the app ID for multiple app escrow addresses and their auth addresses. Returns 0 for each if not registered in the contract.
993
+ *
994
+ * @param params The params for the smart contract call
995
+ * @returns The call result: Array of [app ID for the given address, app ID for the auth address] for each input address, or 0 for each if not registered
996
+ */
997
+ async getWithAuthList(params) {
998
+ const result = await this.appClient.send.call(EscregParamsFactory.getWithAuthList(params));
999
+ return result.return;
1000
+ }
1001
+ /**
1002
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `getList(address[])uint64[]` ABI method.
1003
+ *
1004
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
1005
+ *
1006
+ * Get the app IDs for multiple app escrow addresses. Returns 0 for each if not registered in the contract.
1007
+ *
1008
+ * @param params The params for the smart contract call
1009
+ * @returns The call result: Array of app IDs for each input address, or 0 if not registered
1010
+ */
1011
+ async getList(params) {
1012
+ const result = await this.appClient.send.call(EscregParamsFactory.getList(params));
1013
+ return result.return;
1014
+ }
1015
+ /**
1016
+ * Makes a readonly (simulated) call to the Escreg smart contract using the `mustGetList(address[])uint64[]` ABI method.
1017
+ *
1018
+ * This method is a readonly method; calling it with onComplete of NoOp will result in a simulated transaction rather than a real transaction.
1019
+ *
1020
+ * Get the app IDs for multiple app escrow addresses. Throws an error if any of the app escrows are not registered in the contract.
1021
+ *
1022
+ * @param params The params for the smart contract call
1023
+ * @returns The call result: Array of app IDs for each input address
1024
+ */
1025
+ async mustGetList(params) {
1026
+ const result = await this.appClient.send.call(EscregParamsFactory.mustGetList(params));
1027
+ return result.return;
1028
+ }
1029
+ newGroup() {
1030
+ const client = this;
1031
+ const composer = this.algorand.newGroup();
1032
+ let promiseChain = Promise.resolve();
1033
+ const resultMappers = [];
1034
+ return {
1035
+ /**
1036
+ * Add a withdraw(uint64)void method call against the Escreg contract
1037
+ */
1038
+ withdraw(params) {
1039
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.withdraw(params)));
1040
+ resultMappers.push(undefined);
1041
+ return this;
1042
+ },
1043
+ /**
1044
+ * Add a deleteBoxes(byte[4][])void method call against the Escreg contract
1045
+ */
1046
+ deleteBoxes(params) {
1047
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.deleteBoxes(params)));
1048
+ resultMappers.push(undefined);
1049
+ return this;
1050
+ },
1051
+ /**
1052
+ * Add a register(uint64)void method call against the Escreg contract
1053
+ */
1054
+ register(params) {
1055
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.register(params)));
1056
+ resultMappers.push(undefined);
1057
+ return this;
1058
+ },
1059
+ /**
1060
+ * Add a registerList(uint64[])void method call against the Escreg contract
1061
+ */
1062
+ registerList(params) {
1063
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.registerList(params)));
1064
+ resultMappers.push(undefined);
1065
+ return this;
1066
+ },
1067
+ /**
1068
+ * Add a exists(address)bool method call against the Escreg contract
1069
+ */
1070
+ exists(params) {
1071
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.exists(params)));
1072
+ resultMappers.push((v) => client.decodeReturnValue('exists(address)bool', v));
1073
+ return this;
1074
+ },
1075
+ /**
1076
+ * Add a get(address)uint64 method call against the Escreg contract
1077
+ */
1078
+ get(params) {
1079
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.get(params)));
1080
+ resultMappers.push((v) => client.decodeReturnValue('get(address)uint64', v));
1081
+ return this;
1082
+ },
1083
+ /**
1084
+ * Add a mustGet(address)uint64 method call against the Escreg contract
1085
+ */
1086
+ mustGet(params) {
1087
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.mustGet(params)));
1088
+ resultMappers.push((v) => client.decodeReturnValue('mustGet(address)uint64', v));
1089
+ return this;
1090
+ },
1091
+ /**
1092
+ * Add a getWithAuth(address)(uint64,uint64) method call against the Escreg contract
1093
+ */
1094
+ getWithAuth(params) {
1095
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.getWithAuth(params)));
1096
+ resultMappers.push((v) => client.decodeReturnValue('getWithAuth(address)(uint64,uint64)', v));
1097
+ return this;
1098
+ },
1099
+ /**
1100
+ * Add a getWithAuthList(address[])(uint64,uint64)[] method call against the Escreg contract
1101
+ */
1102
+ getWithAuthList(params) {
1103
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.getWithAuthList(params)));
1104
+ resultMappers.push((v) => client.decodeReturnValue('getWithAuthList(address[])(uint64,uint64)[]', v));
1105
+ return this;
1106
+ },
1107
+ /**
1108
+ * Add a getList(address[])uint64[] method call against the Escreg contract
1109
+ */
1110
+ getList(params) {
1111
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.getList(params)));
1112
+ resultMappers.push((v) => client.decodeReturnValue('getList(address[])uint64[]', v));
1113
+ return this;
1114
+ },
1115
+ /**
1116
+ * Add a mustGetList(address[])uint64[] method call against the Escreg contract
1117
+ */
1118
+ mustGetList(params) {
1119
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.mustGetList(params)));
1120
+ resultMappers.push((v) => client.decodeReturnValue('mustGetList(address[])uint64[]', v));
1121
+ return this;
1122
+ },
1123
+ /**
1124
+ * Add a increaseBudget(uint64)void method call against the Escreg contract
1125
+ */
1126
+ increaseBudget(params) {
1127
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.increaseBudget(params)));
1128
+ resultMappers.push(undefined);
1129
+ return this;
1130
+ },
1131
+ /**
1132
+ * Add a depositCredits(address,pay)void method call against the Escreg contract
1133
+ */
1134
+ depositCredits(params) {
1135
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.depositCredits(params)));
1136
+ resultMappers.push(undefined);
1137
+ return this;
1138
+ },
1139
+ /**
1140
+ * Add a withdrawCredits()void method call against the Escreg contract
1141
+ */
1142
+ withdrawCredits(params) {
1143
+ promiseChain = promiseChain.then(async () => composer.addAppCallMethodCall(await client.params.withdrawCredits(params)));
1144
+ resultMappers.push(undefined);
1145
+ return this;
1146
+ },
1147
+ /**
1148
+ * Add a clear state call to the Escreg contract
1149
+ */
1150
+ clearState(params) {
1151
+ promiseChain = promiseChain.then(() => composer.addAppCall(client.params.clearState(params)));
1152
+ return this;
1153
+ },
1154
+ addTransaction(txn, signer) {
1155
+ promiseChain = promiseChain.then(() => composer.addTransaction(txn, signer));
1156
+ return this;
1157
+ },
1158
+ async composer() {
1159
+ await promiseChain;
1160
+ return composer;
1161
+ },
1162
+ async simulate(options) {
1163
+ await promiseChain;
1164
+ const result = await (!options ? composer.simulate() : composer.simulate(options));
1165
+ return {
1166
+ ...result,
1167
+ returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i](val) : val.returnValue)
1168
+ };
1169
+ },
1170
+ async send(params) {
1171
+ await promiseChain;
1172
+ const result = await composer.send(params);
1173
+ return {
1174
+ ...result,
1175
+ returns: result.returns?.map((val, i) => resultMappers[i] !== undefined ? resultMappers[i](val) : val.returnValue)
1176
+ };
1177
+ }
1178
+ };
1179
+ }
1180
+ }
1181
+ exports.EscregClient = EscregClient;
1182
+ //# sourceMappingURL=EscregGenerated.js.map