From 5c489b5031f554859b1dfb3bc67a153e5786407a Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Mon, 13 May 2024 06:31:48 +0200 Subject: [PATCH] build: bump agent-js v1.3.0 and remove retryTimes default 10 (#621) # Motivation Bump agent-js v1.3.0 and remove `retryTimes` default value to 10 given that the issue is fixed in agent-js. --- CHANGELOG.md | 4 ++ package-lock.json | 96 ++++++++++++------------- packages/ckbtc/package.json | 6 +- packages/cketh/package.json | 6 +- packages/cmc/package.json | 6 +- packages/ic-management/package.json | 6 +- packages/ledger-icp/package.json | 6 +- packages/ledger-icrc/package.json | 6 +- packages/nns/package.json | 6 +- packages/sns/package.json | 6 +- packages/utils/README.md | 72 +++++++++---------- packages/utils/package.json | 6 +- packages/utils/src/utils/agent.utils.ts | 9 +-- 13 files changed, 120 insertions(+), 115 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cedca22f..b4a1d4d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - `@dfinity/ic-management` function `canisterInfo` removed because users cannot call this method (see [documentation](https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-canister-info)). +## Build + +- Upgrade `agent-js` dependencies to `v1.3.0` and revert the default retry times value to 10, given that the issue is fixed. + # 2024.04.29-0930Z ## Overview diff --git a/package-lock.json b/package-lock.json index c90cd193..28f6dae9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -717,9 +717,9 @@ "dev": true }, "node_modules/@dfinity/agent": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-1.2.1.tgz", - "integrity": "sha512-8M1jEDBXU/eMqPJuBqrzFNwHU/54GQGP8uzUjW1lm8mh5LIWbzuNTrN7X+7WHiHuaYDQ19QfEn/HE7A+lTxqOw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-1.3.0.tgz", + "integrity": "sha512-gFc2CqjWURv/Th+vxwHIb7Y39TpRZccjyRm8c51LtyAGLYSpSwJDWbzM/y66h++DSSc3A+1DjN/dRT+6ik3xLw==", "peer": true, "dependencies": { "@noble/curves": "^1.4.0", @@ -730,17 +730,17 @@ "simple-cbor": "^0.4.1" }, "peerDependencies": { - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1" + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0" } }, "node_modules/@dfinity/candid": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-1.2.1.tgz", - "integrity": "sha512-IG+pzMWTEIbNc+SERuSR9Rmva7dVXinXQGaiC7xJeJOMia6M7shWzeqDkuSHYWx/tzB8VfpND/Gxw1lLAMqmYg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-1.3.0.tgz", + "integrity": "sha512-tt5NYfpv8C+3iKS3Awbi+NAIxjwjIRUOLT+1ys/xpA+6DNEqwgfU8WZu0+bKnf/xlASCyJXUmoMzQ6I01GBp9A==", "peer": true, "peerDependencies": { - "@dfinity/principal": "^1.2.1" + "@dfinity/principal": "^1.3.0" } }, "node_modules/@dfinity/ckbtc": { @@ -776,9 +776,9 @@ "link": true }, "node_modules/@dfinity/principal": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-1.2.1.tgz", - "integrity": "sha512-sYyS8oMFLXqU/C29fpd56vTLw7YLX9zw4QGz0wQaeb5qBOrx7M3M4cX3Xijqvn765bYrs9fJXA8ePmipgJRGIQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-1.3.0.tgz", + "integrity": "sha512-04Ly9/VxztgmSk3LeUv1H+aA/8zCfed5gzgydVKBv9U0pk2lcCjUOMhv3G+1UCUSd8GwzrWaSwIsrzrAcHZm/g==", "peer": true, "dependencies": { "@noble/hashes": "^1.3.1" @@ -7498,9 +7498,9 @@ "bech32": "^2.0.0" }, "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7509,9 +7509,9 @@ "version": "3.0.0", "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7520,9 +7520,9 @@ "version": "3.0.4", "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7531,9 +7531,9 @@ "version": "3.2.0", "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7542,9 +7542,9 @@ "version": "2.2.3", "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7553,9 +7553,9 @@ "version": "2.3.0", "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7571,10 +7571,10 @@ "@types/randombytes": "^2.0.0" }, "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", "@dfinity/ledger-icp": "^2.2.3", - "@dfinity/principal": "^1.2.1", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7597,10 +7597,10 @@ "@noble/hashes": "^1.3.2" }, "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", "@dfinity/ledger-icrc": "^2.3.0", - "@dfinity/principal": "^1.2.1", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } }, @@ -7609,9 +7609,9 @@ "version": "2.2.0", "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1" + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0" } } }, @@ -8125,9 +8125,9 @@ "dev": true }, "@dfinity/agent": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-1.2.1.tgz", - "integrity": "sha512-8M1jEDBXU/eMqPJuBqrzFNwHU/54GQGP8uzUjW1lm8mh5LIWbzuNTrN7X+7WHiHuaYDQ19QfEn/HE7A+lTxqOw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@dfinity/agent/-/agent-1.3.0.tgz", + "integrity": "sha512-gFc2CqjWURv/Th+vxwHIb7Y39TpRZccjyRm8c51LtyAGLYSpSwJDWbzM/y66h++DSSc3A+1DjN/dRT+6ik3xLw==", "peer": true, "requires": { "@noble/curves": "^1.4.0", @@ -8139,9 +8139,9 @@ } }, "@dfinity/candid": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-1.2.1.tgz", - "integrity": "sha512-IG+pzMWTEIbNc+SERuSR9Rmva7dVXinXQGaiC7xJeJOMia6M7shWzeqDkuSHYWx/tzB8VfpND/Gxw1lLAMqmYg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@dfinity/candid/-/candid-1.3.0.tgz", + "integrity": "sha512-tt5NYfpv8C+3iKS3Awbi+NAIxjwjIRUOLT+1ys/xpA+6DNEqwgfU8WZu0+bKnf/xlASCyJXUmoMzQ6I01GBp9A==", "peer": true, "requires": {} }, @@ -8189,9 +8189,9 @@ } }, "@dfinity/principal": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-1.2.1.tgz", - "integrity": "sha512-sYyS8oMFLXqU/C29fpd56vTLw7YLX9zw4QGz0wQaeb5qBOrx7M3M4cX3Xijqvn765bYrs9fJXA8ePmipgJRGIQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@dfinity/principal/-/principal-1.3.0.tgz", + "integrity": "sha512-04Ly9/VxztgmSk3LeUv1H+aA/8zCfed5gzgydVKBv9U0pk2lcCjUOMhv3G+1UCUSd8GwzrWaSwIsrzrAcHZm/g==", "peer": true, "requires": { "@noble/hashes": "^1.3.1" diff --git a/packages/ckbtc/package.json b/packages/ckbtc/package.json index 0c377c8c..a11ddff3 100644 --- a/packages/ckbtc/package.json +++ b/packages/ckbtc/package.json @@ -38,9 +38,9 @@ ], "homepage": "https://github.com/dfinity/ic-js#readme", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" }, "dependencies": { diff --git a/packages/cketh/package.json b/packages/cketh/package.json index f6970bb9..56ec9b3d 100644 --- a/packages/cketh/package.json +++ b/packages/cketh/package.json @@ -38,9 +38,9 @@ ], "homepage": "https://github.com/dfinity/ic-js#readme", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } } diff --git a/packages/cmc/package.json b/packages/cmc/package.json index 49e863f8..3232a7ba 100644 --- a/packages/cmc/package.json +++ b/packages/cmc/package.json @@ -36,9 +36,9 @@ ], "homepage": "https://github.com/dfinity/ic-js#readme", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } } diff --git a/packages/ic-management/package.json b/packages/ic-management/package.json index fba1d49c..eef2f8b1 100644 --- a/packages/ic-management/package.json +++ b/packages/ic-management/package.json @@ -34,9 +34,9 @@ ], "homepage": "https://github.com/dfinity/ic-js#readme", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } } diff --git a/packages/ledger-icp/package.json b/packages/ledger-icp/package.json index 4af0e0c6..d4b1eecf 100644 --- a/packages/ledger-icp/package.json +++ b/packages/ledger-icp/package.json @@ -38,9 +38,9 @@ ], "homepage": "https://github.com/dfinity/ic-js#readme", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } } diff --git a/packages/ledger-icrc/package.json b/packages/ledger-icrc/package.json index 98866ee9..69d0fdaf 100644 --- a/packages/ledger-icrc/package.json +++ b/packages/ledger-icrc/package.json @@ -37,9 +37,9 @@ ], "homepage": "https://github.com/dfinity/ic-js#readme", "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } } diff --git a/packages/nns/package.json b/packages/nns/package.json index 3a18b94c..c463a2b4 100644 --- a/packages/nns/package.json +++ b/packages/nns/package.json @@ -51,10 +51,10 @@ "network-nervous-system" ], "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", "@dfinity/ledger-icp": "^2.2.3", - "@dfinity/principal": "^1.2.1", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" } } diff --git a/packages/sns/package.json b/packages/sns/package.json index 517bf856..3a39bb5b 100644 --- a/packages/sns/package.json +++ b/packages/sns/package.json @@ -36,10 +36,10 @@ "sns" ], "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", "@dfinity/ledger-icrc": "^2.3.0", - "@dfinity/principal": "^1.2.1", + "@dfinity/principal": "^1.3.0", "@dfinity/utils": "^2.2.0" }, "dependencies": { diff --git a/packages/utils/README.md b/packages/utils/README.md index 7666fb92..13ce32e2 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -32,6 +32,9 @@ npm i @dfinity/agent @dfinity/candid @dfinity/principal ### :toolbox: Functions - [convertStringToE8s](#gear-convertstringtoe8s) +- [isNullish](#gear-isnullish) +- [nonNullish](#gear-nonnullish) +- [notEmptyString](#gear-notemptystring) - [defaultAgent](#gear-defaultagent) - [createAgent](#gear-createagent) - [createServices](#gear-createservices) @@ -51,9 +54,6 @@ npm i @dfinity/agent @dfinity/candid @dfinity/principal - [bigEndianCrc32](#gear-bigendiancrc32) - [secondsToDuration](#gear-secondstoduration) - [debounce](#gear-debounce) -- [isNullish](#gear-isnullish) -- [nonNullish](#gear-nonnullish) -- [notEmptyString](#gear-notemptystring) - [toNullable](#gear-tonullable) - [fromNullable](#gear-fromnullable) - [fromDefinedNullable](#gear-fromdefinednullable) @@ -76,6 +76,36 @@ Parameters: [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L12) +#### :gear: isNullish + +Is null or undefined + +| Function | Type | +| ----------- | ------------------------------------------------------------------------ | +| `isNullish` | `(argument: T or null or undefined) => argument is null or undefined` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L2) + +#### :gear: nonNullish + +Not null and not undefined + +| Function | Type | +| ------------ | --------------------------------------------------------------------- | +| `nonNullish` | `(argument: T or null or undefined) => argument is NonNullable` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L7) + +#### :gear: notEmptyString + +Not null and not undefined and not empty + +| Function | Type | +| ---------------- | ------------------------------------------------- | +| `notEmptyString` | `(value: string or null or undefined) => boolean` | + +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L12) + #### :gear: defaultAgent Get a default agent that connects to mainnet with the anonymous identity. @@ -84,7 +114,7 @@ Get a default agent that connects to mainnet with the anonymous identity. | -------------- | ------------- | | `defaultAgent` | `() => Agent` | -[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L8) +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L9) #### :gear: createAgent @@ -100,9 +130,9 @@ Parameters: - `host`: An optional host to connect to - `fetchRootKey`: Fetch root key for certificate validation during local development or on testnet - `verifyQuerySignatures`: Check for signatures in the state tree signed by the node that replies to queries - i.e. certify responses. -- `retryTimes`: Set the number of retries the agent should perform before errorring. By default, 10 is applied (as opposed to default 3 in agent-js) to make the agent more resilient against watermark check failures. +- `retryTimes`: Set the number of retries the agent should perform before errorring. -[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L22) +[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L23) #### :gear: createServices @@ -261,36 +291,6 @@ Parameters: [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/debounce.utils.ts#L2) -#### :gear: isNullish - -Is null or undefined - -| Function | Type | -| ----------- | ------------------------------------------------------------------------ | -| `isNullish` | `(argument: T or null or undefined) => argument is null or undefined` | - -[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L2) - -#### :gear: nonNullish - -Not null and not undefined - -| Function | Type | -| ------------ | --------------------------------------------------------------------- | -| `nonNullish` | `(argument: T or null or undefined) => argument is NonNullable` | - -[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L7) - -#### :gear: notEmptyString - -Not null and not undefined and not empty - -| Function | Type | -| ---------------- | ------------------------------------------------- | -| `notEmptyString` | `(value: string or null or undefined) => boolean` | - -[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L12) - #### :gear: toNullable | Function | Type | diff --git a/packages/utils/package.json b/packages/utils/package.json index 3a5c1a68..7f9a721e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -47,8 +47,8 @@ "service-nervous-system" ], "peerDependencies": { - "@dfinity/agent": "^1.2.1", - "@dfinity/candid": "^1.2.1", - "@dfinity/principal": "^1.2.1" + "@dfinity/agent": "^1.3.0", + "@dfinity/candid": "^1.3.0", + "@dfinity/principal": "^1.3.0" } } diff --git a/packages/utils/src/utils/agent.utils.ts b/packages/utils/src/utils/agent.utils.ts index c435a712..797591d7 100644 --- a/packages/utils/src/utils/agent.utils.ts +++ b/packages/utils/src/utils/agent.utils.ts @@ -1,5 +1,6 @@ import type { Agent, Identity } from "@dfinity/agent"; import { AnonymousIdentity, HttpAgent } from "@dfinity/agent"; +import { nonNullish } from "./nullish.utils"; /** * Get a default agent that connects to mainnet with the anonymous identity. @@ -17,14 +18,14 @@ export const defaultAgent = (): Agent => * @param host An optional host to connect to * @param fetchRootKey Fetch root key for certificate validation during local development or on testnet * @param verifyQuerySignatures Check for signatures in the state tree signed by the node that replies to queries - i.e. certify responses. - * @param retryTimes Set the number of retries the agent should perform before errorring. By default, 10 is applied (as opposed to default 3 in agent-js) to make the agent more resilient against watermark check failures. + * @param retryTimes Set the number of retries the agent should perform before errorring. */ export const createAgent = async ({ identity, host, fetchRootKey = false, verifyQuerySignatures = false, - retryTimes = 10, + retryTimes, }: { identity: Identity; host?: string; @@ -35,9 +36,9 @@ export const createAgent = async ({ }): Promise => { const agent: HttpAgent = new HttpAgent({ identity, - ...(host !== undefined && { host }), + ...(nonNullish(host) && { host }), verifyQuerySignatures, - retryTimes, + ...(nonNullish(retryTimes) && { retryTimes }), }); if (fetchRootKey) {