@subwallet/extension-inject 0.6.7-1 → 0.6.7-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle.js +17 -9
- package/chrome.js +1 -0
- package/cjs/bundle.js +14 -10
- package/cjs/chrome.js +1 -2
- package/cjs/crossenv.js +1 -1
- package/cjs/detectPackage.js +2 -4
- package/cjs/index.js +0 -2
- package/cjs/packageInfo.js +3 -1
- package/crossenv.js +1 -0
- package/detectOther.js +2 -0
- package/detectPackage.js +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
- package/packageInfo.js +3 -1
package/bundle.js
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
// Copyright 2019-2022 @polkadot/extension-inject authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
export { packageInfo } from "./packageInfo.js";
|
|
5
|
+
|
|
6
|
+
// It is recommended to always use the function below to shield the extension and dapp from
|
|
4
7
|
// any future changes. The exposed interface will manage access between the 2 environments,
|
|
5
8
|
// be it via window (current), postMessage (under consideration) or any other mechanism
|
|
6
|
-
|
|
7
9
|
export function injectExtension(enable, {
|
|
8
10
|
name,
|
|
9
11
|
version
|
|
10
12
|
}) {
|
|
11
13
|
// small helper with the typescript types, just cast window
|
|
12
|
-
const windowInject = window;
|
|
14
|
+
const windowInject = window;
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
// don't clobber the existing object, we will add it (or create as needed)
|
|
17
|
+
windowInject.injectedWeb3 = windowInject.injectedWeb3 || {};
|
|
15
18
|
|
|
19
|
+
// add our enable function
|
|
16
20
|
windowInject.injectedWeb3[name] = {
|
|
17
21
|
enable: origin => enable(origin),
|
|
18
22
|
version
|
|
19
23
|
};
|
|
20
|
-
}
|
|
24
|
+
}
|
|
21
25
|
|
|
26
|
+
// Inject EVM Provider
|
|
22
27
|
export function injectEvmExtension(evmProvider) {
|
|
23
28
|
// small helper with the typescript types, just cast window
|
|
24
|
-
const windowInject = window;
|
|
29
|
+
const windowInject = window;
|
|
25
30
|
|
|
31
|
+
// add our enable function
|
|
26
32
|
if (windowInject.SubWallet) {
|
|
27
33
|
// Provider has been initialized in proxy mode
|
|
28
34
|
windowInject.SubWallet.provider = evmProvider;
|
|
@@ -30,15 +36,17 @@ export function injectEvmExtension(evmProvider) {
|
|
|
30
36
|
// Provider has been initialized in direct mode
|
|
31
37
|
windowInject.SubWallet = evmProvider;
|
|
32
38
|
}
|
|
39
|
+
windowInject.dispatchEvent(new Event('subwallet#initialized'));
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
// Publish to global if window.ethereum is not available
|
|
36
42
|
windowInject.addEventListener('load', () => {
|
|
37
43
|
if (!windowInject.ethereum) {
|
|
38
44
|
windowInject.ethereum = evmProvider;
|
|
39
45
|
windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
40
46
|
}
|
|
41
|
-
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Todo: Need more discuss to make SubWallet as global before window load because it can be conflict with MetaMask
|
|
42
50
|
// windowInject.ethereum = evmProvider;
|
|
43
51
|
// windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
44
52
|
}
|
package/chrome.js
CHANGED
package/cjs/bundle.js
CHANGED
|
@@ -11,11 +11,10 @@ Object.defineProperty(exports, "packageInfo", {
|
|
|
11
11
|
return _packageInfo.packageInfo;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
|
|
15
14
|
var _packageInfo = require("./packageInfo");
|
|
16
|
-
|
|
17
15
|
// Copyright 2019-2022 @polkadot/extension-inject authors & contributors
|
|
18
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
19
18
|
// It is recommended to always use the function below to shield the extension and dapp from
|
|
20
19
|
// any future changes. The exposed interface will manage access between the 2 environments,
|
|
21
20
|
// be it via window (current), postMessage (under consideration) or any other mechanism
|
|
@@ -25,21 +24,24 @@ function injectExtension(enable, _ref) {
|
|
|
25
24
|
version
|
|
26
25
|
} = _ref;
|
|
27
26
|
// small helper with the typescript types, just cast window
|
|
28
|
-
const windowInject = window;
|
|
27
|
+
const windowInject = window;
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
// don't clobber the existing object, we will add it (or create as needed)
|
|
30
|
+
windowInject.injectedWeb3 = windowInject.injectedWeb3 || {};
|
|
31
31
|
|
|
32
|
+
// add our enable function
|
|
32
33
|
windowInject.injectedWeb3[name] = {
|
|
33
34
|
enable: origin => enable(origin),
|
|
34
35
|
version
|
|
35
36
|
};
|
|
36
|
-
}
|
|
37
|
-
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
+
// Inject EVM Provider
|
|
39
40
|
function injectEvmExtension(evmProvider) {
|
|
40
41
|
// small helper with the typescript types, just cast window
|
|
41
|
-
const windowInject = window;
|
|
42
|
+
const windowInject = window;
|
|
42
43
|
|
|
44
|
+
// add our enable function
|
|
43
45
|
if (windowInject.SubWallet) {
|
|
44
46
|
// Provider has been initialized in proxy mode
|
|
45
47
|
windowInject.SubWallet.provider = evmProvider;
|
|
@@ -47,15 +49,17 @@ function injectEvmExtension(evmProvider) {
|
|
|
47
49
|
// Provider has been initialized in direct mode
|
|
48
50
|
windowInject.SubWallet = evmProvider;
|
|
49
51
|
}
|
|
52
|
+
windowInject.dispatchEvent(new Event('subwallet#initialized'));
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
// Publish to global if window.ethereum is not available
|
|
53
55
|
windowInject.addEventListener('load', () => {
|
|
54
56
|
if (!windowInject.ethereum) {
|
|
55
57
|
windowInject.ethereum = evmProvider;
|
|
56
58
|
windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
57
59
|
}
|
|
58
|
-
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Todo: Need more discuss to make SubWallet as global before window load because it can be conflict with MetaMask
|
|
59
63
|
// windowInject.ethereum = evmProvider;
|
|
60
64
|
// windowInject.dispatchEvent(new Event('ethereum#initialized'));
|
|
61
65
|
}
|
package/cjs/chrome.js
CHANGED
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.chrome = void 0;
|
|
7
|
-
|
|
8
7
|
var _xGlobal = require("@polkadot/x-global");
|
|
9
|
-
|
|
10
8
|
// Copyright 2019-2022 @polkadot/extension-inject authors & contributors
|
|
11
9
|
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
|
|
12
11
|
const chrome = (0, _xGlobal.extractGlobal)('chrome', _xGlobal.xglobal.browser);
|
|
13
12
|
exports.chrome = chrome;
|
package/cjs/crossenv.js
CHANGED
package/cjs/detectPackage.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _util = require("@polkadot/util");
|
|
6
|
-
|
|
7
5
|
var _detectOther = _interopRequireDefault(require("./detectOther"));
|
|
8
|
-
|
|
9
6
|
var _packageInfo = require("./packageInfo");
|
|
10
|
-
|
|
11
7
|
// Copyright 2017-2022 @subwallet/extension-inject authors & contributors
|
|
12
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
13
10
|
// Do not edit, auto-generated by @polkadot/dev
|
|
11
|
+
|
|
14
12
|
(0, _util.detectPackage)(_packageInfo.packageInfo, null, _detectOther.default);
|
package/cjs/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _bundle = require("./bundle");
|
|
8
|
-
|
|
9
7
|
Object.keys(_bundle).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _bundle[key]) return;
|
package/cjs/packageInfo.js
CHANGED
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.packageInfo = void 0;
|
|
7
7
|
// Copyright 2017-2022 @subwallet/extension-inject authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
9
10
|
// Do not edit, auto-generated by @polkadot/dev
|
|
11
|
+
|
|
10
12
|
const packageInfo = {
|
|
11
13
|
name: '@subwallet/extension-inject',
|
|
12
14
|
path: typeof __dirname === 'string' ? __dirname : 'auto',
|
|
13
15
|
type: 'cjs',
|
|
14
|
-
version: '0.6.7-
|
|
16
|
+
version: '0.6.7-2'
|
|
15
17
|
};
|
|
16
18
|
exports.packageInfo = packageInfo;
|
package/crossenv.js
CHANGED
package/detectOther.js
CHANGED
package/detectPackage.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Copyright 2017-2022 @subwallet/extension-inject authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
+
|
|
4
6
|
import { detectPackage } from '@polkadot/util';
|
|
5
7
|
import others from "./detectOther.js";
|
|
6
8
|
import { packageInfo } from "./packageInfo.js";
|
package/index.js
CHANGED
package/package.json
CHANGED
package/packageInfo.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Copyright 2017-2022 @subwallet/extension-inject authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
3
4
|
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
+
|
|
4
6
|
export const packageInfo = {
|
|
5
7
|
name: '@subwallet/extension-inject',
|
|
6
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
9
|
type: 'esm',
|
|
8
|
-
version: '0.6.7-
|
|
10
|
+
version: '0.6.7-2'
|
|
9
11
|
};
|