From caf76a7511c197c4d59ebb935567dc1716fe6e67 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 11 Aug 2021 18:14:28 +0300 Subject: [PATCH] Ensure packageInfo from networks doesn't clobber crypto (#1076) * Ensure packageInfo from networks doesn't clobber crypto * 7.1.2 * Update CHANGELOG.md * Extract network sorting * ... revert, CC still not happy, maybe another day... --- CHANGELOG.md | 3 +- package.json | 2 +- packages/hw-ledger-transports/package.json | 2 +- packages/hw-ledger/package.json | 6 +-- packages/keyring/package.json | 10 ++-- packages/networks/package.json | 6 +-- packages/networks/src/index.ts | 43 +--------------- packages/networks/src/interfaces.ts | 43 ++++++++++++++++ packages/util-crypto/package.json | 10 ++-- packages/util-crypto/src/networks.ts | 2 +- packages/util/package.json | 6 +-- packages/x-bundle/package.json | 4 +- packages/x-fetch/package.json | 4 +- packages/x-global/package.json | 2 +- packages/x-randomvalues/package.json | 4 +- packages/x-textdecoder/package.json | 4 +- packages/x-textencoder/package.json | 4 +- packages/x-ws/package.json | 4 +- yarn.lock | 58 +++++++++++----------- 19 files changed, 110 insertions(+), 107 deletions(-) create mode 100644 packages/networks/src/interfaces.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b3e2afa41..4d86a1d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # CHANGELOG -## master +## 7.1.2 Aug 11, 2021 Changes: +- Ensure `@polkadot/util-crypto` doesn't re-export `packageInfo` from `@polkadot/networks` - Minor TS style cleanups in `@polkadot/x-bundle` diff --git a/package.json b/package.json index ba99e6c43..38740302a 100644 --- a/package.json +++ b/package.json @@ -29,5 +29,5 @@ "@types/ed2curve": "^0.2.2", "@types/jest": "^26.0.24" }, - "version": "7.1.2-0" + "version": "7.1.2" } diff --git a/packages/hw-ledger-transports/package.json b/packages/hw-ledger-transports/package.json index 2dcdb93d0..2ac501a4a 100644 --- a/packages/hw-ledger-transports/package.json +++ b/packages/hw-ledger-transports/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/hw-ledger-transports", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "repository": "github:polkadot-js/common", "author": "Jaco Greeff ", diff --git a/packages/hw-ledger/package.json b/packages/hw-ledger/package.json index 1fcafd5ee..a883e3721 100644 --- a/packages/hw-ledger/package.json +++ b/packages/hw-ledger/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/hw-ledger", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "repository": "github:polkadot-js/common", "author": "Jaco Greeff ", @@ -17,8 +17,8 @@ }, "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/hw-ledger-transports": "7.1.2-0", - "@polkadot/util": "7.1.2-0", + "@polkadot/hw-ledger-transports": "7.1.2", + "@polkadot/util": "7.1.2", "@zondax/ledger-substrate": "^0.17.3" } } diff --git a/packages/keyring/package.json b/packages/keyring/package.json index 930988e7b..c4c8d3c2e 100644 --- a/packages/keyring/package.json +++ b/packages/keyring/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/keyring", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "Keyring management", "author": "Jaco Greeff ", @@ -20,11 +20,11 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/util": "7.1.2-0", - "@polkadot/util-crypto": "7.1.2-0" + "@polkadot/util": "7.1.2", + "@polkadot/util-crypto": "7.1.2" }, "peerDependencies": { - "@polkadot/util": "7.1.2-0", - "@polkadot/util-crypto": "7.1.2-0" + "@polkadot/util": "7.1.2", + "@polkadot/util-crypto": "7.1.2" } } diff --git a/packages/networks/package.json b/packages/networks/package.json index 3773627b3..23d46b996 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/networks", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A list of all available Substrate networks and their applicable prefixes", "main": "index.js", @@ -19,7 +19,7 @@ "@babel/runtime": "^7.14.8" }, "devDependencies": { - "@polkadot/util": "7.1.2-0", - "@polkadot/x-fetch": "7.1.2-0" + "@polkadot/util": "7.1.2", + "@polkadot/x-fetch": "7.1.2" } } diff --git a/packages/networks/src/index.ts b/packages/networks/src/index.ts index e0787dde6..98301b460 100644 --- a/packages/networks/src/index.ts +++ b/packages/networks/src/index.ts @@ -1,46 +1,5 @@ // Copyright 2017-2021 @polkadot/networks authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { Network, SubstrateNetwork } from './types'; - -import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults'; -import { knownSubstrate } from './substrate'; - +export * from './interfaces'; export { packageInfo } from './packageInfo'; - -// These are known prefixes that are not sorted -const UNSORTED = [0, 2, 42]; - -export const allNetworks = knownSubstrate.map((o): SubstrateNetwork => { - const network = o.network || ''; - const n = o as SubstrateNetwork; - - n.slip44 = knownLedger[network]; - n.hasLedgerSupport = !!n.slip44; - - n.genesisHash = knownGenesis[network] || []; - n.icon = knownIcon[network] || 'substrate'; - n.isIgnored = !network || !!knownTestnet[network] || network.startsWith('reserved'); - - return n; -}); - -// The list of available/claimed prefixes -// - no testnets -// - we only include those where we have a standardAccount -// - when no icon has been specified, default to substrate -// - sort by name, however we keep 0, 2, 42 first in the list -export const availableNetworks = allNetworks - .filter((n): n is Network => !n.isIgnored && !!n.network) - .sort((a, b) => - UNSORTED.includes(a.prefix) === UNSORTED.includes(b.prefix) - ? 0 - : UNSORTED.includes(a.prefix) - ? -1 - : UNSORTED.includes(b.prefix) - ? 1 - : a.displayName.localeCompare(b.displayName) - ); - -// A filtered list of those chains we have details about (genesisHashes) -export const selectableNetworks = availableNetworks.filter((n) => n.genesisHash.length || n.prefix === 42); diff --git a/packages/networks/src/interfaces.ts b/packages/networks/src/interfaces.ts new file mode 100644 index 000000000..cffd518e8 --- /dev/null +++ b/packages/networks/src/interfaces.ts @@ -0,0 +1,43 @@ +// Copyright 2017-2021 @polkadot/networks authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { Network, SubstrateNetwork } from './types'; + +import { knownGenesis, knownIcon, knownLedger, knownTestnet } from './defaults'; +import { knownSubstrate } from './substrate'; + +// These are known prefixes that are not sorted +const UNSORTED = [0, 2, 42]; + +export const allNetworks = knownSubstrate.map((o): SubstrateNetwork => { + const network = o.network || ''; + const n = o as SubstrateNetwork; + + n.slip44 = knownLedger[network]; + n.hasLedgerSupport = !!n.slip44; + + n.genesisHash = knownGenesis[network] || []; + n.icon = knownIcon[network] || 'substrate'; + n.isIgnored = !network || !!knownTestnet[network] || network.startsWith('reserved'); + + return n; +}); + +// The list of available/claimed prefixes +// - no testnets +// - we only include those where we have a standardAccount +// - sort by name, however we keep 0, 2, 42 first in the list +export const availableNetworks = allNetworks + .filter((n): n is Network => !n.isIgnored && !!n.network) + .sort((a, b) => + UNSORTED.includes(a.prefix) === UNSORTED.includes(b.prefix) + ? 0 + : UNSORTED.includes(a.prefix) + ? -1 + : UNSORTED.includes(b.prefix) + ? 1 + : a.displayName.localeCompare(b.displayName) + ); + +// A filtered list of those chains we have details about (genesisHashes) +export const selectableNetworks = availableNetworks.filter((n) => n.genesisHash.length || n.prefix === 42); diff --git a/packages/util-crypto/package.json b/packages/util-crypto/package.json index 75d550fd4..b1ad824d7 100644 --- a/packages/util-crypto/package.json +++ b/packages/util-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-crypto", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A collection of useful crypto utilities for @polkadot", "main": "index.js", @@ -22,10 +22,10 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/networks": "7.1.2-0", - "@polkadot/util": "7.1.2-0", + "@polkadot/networks": "7.1.2", + "@polkadot/util": "7.1.2", "@polkadot/wasm-crypto": "^4.1.2", - "@polkadot/x-randomvalues": "7.1.2-0", + "@polkadot/x-randomvalues": "7.1.2", "base-x": "^3.0.8", "base64-js": "^1.5.1", "blakejs": "^1.1.1", @@ -47,6 +47,6 @@ "@types/xxhashjs": "^0.2.2" }, "peerDependencies": { - "@polkadot/util": "7.1.2-0" + "@polkadot/util": "7.1.2" } } diff --git a/packages/util-crypto/src/networks.ts b/packages/util-crypto/src/networks.ts index 0eec5f6ff..70446554e 100644 --- a/packages/util-crypto/src/networks.ts +++ b/packages/util-crypto/src/networks.ts @@ -1,4 +1,4 @@ // Copyright 2017-2021 @polkadot/util-crypto authors & contributors // SPDX-License-Identifier: Apache-2.0 -export * from '@polkadot/networks'; +export * from '@polkadot/networks/interfaces'; diff --git a/packages/util/package.json b/packages/util/package.json index 60e15e367..85a76d47f 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A collection of useful utilities for @polkadot", "main": "index.js", @@ -20,8 +20,8 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/x-textdecoder": "7.1.2-0", - "@polkadot/x-textencoder": "7.1.2-0", + "@polkadot/x-textdecoder": "7.1.2", + "@polkadot/x-textencoder": "7.1.2", "@types/bn.js": "^4.11.6", "bn.js": "^4.11.9", "camelcase": "^5.3.1", diff --git a/packages/x-bundle/package.json b/packages/x-bundle/package.json index 3d51e857c..66ba2d895 100644 --- a/packages/x-bundle/package.json +++ b/packages/x-bundle/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-bundle", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A bundler helper", "main": "index.js", @@ -17,7 +17,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-bundle#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/util": "7.1.2-0", + "@polkadot/util": "7.1.2", "buffer-es6": "^4.9.3" } } diff --git a/packages/x-fetch/package.json b/packages/x-fetch/package.json index 6aea4e81a..fb057848c 100644 --- a/packages/x-fetch/package.json +++ b/packages/x-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-fetch", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A cross-environment fetch replacement", "browser": "browser.js", @@ -19,7 +19,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-fetch#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/x-global": "7.1.2-0", + "@polkadot/x-global": "7.1.2", "@types/node-fetch": "^2.5.12", "node-fetch": "^2.6.1" } diff --git a/packages/x-global/package.json b/packages/x-global/package.json index 10269ab80..d15a3ca8b 100644 --- a/packages/x-global/package.json +++ b/packages/x-global/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-global", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A cross-environment global replacement", "main": "index.js", diff --git a/packages/x-randomvalues/package.json b/packages/x-randomvalues/package.json index 097835130..a36e92004 100644 --- a/packages/x-randomvalues/package.json +++ b/packages/x-randomvalues/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-randomvalues", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A cross-environment window.crypto.getRandomValues replacement", "browser": "browser.js", @@ -19,7 +19,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-randomvalues#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/x-global": "7.1.2-0" + "@polkadot/x-global": "7.1.2" }, "devDependencies": { "@types/react-native": "^0.64.12" diff --git a/packages/x-textdecoder/package.json b/packages/x-textdecoder/package.json index 3f60689fa..1504bf9f8 100644 --- a/packages/x-textdecoder/package.json +++ b/packages/x-textdecoder/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-textdecoder", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A TextDecoder replacement", "browser": "browser.js", @@ -19,6 +19,6 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textdecoder#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/x-global": "7.1.2-0" + "@polkadot/x-global": "7.1.2" } } diff --git a/packages/x-textencoder/package.json b/packages/x-textencoder/package.json index 54f27f661..1e1319ba6 100644 --- a/packages/x-textencoder/package.json +++ b/packages/x-textencoder/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-textencoder", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A TextDecoder replacement", "browser": "browser.js", @@ -19,6 +19,6 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-textencoder#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/x-global": "7.1.2-0" + "@polkadot/x-global": "7.1.2" } } diff --git a/packages/x-ws/package.json b/packages/x-ws/package.json index fb21f1597..29756dc98 100644 --- a/packages/x-ws/package.json +++ b/packages/x-ws/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-ws", - "version": "7.1.2-0", + "version": "7.1.2", "type": "module", "description": "A cross-environment WebSocket replacement", "browser": "browser.js", @@ -19,7 +19,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/x-ws#readme", "dependencies": { "@babel/runtime": "^7.14.8", - "@polkadot/x-global": "7.1.2-0", + "@polkadot/x-global": "7.1.2", "@types/websocket": "^1.0.4", "websocket": "^1.0.34" } diff --git a/yarn.lock b/yarn.lock index b3838764f..22c852935 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2045,7 +2045,7 @@ __metadata: languageName: node linkType: hard -"@polkadot/hw-ledger-transports@7.1.2-0, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports": +"@polkadot/hw-ledger-transports@7.1.2, @polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports": version: 0.0.0-use.local resolution: "@polkadot/hw-ledger-transports@workspace:packages/hw-ledger-transports" dependencies: @@ -2065,8 +2065,8 @@ __metadata: resolution: "@polkadot/hw-ledger@workspace:packages/hw-ledger" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/hw-ledger-transports": 7.1.2-0 - "@polkadot/util": 7.1.2-0 + "@polkadot/hw-ledger-transports": 7.1.2 + "@polkadot/util": 7.1.2 "@zondax/ledger-substrate": ^0.17.3 languageName: unknown linkType: soft @@ -2076,21 +2076,21 @@ __metadata: resolution: "@polkadot/keyring@workspace:packages/keyring" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/util": 7.1.2-0 - "@polkadot/util-crypto": 7.1.2-0 + "@polkadot/util": 7.1.2 + "@polkadot/util-crypto": 7.1.2 peerDependencies: - "@polkadot/util": 7.1.2-0 - "@polkadot/util-crypto": 7.1.2-0 + "@polkadot/util": 7.1.2 + "@polkadot/util-crypto": 7.1.2 languageName: unknown linkType: soft -"@polkadot/networks@7.1.2-0, @polkadot/networks@workspace:packages/networks": +"@polkadot/networks@7.1.2, @polkadot/networks@workspace:packages/networks": version: 0.0.0-use.local resolution: "@polkadot/networks@workspace:packages/networks" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/util": 7.1.2-0 - "@polkadot/x-fetch": 7.1.2-0 + "@polkadot/util": 7.1.2 + "@polkadot/x-fetch": 7.1.2 languageName: unknown linkType: soft @@ -2103,15 +2103,15 @@ __metadata: languageName: node linkType: hard -"@polkadot/util-crypto@7.1.2-0, @polkadot/util-crypto@workspace:packages/util-crypto": +"@polkadot/util-crypto@7.1.2, @polkadot/util-crypto@workspace:packages/util-crypto": version: 0.0.0-use.local resolution: "@polkadot/util-crypto@workspace:packages/util-crypto" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/networks": 7.1.2-0 - "@polkadot/util": 7.1.2-0 + "@polkadot/networks": 7.1.2 + "@polkadot/util": 7.1.2 "@polkadot/wasm-crypto": ^4.1.2 - "@polkadot/x-randomvalues": 7.1.2-0 + "@polkadot/x-randomvalues": 7.1.2 "@types/bn.js": ^4.11.6 "@types/create-hash": ^1.2.2 "@types/elliptic": ^6.4.13 @@ -2130,17 +2130,17 @@ __metadata: tweetnacl: ^1.0.3 xxhashjs: ^0.2.2 peerDependencies: - "@polkadot/util": 7.1.2-0 + "@polkadot/util": 7.1.2 languageName: unknown linkType: soft -"@polkadot/util@7.1.2-0, @polkadot/util@workspace:packages/util": +"@polkadot/util@7.1.2, @polkadot/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@polkadot/util@workspace:packages/util" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/x-textdecoder": 7.1.2-0 - "@polkadot/x-textencoder": 7.1.2-0 + "@polkadot/x-textdecoder": 7.1.2 + "@polkadot/x-textencoder": 7.1.2 "@types/bn.js": ^4.11.6 bn.js: ^4.11.9 camelcase: ^5.3.1 @@ -2185,23 +2185,23 @@ __metadata: resolution: "@polkadot/x-bundle@workspace:packages/x-bundle" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/util": 7.1.2-0 + "@polkadot/util": 7.1.2 buffer-es6: ^4.9.3 languageName: unknown linkType: soft -"@polkadot/x-fetch@7.1.2-0, @polkadot/x-fetch@workspace:packages/x-fetch": +"@polkadot/x-fetch@7.1.2, @polkadot/x-fetch@workspace:packages/x-fetch": version: 0.0.0-use.local resolution: "@polkadot/x-fetch@workspace:packages/x-fetch" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/x-global": 7.1.2-0 + "@polkadot/x-global": 7.1.2 "@types/node-fetch": ^2.5.12 node-fetch: ^2.6.1 languageName: unknown linkType: soft -"@polkadot/x-global@7.1.2-0, @polkadot/x-global@workspace:packages/x-global": +"@polkadot/x-global@7.1.2, @polkadot/x-global@workspace:packages/x-global": version: 0.0.0-use.local resolution: "@polkadot/x-global@workspace:packages/x-global" dependencies: @@ -2209,31 +2209,31 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/x-randomvalues@7.1.2-0, @polkadot/x-randomvalues@workspace:packages/x-randomvalues": +"@polkadot/x-randomvalues@7.1.2, @polkadot/x-randomvalues@workspace:packages/x-randomvalues": version: 0.0.0-use.local resolution: "@polkadot/x-randomvalues@workspace:packages/x-randomvalues" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/x-global": 7.1.2-0 + "@polkadot/x-global": 7.1.2 "@types/react-native": ^0.64.12 languageName: unknown linkType: soft -"@polkadot/x-textdecoder@7.1.2-0, @polkadot/x-textdecoder@workspace:packages/x-textdecoder": +"@polkadot/x-textdecoder@7.1.2, @polkadot/x-textdecoder@workspace:packages/x-textdecoder": version: 0.0.0-use.local resolution: "@polkadot/x-textdecoder@workspace:packages/x-textdecoder" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/x-global": 7.1.2-0 + "@polkadot/x-global": 7.1.2 languageName: unknown linkType: soft -"@polkadot/x-textencoder@7.1.2-0, @polkadot/x-textencoder@workspace:packages/x-textencoder": +"@polkadot/x-textencoder@7.1.2, @polkadot/x-textencoder@workspace:packages/x-textencoder": version: 0.0.0-use.local resolution: "@polkadot/x-textencoder@workspace:packages/x-textencoder" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/x-global": 7.1.2-0 + "@polkadot/x-global": 7.1.2 languageName: unknown linkType: soft @@ -2242,7 +2242,7 @@ __metadata: resolution: "@polkadot/x-ws@workspace:packages/x-ws" dependencies: "@babel/runtime": ^7.14.8 - "@polkadot/x-global": 7.1.2-0 + "@polkadot/x-global": 7.1.2 "@types/websocket": ^1.0.4 websocket: ^1.0.34 languageName: unknown