algosdk 2.4.0 → 2.5.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 (54) 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/client/urlTokenBaseHTTPClient.js +0 -3
  5. package/dist/cjs/client/urlTokenBaseHTTPClient.js.map +1 -1
  6. package/dist/cjs/client/v2/algod/models/types.js +240 -15
  7. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  8. package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js +2 -3
  9. package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  10. package/dist/cjs/client/v2/indexer/lookupAssetBalances.js +2 -1
  11. package/dist/cjs/client/v2/indexer/lookupAssetBalances.js.map +1 -1
  12. package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js +2 -4
  13. package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  14. package/dist/cjs/client/v2/indexer/searchAccounts.js +2 -1
  15. package/dist/cjs/client/v2/indexer/searchAccounts.js.map +1 -1
  16. package/dist/cjs/client/v2/indexer/searchForTransactions.js +61 -62
  17. package/dist/cjs/client/v2/indexer/searchForTransactions.js.map +1 -1
  18. package/dist/cjs/nacl/naclWrappers.js +4 -0
  19. package/dist/cjs/nacl/naclWrappers.js.map +1 -1
  20. package/dist/cjs/utils/utils.js +13 -1
  21. package/dist/cjs/utils/utils.js.map +1 -1
  22. package/dist/esm/client/urlTokenBaseHTTPClient.js +0 -3
  23. package/dist/esm/client/urlTokenBaseHTTPClient.js.map +1 -1
  24. package/dist/esm/client/v2/algod/models/types.js +233 -13
  25. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  26. package/dist/esm/client/v2/indexer/lookupAccountTransactions.js +2 -3
  27. package/dist/esm/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  28. package/dist/esm/client/v2/indexer/lookupAssetBalances.js +2 -1
  29. package/dist/esm/client/v2/indexer/lookupAssetBalances.js.map +1 -1
  30. package/dist/esm/client/v2/indexer/lookupAssetTransactions.js +2 -4
  31. package/dist/esm/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  32. package/dist/esm/client/v2/indexer/searchAccounts.js +2 -1
  33. package/dist/esm/client/v2/indexer/searchAccounts.js.map +1 -1
  34. package/dist/esm/client/v2/indexer/searchForTransactions.js +61 -62
  35. package/dist/esm/client/v2/indexer/searchForTransactions.js.map +1 -1
  36. package/dist/esm/nacl/naclWrappers.js +4 -0
  37. package/dist/esm/nacl/naclWrappers.js.map +1 -1
  38. package/dist/esm/utils/utils.js +11 -0
  39. package/dist/esm/utils/utils.js.map +1 -1
  40. package/dist/types/client/v2/algod/models/types.d.ts +194 -4
  41. package/dist/types/client/v2/indexer/lookupAccountTransactions.d.ts +0 -2
  42. package/dist/types/client/v2/indexer/lookupAssetTransactions.d.ts +0 -3
  43. package/dist/types/client/v2/indexer/searchForTransactions.d.ts +54 -56
  44. package/dist/types/utils/utils.d.ts +5 -0
  45. package/package.json +4 -4
  46. package/src/client/urlTokenBaseHTTPClient.ts +0 -3
  47. package/src/client/v2/algod/models/types.ts +430 -9
  48. package/src/client/v2/indexer/lookupAccountTransactions.ts +2 -3
  49. package/src/client/v2/indexer/lookupAssetBalances.ts +2 -1
  50. package/src/client/v2/indexer/lookupAssetTransactions.ts +2 -4
  51. package/src/client/v2/indexer/searchAccounts.ts +2 -1
  52. package/src/client/v2/indexer/searchForTransactions.ts +63 -64
  53. package/src/nacl/naclWrappers.ts +6 -0
  54. package/src/utils/utils.ts +12 -0
