algosdk 1.15.0-beta.1 → 1.17.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 (112) hide show
  1. package/README.md +4 -4
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.map +1 -1
  4. package/dist/cjs/src/client/kmd.js +1 -1
  5. package/dist/cjs/src/client/kmd.js.map +1 -1
  6. package/dist/cjs/src/client/v2/algod/models/types.js +32 -5
  7. package/dist/cjs/src/client/v2/algod/models/types.js.map +1 -1
  8. package/dist/cjs/src/client/v2/indexer/indexer.js +8 -8
  9. package/dist/cjs/src/client/v2/indexer/lookupAccountAppLocalStates.js +29 -4
  10. package/dist/cjs/src/client/v2/indexer/lookupAccountAppLocalStates.js.map +1 -1
  11. package/dist/cjs/src/client/v2/indexer/lookupAccountAssets.js +29 -3
  12. package/dist/cjs/src/client/v2/indexer/lookupAccountAssets.js.map +1 -1
  13. package/dist/cjs/src/client/v2/indexer/lookupAccountByID.js +76 -3
  14. package/dist/cjs/src/client/v2/indexer/lookupAccountByID.js.map +1 -1
  15. package/dist/cjs/src/client/v2/indexer/lookupAccountCreatedApplications.js +30 -4
  16. package/dist/cjs/src/client/v2/indexer/lookupAccountCreatedApplications.js.map +1 -1
  17. package/dist/cjs/src/client/v2/indexer/lookupAccountCreatedAssets.js +30 -3
  18. package/dist/cjs/src/client/v2/indexer/lookupAccountCreatedAssets.js.map +1 -1
  19. package/dist/cjs/src/client/v2/indexer/lookupAccountTransactions.js +30 -25
  20. package/dist/cjs/src/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  21. package/dist/cjs/src/client/v2/indexer/lookupApplicationLogs.js +112 -6
  22. package/dist/cjs/src/client/v2/indexer/lookupApplicationLogs.js.map +1 -1
  23. package/dist/cjs/src/client/v2/indexer/lookupApplications.js +40 -1
  24. package/dist/cjs/src/client/v2/indexer/lookupApplications.js.map +1 -1
  25. package/dist/cjs/src/client/v2/indexer/lookupAssetBalances.js +29 -6
  26. package/dist/cjs/src/client/v2/indexer/lookupAssetBalances.js.map +1 -1
  27. package/dist/cjs/src/client/v2/indexer/lookupAssetByID.js +2 -0
  28. package/dist/cjs/src/client/v2/indexer/lookupAssetByID.js.map +1 -1
  29. package/dist/cjs/src/client/v2/indexer/lookupAssetTransactions.js +298 -18
  30. package/dist/cjs/src/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  31. package/dist/cjs/src/client/v2/indexer/lookupBlock.js +16 -0
  32. package/dist/cjs/src/client/v2/indexer/lookupBlock.js.map +1 -1
  33. package/dist/cjs/src/client/v2/indexer/lookupTransactionByID.js +16 -0
  34. package/dist/cjs/src/client/v2/indexer/lookupTransactionByID.js.map +1 -1
  35. package/dist/cjs/src/client/v2/indexer/makeHealthCheck.js +15 -0
  36. package/dist/cjs/src/client/v2/indexer/makeHealthCheck.js.map +1 -1
  37. package/dist/cjs/src/client/v2/indexer/searchAccounts.js +210 -10
  38. package/dist/cjs/src/client/v2/indexer/searchAccounts.js.map +1 -1
  39. package/dist/cjs/src/client/v2/indexer/searchForApplications.js +103 -7
  40. package/dist/cjs/src/client/v2/indexer/searchForApplications.js.map +1 -1
  41. package/dist/cjs/src/client/v2/indexer/searchForAssets.js +132 -7
  42. package/dist/cjs/src/client/v2/indexer/searchForAssets.js.map +1 -1
  43. package/dist/cjs/src/client/v2/indexer/searchForTransactions.js +328 -19
  44. package/dist/cjs/src/client/v2/indexer/searchForTransactions.js.map +1 -1
  45. package/dist/cjs/src/dryrun.js +199 -2
  46. package/dist/cjs/src/dryrun.js.map +1 -1
  47. package/dist/esm/src/client/kmd.js +1 -1
  48. package/dist/esm/src/client/kmd.js.map +1 -1
  49. package/dist/esm/src/client/v2/algod/models/types.js +30 -4
  50. package/dist/esm/src/client/v2/algod/models/types.js.map +1 -1
  51. package/dist/esm/src/client/v2/indexer/indexer.js +8 -8
  52. package/dist/esm/src/client/v2/indexer/lookupAccountAppLocalStates.js +29 -4
  53. package/dist/esm/src/client/v2/indexer/lookupAccountAppLocalStates.js.map +1 -1
  54. package/dist/esm/src/client/v2/indexer/lookupAccountAssets.js +29 -3
  55. package/dist/esm/src/client/v2/indexer/lookupAccountAssets.js.map +1 -1
  56. package/dist/esm/src/client/v2/indexer/lookupAccountByID.js +76 -3
  57. package/dist/esm/src/client/v2/indexer/lookupAccountByID.js.map +1 -1
  58. package/dist/esm/src/client/v2/indexer/lookupAccountCreatedApplications.js +30 -4
  59. package/dist/esm/src/client/v2/indexer/lookupAccountCreatedApplications.js.map +1 -1
  60. package/dist/esm/src/client/v2/indexer/lookupAccountCreatedAssets.js +30 -3
  61. package/dist/esm/src/client/v2/indexer/lookupAccountCreatedAssets.js.map +1 -1
  62. package/dist/esm/src/client/v2/indexer/lookupAccountTransactions.js +30 -25
  63. package/dist/esm/src/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  64. package/dist/esm/src/client/v2/indexer/lookupApplicationLogs.js +112 -6
  65. package/dist/esm/src/client/v2/indexer/lookupApplicationLogs.js.map +1 -1
  66. package/dist/esm/src/client/v2/indexer/lookupApplications.js +40 -1
  67. package/dist/esm/src/client/v2/indexer/lookupApplications.js.map +1 -1
  68. package/dist/esm/src/client/v2/indexer/lookupAssetBalances.js +29 -6
  69. package/dist/esm/src/client/v2/indexer/lookupAssetBalances.js.map +1 -1
  70. package/dist/esm/src/client/v2/indexer/lookupAssetByID.js +2 -0
  71. package/dist/esm/src/client/v2/indexer/lookupAssetByID.js.map +1 -1
  72. package/dist/esm/src/client/v2/indexer/lookupAssetTransactions.js +298 -18
  73. package/dist/esm/src/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  74. package/dist/esm/src/client/v2/indexer/lookupBlock.js +16 -0
  75. package/dist/esm/src/client/v2/indexer/lookupBlock.js.map +1 -1
  76. package/dist/esm/src/client/v2/indexer/lookupTransactionByID.js +16 -0
  77. package/dist/esm/src/client/v2/indexer/lookupTransactionByID.js.map +1 -1
  78. package/dist/esm/src/client/v2/indexer/makeHealthCheck.js +15 -0
  79. package/dist/esm/src/client/v2/indexer/makeHealthCheck.js.map +1 -1
  80. package/dist/esm/src/client/v2/indexer/searchAccounts.js +210 -10
  81. package/dist/esm/src/client/v2/indexer/searchAccounts.js.map +1 -1
  82. package/dist/esm/src/client/v2/indexer/searchForApplications.js +103 -7
  83. package/dist/esm/src/client/v2/indexer/searchForApplications.js.map +1 -1
  84. package/dist/esm/src/client/v2/indexer/searchForAssets.js +132 -7
  85. package/dist/esm/src/client/v2/indexer/searchForAssets.js.map +1 -1
  86. package/dist/esm/src/client/v2/indexer/searchForTransactions.js +328 -19
  87. package/dist/esm/src/client/v2/indexer/searchForTransactions.js.map +1 -1
  88. package/dist/esm/src/dryrun.js +197 -1
  89. package/dist/esm/src/dryrun.js.map +1 -1
  90. package/dist/types/src/client/kmd.d.ts +4 -4
  91. package/dist/types/src/client/v2/algod/models/types.d.ts +39 -6
  92. package/dist/types/src/client/v2/indexer/indexer.d.ts +8 -8
  93. package/dist/types/src/client/v2/indexer/lookupAccountAppLocalStates.d.ts +29 -4
  94. package/dist/types/src/client/v2/indexer/lookupAccountAssets.d.ts +29 -3
  95. package/dist/types/src/client/v2/indexer/lookupAccountByID.d.ts +76 -0
  96. package/dist/types/src/client/v2/indexer/lookupAccountCreatedApplications.d.ts +30 -4
  97. package/dist/types/src/client/v2/indexer/lookupAccountCreatedAssets.d.ts +30 -3
  98. package/dist/types/src/client/v2/indexer/lookupAccountTransactions.d.ts +30 -25
  99. package/dist/types/src/client/v2/indexer/lookupApplicationLogs.d.ts +112 -6
  100. package/dist/types/src/client/v2/indexer/lookupApplications.d.ts +40 -0
  101. package/dist/types/src/client/v2/indexer/lookupAssetBalances.d.ts +29 -6
  102. package/dist/types/src/client/v2/indexer/lookupAssetByID.d.ts +2 -0
  103. package/dist/types/src/client/v2/indexer/lookupAssetTransactions.d.ts +298 -1
  104. package/dist/types/src/client/v2/indexer/lookupBlock.d.ts +16 -0
  105. package/dist/types/src/client/v2/indexer/lookupTransactionByID.d.ts +16 -0
  106. package/dist/types/src/client/v2/indexer/makeHealthCheck.d.ts +15 -0
  107. package/dist/types/src/client/v2/indexer/searchAccounts.d.ts +210 -0
  108. package/dist/types/src/client/v2/indexer/searchForApplications.d.ts +102 -1
  109. package/dist/types/src/client/v2/indexer/searchForAssets.d.ts +132 -0
  110. package/dist/types/src/client/v2/indexer/searchForTransactions.d.ts +328 -1
  111. package/dist/types/src/dryrun.d.ts +81 -1
  112. package/package.json +4 -3
