algosdk 2.3.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 (88) 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/algod.js +51 -0
  7. package/dist/cjs/client/v2/algod/algod.js.map +1 -1
  8. package/dist/cjs/client/v2/algod/getLedgerStateDelta.js +20 -0
  9. package/dist/cjs/client/v2/algod/getLedgerStateDelta.js.map +1 -0
  10. package/dist/cjs/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +20 -0
  11. package/dist/cjs/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js.map +1 -0
  12. package/dist/cjs/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +25 -0
  13. package/dist/cjs/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js.map +1 -0
  14. package/dist/cjs/client/v2/algod/models/types.js +301 -6
  15. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  16. package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js +2 -3
  17. package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  18. package/dist/cjs/client/v2/indexer/lookupAssetBalances.js +2 -1
  19. package/dist/cjs/client/v2/indexer/lookupAssetBalances.js.map +1 -1
  20. package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js +2 -4
  21. package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  22. package/dist/cjs/client/v2/indexer/searchAccounts.js +2 -1
  23. package/dist/cjs/client/v2/indexer/searchAccounts.js.map +1 -1
  24. package/dist/cjs/client/v2/indexer/searchForTransactions.js +61 -62
  25. package/dist/cjs/client/v2/indexer/searchForTransactions.js.map +1 -1
  26. package/dist/cjs/client/v2/serviceClient.js +3 -0
  27. package/dist/cjs/client/v2/serviceClient.js.map +1 -1
  28. package/dist/cjs/composer.js +1 -1
  29. package/dist/cjs/composer.js.map +1 -1
  30. package/dist/cjs/nacl/naclWrappers.js +4 -0
  31. package/dist/cjs/nacl/naclWrappers.js.map +1 -1
  32. package/dist/cjs/utils/utils.js +13 -1
  33. package/dist/cjs/utils/utils.js.map +1 -1
  34. package/dist/esm/client/urlTokenBaseHTTPClient.js +0 -3
  35. package/dist/esm/client/urlTokenBaseHTTPClient.js.map +1 -1
  36. package/dist/esm/client/v2/algod/algod.js +51 -0
  37. package/dist/esm/client/v2/algod/algod.js.map +1 -1
  38. package/dist/esm/client/v2/algod/getLedgerStateDelta.js +14 -0
  39. package/dist/esm/client/v2/algod/getLedgerStateDelta.js.map +1 -0
  40. package/dist/esm/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +14 -0
  41. package/dist/esm/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js.map +1 -0
  42. package/dist/esm/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +19 -0
  43. package/dist/esm/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js.map +1 -0
  44. package/dist/esm/client/v2/algod/models/types.js +292 -5
  45. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  46. package/dist/esm/client/v2/indexer/lookupAccountTransactions.js +2 -3
  47. package/dist/esm/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  48. package/dist/esm/client/v2/indexer/lookupAssetBalances.js +2 -1
  49. package/dist/esm/client/v2/indexer/lookupAssetBalances.js.map +1 -1
  50. package/dist/esm/client/v2/indexer/lookupAssetTransactions.js +2 -4
  51. package/dist/esm/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  52. package/dist/esm/client/v2/indexer/searchAccounts.js +2 -1
  53. package/dist/esm/client/v2/indexer/searchAccounts.js.map +1 -1
  54. package/dist/esm/client/v2/indexer/searchForTransactions.js +61 -62
  55. package/dist/esm/client/v2/indexer/searchForTransactions.js.map +1 -1
  56. package/dist/esm/client/v2/serviceClient.js +3 -0
  57. package/dist/esm/client/v2/serviceClient.js.map +1 -1
  58. package/dist/esm/composer.js +1 -1
  59. package/dist/esm/composer.js.map +1 -1
  60. package/dist/esm/nacl/naclWrappers.js +4 -0
  61. package/dist/esm/nacl/naclWrappers.js.map +1 -1
  62. package/dist/esm/utils/utils.js +11 -0
  63. package/dist/esm/utils/utils.js.map +1 -1
  64. package/dist/types/client/v2/algod/algod.d.ts +45 -0
  65. package/dist/types/client/v2/algod/getLedgerStateDelta.d.ts +8 -0
  66. package/dist/types/client/v2/algod/getLedgerStateDeltaForTransactionGroup.d.ts +8 -0
  67. package/dist/types/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.d.ts +10 -0
  68. package/dist/types/client/v2/algod/models/types.d.ts +242 -5
  69. package/dist/types/client/v2/indexer/lookupAccountTransactions.d.ts +0 -2
  70. package/dist/types/client/v2/indexer/lookupAssetTransactions.d.ts +0 -3
  71. package/dist/types/client/v2/indexer/searchForTransactions.d.ts +54 -56
  72. package/dist/types/utils/utils.d.ts +5 -0
  73. package/package.json +4 -6
  74. package/src/client/urlTokenBaseHTTPClient.ts +0 -3
  75. package/src/client/v2/algod/algod.ts +62 -0
  76. package/src/client/v2/algod/getLedgerStateDelta.ts +16 -0
  77. package/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts +16 -0
  78. package/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts +29 -0
  79. package/src/client/v2/algod/models/types.ts +527 -0
  80. package/src/client/v2/indexer/lookupAccountTransactions.ts +2 -3
  81. package/src/client/v2/indexer/lookupAssetBalances.ts +2 -1
  82. package/src/client/v2/indexer/lookupAssetTransactions.ts +2 -4
  83. package/src/client/v2/indexer/searchAccounts.ts +2 -1
  84. package/src/client/v2/indexer/searchForTransactions.ts +63 -64
  85. package/src/client/v2/serviceClient.ts +3 -0
  86. package/src/composer.ts +1 -1
  87. package/src/nacl/naclWrappers.ts +6 -0
  88. package/src/utils/utils.ts +12 -0
