From 82f514f0d98f5b003de9a712afb911621e8f0bd8 Mon Sep 17 00:00:00 2001 From: Fionna Chan Date: Thu, 17 Feb 2022 07:16:53 +0800 Subject: [PATCH 1/8] Docs for `lookupAssetByID` and `lookupAccountTransactions` (#516) * Update typedoc to show grey bg for code blocks * Add docs to lookupAssetByID * Add more examples to lookupAssetByID * Add docs to lookupAccountTransactions * Add method category to lookupAssetByID --- package-lock.json | 48 +-- package.json | 2 +- .../v2/indexer/lookupAccountTransactions.ts | 295 +++++++++++++++++- src/client/v2/indexer/lookupAssetByID.ts | 38 ++- src/client/v2/jsonrequest.ts | 4 + 5 files changed, 346 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24c287cb2..004501ac9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,7 @@ "source-map-loader": "^2.0.2", "ts-loader": "^8.3.0", "ts-node": "^10.0.0", - "typedoc": "^0.22.10", + "typedoc": "^0.22.11", "typedoc-plugin-missing-exports": "^0.22.6", "typedoc-plugin-rename-defaults": "^0.4.0", "typescript": "^4.2.3", @@ -4937,12 +4937,12 @@ "dev": true }, "node_modules/marked": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/marked/-/marked-3.0.8.tgz", - "integrity": "sha512-0gVrAjo5m0VZSJb4rpL59K1unJAMb/hm8HRXqasD8VeC8m91ytDPMritgFSlKonfdt+rRYYpP/JfLxgIX8yoSw==", + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz", + "integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==", "dev": true, "bin": { - "marked": "bin/marked" + "marked": "bin/marked.js" }, "engines": { "node": ">= 12" @@ -6597,9 +6597,9 @@ } }, "node_modules/shiki": { - "version": "0.9.14", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.14.tgz", - "integrity": "sha512-uLHjjyJdNsMzF9GOF8vlOuZ8BwigiYPraMN5yjC826k8K7Xu90JQcC5GUNrzRibLgT2EOk9597I1IX+jRdA8nw==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.0.tgz", + "integrity": "sha512-iczxaIYeBFHTFrQPb9DVy2SKgYxC4Wo7Iucm7C17cCh2Ge/refnvHscUOxM85u57MfLoNOtjoEFUWt9gBexblA==", "dev": true, "dependencies": { "jsonc-parser": "^3.0.0", @@ -7530,16 +7530,16 @@ } }, "node_modules/typedoc": { - "version": "0.22.10", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.10.tgz", - "integrity": "sha512-hQYZ4WtoMZ61wDC6w10kxA42+jclWngdmztNZsDvIz7BMJg7F2xnT+uYsUa7OluyKossdFj9E9Ye4QOZKTy8SA==", + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", "dev": true, "dependencies": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^3.0.8", + "marked": "^4.0.10", "minimatch": "^3.0.4", - "shiki": "^0.9.12" + "shiki": "^0.10.0" }, "bin": { "typedoc": "bin/typedoc" @@ -12113,9 +12113,9 @@ "dev": true }, "marked": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/marked/-/marked-3.0.8.tgz", - "integrity": "sha512-0gVrAjo5m0VZSJb4rpL59K1unJAMb/hm8HRXqasD8VeC8m91ytDPMritgFSlKonfdt+rRYYpP/JfLxgIX8yoSw==", + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz", + "integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==", "dev": true }, "media-typer": { @@ -13350,9 +13350,9 @@ "dev": true }, "shiki": { - "version": "0.9.14", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.9.14.tgz", - "integrity": "sha512-uLHjjyJdNsMzF9GOF8vlOuZ8BwigiYPraMN5yjC826k8K7Xu90JQcC5GUNrzRibLgT2EOk9597I1IX+jRdA8nw==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.0.tgz", + "integrity": "sha512-iczxaIYeBFHTFrQPb9DVy2SKgYxC4Wo7Iucm7C17cCh2Ge/refnvHscUOxM85u57MfLoNOtjoEFUWt9gBexblA==", "dev": true, "requires": { "jsonc-parser": "^3.0.0", @@ -14074,16 +14074,16 @@ } }, "typedoc": { - "version": "0.22.10", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.10.tgz", - "integrity": "sha512-hQYZ4WtoMZ61wDC6w10kxA42+jclWngdmztNZsDvIz7BMJg7F2xnT+uYsUa7OluyKossdFj9E9Ye4QOZKTy8SA==", + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", "dev": true, "requires": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^3.0.8", + "marked": "^4.0.10", "minimatch": "^3.0.4", - "shiki": "^0.9.12" + "shiki": "^0.10.0" }, "dependencies": { "glob": { diff --git a/package.json b/package.json index 88f12abae..19811aa9f 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "source-map-loader": "^2.0.2", "ts-loader": "^8.3.0", "ts-node": "^10.0.0", - "typedoc": "^0.22.10", + "typedoc": "^0.22.11", "typedoc-plugin-missing-exports": "^0.22.6", "typedoc-plugin-rename-defaults": "^0.4.0", "typescript": "^4.2.3", diff --git a/src/client/v2/indexer/lookupAccountTransactions.ts b/src/client/v2/indexer/lookupAccountTransactions.ts index df54e062b..56c36b55e 100644 --- a/src/client/v2/indexer/lookupAccountTransactions.ts +++ b/src/client/v2/indexer/lookupAccountTransactions.ts @@ -15,6 +15,18 @@ export function base64StringFunnel(data: Uint8Array | string) { } export default class LookupAccountTransactions extends JSONRequest { + /** + * Returns transactions relating to the given account. + * + * #### Example + * ```typescript + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient.lookupAccountTransactions(address).do(); + * ``` + * + * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idtransactions) + * @param account - The address of the account. + */ constructor( c: HTTPClient, intDecoding: IntDecoding, @@ -24,98 +36,351 @@ export default class LookupAccountTransactions extends JSONRequest { this.account = account; } + /** + * @returns /v2/accounts/`${account}`/transactions + */ path() { return `/v2/accounts/${this.account}/transactions`; } /** - * notePrefix to filter with + * Specifies a prefix which must be contained in the note field + * + * #### Example + * ```typescript + * const notePrefixBase64Encoded = "Y3JlYXRl"; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .notePrefix(notePrefixBase64Encoded) + * .do(); + * ``` + * * @param prefix - base64 string or uint8array + * @category query */ notePrefix(prefix: Uint8Array | string) { this.query['note-prefix'] = base64StringFunnel(prefix); return this; } - // txtype to filter with, as string + /** + * Type of transaction to filter with + * + * #### Example + * ```typescript + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .txType("appl") + * .do(); + * ``` + * + * @param type - one of “pay”, “keyreg”, “acfg”, “axfer”, “afrz”, "appl" + * @category query + */ txType(type: string) { this.query['tx-type'] = type; return this; } - // sigtype to filter with, as string + /** + * Type of signature to filter with + * - sig: Standard + * - msig: MultiSig + * - lsig: LogicSig + * + * #### Example + * ```typescript + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .sigType("msig") + * .do(); + * ``` + * + * @param type - one of “sig”, “msig”, “lsig” + * @category query + */ sigType(type: string) { this.query['sig-type'] = type; return this; } - // txid to filter with, as string + /** + * Lookup the specific transaction by ID + * + * #### Example + * ```typescript + * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .txid(txId) + * .do(); + * ``` + * + * @param txid + * @category query + */ txid(txid: string) { this.query.txid = txid; return this; } - // round to filter with, as int + /** + * Include results for the specified round + * + * #### Example + * ```typescript + * const targetBlock = 18309917; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .round(targetBlock) + * .do(); + * ``` + * + * @param round + * @category query + */ round(round: number) { this.query.round = round; return this; } - // min round to filter with, as int + /** + * Include results at or after the specified min-round + * + * #### Example + * ```typescript + * const minRound = 18309917; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .minRound(minRound) + * .do(); + * ``` + * + * @param round + * @category query + */ minRound(round: number) { this.query['min-round'] = round; return this; } - // max round to filter with, as int + /** + * Include results at or before the specified max-round + * + * #### Example + * ```typescript + * const maxRound = 18309917; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .maxRound(maxRound) + * .do(); + * ``` + * + * @param round + * @category query + */ maxRound(round: number) { this.query['max-round'] = round; return this; } - // asset ID to filter with, as int + /** + * Asset ID to filter with + * + * #### Example + * ```typescript + * const assetID = 163650; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .assetID(assetID) + * .do(); + * ``` + * + * @param id + * @category query + */ assetID(id: number) { this.query['asset-id'] = id; return this; } - // limit for filter, as int + /** + * Maximum number of results to return + * + * #### Example + * ```typescript + * const limit = 25; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .limit(limit) + * .do(); + * ``` + * + * @param limit + * @category query + */ limit(limit: number) { this.query.limit = limit; return this; } - // before-time to filter with, as rfc3339 string + /** + * Include results before the given time + * + * #### Example + * ```typescript + * const beforeTime = "2022-02-02T20:20:22.02Z"; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .beforeTime(beforeTime) + * .do(); + * ``` + * + * @param before - rfc3339 string + * @category query + */ beforeTime(before: string) { this.query['before-time'] = before; return this; } - // after-time to filter with, as rfc3339 string + /** + * Include results after the given time + * + * #### Example + * ```typescript + * const afterTime = "2022-10-21T00:00:11.55Z"; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .afterTime(afterTime) + * .do(); + * ``` + * + * @param after - rfc3339 string + * @category query + */ afterTime(after: string) { this.query['after-time'] = after; return this; } - // 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 + /** + * 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. + * + * #### Example 1 + * ```typescript + * const minBalance = 300000; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .currencyGreaterThan(minBalance - 1) + * .do(); + * ``` + * + * #### Example 2 + * ```typescript + * const assetID = 163650; + * const minBalance = 300000; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .assetID(assetID) + * .currencyGreaterThan(minBalance - 1) + * .do(); + * ``` + * @remarks + * 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. + * + * @param greater + * @category query + */ currencyGreaterThan(greater: number) { this.query['currency-greater-than'] = greater; return this; } - // 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 + /** + * 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 + * + * #### Example 1 + * ```typescript + * const maxBalance = 500000; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .currencyLessThan(maxBalance + 1) + * .do(); + * ``` + * + * #### Example 2 + * ```typescript + * const assetID = 163650; + * const maxBalance = 500000; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .assetID(assetID) + * .currencyLessThan(maxBalance + 1) + * .do(); + * ``` + * + * @param lesser + * @category query + */ currencyLessThan(lesser: number) { this.query['currency-less-than'] = lesser; return this; } - // used for pagination + /** + * The next page of results. Use the next token provided by the previous results. + * + * #### Example + * ```typescript + * const limit = 25; + * const nextToken = "the next token returned in the previous query response"; + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .limit(limit) + * .nextToken(nextToken) + * .do(); + * ``` + * + * @param nextToken + * @category query + */ nextToken(nextToken: string) { this.query.next = nextToken; return this; } - // whether or not to include rekeying transactions + /** + * Include results which include the rekey-to field + * + * #### Example + * ```typescript + * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; + * const accountTxns = await indexerClient + * .lookupAccountTransactions(address) + * .rekeyTo(false) + * .do(); + * ``` + * + * @param rekeyTo + * @category query + */ rekeyTo(rekeyTo: boolean) { this.query['rekey-to'] = rekeyTo; return this; diff --git a/src/client/v2/indexer/lookupAssetByID.ts b/src/client/v2/indexer/lookupAssetByID.ts index 57eb40a53..01f9fe866 100644 --- a/src/client/v2/indexer/lookupAssetByID.ts +++ b/src/client/v2/indexer/lookupAssetByID.ts @@ -3,16 +3,52 @@ import HTTPClient from '../../client'; import IntDecoding from '../../../types/intDecoding'; export default class LookupAssetByID extends JSONRequest { + /** + * Returns asset information of the queried asset. + * + * #### Example + * ```typescript + * const assetId = 163650; + * const assetInfo = await indexerClient.lookupAssetByID(assetId).do(); + * ``` + * + * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id) + * @param index - The asset ID to look up. + */ constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) { super(c, intDecoding); this.index = index; } + /** + * @returns `/v2/assets/${index}` + */ path() { return `/v2/assets/${this.index}`; } - // include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates + /** + * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates + * + * #### Example 1 + * ```typescript + * const assetInfo = await indexerClient + * .lookupAssetByID(assetId) + * .includeAll(false) + * .do(); + * ``` + * + * #### Example 2 + * ```typescript + * const assetInfo = await indexerClient + * .lookupAssetByID(assetId) + * .includeAll() + * .do(); + * ``` + * + * @param value - default true when called without passing a value + * @category query + */ includeAll(value = true) { this.query['include-all'] = value; return this; diff --git a/src/client/v2/jsonrequest.ts b/src/client/v2/jsonrequest.ts index 70f9b552e..16e344440 100644 --- a/src/client/v2/jsonrequest.ts +++ b/src/client/v2/jsonrequest.ts @@ -30,6 +30,7 @@ export default abstract class JSONRequest< /** * @returns The path of this request. + * @category JSONRequest */ abstract path(): string; @@ -39,6 +40,7 @@ export default abstract class JSONRequest< * Use this method to change and restructure response * data as needed after receiving it from the `do()` method. * @param body - Response body received + * @category JSONRequest */ // eslint-disable-next-line class-methods-use-this prepare(body: Body): Data { @@ -49,6 +51,7 @@ export default abstract class JSONRequest< * Execute the request. * @param headers - Additional headers to send in the request. Optional. * @returns A promise which resolves to the response data. + * @category JSONRequest */ async do(headers: Record = {}): Promise { const jsonOptions: Record = {}; @@ -73,6 +76,7 @@ export default abstract class JSONRequest< * * @param method - The method to use when parsing the * response for this request. Must be one of "default", "safe", "mixed", or "bigint". + * @category JSONRequest */ setIntDecoding(method: IntDecoding) { if ( From a98f1df546b5ebf0e3cba79a20774d2b2504661b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Feb 2022 09:22:15 -0800 Subject: [PATCH 2/8] Bump url-parse from 1.5.1 to 1.5.8 (#529) Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.8. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](https://github.com/unshiftio/url-parse/compare/1.5.1...1.5.8) --- updated-dependencies: - dependency-name: url-parse dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 004501ac9..8572a4085 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7660,9 +7660,9 @@ } }, "node_modules/url-parse": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz", - "integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==", + "version": "1.5.8", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.8.tgz", + "integrity": "sha512-9JZ5zDrn9wJoOy/t+rH00HHejbU8dq9VsOYVu272TYDrCiyVAgHKUSpPh3ruZIpv8PMVR+NXLZvfRPJv8xAcQw==", "dependencies": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" @@ -14171,9 +14171,9 @@ } }, "url-parse": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz", - "integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==", + "version": "1.5.8", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.8.tgz", + "integrity": "sha512-9JZ5zDrn9wJoOy/t+rH00HHejbU8dq9VsOYVu272TYDrCiyVAgHKUSpPh3ruZIpv8PMVR+NXLZvfRPJv8xAcQw==", "requires": { "querystringify": "^2.1.1", "requires-port": "^1.0.0" From 82c7c4c5c32dafcfdfc8ebf31f68010322c45b0f Mon Sep 17 00:00:00 2001 From: Joe Polny <50534337+joe-p@users.noreply.github.com> Date: Mon, 28 Feb 2022 12:55:26 -0500 Subject: [PATCH 3/8] Make FromObject parameter IntelliSense human readable (#528) * add Expand to expand types for IntelliSense * expand types for FromObject parameters --- src/makeTxn.ts | 698 ++++++++++++++++++++++++--------------------- src/types/utils.ts | 10 + 2 files changed, 375 insertions(+), 333 deletions(-) diff --git a/src/makeTxn.ts b/src/makeTxn.ts index d402db72e..d0782e6de 100644 --- a/src/makeTxn.ts +++ b/src/makeTxn.ts @@ -23,7 +23,7 @@ import { AppClearStateTxn, AppNoOpTxn, } from './types/transactions'; -import { RenameProperties, RenameProperty } from './types/utils'; +import { RenameProperties, RenameProperty, Expand } from './types/utils'; /** * makePaymentTxnWithSuggestedParams takes payment arguments and returns a Transaction object @@ -113,15 +113,17 @@ export function makePaymentTxn( // helper for above makePaymentTxnWithSuggestedParams, instead accepting an arguments object export function makePaymentTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperty, 'reKeyTo', 'rekeyTo'>, - | 'from' - | 'to' - | 'amount' - | 'closeRemainderTo' - | 'note' - | 'suggestedParams' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperty, 'reKeyTo', 'rekeyTo'>, + | 'from' + | 'to' + | 'amount' + | 'closeRemainderTo' + | 'note' + | 'suggestedParams' + | 'rekeyTo' + > > ) { return makePaymentTxnWithSuggestedParams( @@ -313,37 +315,41 @@ export function makeKeyRegistrationTxn( // helper for above makeKeyRegistrationTxnWithSuggestedParams, instead accepting an arguments object export function makeKeyRegistrationTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperty< - MustHaveSuggestedParams, - 'reKeyTo', - 'rekeyTo' - >, - | 'from' - | 'note' - | 'voteKey' - | 'selectionKey' - | 'stateProofKey' - | 'voteFirst' - | 'voteLast' - | 'voteKeyDilution' - | 'suggestedParams' - | 'rekeyTo' - > & { - nonParticipation?: false; - } + o: Expand< + Pick< + RenameProperty< + MustHaveSuggestedParams, + 'reKeyTo', + 'rekeyTo' + >, + | 'from' + | 'note' + | 'voteKey' + | 'selectionKey' + | 'stateProofKey' + | 'voteFirst' + | 'voteLast' + | 'voteKeyDilution' + | 'suggestedParams' + | 'rekeyTo' + > & { + nonParticipation?: false; + } + > ): txnBuilder.Transaction; export function makeKeyRegistrationTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperty< - MustHaveSuggestedParams, - 'reKeyTo', - 'rekeyTo' - >, - 'from' | 'note' | 'suggestedParams' | 'rekeyTo' - > & { - nonParticipation: true; - } + o: Expand< + Pick< + RenameProperty< + MustHaveSuggestedParams, + 'reKeyTo', + 'rekeyTo' + >, + 'from' | 'note' | 'suggestedParams' | 'rekeyTo' + > & { + nonParticipation: true; + } + > ): txnBuilder.Transaction; export function makeKeyRegistrationTxnWithSuggestedParamsFromObject(o: any) { return makeKeyRegistrationTxnWithSuggestedParams( @@ -499,36 +505,38 @@ export function makeAssetCreateTxn( // helper for above makeAssetCreateTxnWithSuggestedParams, instead accepting an arguments object export function makeAssetCreateTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - reKeyTo: 'rekeyTo'; - assetTotal: 'total'; - assetDecimals: 'decimals'; - assetDefaultFrozen: 'defaultFrozen'; - assetManager: 'manager'; - assetReserve: 'reserve'; - assetFreeze: 'freeze'; - assetClawback: 'clawback'; - assetUnitName: 'unitName'; - } - >, - | 'from' - | 'note' - | 'total' - | 'decimals' - | 'defaultFrozen' - | 'manager' - | 'reserve' - | 'freeze' - | 'clawback' - | 'unitName' - | 'assetName' - | 'assetURL' - | 'assetMetadataHash' - | 'suggestedParams' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + reKeyTo: 'rekeyTo'; + assetTotal: 'total'; + assetDecimals: 'decimals'; + assetDefaultFrozen: 'defaultFrozen'; + assetManager: 'manager'; + assetReserve: 'reserve'; + assetFreeze: 'freeze'; + assetClawback: 'clawback'; + assetUnitName: 'unitName'; + } + >, + | 'from' + | 'note' + | 'total' + | 'decimals' + | 'defaultFrozen' + | 'manager' + | 'reserve' + | 'freeze' + | 'clawback' + | 'unitName' + | 'assetName' + | 'assetURL' + | 'assetMetadataHash' + | 'suggestedParams' + | 'rekeyTo' + > > ) { return makeAssetCreateTxnWithSuggestedParams( @@ -670,29 +678,31 @@ export function makeAssetConfigTxn( // helper for above makeAssetConfigTxnWithSuggestedParams, instead accepting an arguments object export function makeAssetConfigTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - reKeyTo: 'rekeyTo'; - assetManager: 'manager'; - assetReserve: 'reserve'; - assetFreeze: 'freeze'; - assetClawback: 'clawback'; - } - >, - | 'from' - | 'note' - | 'assetIndex' - | 'manager' - | 'reserve' - | 'freeze' - | 'clawback' - | 'suggestedParams' - | 'rekeyTo' - > & { - strictEmptyAddressChecking: boolean; - } + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + reKeyTo: 'rekeyTo'; + assetManager: 'manager'; + assetReserve: 'reserve'; + assetFreeze: 'freeze'; + assetClawback: 'clawback'; + } + >, + | 'from' + | 'note' + | 'assetIndex' + | 'manager' + | 'reserve' + | 'freeze' + | 'clawback' + | 'suggestedParams' + | 'rekeyTo' + > & { + strictEmptyAddressChecking: boolean; + } + > ) { return makeAssetConfigTxnWithSuggestedParams( o.from, @@ -786,13 +796,15 @@ export function makeAssetDestroyTxn( // helper for above makeAssetDestroyTxnWithSuggestedParams, instead accepting an arguments object export function makeAssetDestroyTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperty< - MustHaveSuggestedParams, - 'reKeyTo', - 'rekeyTo' - >, - 'from' | 'note' | 'assetIndex' | 'suggestedParams' | 'rekeyTo' + o: Expand< + Pick< + RenameProperty< + MustHaveSuggestedParams, + 'reKeyTo', + 'rekeyTo' + >, + 'from' | 'note' | 'assetIndex' | 'suggestedParams' | 'rekeyTo' + > > ) { return makeAssetDestroyTxnWithSuggestedParams( @@ -894,21 +906,23 @@ export function makeAssetFreezeTxn( // helper for above makeAssetFreezeTxnWithSuggestedParams, instead accepting an arguments object export function makeAssetFreezeTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - freezeAccount: 'freezeTarget'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'note' - | 'assetIndex' - | 'freezeTarget' - | 'freezeState' - | 'suggestedParams' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + freezeAccount: 'freezeTarget'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'note' + | 'assetIndex' + | 'freezeTarget' + | 'freezeState' + | 'suggestedParams' + | 'rekeyTo' + > > ) { return makeAssetFreezeTxnWithSuggestedParams( @@ -1030,23 +1044,25 @@ export function makeAssetTransferTxn( // helper for above makeAssetTransferTxnWithSuggestedParams, instead accepting an arguments object export function makeAssetTransferTxnWithSuggestedParamsFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - assetRevocationTarget: 'revocationTarget'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'to' - | 'closeRemainderTo' - | 'revocationTarget' - | 'amount' - | 'note' - | 'assetIndex' - | 'suggestedParams' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + assetRevocationTarget: 'revocationTarget'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'to' + | 'closeRemainderTo' + | 'revocationTarget' + | 'amount' + | 'note' + | 'assetIndex' + | 'suggestedParams' + | 'rekeyTo' + > > ) { return makeAssetTransferTxnWithSuggestedParams( @@ -1134,40 +1150,42 @@ export function makeApplicationCreateTxn( // helper for above makeApplicationCreateTxn, instead accepting an arguments object export function makeApplicationCreateTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appOnComplete: 'onComplete'; - appApprovalProgram: 'approvalProgram'; - appClearProgram: 'clearProgram'; - appLocalInts: 'numLocalInts'; - appLocalByteSlices: 'numLocalByteSlices'; - appGlobalInts: 'numGlobalInts'; - appGlobalByteSlices: 'numGlobalByteSlices'; - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'onComplete' - | 'approvalProgram' - | 'clearProgram' - | 'numLocalInts' - | 'numLocalByteSlices' - | 'numGlobalInts' - | 'numGlobalByteSlices' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' - | 'extraPages' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appOnComplete: 'onComplete'; + appApprovalProgram: 'approvalProgram'; + appClearProgram: 'clearProgram'; + appLocalInts: 'numLocalInts'; + appLocalByteSlices: 'numLocalByteSlices'; + appGlobalInts: 'numGlobalInts'; + appGlobalByteSlices: 'numGlobalByteSlices'; + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'onComplete' + | 'approvalProgram' + | 'clearProgram' + | 'numLocalInts' + | 'numLocalByteSlices' + | 'numGlobalInts' + | 'numGlobalByteSlices' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + | 'extraPages' + > > ) { return makeApplicationCreateTxn( @@ -1248,30 +1266,32 @@ export function makeApplicationUpdateTxn( // helper for above makeApplicationUpdateTxn, instead accepting an arguments object export function makeApplicationUpdateTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appApprovalProgram: 'approvalProgram'; - appClearProgram: 'clearProgram'; - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'approvalProgram' - | 'clearProgram' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appApprovalProgram: 'approvalProgram'; + appClearProgram: 'clearProgram'; + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'approvalProgram' + | 'clearProgram' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + > > ) { return makeApplicationUpdateTxn( @@ -1341,26 +1361,28 @@ export function makeApplicationDeleteTxn( // helper for above makeApplicationDeleteTxn, instead accepting an arguments object export function makeApplicationDeleteTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + > > ) { return makeApplicationDeleteTxn( @@ -1428,26 +1450,28 @@ export function makeApplicationOptInTxn( // helper for above makeApplicationOptInTxn, instead accepting an argument object export function makeApplicationOptInTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + > > ) { return makeApplicationOptInTxn( @@ -1515,26 +1539,28 @@ export function makeApplicationCloseOutTxn( // helper for above makeApplicationCloseOutTxn, instead accepting an argument object export function makeApplicationCloseOutTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + > > ) { return makeApplicationCloseOutTxn( @@ -1602,26 +1628,28 @@ export function makeApplicationClearStateTxn( // helper for above makeApplicationClearStateTxn, instead accepting an argument object export function makeApplicationClearStateTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + > > ) { return makeApplicationClearStateTxn( @@ -1689,26 +1717,28 @@ export function makeApplicationNoOpTxn( // helper for above makeApplicationNoOpTxn, instead accepting an argument object export function makeApplicationNoOpTxnFromObject( - o: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' + o: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + > > ) { return makeApplicationNoOpTxn( @@ -1731,51 +1761,53 @@ export { OnApplicationComplete } from './types/transactions/base'; * Generic function for creating any application call transaction. */ export function makeApplicationCallTxnFromObject( - options: Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appOnComplete: 'onComplete'; - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - reKeyTo: 'rekeyTo'; - } - >, - | 'from' - | 'suggestedParams' - | 'appIndex' - | 'onComplete' - | 'appArgs' - | 'accounts' - | 'foreignApps' - | 'foreignAssets' - | 'note' - | 'lease' - | 'rekeyTo' - | 'extraPages' - > & - Partial< - Pick< - RenameProperties< - MustHaveSuggestedParams, - { - appApprovalProgram: 'approvalProgram'; - appClearProgram: 'clearProgram'; - appLocalInts: 'numLocalInts'; - appLocalByteSlices: 'numLocalByteSlices'; - appGlobalInts: 'numGlobalInts'; - appGlobalByteSlices: 'numGlobalByteSlices'; - } - >, - | 'approvalProgram' - | 'clearProgram' - | 'numLocalInts' - | 'numLocalByteSlices' - | 'numGlobalInts' - | 'numGlobalByteSlices' + options: Expand< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appOnComplete: 'onComplete'; + appAccounts: 'accounts'; + appForeignApps: 'foreignApps'; + appForeignAssets: 'foreignAssets'; + reKeyTo: 'rekeyTo'; + } + >, + | 'from' + | 'suggestedParams' + | 'appIndex' + | 'onComplete' + | 'appArgs' + | 'accounts' + | 'foreignApps' + | 'foreignAssets' + | 'note' + | 'lease' + | 'rekeyTo' + | 'extraPages' + > & + Partial< + Pick< + RenameProperties< + MustHaveSuggestedParams, + { + appApprovalProgram: 'approvalProgram'; + appClearProgram: 'clearProgram'; + appLocalInts: 'numLocalInts'; + appLocalByteSlices: 'numLocalByteSlices'; + appGlobalInts: 'numGlobalInts'; + appGlobalByteSlices: 'numGlobalByteSlices'; + } + >, + | 'approvalProgram' + | 'clearProgram' + | 'numLocalInts' + | 'numLocalByteSlices' + | 'numGlobalInts' + | 'numGlobalByteSlices' + > > - > + > ) { const o: AppCreateTxn = { type: TransactionType.appl, diff --git a/src/types/utils.ts b/src/types/utils.ts index 4aeae0c75..90531337d 100644 --- a/src/types/utils.ts +++ b/src/types/utils.ts @@ -1,3 +1,13 @@ +/** + * Expands types for IntelliSense so they are more human readable + * See https://stackoverflow.com/a/69288824 + */ +export type Expand = T extends (...args: infer A) => infer R + ? (...args: Expand) => Expand + : T extends infer O + ? { [K in keyof O]: O[K] } + : never; + /** * Same as TypeScript's Pick, but will distribute the Pick over unions */ From 262c762be99bee0cddc3559a33e6e65e9ca84cb8 Mon Sep 17 00:00:00 2001 From: Jason Paulos Date: Mon, 7 Mar 2022 10:52:15 -0800 Subject: [PATCH 4/8] Update chromedriver (#535) * Update chromedriver * Always use latest version of chromedriver in tests * chromedriver v99 --- package-lock.json | 62 ++++++++++++++--------------- package.json | 2 +- tests/cucumber/docker/run_docker.sh | 7 ++++ 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8572a4085..81f85e2b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "@typescript-eslint/eslint-plugin": "^4.26.1", "@typescript-eslint/parser": "^4.26.1", "assert": "^2.0.0", - "chromedriver": "^97.0.0", + "chromedriver": "^99.0.0", "concurrently": "^6.2.0", "coveralls": "^3.1.0", "cucumber": "^5.1.0", @@ -284,9 +284,9 @@ } }, "node_modules/@testim/chrome-version": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@testim/chrome-version/-/chrome-version-1.0.7.tgz", - "integrity": "sha512-8UT/J+xqCYfn3fKtOznAibsHpiuDshCb0fwgWxRazTT19Igp9ovoXMPhXyLD6m3CKQGTMHgqoxaFfMWaL40Rnw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@testim/chrome-version/-/chrome-version-1.1.2.tgz", + "integrity": "sha512-1c4ZOETSRpI0iBfIFUqU4KqwBAB2lHUAlBjZz/YqOHqwM9dTTzjV6Km0ZkiEiSCx/tLr1BtESIKyWWMww+RUqw==", "dev": true }, "node_modules/@tsconfig/node10": { @@ -1150,12 +1150,12 @@ "dev": true }, "node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", "dev": true, "dependencies": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.14.4" } }, "node_modules/balanced-match": { @@ -1514,14 +1514,14 @@ } }, "node_modules/chromedriver": { - "version": "97.0.0", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-97.0.0.tgz", - "integrity": "sha512-SZ9MW+/6/Ypz20CNdRKocsmRM2AJ/YwHaWpA1Np2QVPFUbhjhus6vBtqFD+l8M5qrktLWPQSjTwIsDckNfXIRg==", + "version": "99.0.0", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-99.0.0.tgz", + "integrity": "sha512-pyB+5LuyZdb7EBPL3i5D5yucZUD+SlkdiUtmpjaEnLd9zAXp+SvD/hP5xF4l/ZmWvUo/1ZLxAI1YBdhazGTpgA==", "dev": true, "hasInstallScript": true, "dependencies": { - "@testim/chrome-version": "^1.0.7", - "axios": "^0.21.2", + "@testim/chrome-version": "^1.1.2", + "axios": "^0.24.0", "del": "^6.0.0", "extract-zip": "^2.0.1", "https-proxy-agent": "^5.0.0", @@ -3245,9 +3245,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", - "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", "dev": true, "funding": [ { @@ -8515,9 +8515,9 @@ } }, "@testim/chrome-version": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@testim/chrome-version/-/chrome-version-1.0.7.tgz", - "integrity": "sha512-8UT/J+xqCYfn3fKtOznAibsHpiuDshCb0fwgWxRazTT19Igp9ovoXMPhXyLD6m3CKQGTMHgqoxaFfMWaL40Rnw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@testim/chrome-version/-/chrome-version-1.1.2.tgz", + "integrity": "sha512-1c4ZOETSRpI0iBfIFUqU4KqwBAB2lHUAlBjZz/YqOHqwM9dTTzjV6Km0ZkiEiSCx/tLr1BtESIKyWWMww+RUqw==", "dev": true }, "@tsconfig/node10": { @@ -9209,12 +9209,12 @@ "dev": true }, "axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", "dev": true, "requires": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.14.4" } }, "balanced-match": { @@ -9478,13 +9478,13 @@ "dev": true }, "chromedriver": { - "version": "97.0.0", - "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-97.0.0.tgz", - "integrity": "sha512-SZ9MW+/6/Ypz20CNdRKocsmRM2AJ/YwHaWpA1Np2QVPFUbhjhus6vBtqFD+l8M5qrktLWPQSjTwIsDckNfXIRg==", + "version": "99.0.0", + "resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-99.0.0.tgz", + "integrity": "sha512-pyB+5LuyZdb7EBPL3i5D5yucZUD+SlkdiUtmpjaEnLd9zAXp+SvD/hP5xF4l/ZmWvUo/1ZLxAI1YBdhazGTpgA==", "dev": true, "requires": { - "@testim/chrome-version": "^1.0.7", - "axios": "^0.21.2", + "@testim/chrome-version": "^1.1.2", + "axios": "^0.24.0", "del": "^6.0.0", "extract-zip": "^2.0.1", "https-proxy-agent": "^5.0.0", @@ -10868,9 +10868,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", - "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==", + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", "dev": true }, "foreach": { diff --git a/package.json b/package.json index 19811aa9f..5bba4fc35 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@typescript-eslint/eslint-plugin": "^4.26.1", "@typescript-eslint/parser": "^4.26.1", "assert": "^2.0.0", - "chromedriver": "^97.0.0", + "chromedriver": "^99.0.0", "concurrently": "^6.2.0", "coveralls": "^3.1.0", "cucumber": "^5.1.0", diff --git a/tests/cucumber/docker/run_docker.sh b/tests/cucumber/docker/run_docker.sh index 87da13e5c..72e6bb977 100755 --- a/tests/cucumber/docker/run_docker.sh +++ b/tests/cucumber/docker/run_docker.sh @@ -12,6 +12,13 @@ git clone --single-branch --branch master https://github.com/algorand/algorand-s # move feature files and example files to destination mv test-harness/features tests/cucumber/features +if [ $TEST_BROWSER == "chrome" ]; then + # use latest version of chromedriver for compatability with the current Chrome version + npm install chromedriver@latest + # print the version installed + npm ls chromedriver +fi + # build test environment docker build -t js-sdk-testing -f tests/cucumber/docker/Dockerfile "$(pwd)" --build-arg TEST_BROWSER --build-arg CI=true From 486ba93c381a5ade554e234befed937d03e12699 Mon Sep 17 00:00:00 2001 From: Jason Paulos Date: Mon, 7 Mar 2022 11:47:24 -0800 Subject: [PATCH 5/8] Use request format arg to determine response type (#532) --- src/client/client.ts | 63 +++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 8be88c13c..2fc35b085 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -64,33 +64,6 @@ function getAcceptFormat( } else return 'application/json'; } -/** - * Check is a response is JSON or not - * Inspired from superagent code - */ -function isResponseJSON(res: BaseHTTPClientResponse): boolean { - let contentType = tolowerCaseKeys(res.headers)['content-type']; - if (contentType) { - /* eslint-disable prefer-destructuring */ - contentType = contentType.split(';')[0]; - /* eslint-enable prefer-destructuring */ - } - // regex should match /json or +json - // but not /json-seq - // from https://github.com/visionmedia/superagent/blob/048cf185d954028b1dccde0717d2488b2284c297/src/client.js#L276 - return /[/+]json($|[^-\w])/i.test(contentType); -} - -/** - * Check is a response is text - * Inspired from superagent code - */ -function isResponseText(res: BaseHTTPClientResponse): boolean { - const contentType = - tolowerCaseKeys(res.headers)['content-type'] || 'text/plain'; - return /^\w*text\//i.test(contentType); -} - /** * HTTPClient is a wrapper around a BaseHTTPClient * It takes care of setting the proper "Accept" header and of @@ -136,9 +109,9 @@ export default class HTTPClient { * Parse JSON using either the built-in JSON.parse or utils.parseJSON * depending on whether jsonOptions are provided or not * - * @param text JSON data - * @param status Status of the response (used in case parseJSON fails) - * @param jsonOptions Options object to use to decode JSON responses. See + * @param text - JSON data + * @param status - Status of the response (used in case parseJSON fails) + * @param jsonOptions - Options object to use to decode JSON responses. See * utils.parseJSON for the options available. */ public static parseJSON( @@ -197,15 +170,18 @@ export default class HTTPClient { */ private static prepareResponse( res: BaseHTTPClientResponse, + format: 'application/msgpack' | 'application/json', jsonOptions: utils.JSONOptions = {} ): HTTPClientResponse { let { body } = res; let text; - if (isResponseJSON(res)) { - text = (body && new TextDecoder().decode(body)) || ''; + + if (format !== 'application/msgpack') { + text = (body && Buffer.from(body).toString()) || ''; + } + + if (format === 'application/json') { body = HTTPClient.parseJSON(text, res.status, jsonOptions); - } else if (isResponseText(res)) { - text = (body && new TextDecoder().decode(body)) || ''; } return { @@ -225,7 +201,10 @@ export default class HTTPClient { private static prepareResponseError(err) { if (err.response) { // eslint-disable-next-line no-param-reassign - err.response = HTTPClient.prepareResponse(err.response); + err.response = HTTPClient.prepareResponse( + err.response, + 'application/json' + ); // eslint-disable-next-line no-param-reassign err.status = err.response.status; } @@ -234,10 +213,10 @@ export default class HTTPClient { /** * Send a GET request. - * @param {string} relativePath The path of the request. - * @param {object} query An object containing the query paramters of the request. - * @param {object} requestHeaders An object containing additional request headers to use. - * @param {object} jsonOptions Options object to use to decode JSON responses. See + * @param relativePath - The path of the request. + * @param query - An object containing the query parameters of the request. + * @param requestHeaders - An object containing additional request headers to use. + * @param jsonOptions - Options object to use to decode JSON responses. See * utils.parseJSON for the options available. * @returns Response object. */ @@ -257,7 +236,7 @@ export default class HTTPClient { fullHeaders ); - return HTTPClient.prepareResponse(res, jsonOptions); + return HTTPClient.prepareResponse(res, format, jsonOptions); } catch (err) { throw HTTPClient.prepareResponseError(err); } @@ -286,7 +265,7 @@ export default class HTTPClient { fullHeaders ); - return HTTPClient.prepareResponse(res); + return HTTPClient.prepareResponse(res, 'application/json'); } catch (err) { throw HTTPClient.prepareResponseError(err); } @@ -314,6 +293,6 @@ export default class HTTPClient { fullHeaders ); - return HTTPClient.prepareResponse(res); + return HTTPClient.prepareResponse(res, 'application/json'); } } From 7441b516e6fa3b23933e37fa1dd5d755b0f549a6 Mon Sep 17 00:00:00 2001 From: John Lee Date: Mon, 7 Mar 2022 15:20:15 -0500 Subject: [PATCH 6/8] bump to 1.14.0 and update changelog --- CHANGELOG.md | 10 +++++++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2feb090..187463f7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# v1.14.0-beta.1 +# v1.14.0 ## Added @@ -10,6 +10,14 @@ - Moving from travis to circleci (#507) - Add installation instructions for vite users (#512) - Update langspec for TEAL 6 (#518) +- Docs for `lookupAssetByID` and `lookupAccountTransactions` (#516) +- Make FromObject parameter IntelliSense human readable (#528) +- Bump url-parse from 1.5.1 to 1.5.8 (#529) + +## Fixed + +- Use HTTP request format arg to determine response type (#532) +- Update chromedriver (#535) # 1.13.1 diff --git a/package-lock.json b/package-lock.json index 81f85e2b0..053c11ab9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "algosdk", - "version": "1.14.0-beta.1", + "version": "1.14.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "algosdk", - "version": "1.14.0-beta.1", + "version": "1.14.0", "license": "MIT", "dependencies": { "algo-msgpack-with-bigint": "^2.1.1", diff --git a/package.json b/package.json index 5bba4fc35..8bcbbf678 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "algosdk", - "version": "1.14.0-beta.1", + "version": "1.14.0", "description": "The official JavaScript SDK for Algorand", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", From c7ba32817e8bcbe956a6d787ffc736dd299f7e6d Mon Sep 17 00:00:00 2001 From: John Lee Date: Mon, 7 Mar 2022 15:23:13 -0500 Subject: [PATCH 7/8] update README.md with new hash --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aa97b9b39..03db8008c 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ Include a minified browser bundle directly in your HTML like so: ```html ``` @@ -32,8 +32,8 @@ or ```html ``` From ffe2d3cad25f76128cea9439fb1ab1e269ba2dc5 Mon Sep 17 00:00:00 2001 From: John Lee Date: Mon, 7 Mar 2022 15:38:31 -0500 Subject: [PATCH 8/8] Restored v1.14.0b1 changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 187463f7b..c4e121763 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,19 @@ - Use HTTP request format arg to determine response type (#532) - Update chromedriver (#535) +# v1.14.0-beta.1 + +## Added + +- Add stateproof keyreg field (#463) + +## Changed + +- Implement C2C tests (#498) +- Moving from travis to circleci (#507) +- Add installation instructions for vite users (#512) +- Update langspec for TEAL 6 (#518) + # 1.13.1 ## Added: