diff --git a/jest.config.js b/jest.config.js index c47ba76192..e0c5ffafb9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -31,5 +31,6 @@ module.exports = Object.assign({}, config, { ws_local_polkadot_alex: 'ws://127.0.0.1:9949/', ws_substrate_1: 'wss://substrate-rpc.parity.io/', ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/' - } + }, + resolver: './jest.resolver.js' }); diff --git a/jest.resolver.js b/jest.resolver.js new file mode 100644 index 0000000000..1cdd153d6b --- /dev/null +++ b/jest.resolver.js @@ -0,0 +1,15 @@ +// Copyright 2017-2020 @polkadot/util authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const path = require('path'); + +module.exports = function resolver (file, config) { + if (file.includes('package.json')) { + console.error(file, config); + return path.join(config.basedir.replace('/src', '/'), file); + } + + return config.defaultResolver(file, config); +}; diff --git a/packages/api-derive/package.json b/packages/api-derive/package.json index c24976228f..8a1963b04e 100644 --- a/packages/api-derive/package.json +++ b/packages/api-derive/package.json @@ -32,6 +32,6 @@ "@polkadot/types": "^1.1.0-beta.21" }, "devDependencies": { - "@polkadot/keyring": "^2.1.1" + "@polkadot/keyring": "^2.2.0-beta.0" } } diff --git a/packages/api/package.json b/packages/api/package.json index b2e60c0d13..26455f27cd 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -25,20 +25,17 @@ "url": "https://github.com/polkadot-js/api/issues" }, "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme", - "browser": { - "../package.json": "./package.json" - }, "dependencies": { "@babel/runtime": "^7.8.3", "@polkadot/api-derive": "^1.1.0-beta.21", - "@polkadot/keyring": "^2.1.1", + "@polkadot/keyring": "^2.2.0-beta.0", "@polkadot/metadata": "^1.1.0-beta.21", "@polkadot/rpc-core": "^1.1.0-beta.21", "@polkadot/rpc-provider": "^1.1.0-beta.21", "@polkadot/types": "^1.1.0-beta.21", - "@polkadot/util-crypto": "^2.1.1" + "@polkadot/util-crypto": "^2.2.0-beta.0" }, "devDependencies": { - "@polkadot/keyring": "^2.1.1" + "@polkadot/keyring": "^2.2.0-beta.0" } } diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 816fb7a808..cf743bf450 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -4,23 +4,14 @@ import { detectPackage } from '@polkadot/util'; -let dirname; -let pkgJson; - +// eslint-disable-next-line no-useless-catch try { - dirname = __dirname; + // eslint-disable-next-line @typescript-eslint/no-var-requires + detectPackage(require('./package.json'), __dirname); } catch (error) { - // ignore + throw error; } -try { - pkgJson = require('./package.json'); -} catch (error) { - pkgJson = require('../package.json'); -} - -detectPackage(pkgJson, dirname); - export { Keyring } from '@polkadot/keyring'; export { WsProvider } from '@polkadot/rpc-provider'; diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 6bbc68eb00..e2529bb6b0 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -28,10 +28,10 @@ "dependencies": { "@babel/runtime": "^7.8.3", "@polkadot/types": "^1.1.0-beta.21", - "@polkadot/util": "^2.1.1", - "@polkadot/util-crypto": "^2.1.1" + "@polkadot/util": "^2.2.0-beta.0", + "@polkadot/util-crypto": "^2.2.0-beta.0" }, "devDependencies": { - "@polkadot/keyring": "^2.1.1" + "@polkadot/keyring": "^2.2.0-beta.0" } } diff --git a/packages/rpc-core/package.json b/packages/rpc-core/package.json index 62ab2244b9..84915c6f15 100644 --- a/packages/rpc-core/package.json +++ b/packages/rpc-core/package.json @@ -30,7 +30,7 @@ "@polkadot/jsonrpc": "^1.1.0-beta.21", "@polkadot/rpc-provider": "^1.1.0-beta.21", "@polkadot/types": "^1.1.0-beta.21", - "@polkadot/util": "^2.1.1", + "@polkadot/util": "^2.2.0-beta.0", "rxjs": "^6.5.4" } } diff --git a/packages/rpc-provider/package.json b/packages/rpc-provider/package.json index 8d8a71be82..79c3fdf3de 100644 --- a/packages/rpc-provider/package.json +++ b/packages/rpc-provider/package.json @@ -28,14 +28,14 @@ "dependencies": { "@babel/runtime": "^7.8.3", "@polkadot/metadata": "^1.1.0-beta.21", - "@polkadot/util": "^2.1.1", - "@polkadot/util-crypto": "^2.1.1", + "@polkadot/util": "^2.2.0-beta.0", + "@polkadot/util-crypto": "^2.2.0-beta.0", "eventemitter3": "^4.0.0", "isomorphic-fetch": "^2.2.1", "websocket": "^1.0.31" }, "devDependencies": { - "@polkadot/keyring": "^2.1.1", + "@polkadot/keyring": "^2.2.0-beta.0", "mock-socket": "^9.0.3", "nock": "^11.7.2" } diff --git a/packages/types/package.json b/packages/types/package.json index 38de7deb94..b7587dc100 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -35,13 +35,13 @@ "dependencies": { "@babel/runtime": "^7.8.3", "@polkadot/metadata": "^1.1.0-beta.21", - "@polkadot/util": "^2.1.1", - "@polkadot/util-crypto": "^2.1.1", + "@polkadot/util": "^2.2.0-beta.0", + "@polkadot/util-crypto": "^2.2.0-beta.0", "memoizee": "^0.4.14", "yargs": "^15.1.0" }, "devDependencies": { - "@polkadot/keyring": "^2.1.1", + "@polkadot/keyring": "^2.2.0-beta.0", "@types/memoizee": "^0.4.3", "@types/yargs": "^15.0.2" } diff --git a/yarn.lock b/yarn.lock index ebc64ed332..99aba0ed1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2015,14 +2015,14 @@ typescript "^3.7.5" vuepress "^1.2.0" -"@polkadot/keyring@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-2.1.1.tgz#8691140bb55185ade49d3bfec137b2974c7e80fa" - integrity sha512-fhg9YiatH1s9K0LM3RF7dA6eRJUx0sED0nhaER3fzboXdlJDHChHbr/Q2VoZzbXdmuNWxWQnAI1Q5rRCZQ5HRQ== +"@polkadot/keyring@^2.2.0-beta.0": + version "2.2.0-beta.0" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-2.2.0-beta.0.tgz#481810e81c690ce343ffdf005a3ba71cfe6c4961" + integrity sha512-iabxyYzdyD8Bv0tW4g8e/x7hQGSsmI3TGMZHhAxLRc+ICFEPCB9sqqnu09DoB6QzyDTYD/kBArE2sOHhZacpPQ== dependencies: "@babel/runtime" "^7.8.3" - "@polkadot/util" "^2.1.1" - "@polkadot/util-crypto" "^2.1.1" + "@polkadot/util" "^2.2.0-beta.0" + "@polkadot/util-crypto" "^2.2.0-beta.0" "@polkadot/ts@^0.2.1": version "0.2.1" @@ -2031,13 +2031,13 @@ dependencies: "@types/chrome" "^0.0.92" -"@polkadot/util-crypto@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-2.1.1.tgz#12eda3ceb6dc6301a0e6e0eebdb6e111285c269b" - integrity sha512-RelZiT4DsKvPa44iNuSdVL2fYo+MRCwUwsy0F+boQzCRYMLlNAOabFZiuhZFjRbDMpmFtFTelALYBMC3PKcRFQ== +"@polkadot/util-crypto@^2.2.0-beta.0": + version "2.2.0-beta.0" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-2.2.0-beta.0.tgz#14d587a101864abafa825d1c2a347e142bb981a3" + integrity sha512-xJnDL8YdQFjEaJ6KYoRN/DhVA/NKZqja2yZqQqbvtVZX46l6kY56Vu6F3ZNlKsJxc6mSfr0qM2A7qiPcLkiw7g== dependencies: "@babel/runtime" "^7.8.3" - "@polkadot/util" "^2.1.1" + "@polkadot/util" "^2.2.0-beta.0" "@polkadot/wasm-crypto" "^0.20.1" "@types/bs58" "^4.0.0" "@types/elliptic" "^6.4.12" @@ -2052,10 +2052,10 @@ tweetnacl "^1.0.2" xxhashjs "^0.2.2" -"@polkadot/util@^2.1.1": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-2.1.1.tgz#bf011ac565a33e719eeffe690b57efac71f99be1" - integrity sha512-YpEuOf75i9rV565j0SW1tsjlfqrKN+86KuV5Dc/GfilrNUqmSLjQWzEC+KgIBghwJTDYeDFVAMLfhlzhvw6I1g== +"@polkadot/util@^2.2.0-beta.0": + version "2.2.0-beta.0" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-2.2.0-beta.0.tgz#d0b5cadc09ee131196a4e48cfc54b12292ed1e35" + integrity sha512-VjvXt4PvItLynk3JFKcTNQa+Jf85Q8PENEt4WOfJYElbzDv2tevVoJtE9Ds5RFms2ONmnRu3yeXWtNSHd91x+A== dependencies: "@babel/runtime" "^7.8.3" "@types/bn.js" "^4.11.6"