@@ -49,7 +49,8 @@ export default class SearchAccounts extends JSONRequest {
49
49
  * @category query
50
50
  */
51
51
  currencyGreaterThan(greater: number) {
52
- this.query['currency-greater-than'] = greater;
52
+ // We convert the following to a string for now to correctly include zero values in request parameters.
53
+ this.query['currency-greater-than'] = greater.toString();
53
54
  return this;
54
55
  }
55
56
 
@@ -242,70 +242,6 @@ export default class SearchForTransactions extends JSONRequest {
242
242
  return this;
243
243
  }
244
244
 
245
- /**
246
- * 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.
247
- *
248
- * #### Example 1
249
- * ```typescript
250
- * const minBalance = 300000;
251
- * const txns = await indexerClient
252
- * .searchForTransactions()
253
- * .currencyGreaterThan(minBalance - 1)
254
- * .do();
255
- * ```
256
- *
257
- * #### Example 2
258
- * ```typescript
259
- * const assetID = 163650;
260
- * const minBalance = 300000;
261
- * const txns = await indexerClient
262
- * .searchForTransactions()
263
- * .assetID(assetID)
264
- * .currencyGreaterThan(minBalance - 1)
265
- * .do();
266
- * ```
267
- * @remarks
268
- * 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.
269
- *
270
- * @param greater
271
- * @category query
272
- */
273
- currencyGreaterThan(greater: number) {
274
- this.query['currency-greater-than'] = greater;
275
- return this;
276
- }
277
-
278
- /**
279
- * 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.
280
- *
281
- * #### Example 1
282
- * ```typescript
283
- * const maxBalance = 500000;
284
- * const txns = await indexerClient
285
- * .searchForTransactions()
286
- * .currencyLessThan(maxBalance + 1)
287
- * .do();
288
- * ```
289
- *
290
- * #### Example 2
291
- * ```typescript
292
- * const assetID = 163650;
293
- * const maxBalance = 500000;
294
- * const txns = await indexerClient
295
- * .searchForTransactions()
296
- * .assetID(assetID)
297
- * .currencyLessThan(maxBalance + 1)
298
- * .do();
299
- * ```
300
- *
301
- * @param lesser
302
- * @category query
303
- */
304
- currencyLessThan(lesser: number) {
305
- this.query['currency-less-than'] = lesser;
306
- return this;
307
- }
308
-
309
245
  /**
310
246
  * Combined with address, defines what address to filter on, as string.
311
247
  *
@@ -432,4 +368,67 @@ export default class SearchForTransactions extends JSONRequest {
432
368
  this.query['application-id'] = applicationID;
433
369
  return this;
434
370
  }
371
+
372
+ /**
373
+ * 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.
374
+ *
375
+ * #### Example 1
376
+ * ```typescript
377
+ * const minBalance = 300000;
378
+ * const txns = await indexerClient
379
+ * .searchForTransactions()
380
+ * .currencyGreaterThan(minBalance - 1)
381
+ * .do();
382
+ * ```
383
+ *
384
+ * #### Example 2
385
+ * ```typescript
386
+ * const assetID = 163650;
387
+ * const minBalance = 300000;
388
+ * const txns = await indexerClient
389
+ * .searchForTransactions()
390
+ * .assetID(assetID)
391
+ * .currencyGreaterThan(minBalance - 1)
392
+ * .do();
393
+ * ```
394
+ *
395
+ * @param greater
396
+ * @category query
397
+ */
398
+ currencyGreaterThan(greater: number) {
399
+ // We convert the following to a string for now to correctly include zero values in request parameters.
400
+ this.query['currency-greater-than'] = greater.toString();
401
+ return this;
402
+ }
403
+
404
+ /**
405
+ * 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.
406
+ *
407
+ * #### Example 1
408
+ * ```typescript
409
+ * const maxBalance = 500000;
410
+ * const txns = await indexerClient
411
+ * .searchForTransactions()
412
+ * .currencyLessThan(maxBalance + 1)
413
+ * .do();
414
+ * ```
415
+ *
416
+ * #### Example 2
417
+ * ```typescript
418
+ * const assetID = 163650;
419
+ * const maxBalance = 500000;
420
+ * const txns = await indexerClient
421
+ * .searchForTransactions()
422
+ * .assetID(assetID)
423
+ * .currencyLessThan(maxBalance + 1)
424
+ * .do();
425
+ * ```
426
+ *
427
+ * @param lesser
428
+ * @category query
429
+ */
430
+ currencyLessThan(lesser: number) {
431
+ this.query['currency-less-than'] = lesser;
432
+ return this;
433
+ }
435
434
  }
@@ -1,11 +1,17 @@
1
1
  import nacl from 'tweetnacl';
2
2
  import sha512 from 'js-sha512';
3
+ import { isReactNative } from '../utils/utils';
3
4
 
4
5
  export function genericHash(arr: sha512.Message) {
5
6
  return sha512.sha512_256.array(arr);
6
7
  }
7
8
 
8
9
  export function randomBytes(length: number) {
10
+ if (isReactNative()) {
11
+ console.warn(
12
+ `It looks like you're running in react-native. In order to perform common crypto operations you will need to polyfill common operations such as crypto.getRandomValues`
13
+ );
14
+ }
9
15
  return nacl.randomBytes(length);
10
16
  }
11
17
 
@@ -122,3 +122,15 @@ export function isNode() {
122
122
  typeof process.versions.node !== 'undefined'
123
123
  );
124
124
  }
125
+
126
+ /**
127
+ * Check whether the environment is ReactNative
128
+ * @returns True if ReactNative, false otherwise
129
+ */
130
+ export function isReactNative() {
131
+ const { navigator } = globalThis as { navigator?: { product?: string } };
132
+ if (typeof navigator === 'object' && navigator.product === 'ReactNative') {
133
+ return true;
134
+ }
135
+ return false;
136
+ }