Adjust web3Enable with document readyState (#321)
* Adjust web3Enable with document readyState * Bumps
This commit is contained in:
parent
0806bf3cce
commit
6455e246c8
@ -1,3 +1,7 @@
|
||||
# 0.25.0-beta.x
|
||||
|
||||
- Adjust `web3Enable` promise to only resolve after the document has been loaded (is interactive)
|
||||
|
||||
# 0.24.1 Apr 19, 2020
|
||||
|
||||
- Allow for per root-account derivation & indicators (Thanks to https://github.com/EthWorks)
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"@polkadot/api": "^1.11.0-beta.33",
|
||||
"@polkadot/api": "^1.11.1",
|
||||
"@polkadot/keyring": "^2.8.1",
|
||||
"@polkadot/types": "^1.11.0-beta.33",
|
||||
"@polkadot/types": "^1.11.1",
|
||||
"@polkadot/util": "^2.8.1",
|
||||
"@polkadot/util-crypto": "^2.8.1",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
@ -30,7 +30,7 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@polkadot/dev": "^0.52.11",
|
||||
"@polkadot/typegen": "^1.11.0-beta.33",
|
||||
"@polkadot/typegen": "^1.11.1",
|
||||
"@types/jest": "^25.2.1",
|
||||
"copy-webpack-plugin": "^5.1.1",
|
||||
"sinon-chrome": "^3.0.1",
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"license": "Apache-2",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.9.2",
|
||||
"@polkadot/api": "^1.11.0-beta.33",
|
||||
"@polkadot/api": "^1.11.1",
|
||||
"@polkadot/extension-inject": "0.25.0-beta.0",
|
||||
"@polkadot/keyring": "^2.8.1",
|
||||
"@polkadot/ui-keyring": "^0.52.1"
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
import { Injected, InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedExtensionInfo, InjectedProviderWithMeta, InjectedWindow, Unsubcall, ProviderList } from '@polkadot/extension-inject/types';
|
||||
|
||||
import { documentReadyPromise } from './util';
|
||||
|
||||
// just a helper (otherwise we cast all-over, so shorter and more readable)
|
||||
const win = window as Window & InjectedWindow;
|
||||
|
||||
@ -38,7 +40,7 @@ export { isWeb3Injected, web3EnablePromise };
|
||||
|
||||
// enables all the providers found on the injected window interface
|
||||
export function web3Enable (originName: string): Promise<InjectedExtension[]> {
|
||||
web3EnablePromise =
|
||||
const inner =
|
||||
Promise
|
||||
.all(
|
||||
Object.entries(win.injectedWeb3).map(([name, { enable, version }]): Promise<[InjectedExtensionInfo, Injected | void]> => {
|
||||
@ -81,6 +83,8 @@ export function web3Enable (originName: string): Promise<InjectedExtension[]> {
|
||||
return values;
|
||||
});
|
||||
|
||||
web3EnablePromise = documentReadyPromise(inner);
|
||||
|
||||
return web3EnablePromise;
|
||||
}
|
||||
|
||||
|
||||
15
packages/extension-dapp/src/util.ts
Normal file
15
packages/extension-dapp/src/util.ts
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2019-2020 @polkadot/extension-dapp authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export function documentReadyPromise <T> (inner: Promise<T>): Promise<T> {
|
||||
return new Promise((resolve): void => {
|
||||
if (['interactive', 'loaded'].includes(document.readyState)) {
|
||||
resolve(inner);
|
||||
} else {
|
||||
window.addEventListener('load', (): void => {
|
||||
resolve(inner);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
114
yarn.lock
114
yarn.lock
@ -2784,42 +2784,42 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/api-derive@npm:1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/api-derive@npm:1.11.0-beta.33"
|
||||
"@polkadot/api-derive@npm:1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/api-derive@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/api": 1.11.0-beta.33
|
||||
"@polkadot/rpc-core": 1.11.0-beta.33
|
||||
"@polkadot/rpc-provider": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/api": 1.11.1
|
||||
"@polkadot/rpc-core": 1.11.1
|
||||
"@polkadot/rpc-provider": 1.11.1
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
"@polkadot/util-crypto": ^2.8.1
|
||||
bn.js: ^5.1.1
|
||||
memoizee: ^0.4.14
|
||||
rxjs: ^6.5.5
|
||||
checksum: 2/856c8dce1a5698bd806022402f5936d98efae6dc72e239a02949f90dbcffbf872e541c9a7c3e6c7ceaccabca917228a4995bdc19b1e918e538e94cce815ee4f8
|
||||
checksum: 2/923e15d847624d4dd0adf9277f551a8647634ae6498b6d899cbb301113b1ce40db20f31d47fab917b3e4fcc8bd7bcb86cf19a12769034f328e0edcd40aced7ac
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/api@npm:^1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/api@npm:1.11.0-beta.33"
|
||||
"@polkadot/api@npm:^1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/api@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/api-derive": 1.11.0-beta.33
|
||||
"@polkadot/api-derive": 1.11.1
|
||||
"@polkadot/keyring": ^2.8.1
|
||||
"@polkadot/metadata": 1.11.0-beta.33
|
||||
"@polkadot/rpc-core": 1.11.0-beta.33
|
||||
"@polkadot/rpc-provider": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/types-known": 1.11.0-beta.33
|
||||
"@polkadot/metadata": 1.11.1
|
||||
"@polkadot/rpc-core": 1.11.1
|
||||
"@polkadot/rpc-provider": 1.11.1
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/types-known": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
"@polkadot/util-crypto": ^2.8.1
|
||||
bn.js: ^5.1.1
|
||||
eventemitter3: ^4.0.0
|
||||
rxjs: ^6.5.5
|
||||
checksum: 2/d52c72700619713e965787289308725587da390af65155ac542c26b3ac9b0411b84d6f44df9ccc76fcd67c2c71bece266dd48bfad6269300a92c217d37b299a4
|
||||
checksum: 2/47e27c499ec4e9f07ca0c96def217fae046f98b5e778e6bc12e7f9fea76311d4a1a922dd42c151f6a508109c1ff6dfbaf21844c6f190ec4fca44b7f6c1446c4a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -2915,7 +2915,7 @@ __metadata:
|
||||
resolution: "@polkadot/extension-base@workspace:packages/extension-base"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/api": ^1.11.0-beta.33
|
||||
"@polkadot/api": ^1.11.1
|
||||
"@polkadot/extension-inject": 0.25.0-beta.0
|
||||
"@polkadot/keyring": ^2.8.1
|
||||
"@polkadot/ui-keyring": ^0.52.1
|
||||
@ -3020,17 +3020,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/metadata@npm:1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/metadata@npm:1.11.0-beta.33"
|
||||
"@polkadot/metadata@npm:1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/metadata@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/types-known": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/types-known": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
"@polkadot/util-crypto": ^2.8.1
|
||||
bn.js: ^5.1.1
|
||||
checksum: 2/49ac2547396a965f04433ced65e1b8a64e25066e0874c1a6bb98edd1c8539937464734abb2590339f5ead1d44b346d0a17181a20d3b63cf45f6f1c19ef764ddb
|
||||
checksum: 2/96b617d0a78de159da2760e27fd1181b1025297bb932ae151bea760f24170e01e561f941532f39733c8e7322b935fde2aae1f3e25d664ae2631157618219f241
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -3073,49 +3073,49 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/rpc-core@npm:1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/rpc-core@npm:1.11.0-beta.33"
|
||||
"@polkadot/rpc-core@npm:1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/rpc-core@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/metadata": 1.11.0-beta.33
|
||||
"@polkadot/rpc-provider": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/metadata": 1.11.1
|
||||
"@polkadot/rpc-provider": 1.11.1
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
memoizee: ^0.4.14
|
||||
rxjs: ^6.5.5
|
||||
checksum: 2/0acd2f0824b253919c70f1521e1825df3292f5a7707ed3575d3ee441c1ec44331876ef31bed3b17d02908e14881e1b09425dbe39c123666cab903fedd300b9f2
|
||||
checksum: 2/8fd25563c1dc776c12b82632428dbd636f7b8d80b7a854e7b54dd4dc7938ea8b90f4dc7038256ab6f4e13a6e8d50d83bca2444f5d157cbd032bf985e3bf38a37
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/rpc-provider@npm:1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/rpc-provider@npm:1.11.0-beta.33"
|
||||
"@polkadot/rpc-provider@npm:1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/rpc-provider@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/metadata": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/metadata": 1.11.1
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
"@polkadot/util-crypto": ^2.8.1
|
||||
bn.js: ^5.1.1
|
||||
eventemitter3: ^4.0.0
|
||||
isomorphic-fetch: ^2.2.1
|
||||
websocket: ^1.0.31
|
||||
checksum: 2/84cae896a152245fef3a244f83d49a4aa0af5467729a44d9a71dc154093737129aa4a64e97677b3ab3f5a645303b76afc8fba1454db597a22c4939df9425f4a3
|
||||
checksum: 2/430e915c23ce3a7e0bb267c9cfdd4aa9822637d8f38ff5b2141354bf0ab6044a01d252f07509c272d2f73d624efc01eacc8307d9378e5fc4260a8300aacc52b9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/typegen@npm:^1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/typegen@npm:1.11.0-beta.33"
|
||||
"@polkadot/typegen@npm:^1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/typegen@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/core": ^7.9.0
|
||||
"@babel/register": ^7.9.0
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/api": 1.11.0-beta.33
|
||||
"@polkadot/metadata": 1.11.0-beta.33
|
||||
"@polkadot/rpc-provider": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/api": 1.11.1
|
||||
"@polkadot/metadata": 1.11.1
|
||||
"@polkadot/rpc-provider": 1.11.1
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
websocket: ^1.0.31
|
||||
yargs: ^15.3.1
|
||||
@ -3125,35 +3125,35 @@ __metadata:
|
||||
polkadot-types-from-defs: scripts/polkadot-types-from-defs.js
|
||||
polkadot-types-internal-interfaces: scripts/polkadot-types-internal-interfaces.js
|
||||
polkadot-types-internal-metadata: scripts/polkadot-types-internal-metadata.js
|
||||
checksum: 2/4543c9044e202db88ba42fcc801cc3d4ba17c46731cb02fc3355f3836f16fc3bfa66fcccf267b5ad9bb2513d69a0c79e5fb6893fc66908e010a7fcf3fee80bff
|
||||
checksum: 2/cb7f5511a3ede11fc8c1050881e0bb5f0d5bf3ef98e2ceda95402806942d682dd74b59ae6ab3854957ce2f547b5a516f5d20f415444a3606d72615d3e3d87e9a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/types-known@npm:1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/types-known@npm:1.11.0-beta.33"
|
||||
"@polkadot/types-known@npm:1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/types-known@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/types": 1.11.0-beta.33
|
||||
"@polkadot/types": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
bn.js: ^5.1.1
|
||||
checksum: 2/ac78127dddf4eb62e4aba66febe40a3fd1a655ac462008ba152f65adaaad7536e3513b39511ff93b34b55bb6fee8bd46f1e27234ff360ac5398ba0281d577c3d
|
||||
checksum: 2/5f69055f81175f2dee4232efef009565b490f66c1d882b15600e32521790c126e295b0a45cfa811d77dfbcf2b9ef0aba137c82e2d3180bfc02f6f0341f74b9d4
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/types@npm:^1.11.0-beta.33":
|
||||
version: 1.11.0-beta.33
|
||||
resolution: "@polkadot/types@npm:1.11.0-beta.33"
|
||||
"@polkadot/types@npm:^1.11.1":
|
||||
version: 1.11.1
|
||||
resolution: "@polkadot/types@npm:1.11.1"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.9.2
|
||||
"@polkadot/metadata": 1.11.0-beta.33
|
||||
"@polkadot/metadata": 1.11.1
|
||||
"@polkadot/util": ^2.8.1
|
||||
"@polkadot/util-crypto": ^2.8.1
|
||||
"@types/bn.js": ^4.11.6
|
||||
bn.js: ^5.1.1
|
||||
memoizee: ^0.4.14
|
||||
rxjs: ^6.5.5
|
||||
checksum: 2/b476b0a8206f1d998ba92d89d485a8d54ba0de857508ec6e00af82097d2349019254d85170c15be486e5278156f505fe0b00391d7d9e183cf80a1d100f26b161
|
||||
checksum: 2/bb6a36707a2d5f07ad7c0961f790272d4e51a2fef4284493fe0a025280b27fcfb9ef0e1e4725f23945d04cd4d2bbc7df0ac965fb8642853e204b3c140c8024b7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -18002,7 +18002,7 @@ __metadata:
|
||||
dependencies:
|
||||
"@babel/core": ^7.9.0
|
||||
"@polkadot/dev": ^0.52.11
|
||||
"@polkadot/typegen": ^1.11.0-beta.33
|
||||
"@polkadot/typegen": ^1.11.1
|
||||
"@types/jest": ^25.2.1
|
||||
copy-webpack-plugin: ^5.1.1
|
||||
sinon-chrome: ^3.0.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user