@@ -192,62 +192,6 @@ export default class SearchForTransactions extends JSONRequest {
192
192
  * @category query
193
193
  */
194
194
  afterTime(after: string): this;
195
- /**
196
- * 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.
197
- *
198
- * #### Example 1
199
- * ```typescript
200
- * const minBalance = 300000;
201
- * const txns = await indexerClient
202
- * .searchForTransactions()
203
- * .currencyGreaterThan(minBalance - 1)
204
- * .do();
205
- * ```
206
- *
207
- * #### Example 2
208
- * ```typescript
209
- * const assetID = 163650;
210
- * const minBalance = 300000;
211
- * const txns = await indexerClient
212
- * .searchForTransactions()
213
- * .assetID(assetID)
214
- * .currencyGreaterThan(minBalance - 1)
215
- * .do();
216
- * ```
217
- * @remarks
218
- * 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.
219
- *
220
- * @param greater
221
- * @category query
222
- */
223
- currencyGreaterThan(greater: number): this;
224
- /**
225
- * 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.
226
- *
227
- * #### Example 1
228
- * ```typescript
229
- * const maxBalance = 500000;
230
- * const txns = await indexerClient
231
- * .searchForTransactions()
232
- * .currencyLessThan(maxBalance + 1)
233
- * .do();
234
- * ```
235
- *
236
- * #### Example 2
237
- * ```typescript
238
- * const assetID = 163650;
239
- * const maxBalance = 500000;
240
- * const txns = await indexerClient
241
- * .searchForTransactions()
242
- * .assetID(assetID)
243
- * .currencyLessThan(maxBalance + 1)
244
- * .do();
245
- * ```
246
- *
247
- * @param lesser
248
- * @category query
249
- */
250
- currencyLessThan(lesser: number): this;
251
195
  /**
252
196
  * Combined with address, defines what address to filter on, as string.
253
197
  *
@@ -351,4 +295,58 @@ export default class SearchForTransactions extends JSONRequest {
351
295
  * @category query
352
296
  */
353
297
  applicationID(applicationID: number): this;
298
+ /**
299
+ * 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.
300
+ *
301
+ * #### Example 1
302
+ * ```typescript
303
+ * const minBalance = 300000;
304
+ * const txns = await indexerClient
305
+ * .searchForTransactions()
306
+ * .currencyGreaterThan(minBalance - 1)
307
+ * .do();
308
+ * ```
309
+ *
310
+ * #### Example 2
311
+ * ```typescript
312
+ * const assetID = 163650;
313
+ * const minBalance = 300000;
314
+ * const txns = await indexerClient
315
+ * .searchForTransactions()
316
+ * .assetID(assetID)
317
+ * .currencyGreaterThan(minBalance - 1)
318
+ * .do();
319
+ * ```
320
+ *
321
+ * @param greater
322
+ * @category query
323
+ */
324
+ currencyGreaterThan(greater: number): this;
325
+ /**
326
+ * 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.
327
+ *
328
+ * #### Example 1
329
+ * ```typescript
330
+ * const maxBalance = 500000;
331
+ * const txns = await indexerClient
332
+ * .searchForTransactions()
333
+ * .currencyLessThan(maxBalance + 1)
334
+ * .do();
335
+ * ```
336
+ *
337
+ * #### Example 2
338
+ * ```typescript
339
+ * const assetID = 163650;
340
+ * const maxBalance = 500000;
341
+ * const txns = await indexerClient
342
+ * .searchForTransactions()
343
+ * .assetID(assetID)
344
+ * .currencyLessThan(maxBalance + 1)
345
+ * .do();
346
+ * ```
347
+ *
348
+ * @param lesser
349
+ * @category query
350
+ */
351
+ currencyLessThan(lesser: number): this;
354
352
  }