@@ -1,104 +1,413 @@
1
1
  import JSONRequest from '../jsonrequest';
2
2
  import { base64StringFunnel } from './lookupAccountTransactions';
3
+ /**
4
+ * Returns information about indexed transactions.
5
+ *
6
+ * #### Example
7
+ * ```typescript
8
+ * const txns = await indexerClient.searchForTransactions().do();
9
+ * ```
10
+ *
11
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions)
12
+ * @category GET
13
+ */
3
14
  export default class SearchForTransactions extends JSONRequest {
15
+ /**
16
+ * @returns `/v2/transactions`
17
+ */
4
18
  // eslint-disable-next-line class-methods-use-this
5
19
  path() {
6
20
  return '/v2/transactions';
7
21
  }
8
22
  /**
9
- * notePrefix to filter with
23
+ * Specifies a prefix which must be contained in the note field.
24
+ *
25
+ * #### Example
26
+ * ```typescript
27
+ * const notePrefixBase64Encoded = "Y3JlYXRl";
28
+ * const txns = await indexerClient
29
+ * .searchForTransactions()
30
+ * .notePrefix(notePrefixBase64Encoded)
31
+ * .do();
32
+ * ```
33
+ *
10
34
  * @param prefix - base64 string or uint8array
35
+ * @category query
11
36
  */
12
37
  notePrefix(prefix) {
13
38
  this.query['note-prefix'] = base64StringFunnel(prefix);
14
39
  return this;
15
40
  }
16
- // txtype to filter with, as string
41
+ /**
42
+ * Type of transaction to filter with.
43
+ *
44
+ * #### Example
45
+ * ```typescript
46
+ * const txns = await indexerClient
47
+ * .searchForTransactions()
48
+ * .txType("keyreg")
49
+ * .do();
50
+ * ```
51
+ *
52
+ * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl`
53
+ * @category query
54
+ */
17
55
  txType(type) {
18
56
  this.query['tx-type'] = type;
19
57
  return this;
20
58
  }
21
- // sigtype to filter with, as string
59
+ /**
60
+ * Type of signature to filter with.
61
+ * - sig: Standard
62
+ * - msig: MultiSig
63
+ * - lsig: LogicSig
64
+ *
65
+ * #### Example
66
+ * ```typescript
67
+ * const txns = await indexerClient
68
+ * .searchForTransactions()
69
+ * .sigType("sig")
70
+ * .do();
71
+ * ```
72
+ *
73
+ * @param type - one of `sig`, `msig`, `lsig`
74
+ * @category query
75
+ */
22
76
  sigType(type) {
23
77
  this.query['sig-type'] = type;
24
78
  return this;
25
79
  }
26
- // txid to filter with, as string
80
+ /**
81
+ * Lookup the specific transaction by ID.
82
+ *
83
+ * #### Example
84
+ * ```typescript
85
+ * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA";
86
+ * const txns = await indexerClient
87
+ * .searchForTransactions()
88
+ * .txid(txId)
89
+ * .do();
90
+ * ```
91
+ * @remarks Alternatively, use `indexerClient.lookupTransactionByID(txnId).do()`
92
+ * @param txid
93
+ * @category query
94
+ */
27
95
  txid(txid) {
28
96
  this.query.txid = txid;
29
97
  return this;
30
98
  }
31
- // round to filter with, as int
99
+ /**
100
+ * Include results for the specified round.
101
+ *
102
+ * #### Example
103
+ * ```typescript
104
+ * const targetBlock = 18309917;
105
+ * const txns = await indexerClient
106
+ * .searchForTransactions()
107
+ * .round(targetBlock)
108
+ * .do();
109
+ * ```
110
+ * @remarks Alternatively, use `indexerClient.lookupBlock(targetBlock).do()`
111
+ * @param round
112
+ * @category query
113
+ */
32
114
  round(round) {
33
115
  this.query.round = round;
34
116
  return this;
35
117
  }
36
- // min round to filter with, as int
118
+ /**
119
+ * Include results at or after the specified min-round.
120
+ *
121
+ * #### Example
122
+ * ```typescript
123
+ * const minRound = 18309917;
124
+ * const txns = await indexerClient
125
+ * .searchForTransactions()
126
+ * .minRound(minRound)
127
+ * .do();
128
+ * ```
129
+ *
130
+ * @param round
131
+ * @category query
132
+ */
37
133
  minRound(round) {
38
134
  this.query['min-round'] = round;
39
135
  return this;
40
136
  }
41
- // max round to filter with, as int
137
+ /**
138
+ * Include results at or before the specified max-round.
139
+ *
140
+ * #### Example
141
+ * ```typescript
142
+ * const maxRound = 18309917;
143
+ * const txns = await indexerClient
144
+ * .searchForTransactions()
145
+ * .maxRound(maxRound)
146
+ * .do();
147
+ * ```
148
+ *
149
+ * @param round
150
+ * @category query
151
+ */
42
152
  maxRound(round) {
43
153
  this.query['max-round'] = round;
44
154
  return this;
45
155
  }
46
- // asset ID to filter with, as int
156
+ /**
157
+ * Asset ID to filter with.
158
+ *
159
+ * #### Example
160
+ * ```typescript
161
+ * const assetID = 163650;
162
+ * const txns = await indexerClient
163
+ * .searchForTransactions()
164
+ * .assetID(assetID)
165
+ * .do();
166
+ * ```
167
+ * @remarks Alternatively, use `indexerClient.lookupAssetTransactions(assetId).do()`
168
+ * @param id
169
+ * @category query
170
+ */
47
171
  assetID(id) {
48
172
  this.query['asset-id'] = id;
49
173
  return this;
50
174
  }
51
- // limit for filter, as int
175
+ /**
176
+ * Maximum number of results to return.
177
+ *
178
+ * #### Example
179
+ * ```typescript
180
+ * const maxResults = 25;
181
+ * const txns = await indexerClient
182
+ * .searchForTransactions()
183
+ * .limit(maxResults)
184
+ * .do();
185
+ * ```
186
+ *
187
+ * @param limit
188
+ * @category query
189
+ */
52
190
  limit(limit) {
53
191
  this.query.limit = limit;
54
192
  return this;
55
193
  }
56
- // before-time to filter with, as rfc3339 string
194
+ /**
195
+ * Include results before the given time.
196
+ *
197
+ * #### Example
198
+ * ```typescript
199
+ * const beforeTime = "2022-02-02T20:20:22.02Z";
200
+ * const txns = await indexerClient
201
+ * .searchForTransactions()
202
+ * .beforeTime(beforeTime)
203
+ * .do();
204
+ * ```
205
+ *
206
+ * @param before - rfc3339 string
207
+ * @category query
208
+ */
57
209
  beforeTime(before) {
58
210
  this.query['before-time'] = before;
59
211
  return this;
60
212
  }
61
- // after-time to filter with, as rfc3339 string
213
+ /**
214
+ * Include results after the given time.
215
+ *
216
+ * #### Example
217
+ * ```typescript
218
+ * const afterTime = "2022-10-21T00:00:11.55Z";
219
+ * const txns = await indexerClient
220
+ * .searchForTransactions()
221
+ * .afterTime(afterTime)
222
+ * .do();
223
+ * ```
224
+ *
225
+ * @param after - rfc3339 string
226
+ * @category query
227
+ */
62
228
  afterTime(after) {
63
229
  this.query['after-time'] = after;
64
230
  return this;
65
231
  }
66
- // filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units
232
+ /**
233
+ * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units.
234
+ *
235
+ * #### Example 1
236
+ * ```typescript
237
+ * const minBalance = 300000;
238
+ * const txns = await indexerClient
239
+ * .searchForTransactions()
240
+ * .currencyGreaterThan(minBalance - 1)
241
+ * .do();
242
+ * ```
243
+ *
244
+ * #### Example 2
245
+ * ```typescript
246
+ * const assetID = 163650;
247
+ * const minBalance = 300000;
248
+ * const txns = await indexerClient
249
+ * .searchForTransactions()
250
+ * .assetID(assetID)
251
+ * .currencyGreaterThan(minBalance - 1)
252
+ * .do();
253
+ * ```
254
+ * @remarks
255
+ * If you are looking for transactions with the currency amount greater than 0, simply construct the query without `currencyGreaterThan` because it doesn't accept `-1`, and passing the `0` `currency-greater-than` value would exclude transactions with a 0 amount.
256
+ *
257
+ * @param greater
258
+ * @category query
259
+ */
67
260
  currencyGreaterThan(greater) {
68
261
  this.query['currency-greater-than'] = greater;
69
262
  return this;
70
263
  }
71
- // filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units
264
+ /**
265
+ * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units.
266
+ *
267
+ * #### Example 1
268
+ * ```typescript
269
+ * const maxBalance = 500000;
270
+ * const txns = await indexerClient
271
+ * .searchForTransactions()
272
+ * .currencyLessThan(maxBalance + 1)
273
+ * .do();
274
+ * ```
275
+ *
276
+ * #### Example 2
277
+ * ```typescript
278
+ * const assetID = 163650;
279
+ * const maxBalance = 500000;
280
+ * const txns = await indexerClient
281
+ * .searchForTransactions()
282
+ * .assetID(assetID)
283
+ * .currencyLessThan(maxBalance + 1)
284
+ * .do();
285
+ * ```
286
+ *
287
+ * @param lesser
288
+ * @category query
289
+ */
72
290
  currencyLessThan(lesser) {
73
291
  this.query['currency-less-than'] = lesser;
74
292
  return this;
75
293
  }
76
- // combined with address, defines what address to filter on, as string
294
+ /**
295
+ * Combined with address, defines what address to filter on, as string.
296
+ *
297
+ * #### Example
298
+ * ```typescript
299
+ * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
300
+ * const role = "freeze-target";
301
+ * const txns = await indexerClient
302
+ * .searchForTransactions()
303
+ * .address(address)
304
+ * .addressRole(role)
305
+ * .do();
306
+ * ```
307
+ *
308
+ * @param role - one of `sender`, `receiver`, `freeze-target`
309
+ * @category query
310
+ */
77
311
  addressRole(role) {
78
312
  this.query['address-role'] = role;
79
313
  return this;
80
314
  }
81
- // address to filter with, as string
315
+ /**
316
+ * Only include transactions with this address in one of the transaction fields.
317
+ *
318
+ * #### Example
319
+ * ```typescript
320
+ * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
321
+ * const txns = await indexerClient
322
+ * .searchForTransactions()
323
+ * .address(address)
324
+ * .do();
325
+ * ```
326
+ * @remarks Alternatively, use `indexerClient.lookupAccountTransactions(address).do()`
327
+ * @param address
328
+ * @category query
329
+ */
82
330
  address(address) {
83
331
  this.query.address = address;
84
332
  return this;
85
333
  }
86
- // whether or not to consider the close-to field as a receiver when filtering transactions, as bool. set to true to ignore close-to
334
+ /**
335
+ * Whether or not to consider the `close-to` field as a receiver when filtering transactions, as bool. Set to `true` to ignore `close-to`.
336
+ *
337
+ * #### Example
338
+ * ```typescript
339
+ * const txns = await indexerClient
340
+ * .searchForTransactions()
341
+ * .excludeCloseTo(true)
342
+ * .do();
343
+ * ```
344
+ *
345
+ * @param exclude
346
+ * @category query
347
+ */
87
348
  excludeCloseTo(exclude) {
88
349
  this.query['exclude-close-to'] = exclude;
89
350
  return this;
90
351
  }
91
- // used for pagination
352
+ /**
353
+ * The next page of results.
354
+ *
355
+ * #### Example
356
+ * ```typescript
357
+ * const maxResults = 25;
358
+ *
359
+ * const txnsPage1 = await indexerClient
360
+ * .searchForTransactions()
361
+ * .limit(maxResults)
362
+ * .do();
363
+ *
364
+ * const txnsPage2 = await indexerClient
365
+ * .searchForTransactions()
366
+ * .limit(maxResults)
367
+ * .nextToken(txnsPage1["next-token"])
368
+ * .do();
369
+ * ```
370
+ *
371
+ * @param nextToken - provided by the previous results
372
+ * @category query
373
+ */
92
374
  nextToken(nextToken) {
93
375
  this.query.next = nextToken;
94
376
  return this;
95
377
  }
96
- // whether or not to include rekeying transactions
378
+ /**
379
+ * Whether or not to include rekeying transactions.
380
+ *
381
+ * #### Example
382
+ * ```typescript
383
+ * const txns = await indexerClient
384
+ * .searchForTransactions()
385
+ * .rekeyTo(false)
386
+ * .do();
387
+ * ```
388
+ *
389
+ * @param rekeyTo
390
+ * @category query
391
+ */
97
392
  rekeyTo(rekeyTo) {
98
393
  this.query['rekey-to'] = rekeyTo;
99
394
  return this;
100
395
  }
101
- // filter for this application
396
+ /**
397
+ * Filter for this application.
398
+ *
399
+ * #### Example
400
+ * ```typescript
401
+ * const appId = 60553466;
402
+ * const txns = await indexerClient
403
+ * .searchForTransactions()
404
+ * .applicationID(appId)
405
+ * .do();
406
+ * ```
407
+ *
408
+ * @param applicationID
409
+ * @category query
410
+ */
102
411
  applicationID(applicationID) {
103
412
  this.query['application-id'] = applicationID;
104
413
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"searchForTransactions.js","sourceRoot":"","sources":["../../../../../../src/client/v2/indexer/searchForTransactions.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;IAC5D,kDAAkD;IAClD,IAAI;QACF,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAA2B;QACpC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mCAAmC;IACnC,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oCAAoC;IACpC,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iCAAiC;IACjC,IAAI,CAAC,IAAY;QACf,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+BAA+B;IAC/B,KAAK,CAAC,KAAa;QACjB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mCAAmC;IACnC,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mCAAmC;IACnC,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,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AiB;QACzB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kDAAkD;IAClD,OAAO,CAAC,OAAgB;QACtB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,8BAA8B;IAC9B,aAAa,CAAC,aAAqB;QACjC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
1
+ {"version":3,"file":"searchForTransactions.js","sourceRoot":"","sources":["../../../../../../src/client/v2/indexer/searchForTransactions.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;IAC5D;;OAEG;IACH,kDAAkD;IAClD,IAAI;QACF,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,MAA2B;QACpC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,IAAY;QACf,IAAI,C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C;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,gBAAgB,CAAC,MAAc;QAC7B,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,OAAe;QACrB,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,OAAgB;QAC7B,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,SAAiB;QACzB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,OAAgB;QACtB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,aAAqB;QACjC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -2,6 +2,7 @@ import { Application, ApplicationParams, ApplicationStateSchema, DryrunRequest,
2
2
  import { TransactionType } from './types/transactions';
3
3
  import { encodeAddress, getApplicationAddress } from './encoding/address';
4
4
  const defaultAppId = 1380011588;
5
+ const defaultMaxWidth = 30;
5
6
  function decodePrograms(ap) {
6
7
  // eslint-disable-next-line no-param-reassign
7
8
  ap.params['approval-program'] = Buffer.from(ap.params['approval-program'].toString(), 'base64');
@@ -29,8 +30,10 @@ export async function createDryrun({ client, txns, protocolVersion, latestTimest
29
30
  accts.push(encodeAddress(t.txn.from.publicKey));
30
31
  if (t.txn.appAccounts)
31
32
  accts.push(...t.txn.appAccounts.map((a) => encodeAddress(a.publicKey)));
32
- if (t.txn.appForeignApps)
33
+ if (t.txn.appForeignApps) {
33
34
  apps.push(...t.txn.appForeignApps);
35
+ accts.push(...t.txn.appForeignApps.map((aidx) => getApplicationAddress(aidx)));
36
+ }
34
37
  if (t.txn.appForeignAssets)
35
38
  assets.push(...t.txn.appForeignAssets);
36
39
  // Create application,
@@ -98,4 +101,197 @@ export async function createDryrun({ client, txns, protocolVersion, latestTimest
98
101
  sources,
99
102
  });
100
103
  }
104
+ class DryrunStackValue {
105
+ constructor(sv) {
106
+ this.type = 0;
107
+ this.bytes = '';
108
+ this.uint = 0;
109
+ this.type = sv.type;
110
+ this.bytes = sv.bytes;
111
+ this.uint = sv.uint;
112
+ }
113
+ toString() {
114
+ if (this.type === 1) {
115
+ return `0x${Buffer.from(this.bytes, 'base64').toString('hex')}`;
116
+ }
117
+ return this.uint.toString();
118
+ }
119
+ }
120
+ class DryrunTraceLine {
121
+ constructor(line) {
122
+ this.error = '';
123
+ this.line = 0;
124
+ this.pc = 0;
125
+ this.scratch = [];
126
+ this.stack = [];
127
+ this.error = line.error === undefined ? '' : line.error;
128
+ this.line = line.line;
129
+ this.pc = line.pc;
130
+ this.scratch = line.scratch;
131
+ this.stack = line.stack.map((sv) => new DryrunStackValue(sv));
132
+ }
133
+ }
134
+ class DryrunTrace {
135
+ constructor(t) {
136
+ this.trace = [];
137
+ if (t === undefined)
138
+ return;
139
+ this.trace = t.map((line) => new DryrunTraceLine(line));
140
+ }
141
+ }
142
+ function truncate(str, maxValueWidth) {
143
+ if (str.length > maxValueWidth && maxValueWidth > 0) {
144
+ return `${str.slice(0, maxValueWidth)}...`;
145
+ }
146
+ return str;
147
+ }
148
+ function scratchToString(prevScratch, currScratch) {
149
+ if (currScratch.length === 0)
150
+ return '';
151
+ let newScratchIdx = null;
152
+ for (let idx = 0; idx < currScratch.length; idx++) {
153
+ if (idx > prevScratch.length) {
154
+ newScratchIdx = idx;
155
+ continue;
156
+ }
157
+ if (JSON.stringify(prevScratch[idx]) !== JSON.stringify(currScratch[idx])) {
158
+ newScratchIdx = idx;
159
+ }
160
+ }
161
+ if (newScratchIdx == null)
162
+ return '';
163
+ const newScratch = currScratch[newScratchIdx];
164
+ if (newScratch.bytes.length > 0) {
165
+ return `${newScratchIdx} = 0x${Buffer.from(newScratch.bytes, 'base64').toString('hex')}`;
166
+ }
167
+ return `${newScratchIdx} = ${newScratch.uint.toString()}`;
168
+ }
169
+ function stackToString(stack, reverse) {
170
+ const svs = reverse ? stack.reverse() : stack;
171
+ return `[${svs
172
+ .map((sv) => {
173
+ switch (sv.type) {
174
+ case 1:
175
+ return `0x${Buffer.from(sv.bytes, 'base64').toString('hex')}`;
176
+ case 2:
177
+ return `${sv.uint.toString()}`;
178
+ default:
179
+ return '';
180
+ }
181
+ })
182
+ .join(', ')}]`;
183
+ }
184
+ class DryrunTransactionResult {
185
+ constructor(dtr) {
186
+ this.disassembly = [];
187
+ this.appCallMessages = [];
188
+ this.localDeltas = [];
189
+ this.globalDelta = [];
190
+ this.cost = 0;
191
+ this.logicSigMessages = [];
192
+ this.logicSigDisassembly = [];
193
+ this.logs = [];
194
+ this.appCallTrace = undefined;
195
+ this.logicSigTrace = undefined;
196
+ this.required = ['disassembly'];
197
+ this.optionals = [
198
+ 'app-call-messages',
199
+ 'local-deltas',
200
+ 'global-delta',
201
+ 'cost',
202
+ 'logic-sig-messages',
203
+ 'logic-sig-disassembly',
204
+ 'logs',
205
+ ];
206
+ this.traces = ['app-call-trace', 'logic-sig-trace'];
207
+ this.disassembly = dtr.disassembly;
208
+ this.appCallMessages = dtr['app-call-messages'];
209
+ this.localDeltas = dtr['local-deltas'];
210
+ this.globalDelta = dtr['global-delta'];
211
+ this.cost = dtr.cost;
212
+ this.logicSigMessages = dtr['logic-sig-messages'];
213
+ this.logicSigDisassembly = dtr['logic-sig-disassembly'];
214
+ this.logs = dtr.logs;
215
+ this.appCallTrace = new DryrunTrace(dtr['app-call-trace']);
216
+ this.logicSigTrace = new DryrunTrace(dtr['logic-sig-trace']);
217
+ }
218
+ appCallRejected() {
219
+ return (this.appCallMessages !== undefined &&
220
+ this.appCallMessages.includes('REJECT'));
221
+ }
222
+ logicSigRejected() {
223
+ return (this.logicSigMessages !== undefined &&
224
+ this.logicSigMessages.includes('REJECT'));
225
+ }
226
+ static trace(drt, disassembly, spc) {
227
+ let maxWidth = defaultMaxWidth;
228
+ if (spc.maxValueWidth === undefined)
229
+ maxWidth = spc.maxValueWidth;
230
+ // Create the array of arrays, each sub array contains N columns
231
+ const lines = [['pc#', 'ln#', 'source', 'scratch', 'stack']];
232
+ for (let idx = 0; idx < drt.trace.length; idx++) {
233
+ const { line, error, pc, scratch, stack } = drt.trace[idx];
234
+ const currScratch = scratch !== undefined ? scratch : [];
235
+ const prevScratch = idx > 0 && drt.trace[idx - 1].scratch !== undefined
236
+ ? drt.trace[idx - 1].scratch
237
+ : [];
238
+ const src = error === '' ? disassembly[line] : `!! ${error} !!`;
239
+ lines.push([
240
+ pc.toString().padEnd(3, ' '),
241
+ line.toString().padEnd(3, ' '),
242
+ truncate(src, maxWidth),
243
+ truncate(scratchToString(prevScratch, currScratch), maxWidth),
244
+ truncate(stackToString(stack, spc.topOfStackFirst), maxWidth),
245
+ ]);
246
+ }
247
+ // Get the max length for each column
248
+ const maxLengths = lines.reduce((prev, curr) => {
249
+ const newVal = new Array(lines[0].length).fill(0);
250
+ for (let idx = 0; idx < prev.length; idx++) {
251
+ newVal[idx] =
252
+ curr[idx].length > prev[idx] ? curr[idx].length : prev[idx];
253
+ }
254
+ return newVal;
255
+ }, new Array(lines[0].length).fill(0));
256
+ return `${lines
257
+ .map((line) => line
258
+ .map((v, idx) => v.padEnd(maxLengths[idx] + 1, ' '))
259
+ .join('|')
260
+ .trim())
261
+ .join('\n')}\n`;
262
+ }
263
+ appTrace(spc) {
264
+ if (this.appCallTrace === undefined || !this.disassembly)
265
+ return '';
266
+ let conf = spc;
267
+ if (spc === undefined)
268
+ conf = {
269
+ maxValueWidth: defaultMaxWidth,
270
+ topOfStackFirst: false,
271
+ };
272
+ return DryrunTransactionResult.trace(this.appCallTrace, this.disassembly, conf);
273
+ }
274
+ lsigTrace(spc) {
275
+ if (this.logicSigTrace === undefined ||
276
+ this.logicSigDisassembly === undefined)
277
+ return '';
278
+ let conf = spc;
279
+ if (spc === undefined)
280
+ conf = {
281
+ maxValueWidth: defaultMaxWidth,
282
+ topOfStackFirst: true,
283
+ };
284
+ return DryrunTransactionResult.trace(this.logicSigTrace, this.logicSigDisassembly, conf);
285
+ }
286
+ }
287
+ export class DryrunResult {
288
+ constructor(drrResp) {
289
+ this.error = '';
290
+ this.protocolVersion = '';
291
+ this.txns = [];
292
+ this.error = drrResp.error;
293
+ this.protocolVersion = drrResp['protocol-version'];
294
+ this.txns = drrResp.txns.map((txn) => new DryrunTransactionResult(txn));
295
+ }
296
+ }
101
297
  //# sourceMappingURL=dryrun.js.map