@onekeyfe/inpage-providers-hub 1.1.17 → 1.1.19
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/dist/cjs/injectWeb3Provider.js +20 -12
- package/dist/injectWeb3Provider.d.ts +4 -0
- package/dist/injectWeb3Provider.js +21 -13
- package/package.json +14 -14
|
@@ -16,6 +16,23 @@ require("./connectButtonHack");
|
|
|
16
16
|
const consts_1 = require("./connectButtonHack/consts");
|
|
17
17
|
// import Web3 from 'web3'; // cause build error
|
|
18
18
|
const { WALLET_INFO_LOACAL_KEY } = cross_inpage_provider_core_1.consts;
|
|
19
|
+
function checkWalletSwitchEnable(property) {
|
|
20
|
+
try {
|
|
21
|
+
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
22
|
+
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
23
|
+
if (walletInfoLocal && walletInfoLocal.walletSwitchConfig) {
|
|
24
|
+
const { enable, disable } = walletInfoLocal.walletSwitchConfig;
|
|
25
|
+
const enableList = enable || [];
|
|
26
|
+
const disableList = disable || [];
|
|
27
|
+
return ((enableList.includes(property) && !disableList.includes(property)) ||
|
|
28
|
+
(!enableList.includes(property) && !disableList.includes(property)));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
19
36
|
function checkEnableDefineProperty(property) {
|
|
20
37
|
if (property === '$onekey')
|
|
21
38
|
return false;
|
|
@@ -30,6 +47,8 @@ function checkEnableDefineProperty(property) {
|
|
|
30
47
|
return false;
|
|
31
48
|
}
|
|
32
49
|
function defineWindowProperty(property, provider) {
|
|
50
|
+
if (!checkWalletSwitchEnable(property))
|
|
51
|
+
return;
|
|
33
52
|
const enable = checkEnableDefineProperty(property);
|
|
34
53
|
const proxyProvider = new Proxy(provider, {
|
|
35
54
|
defineProperty(target, property, attributes) {
|
|
@@ -107,17 +126,6 @@ function injectWeb3Provider() {
|
|
|
107
126
|
cardano,
|
|
108
127
|
cosmos });
|
|
109
128
|
defineWindowProperty('$onekey', $onekey);
|
|
110
|
-
try {
|
|
111
|
-
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
112
|
-
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
113
|
-
if (walletInfoLocal && walletInfoLocal.platformEnv.isExtension && walletInfoLocal.disableExt) {
|
|
114
|
-
// disable onekey ext stop inject
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch (e) {
|
|
119
|
-
console.error(e);
|
|
120
|
-
}
|
|
121
129
|
const martianProxy = new Proxy(martian, {
|
|
122
130
|
get: (target, property, ...args) => {
|
|
123
131
|
if (property === 'aptosProviderType') {
|
|
@@ -136,7 +144,7 @@ function injectWeb3Provider() {
|
|
|
136
144
|
defineWindowProperty('conflux', conflux);
|
|
137
145
|
defineWindowProperty('tronLink', tron);
|
|
138
146
|
defineWindowProperty('suiWallet', sui);
|
|
139
|
-
|
|
147
|
+
(0, onekey_cardano_provider_1.defineWindowCardanoProperty)('cardano', cardano);
|
|
140
148
|
// cosmos keplr
|
|
141
149
|
defineWindowProperty('keplr', cosmos);
|
|
142
150
|
defineWindowProperty('getOfflineSigner', cosmos.getOfflineSigner.bind(cosmos));
|
|
@@ -5,7 +5,7 @@ import { ProviderStarcoin } from '@onekeyfe/onekey-starcoin-provider';
|
|
|
5
5
|
import { ProviderAptosMartian } from '@onekeyfe/onekey-aptos-provider';
|
|
6
6
|
import { ProviderConflux } from '@onekeyfe/onekey-conflux-provider';
|
|
7
7
|
import { ProviderTron } from '@onekeyfe/onekey-tron-provider';
|
|
8
|
-
import { ProviderCardano } from '@onekeyfe/onekey-cardano-provider';
|
|
8
|
+
import { ProviderCardano, defineWindowCardanoProperty } from '@onekeyfe/onekey-cardano-provider';
|
|
9
9
|
import { ProviderCosmos } from '@onekeyfe/onekey-cosmos-provider';
|
|
10
10
|
import { consts } from '@onekeyfe/cross-inpage-provider-core';
|
|
11
11
|
import { ProviderSui, registerSuiWallet } from '@onekeyfe/onekey-sui-provider';
|
|
@@ -13,6 +13,23 @@ import './connectButtonHack';
|
|
|
13
13
|
import { WALLET_CONNECT_INFO } from './connectButtonHack/consts';
|
|
14
14
|
// import Web3 from 'web3'; // cause build error
|
|
15
15
|
const { WALLET_INFO_LOACAL_KEY } = consts;
|
|
16
|
+
function checkWalletSwitchEnable(property) {
|
|
17
|
+
try {
|
|
18
|
+
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
19
|
+
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
20
|
+
if (walletInfoLocal && walletInfoLocal.walletSwitchConfig) {
|
|
21
|
+
const { enable, disable } = walletInfoLocal.walletSwitchConfig;
|
|
22
|
+
const enableList = enable || [];
|
|
23
|
+
const disableList = disable || [];
|
|
24
|
+
return ((enableList.includes(property) && !disableList.includes(property)) ||
|
|
25
|
+
(!enableList.includes(property) && !disableList.includes(property)));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.error(e);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
16
33
|
function checkEnableDefineProperty(property) {
|
|
17
34
|
if (property === '$onekey')
|
|
18
35
|
return false;
|
|
@@ -27,6 +44,8 @@ function checkEnableDefineProperty(property) {
|
|
|
27
44
|
return false;
|
|
28
45
|
}
|
|
29
46
|
function defineWindowProperty(property, provider) {
|
|
47
|
+
if (!checkWalletSwitchEnable(property))
|
|
48
|
+
return;
|
|
30
49
|
const enable = checkEnableDefineProperty(property);
|
|
31
50
|
const proxyProvider = new Proxy(provider, {
|
|
32
51
|
defineProperty(target, property, attributes) {
|
|
@@ -104,17 +123,6 @@ function injectWeb3Provider() {
|
|
|
104
123
|
cardano,
|
|
105
124
|
cosmos });
|
|
106
125
|
defineWindowProperty('$onekey', $onekey);
|
|
107
|
-
try {
|
|
108
|
-
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
109
|
-
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
110
|
-
if (walletInfoLocal && walletInfoLocal.platformEnv.isExtension && walletInfoLocal.disableExt) {
|
|
111
|
-
// disable onekey ext stop inject
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
catch (e) {
|
|
116
|
-
console.error(e);
|
|
117
|
-
}
|
|
118
126
|
const martianProxy = new Proxy(martian, {
|
|
119
127
|
get: (target, property, ...args) => {
|
|
120
128
|
if (property === 'aptosProviderType') {
|
|
@@ -133,7 +141,7 @@ function injectWeb3Provider() {
|
|
|
133
141
|
defineWindowProperty('conflux', conflux);
|
|
134
142
|
defineWindowProperty('tronLink', tron);
|
|
135
143
|
defineWindowProperty('suiWallet', sui);
|
|
136
|
-
|
|
144
|
+
defineWindowCardanoProperty('cardano', cardano);
|
|
137
145
|
// cosmos keplr
|
|
138
146
|
defineWindowProperty('keplr', cosmos);
|
|
139
147
|
defineWindowProperty('getOfflineSigner', cosmos.getOfflineSigner.bind(cosmos));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/inpage-providers-hub",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.
|
|
33
|
-
"@onekeyfe/onekey-aptos-provider": "1.1.
|
|
34
|
-
"@onekeyfe/onekey-cardano-provider": "1.1.
|
|
35
|
-
"@onekeyfe/onekey-conflux-provider": "1.1.
|
|
36
|
-
"@onekeyfe/onekey-cosmos-provider": "1.1.
|
|
37
|
-
"@onekeyfe/onekey-eth-provider": "1.1.
|
|
38
|
-
"@onekeyfe/onekey-private-provider": "1.1.
|
|
39
|
-
"@onekeyfe/onekey-solana-provider": "1.1.
|
|
40
|
-
"@onekeyfe/onekey-starcoin-provider": "1.1.
|
|
41
|
-
"@onekeyfe/onekey-sui-provider": "1.1.
|
|
42
|
-
"@onekeyfe/onekey-tron-provider": "1.1.
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.19",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.19",
|
|
33
|
+
"@onekeyfe/onekey-aptos-provider": "1.1.19",
|
|
34
|
+
"@onekeyfe/onekey-cardano-provider": "1.1.19",
|
|
35
|
+
"@onekeyfe/onekey-conflux-provider": "1.1.19",
|
|
36
|
+
"@onekeyfe/onekey-cosmos-provider": "1.1.19",
|
|
37
|
+
"@onekeyfe/onekey-eth-provider": "1.1.19",
|
|
38
|
+
"@onekeyfe/onekey-private-provider": "1.1.19",
|
|
39
|
+
"@onekeyfe/onekey-solana-provider": "1.1.19",
|
|
40
|
+
"@onekeyfe/onekey-starcoin-provider": "1.1.19",
|
|
41
|
+
"@onekeyfe/onekey-sui-provider": "1.1.19",
|
|
42
|
+
"@onekeyfe/onekey-tron-provider": "1.1.19",
|
|
43
43
|
"web3": "^1.7.3"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "54769507c61bc8c7a5cc699d03d1c4a131fc0ebb"
|
|
46
46
|
}
|