@@ -45,3 +45,8 @@ export declare function removeUndefinedProperties(obj: Record<string | number |
45
45
  * @returns True if Node.js environment, false otherwise
46
46
  */
47
47
  export declare function isNode(): boolean;
48
+ /**
49
+ * Check whether the environment is ReactNative
50
+ * @returns True if ReactNative, false otherwise
51
+ */
52
+ export declare function isReactNative(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algosdk",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "The official JavaScript SDK for Algorand",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "algo-msgpack-with-bigint": "^2.1.1",
25
25
  "buffer": "^6.0.3",
26
- "cross-fetch": "^3.1.5",
26
+ "cross-fetch": "^4.0.0",
27
27
  "hi-base32": "^0.5.1",
28
28
  "js-sha256": "^0.9.0",
29
29
  "js-sha3": "^0.8.0",
@@ -38,9 +38,8 @@
38
38
  "@typescript-eslint/eslint-plugin": "^4.26.1",
39
39
  "@typescript-eslint/parser": "^4.26.1",
40
40
  "assert": "^2.0.0",
41
- "chromedriver": "^108.0.0",
41
+ "chromedriver": "^116.0.0",
42
42
  "concurrently": "^6.2.0",
43
- "coveralls": "^3.1.0",
44
43
  "cucumber": "^5.1.0",
45
44
  "es-abstract": "^1.18.3",
46
45
  "eslint": "^7.21.0",
@@ -53,10 +52,9 @@
53
52
  "husky": "^4.3.8",
54
53
  "lint-staged": "^10.5.4",
55
54
  "mocha": "^9.0.0",
56
- "mocha-lcov-reporter": "^1.3.0",
57
55
  "mock-http-server": "^1.4.3",
58
56
  "prettier": "2.2.1",
59
- "selenium-webdriver": "^4.2.0",
57
+ "selenium-webdriver": "^4.10.0",
60
58
  "source-map-loader": "^2.0.2",
61
59
  "ts-loader": "^9.3.1",
62
60
  "ts-node": "^10.9.1",
@@ -163,7 +163,6 @@ export class URLTokenBaseHTTPClient implements BaseHTTPClient {
163
163
  };
164
164
 
165
165
  const res = await fetch(this.getURL(relativePath, query), {
166
- mode: 'cors',
167
166
  headers,
168
167
  });
169
168
 
@@ -185,7 +184,6 @@ export class URLTokenBaseHTTPClient implements BaseHTTPClient {
185
184
 
186
185
  const res = await fetch(this.getURL(relativePath, query), {
187
186
  method: 'POST',
188
- mode: 'cors',
189
187
  body: data,
190
188
  headers,
191
189
  });
@@ -208,7 +206,6 @@ export class URLTokenBaseHTTPClient implements BaseHTTPClient {
208
206
 
209
207
  const res = await fetch(this.getURL(relativePath, query), {
210
208
  method: 'DELETE',
211
- mode: 'cors',
212
209
  body: data,
213
210
  headers,
214
211
  });
@@ -40,6 +40,9 @@ import { EncodedSignedTransaction } from '../../../types';
40
40
  import * as encoding from '../../../encoding/encoding';
41
41
  import Ready from './ready';
42
42
  import UnsetSyncRound from './unsetSyncRound';
43
+ import GetLedgerStateDeltaForTransactionGroup from './getLedgerStateDeltaForTransactionGroup';
44
+ import GetLedgerStateDelta from './getLedgerStateDelta';
45
+ import GetTransactionGroupLedgerStateDeltasForRound from './getTransactionGroupLedgerStateDeltasForRound';
43
46
 
44
47
  /**
45
48
  * Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with.
@@ -751,4 +754,63 @@ export default class AlgodClient extends ServiceClient {
751
754
  ready() {
752
755
  return new Ready(this.c, this.intDecoding);
753
756
  }
757
+
758
+ /**
759
+ * GetLedgerStateDeltaForTransactionGroup returns the ledger delta for the txn group identified by id
760
+ *
761
+ * #### Example
762
+ * ```typescript
763
+ * const id = "ABC123";
764
+ * await client.getLedgerStateDeltaForTransactionGroup(id).do();
765
+ * ```
766
+ *
767
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltastxngroupid)
768
+ * @param id txn ID or group ID to be searched for
769
+ * @category GET
770
+ */
771
+ getLedgerStateDeltaForTransactionGroup(id: string) {
772
+ return new GetLedgerStateDeltaForTransactionGroup(
773
+ this.c,
774
+ this.intDecoding,
775
+ id
776
+ );
777
+ }
778
+
779
+ /**
780
+ * GetLedgerStateDelta returns the ledger delta for the entire round
781
+ *
782
+ * #### Example
783
+ * ```typescript
784
+ * const round = 12345;
785
+ * await client.getLedgerStateDelta(round).do();
786
+ * ```
787
+ *
788
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasround)
789
+ * @param round the round number to be searched for
790
+ * @category GET
791
+ */
792
+ getLedgerStateDelta(round: bigint) {
793
+ return new GetLedgerStateDelta(this.c, this.intDecoding, round);
794
+ }
795
+
796
+ /**
797
+ * GetTransactionGroupLedgerStateDeltasForRound returns all ledger deltas for txn groups in the provided round
798
+ *
799
+ * #### Example
800
+ * ```typescript
801
+ * const round = 12345;
802
+ * await client.getTransactionGroupLedgerStateDeltasForRound(round).do();
803
+ * ```
804
+ *
805
+ * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasroundtxngroup)
806
+ * @param round the round number to be searched for
807
+ * @category GET
808
+ */
809
+ getTransactionGroupLedgerStateDeltasForRound(round: bigint) {
810
+ return new GetTransactionGroupLedgerStateDeltasForRound(
811
+ this.c,
812
+ this.intDecoding,
813
+ round
814
+ );
815
+ }
754
816
  }
@@ -0,0 +1,16 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import HTTPClient from '../../client';
3
+ import IntDecoding from '../../../types/intDecoding';
4
+
5
+ export default class GetLedgerStateDelta extends JSONRequest {
6
+ constructor(c: HTTPClient, intDecoding: IntDecoding, private round: bigint) {
7
+ super(c, intDecoding);
8
+ this.round = round;
9
+ this.query = { format: 'json' };
10
+ }
11
+
12
+ // eslint-disable-next-line class-methods-use-this
13
+ path() {
14
+ return `/v2/deltas/${this.round}`;
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import HTTPClient from '../../client';
3
+ import IntDecoding from '../../../types/intDecoding';
4
+
5
+ export default class GetLedgerStateDeltaForTransactionGroup extends JSONRequest {
6
+ constructor(c: HTTPClient, intDecoding: IntDecoding, private id: string) {
7
+ super(c, intDecoding);
8
+ this.id = id;
9
+ this.query = { format: 'json' };
10
+ }
11
+
12
+ // eslint-disable-next-line class-methods-use-this
13
+ path() {
14
+ return `/v2/deltas/txn/group/${this.id}`;
15
+ }
16
+ }
@@ -0,0 +1,29 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import { TransactionGroupLedgerStateDeltasForRoundResponse } from './models/types';
3
+ import HTTPClient from '../../client';
4
+ import IntDecoding from '../../../types/intDecoding';
5
+
6
+ export default class GetTransactionGroupLedgerStateDeltasForRound extends JSONRequest<
7
+ TransactionGroupLedgerStateDeltasForRoundResponse,
8
+ Record<string, any>
9
+ > {
10
+ constructor(c: HTTPClient, intDecoding: IntDecoding, private round: bigint) {
11
+ super(c, intDecoding);
12
+ this.round = round;
13
+ this.query = { format: 'json' };
14
+ }
15
+
16
+ // eslint-disable-next-line class-methods-use-this
17
+ path() {
18
+ return `/v2/deltas/${this.round}/txn/group`;
19
+ }
20
+
21
+ // eslint-disable-next-line class-methods-use-this
22
+ prepare(
23
+ body: Record<string, any>
24
+ ): TransactionGroupLedgerStateDeltasForRoundResponse {
25
+ return TransactionGroupLedgerStateDeltasForRoundResponse.from_obj_for_encoding(
26
+ body
27
+ );
28
+ }
29
+ }