@onekeyfe/inpage-providers-hub 1.1.14 → 1.1.16
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.
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.hackConnectButton = exports.createNewImageToContainer = exports.createWalletConnectToButton = exports.detectQrcodeFromSvg = void 0;
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-types");
|
|
15
|
-
function checkIfInjectedProviderConnected({ providerName }) {
|
|
15
|
+
function checkIfInjectedProviderConnected({ providerName, }) {
|
|
16
16
|
var _a;
|
|
17
17
|
const hub = window.$onekey;
|
|
18
18
|
if (providerName === cross_inpage_provider_types_1.IInjectedProviderNames.ethereum) {
|
|
@@ -30,6 +30,15 @@ function detectQrcodeFromSvg({ img, }) {
|
|
|
30
30
|
var _a, _b;
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
// https://unpkg.com/qr-scanner@1.4.1/qr-scanner.umd.min.js
|
|
33
|
+
// Firefox does not support drawing SVG images to canvas
|
|
34
|
+
// Unless the svg file has width/height attributes on the root <svg> element
|
|
35
|
+
try {
|
|
36
|
+
img.setAttribute('width', img.clientWidth.toString());
|
|
37
|
+
img.setAttribute('height', img.clientHeight.toString());
|
|
38
|
+
}
|
|
39
|
+
catch (_c) {
|
|
40
|
+
//pass
|
|
41
|
+
}
|
|
33
42
|
const serialized = new XMLSerializer().serializeToString(img);
|
|
34
43
|
const encodedData = window.btoa(serialized);
|
|
35
44
|
const base64 = `data:image/svg+xml;base64,${encodedData}`;
|
|
@@ -13,9 +13,12 @@ const onekey_cosmos_provider_1 = require("@onekeyfe/onekey-cosmos-provider");
|
|
|
13
13
|
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
14
14
|
const onekey_sui_provider_1 = require("@onekeyfe/onekey-sui-provider");
|
|
15
15
|
require("./connectButtonHack");
|
|
16
|
+
const consts_1 = require("./connectButtonHack/consts");
|
|
16
17
|
// import Web3 from 'web3'; // cause build error
|
|
17
18
|
const { WALLET_INFO_LOACAL_KEY } = cross_inpage_provider_core_1.consts;
|
|
18
|
-
function checkEnableDefineProperty() {
|
|
19
|
+
function checkEnableDefineProperty(property) {
|
|
20
|
+
if (property === '$onekey')
|
|
21
|
+
return false;
|
|
19
22
|
try {
|
|
20
23
|
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
21
24
|
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
@@ -27,7 +30,7 @@ function checkEnableDefineProperty() {
|
|
|
27
30
|
return false;
|
|
28
31
|
}
|
|
29
32
|
function defineWindowProperty(property, provider) {
|
|
30
|
-
const enable = checkEnableDefineProperty();
|
|
33
|
+
const enable = checkEnableDefineProperty(property);
|
|
31
34
|
const proxyProvider = new Proxy(provider, {
|
|
32
35
|
defineProperty(target, property, attributes) {
|
|
33
36
|
// skip define Prevent overwriting
|
|
@@ -90,10 +93,10 @@ function injectWeb3Provider() {
|
|
|
90
93
|
bridge,
|
|
91
94
|
});
|
|
92
95
|
const cardano = new onekey_cardano_provider_1.ProviderCardano({
|
|
93
|
-
bridge
|
|
96
|
+
bridge,
|
|
94
97
|
});
|
|
95
98
|
const cosmos = new onekey_cosmos_provider_1.ProviderCosmos({
|
|
96
|
-
bridge
|
|
99
|
+
bridge,
|
|
97
100
|
});
|
|
98
101
|
// providerHub
|
|
99
102
|
const $onekey = Object.assign(Object.assign({}, window.$onekey), { jsBridge: bridge, $private,
|
|
@@ -148,7 +151,10 @@ function injectWeb3Provider() {
|
|
|
148
151
|
(0, onekey_eth_provider_1.shimWeb3)(ethereum);
|
|
149
152
|
// TODO use initializeInpageProvider.ts
|
|
150
153
|
window.dispatchEvent(new Event('ethereum#initialized'));
|
|
151
|
-
|
|
154
|
+
// Sui Standard Wallet
|
|
155
|
+
(0, onekey_sui_provider_1.registerSuiWallet)(sui, {
|
|
156
|
+
logo: consts_1.WALLET_CONNECT_INFO.onekey.icon,
|
|
157
|
+
});
|
|
152
158
|
return $onekey;
|
|
153
159
|
}
|
|
154
160
|
exports.injectWeb3Provider = injectWeb3Provider;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { throttle } from 'lodash';
|
|
11
11
|
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
12
|
-
function checkIfInjectedProviderConnected({ providerName }) {
|
|
12
|
+
function checkIfInjectedProviderConnected({ providerName, }) {
|
|
13
13
|
var _a;
|
|
14
14
|
const hub = window.$onekey;
|
|
15
15
|
if (providerName === IInjectedProviderNames.ethereum) {
|
|
@@ -27,6 +27,15 @@ export function detectQrcodeFromSvg({ img, }) {
|
|
|
27
27
|
var _a, _b;
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
// https://unpkg.com/qr-scanner@1.4.1/qr-scanner.umd.min.js
|
|
30
|
+
// Firefox does not support drawing SVG images to canvas
|
|
31
|
+
// Unless the svg file has width/height attributes on the root <svg> element
|
|
32
|
+
try {
|
|
33
|
+
img.setAttribute('width', img.clientWidth.toString());
|
|
34
|
+
img.setAttribute('height', img.clientHeight.toString());
|
|
35
|
+
}
|
|
36
|
+
catch (_c) {
|
|
37
|
+
//pass
|
|
38
|
+
}
|
|
30
39
|
const serialized = new XMLSerializer().serializeToString(img);
|
|
31
40
|
const encodedData = window.btoa(serialized);
|
|
32
41
|
const base64 = `data:image/svg+xml;base64,${encodedData}`;
|
|
@@ -10,9 +10,12 @@ 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';
|
|
12
12
|
import './connectButtonHack';
|
|
13
|
+
import { WALLET_CONNECT_INFO } from './connectButtonHack/consts';
|
|
13
14
|
// import Web3 from 'web3'; // cause build error
|
|
14
15
|
const { WALLET_INFO_LOACAL_KEY } = consts;
|
|
15
|
-
function checkEnableDefineProperty() {
|
|
16
|
+
function checkEnableDefineProperty(property) {
|
|
17
|
+
if (property === '$onekey')
|
|
18
|
+
return false;
|
|
16
19
|
try {
|
|
17
20
|
const walletInfoLocalStr = localStorage.getItem(WALLET_INFO_LOACAL_KEY);
|
|
18
21
|
const walletInfoLocal = walletInfoLocalStr ? JSON.parse(walletInfoLocalStr) : null;
|
|
@@ -24,7 +27,7 @@ function checkEnableDefineProperty() {
|
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
29
|
function defineWindowProperty(property, provider) {
|
|
27
|
-
const enable = checkEnableDefineProperty();
|
|
30
|
+
const enable = checkEnableDefineProperty(property);
|
|
28
31
|
const proxyProvider = new Proxy(provider, {
|
|
29
32
|
defineProperty(target, property, attributes) {
|
|
30
33
|
// skip define Prevent overwriting
|
|
@@ -87,10 +90,10 @@ function injectWeb3Provider() {
|
|
|
87
90
|
bridge,
|
|
88
91
|
});
|
|
89
92
|
const cardano = new ProviderCardano({
|
|
90
|
-
bridge
|
|
93
|
+
bridge,
|
|
91
94
|
});
|
|
92
95
|
const cosmos = new ProviderCosmos({
|
|
93
|
-
bridge
|
|
96
|
+
bridge,
|
|
94
97
|
});
|
|
95
98
|
// providerHub
|
|
96
99
|
const $onekey = Object.assign(Object.assign({}, window.$onekey), { jsBridge: bridge, $private,
|
|
@@ -145,7 +148,10 @@ function injectWeb3Provider() {
|
|
|
145
148
|
shimWeb3(ethereum);
|
|
146
149
|
// TODO use initializeInpageProvider.ts
|
|
147
150
|
window.dispatchEvent(new Event('ethereum#initialized'));
|
|
148
|
-
|
|
151
|
+
// Sui Standard Wallet
|
|
152
|
+
registerSuiWallet(sui, {
|
|
153
|
+
logo: WALLET_CONNECT_INFO.onekey.icon,
|
|
154
|
+
});
|
|
149
155
|
return $onekey;
|
|
150
156
|
}
|
|
151
157
|
export { injectWeb3Provider };
|
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.16",
|
|
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.16",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.16",
|
|
33
|
+
"@onekeyfe/onekey-aptos-provider": "1.1.16",
|
|
34
|
+
"@onekeyfe/onekey-cardano-provider": "1.1.16",
|
|
35
|
+
"@onekeyfe/onekey-conflux-provider": "1.1.16",
|
|
36
|
+
"@onekeyfe/onekey-cosmos-provider": "1.1.16",
|
|
37
|
+
"@onekeyfe/onekey-eth-provider": "1.1.16",
|
|
38
|
+
"@onekeyfe/onekey-private-provider": "1.1.16",
|
|
39
|
+
"@onekeyfe/onekey-solana-provider": "1.1.16",
|
|
40
|
+
"@onekeyfe/onekey-starcoin-provider": "1.1.16",
|
|
41
|
+
"@onekeyfe/onekey-sui-provider": "1.1.16",
|
|
42
|
+
"@onekeyfe/onekey-tron-provider": "1.1.16",
|
|
43
43
|
"web3": "^1.7.3"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a2aa4f3e6d8ad7ac8ad73b31e7f8d80f5abd3d46"
|
|
46
46
|
}
|