@onekeyfe/inpage-providers-hub 1.1.45 → 1.1.48
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/connectButtonHack/hackConnectButton.js +73 -11
- package/dist/cjs/connectButtonHack/index.js +1 -0
- package/dist/cjs/connectButtonHack/sites/dydxv4.js +44 -0
- package/dist/cjs/connectButtonHack/sites/magiceden.js +45 -27
- package/dist/cjs/connectButtonHack/sites/opensea.js +21 -16
- package/dist/cjs/connectButtonHack/sites/rarible.js +21 -16
- package/dist/cjs/connectButtonHack/sites/zapper.js +13 -26
- package/dist/cjs/injectWeb3Provider.js +7 -1
- package/dist/connectButtonHack/hackConnectButton.d.ts +3 -1
- package/dist/connectButtonHack/hackConnectButton.js +73 -11
- package/dist/connectButtonHack/index.d.ts +1 -0
- package/dist/connectButtonHack/index.js +1 -0
- package/dist/connectButtonHack/sites/dydxv4.d.ts +1 -0
- package/dist/connectButtonHack/sites/dydxv4.js +42 -0
- package/dist/connectButtonHack/sites/magiceden.js +45 -27
- package/dist/connectButtonHack/sites/opensea.js +21 -16
- package/dist/connectButtonHack/sites/rarible.js +21 -16
- package/dist/connectButtonHack/sites/zapper.js +14 -27
- package/dist/injectWeb3Provider.js +8 -2
- package/package.json +18 -18
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.hackConnectButton = exports.createNewImageToContainer = exports.createWalletConnectToButton = exports.detectQrcodeFromSvg = void 0;
|
|
13
|
+
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
13
14
|
const lodash_1 = require("lodash");
|
|
14
15
|
const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-types");
|
|
15
16
|
function checkIfInjectedProviderConnected({ providerName, }) {
|
|
@@ -26,6 +27,49 @@ function checkIfInjectedProviderConnected({ providerName, }) {
|
|
|
26
27
|
}
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the given key is a valid key of the `ISpecialPropertyProviderNamesReflection` enum.
|
|
32
|
+
* This function acts as a type guard, verifying if a string is one of the keys in the `ISpecialPropertyProviderNamesReflection` enum.
|
|
33
|
+
*
|
|
34
|
+
* @param key - The key to be checked against the `ISpecialPropertyProviderNamesReflection` enum.
|
|
35
|
+
* @returns Returns `true` if the key is a valid enum key, otherwise returns `false`.
|
|
36
|
+
*/
|
|
37
|
+
function isKeyOfISpecialPropertyProviderNamesReflection(key) {
|
|
38
|
+
return key in cross_inpage_provider_core_1.ISpecialPropertyProviderNamesReflection;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Checks if the provided blockchain provider is enabled.
|
|
42
|
+
* This function determines the status of a blockchain provider by mapping its name to a special property name (if applicable) and then checking if the wallet switch for that property is enabled.
|
|
43
|
+
*
|
|
44
|
+
* @param param - An object containing the name of the blockchain provider.
|
|
45
|
+
* @param providerName - The name of the provider to check. This should be a member of the `IInjectedProviderNames` enum.
|
|
46
|
+
* @returns Returns `true` if the provider is enabled, otherwise returns `false`.
|
|
47
|
+
*/
|
|
48
|
+
function checkIfInjectedProviderEnable({ providerName }) {
|
|
49
|
+
let property;
|
|
50
|
+
if (isKeyOfISpecialPropertyProviderNamesReflection(providerName)) {
|
|
51
|
+
property = cross_inpage_provider_core_1.ISpecialPropertyProviderNamesReflection[providerName];
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
property = providerName;
|
|
55
|
+
}
|
|
56
|
+
const result = (0, cross_inpage_provider_core_1.checkWalletSwitchEnable)(property);
|
|
57
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
+
console.log('checkIfInjectedProviderEnable', property, result);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieves an array of enabled provider names.
|
|
64
|
+
*
|
|
65
|
+
* @param providers - An array of provider names to check.
|
|
66
|
+
* @returns Returns an array containing the names of all enabled providers.
|
|
67
|
+
*/
|
|
68
|
+
function getEnabledProviders({ providers, }) {
|
|
69
|
+
return providers.filter((providerName) => {
|
|
70
|
+
return checkIfInjectedProviderEnable({ providerName });
|
|
71
|
+
});
|
|
72
|
+
}
|
|
29
73
|
function detectQrcodeFromSvg({ img, }) {
|
|
30
74
|
var _a, _b;
|
|
31
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -193,6 +237,25 @@ function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOpt
|
|
|
193
237
|
trailing: true,
|
|
194
238
|
}, callbackDelay = 10, }) {
|
|
195
239
|
const isUrlMatched = () => Boolean(urls.includes(window.location.hostname) || urls.includes('*'));
|
|
240
|
+
const getEnabledInjectedProviders = () => {
|
|
241
|
+
if (!isUrlMatched()) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (providers.find((providerName) => checkIfInjectedProviderConnected({ providerName }))) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const enabledProviders = getEnabledProviders({ providers });
|
|
248
|
+
if (!enabledProviders || enabledProviders.length === 0) {
|
|
249
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
250
|
+
console.log('inject Provider disabled, skip hackConnectButton (DEV only log)');
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
255
|
+
console.log('mutation triggered: hackConnectButton (DEV only log)');
|
|
256
|
+
}
|
|
257
|
+
return enabledProviders;
|
|
258
|
+
};
|
|
196
259
|
const run = () => {
|
|
197
260
|
// ignore web site run in iframe
|
|
198
261
|
if (window.top !== window) {
|
|
@@ -209,18 +272,13 @@ function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOpt
|
|
|
209
272
|
const callback = (0, lodash_1.throttle)((mutationList, observer) => {
|
|
210
273
|
setTimeout(() => {
|
|
211
274
|
var _a, _b;
|
|
212
|
-
if (!isUrlMatched()) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
if (providers.find((providerName) => checkIfInjectedProviderConnected({ providerName }))) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
219
|
-
console.log('mutation triggered: hackConnectButton (DEV only log)');
|
|
220
|
-
}
|
|
221
275
|
try {
|
|
276
|
+
const enabledProviders = getEnabledInjectedProviders();
|
|
222
277
|
(_a = observer === null || observer === void 0 ? void 0 : observer.disconnect) === null || _a === void 0 ? void 0 : _a.call(observer);
|
|
223
|
-
|
|
278
|
+
if (!enabledProviders) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
replaceMethod === null || replaceMethod === void 0 ? void 0 : replaceMethod({ providers: enabledProviders });
|
|
224
282
|
}
|
|
225
283
|
catch (error) {
|
|
226
284
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -260,7 +318,11 @@ function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOpt
|
|
|
260
318
|
}
|
|
261
319
|
setTimeout(() => {
|
|
262
320
|
try {
|
|
263
|
-
|
|
321
|
+
const enabledProviders = getEnabledInjectedProviders();
|
|
322
|
+
if (!enabledProviders) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
replaceMethod === null || replaceMethod === void 0 ? void 0 : replaceMethod({ providers: enabledProviders });
|
|
264
326
|
}
|
|
265
327
|
catch (error) {
|
|
266
328
|
// noop
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hackConnectButton_1 = require("../hackConnectButton");
|
|
4
|
+
const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-types");
|
|
5
|
+
const consts_1 = require("../consts");
|
|
6
|
+
(0, hackConnectButton_1.hackConnectButton)({
|
|
7
|
+
urls: ['dydx.trade'],
|
|
8
|
+
providers: [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum],
|
|
9
|
+
replaceMethod() {
|
|
10
|
+
const replaceFunc = ({ findName, icon, text, }) => {
|
|
11
|
+
const buttons = Array.from(document.querySelectorAll('div[role="dialog"] div > div > button'));
|
|
12
|
+
const btn = buttons.find((item) => {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = item.querySelector('div')) === null || _a === void 0 ? void 0 : _a.innerText.includes(findName);
|
|
15
|
+
});
|
|
16
|
+
const datasetKey = 'onekey_auto_created_icon_img';
|
|
17
|
+
if (btn && !btn.querySelector(`[data-${datasetKey}]`)) {
|
|
18
|
+
(0, hackConnectButton_1.createNewImageToContainer)({
|
|
19
|
+
container: btn,
|
|
20
|
+
icon,
|
|
21
|
+
removeSvg: true,
|
|
22
|
+
onCreated(img) {
|
|
23
|
+
img.style.width = '20px';
|
|
24
|
+
img.style.height = '20px';
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const textNode = btn.querySelector('div');
|
|
28
|
+
if (textNode) {
|
|
29
|
+
textNode.innerText = text;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
replaceFunc({
|
|
34
|
+
findName: 'MetaMask',
|
|
35
|
+
icon: consts_1.WALLET_CONNECT_INFO.metamask.icon,
|
|
36
|
+
text: consts_1.WALLET_CONNECT_INFO.metamask.text,
|
|
37
|
+
});
|
|
38
|
+
replaceFunc({
|
|
39
|
+
findName: 'WalletConnect',
|
|
40
|
+
icon: consts_1.WALLET_CONNECT_INFO.walletconnect.icon,
|
|
41
|
+
text: consts_1.WALLET_CONNECT_INFO.walletconnect.text,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -5,11 +5,16 @@ const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-t
|
|
|
5
5
|
const consts_1 = require("../consts");
|
|
6
6
|
(0, hackConnectButton_1.hackConnectButton)({
|
|
7
7
|
urls: ['magiceden.io', 'www.magiceden.io'],
|
|
8
|
-
providers: [
|
|
9
|
-
|
|
8
|
+
providers: [
|
|
9
|
+
cross_inpage_provider_types_1.IInjectedProviderNames.ethereum,
|
|
10
|
+
cross_inpage_provider_types_1.IInjectedProviderNames.solana,
|
|
11
|
+
cross_inpage_provider_types_1.IInjectedProviderNames.btc,
|
|
12
|
+
],
|
|
13
|
+
replaceMethod(options) {
|
|
14
|
+
var _a, _b, _c;
|
|
10
15
|
const replaceFunc = ({ findName, findIconText, icon, text, }) => {
|
|
11
16
|
var _a;
|
|
12
|
-
const img = document.querySelector(`#headlessui-portal-root
|
|
17
|
+
const img = document.querySelector(`#headlessui-portal-root div > button > div > img[alt="${findIconText}"]`);
|
|
13
18
|
if (img && img.src) {
|
|
14
19
|
img.src = icon;
|
|
15
20
|
const span = (_a = img.nextSibling) === null || _a === void 0 ? void 0 : _a.querySelector('span');
|
|
@@ -18,29 +23,42 @@ const consts_1 = require("../consts");
|
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.providers) === null || _a === void 0 ? void 0 : _a.includes(cross_inpage_provider_types_1.IInjectedProviderNames.ethereum)) {
|
|
27
|
+
replaceFunc({
|
|
28
|
+
findName: 'MetaMask',
|
|
29
|
+
findIconText: 'MetaMask icon',
|
|
30
|
+
icon: consts_1.WALLET_CONNECT_INFO.metamask.icon,
|
|
31
|
+
text: consts_1.WALLET_CONNECT_INFO.metamask.text,
|
|
32
|
+
});
|
|
33
|
+
// The magiceden bug will probably be fixed later
|
|
34
|
+
replaceFunc({
|
|
35
|
+
findName: 'MetaMask',
|
|
36
|
+
findIconText: 'MetaMask icon',
|
|
37
|
+
icon: consts_1.WALLET_CONNECT_INFO.metamask.icon,
|
|
38
|
+
text: consts_1.WALLET_CONNECT_INFO.metamask.text,
|
|
39
|
+
});
|
|
40
|
+
replaceFunc({
|
|
41
|
+
findName: 'WalletConnect',
|
|
42
|
+
findIconText: 'WalletConnect icon',
|
|
43
|
+
icon: consts_1.WALLET_CONNECT_INFO.walletconnect.icon,
|
|
44
|
+
text: consts_1.WALLET_CONNECT_INFO.walletconnect.text,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.providers) === null || _b === void 0 ? void 0 : _b.includes(cross_inpage_provider_types_1.IInjectedProviderNames.solana)) {
|
|
48
|
+
replaceFunc({
|
|
49
|
+
findName: 'Phantom',
|
|
50
|
+
findIconText: 'Phantom icon',
|
|
51
|
+
icon: consts_1.WALLET_CONNECT_INFO.phantom.icon,
|
|
52
|
+
text: consts_1.WALLET_CONNECT_INFO.phantom.text,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if ((_c = options === null || options === void 0 ? void 0 : options.providers) === null || _c === void 0 ? void 0 : _c.includes(cross_inpage_provider_types_1.IInjectedProviderNames.btc)) {
|
|
56
|
+
replaceFunc({
|
|
57
|
+
findName: 'Unisat',
|
|
58
|
+
findIconText: 'Unisat icon',
|
|
59
|
+
icon: consts_1.WALLET_CONNECT_INFO.unisat.icon,
|
|
60
|
+
text: consts_1.WALLET_CONNECT_INFO.unisat.text,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
45
63
|
},
|
|
46
64
|
});
|
|
@@ -6,7 +6,8 @@ const consts_1 = require("../consts");
|
|
|
6
6
|
(0, hackConnectButton_1.hackConnectButton)({
|
|
7
7
|
urls: ['opensea.io', 'www.opensea.io'],
|
|
8
8
|
providers: [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum, cross_inpage_provider_types_1.IInjectedProviderNames.solana],
|
|
9
|
-
replaceMethod() {
|
|
9
|
+
replaceMethod(options) {
|
|
10
|
+
var _a, _b;
|
|
10
11
|
const replaceFunc = ({ findName, icon, text, }) => {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
const listDom = (_a = window.document.querySelector('div[data-testid="wallet-modal"] ul')) === null || _a === void 0 ? void 0 : _a.childNodes;
|
|
@@ -30,20 +31,24 @@ const consts_1 = require("../consts");
|
|
|
30
31
|
span.innerText = text;
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.providers) === null || _a === void 0 ? void 0 : _a.includes(cross_inpage_provider_types_1.IInjectedProviderNames.ethereum)) {
|
|
35
|
+
replaceFunc({
|
|
36
|
+
findName: 'MetaMask',
|
|
37
|
+
icon: consts_1.WALLET_CONNECT_INFO.metamask.icon,
|
|
38
|
+
text: consts_1.WALLET_CONNECT_INFO.metamask.text,
|
|
39
|
+
});
|
|
40
|
+
replaceFunc({
|
|
41
|
+
findName: 'WalletConnect',
|
|
42
|
+
icon: consts_1.WALLET_CONNECT_INFO.walletconnect.icon,
|
|
43
|
+
text: consts_1.WALLET_CONNECT_INFO.walletconnect.text,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.providers) === null || _b === void 0 ? void 0 : _b.includes(cross_inpage_provider_types_1.IInjectedProviderNames.solana)) {
|
|
47
|
+
replaceFunc({
|
|
48
|
+
findName: 'Phantom',
|
|
49
|
+
icon: consts_1.WALLET_CONNECT_INFO.phantom.icon,
|
|
50
|
+
text: consts_1.WALLET_CONNECT_INFO.phantom.text,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
48
53
|
},
|
|
49
54
|
});
|
|
@@ -7,7 +7,8 @@ const consts_1 = require("../consts");
|
|
|
7
7
|
urls: ['rarible.com', 'www.rarible.com'],
|
|
8
8
|
providers: [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum, cross_inpage_provider_types_1.IInjectedProviderNames.solana],
|
|
9
9
|
callbackDelay: 0,
|
|
10
|
-
replaceMethod() {
|
|
10
|
+
replaceMethod(options) {
|
|
11
|
+
var _a, _b;
|
|
11
12
|
const replaceFunc = ({ findName, icon, text, }) => {
|
|
12
13
|
const spans = Array.from(document.querySelectorAll('.ScrollbarsCustom ~ div > div > button > span > span > span > span'));
|
|
13
14
|
const span = spans.find((item) => item.innerHTML === findName);
|
|
@@ -19,20 +20,24 @@ const consts_1 = require("../consts");
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.providers) === null || _a === void 0 ? void 0 : _a.includes(cross_inpage_provider_types_1.IInjectedProviderNames.ethereum)) {
|
|
24
|
+
replaceFunc({
|
|
25
|
+
findName: 'MetaMask',
|
|
26
|
+
icon: consts_1.WALLET_CONNECT_INFO.metamask.icon,
|
|
27
|
+
text: consts_1.WALLET_CONNECT_INFO.metamask.text,
|
|
28
|
+
});
|
|
29
|
+
replaceFunc({
|
|
30
|
+
findName: 'WalletConnect',
|
|
31
|
+
icon: consts_1.WALLET_CONNECT_INFO.walletconnect.icon,
|
|
32
|
+
text: consts_1.WALLET_CONNECT_INFO.walletconnect.text,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.providers) === null || _b === void 0 ? void 0 : _b.includes(cross_inpage_provider_types_1.IInjectedProviderNames.solana)) {
|
|
36
|
+
replaceFunc({
|
|
37
|
+
findName: 'Phantom',
|
|
38
|
+
icon: consts_1.WALLET_CONNECT_INFO.phantom.icon,
|
|
39
|
+
text: consts_1.WALLET_CONNECT_INFO.phantom.text,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
37
42
|
},
|
|
38
43
|
});
|
|
@@ -4,7 +4,7 @@ const hackConnectButton_1 = require("../hackConnectButton");
|
|
|
4
4
|
const cross_inpage_provider_types_1 = require("@onekeyfe/cross-inpage-provider-types");
|
|
5
5
|
const consts_1 = require("../consts");
|
|
6
6
|
(0, hackConnectButton_1.hackConnectButton)({
|
|
7
|
-
urls: ['zapper.
|
|
7
|
+
urls: ['zapper.xyz', 'zapper.fi', 'www.zapper.xyz'],
|
|
8
8
|
providers: [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum],
|
|
9
9
|
mutationObserverOptions: {
|
|
10
10
|
attributes: true,
|
|
@@ -14,32 +14,19 @@ const consts_1 = require("../consts");
|
|
|
14
14
|
},
|
|
15
15
|
replaceMethod() {
|
|
16
16
|
const replaceFunc = ({ findName, icon, text, }) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const buttons = Array.from(shadowRoot.querySelectorAll('.wallets-container button'));
|
|
23
|
-
const btn = buttons.find((item) => item.innerHTML.includes(findName));
|
|
24
|
-
if (btn) {
|
|
25
|
-
const replaceImg = () => {
|
|
26
|
-
const imgContainer = btn.querySelector('div.icon');
|
|
27
|
-
if (imgContainer) {
|
|
28
|
-
(0, hackConnectButton_1.createNewImageToContainer)({
|
|
29
|
-
container: imgContainer,
|
|
30
|
-
icon,
|
|
31
|
-
removeSvg: true,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const span = btn.querySelector('span.name');
|
|
36
|
-
if (span && span.innerHTML === findName) {
|
|
37
|
-
span.innerHTML = text;
|
|
38
|
-
// shadowRoot update image, need some delay to replace image
|
|
39
|
-
setTimeout(replaceImg, 1000);
|
|
40
|
-
}
|
|
41
|
-
replaceImg();
|
|
17
|
+
const buttons = Array.from(document.querySelectorAll('.ReactModal__Content--after-open div > button > div:first-child'));
|
|
18
|
+
const btnContent = buttons.reverse().find((item) => item.innerText.includes(findName));
|
|
19
|
+
if (btnContent) {
|
|
20
|
+
while (btnContent.firstChild) {
|
|
21
|
+
btnContent.removeChild(btnContent.firstChild);
|
|
42
22
|
}
|
|
23
|
+
const image = document.createElement('img');
|
|
24
|
+
image.src = icon;
|
|
25
|
+
image.style.width = '32px';
|
|
26
|
+
image.style.height = '32px';
|
|
27
|
+
btnContent.appendChild(image);
|
|
28
|
+
const newText = document.createTextNode(text);
|
|
29
|
+
btnContent.appendChild(newText);
|
|
43
30
|
}
|
|
44
31
|
};
|
|
45
32
|
replaceFunc({
|
|
@@ -104,7 +104,7 @@ function injectWeb3Provider() {
|
|
|
104
104
|
(0, cross_inpage_provider_core_1.defineWindowProperty)('getOfflineSigner', cosmos.getOfflineSigner.bind(cosmos));
|
|
105
105
|
(0, cross_inpage_provider_core_1.defineWindowProperty)('getOfflineSignerOnlyAmino', cosmos.getOfflineSignerOnlyAmino.bind(cosmos));
|
|
106
106
|
(0, cross_inpage_provider_core_1.defineWindowProperty)('getOfflineSignerAuto', cosmos.getOfflineSignerAuto.bind(cosmos));
|
|
107
|
-
// Lightning Network
|
|
107
|
+
// Lightning Network
|
|
108
108
|
(0, cross_inpage_provider_core_1.defineWindowProperty)('webln', webln);
|
|
109
109
|
(0, cross_inpage_provider_core_1.defineWindowProperty)('nostr', nostr);
|
|
110
110
|
// ** shim or inject real web3
|
|
@@ -116,6 +116,12 @@ function injectWeb3Provider() {
|
|
|
116
116
|
(0, onekey_eth_provider_1.shimWeb3)(ethereum);
|
|
117
117
|
// TODO use initializeInpageProvider.ts
|
|
118
118
|
window.dispatchEvent(new Event('ethereum#initialized'));
|
|
119
|
+
// Solana Standard Wallet
|
|
120
|
+
if ((0, cross_inpage_provider_core_1.checkWalletSwitchEnable)('onekey-solana')) {
|
|
121
|
+
(0, onekey_solana_provider_1.registerSolanaWallet)(solana, {
|
|
122
|
+
icon: consts_1.WALLET_CONNECT_INFO.onekey.icon,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
119
125
|
// Sui Standard Wallet
|
|
120
126
|
if ((0, cross_inpage_provider_core_1.checkWalletSwitchEnable)('onekey-sui')) {
|
|
121
127
|
(0, onekey_sui_provider_1.registerSuiWallet)(sui, {
|
|
@@ -18,7 +18,9 @@ export declare function createNewImageToContainer({ container, icon, removeSvg,
|
|
|
18
18
|
}): void;
|
|
19
19
|
declare function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOptions, throttleDelay, throttleSettings, callbackDelay, }: {
|
|
20
20
|
urls: string[];
|
|
21
|
-
replaceMethod: (
|
|
21
|
+
replaceMethod: (options?: {
|
|
22
|
+
providers: IInjectedProviderNames[];
|
|
23
|
+
}) => void;
|
|
22
24
|
providers: IInjectedProviderNames[];
|
|
23
25
|
mutationObserverOptions?: MutationObserverInit;
|
|
24
26
|
throttleDelay?: number;
|
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { ISpecialPropertyProviderNamesReflection, checkWalletSwitchEnable, } from '@onekeyfe/cross-inpage-provider-core';
|
|
10
11
|
import { throttle } from 'lodash';
|
|
11
12
|
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
12
13
|
function checkIfInjectedProviderConnected({ providerName, }) {
|
|
@@ -23,6 +24,49 @@ function checkIfInjectedProviderConnected({ providerName, }) {
|
|
|
23
24
|
}
|
|
24
25
|
return false;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the given key is a valid key of the `ISpecialPropertyProviderNamesReflection` enum.
|
|
29
|
+
* This function acts as a type guard, verifying if a string is one of the keys in the `ISpecialPropertyProviderNamesReflection` enum.
|
|
30
|
+
*
|
|
31
|
+
* @param key - The key to be checked against the `ISpecialPropertyProviderNamesReflection` enum.
|
|
32
|
+
* @returns Returns `true` if the key is a valid enum key, otherwise returns `false`.
|
|
33
|
+
*/
|
|
34
|
+
function isKeyOfISpecialPropertyProviderNamesReflection(key) {
|
|
35
|
+
return key in ISpecialPropertyProviderNamesReflection;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the provided blockchain provider is enabled.
|
|
39
|
+
* This function determines the status of a blockchain provider by mapping its name to a special property name (if applicable) and then checking if the wallet switch for that property is enabled.
|
|
40
|
+
*
|
|
41
|
+
* @param param - An object containing the name of the blockchain provider.
|
|
42
|
+
* @param providerName - The name of the provider to check. This should be a member of the `IInjectedProviderNames` enum.
|
|
43
|
+
* @returns Returns `true` if the provider is enabled, otherwise returns `false`.
|
|
44
|
+
*/
|
|
45
|
+
function checkIfInjectedProviderEnable({ providerName }) {
|
|
46
|
+
let property;
|
|
47
|
+
if (isKeyOfISpecialPropertyProviderNamesReflection(providerName)) {
|
|
48
|
+
property = ISpecialPropertyProviderNamesReflection[providerName];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
property = providerName;
|
|
52
|
+
}
|
|
53
|
+
const result = checkWalletSwitchEnable(property);
|
|
54
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
55
|
+
console.log('checkIfInjectedProviderEnable', property, result);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves an array of enabled provider names.
|
|
61
|
+
*
|
|
62
|
+
* @param providers - An array of provider names to check.
|
|
63
|
+
* @returns Returns an array containing the names of all enabled providers.
|
|
64
|
+
*/
|
|
65
|
+
function getEnabledProviders({ providers, }) {
|
|
66
|
+
return providers.filter((providerName) => {
|
|
67
|
+
return checkIfInjectedProviderEnable({ providerName });
|
|
68
|
+
});
|
|
69
|
+
}
|
|
26
70
|
export function detectQrcodeFromSvg({ img, }) {
|
|
27
71
|
var _a, _b;
|
|
28
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -187,6 +231,25 @@ function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOpt
|
|
|
187
231
|
trailing: true,
|
|
188
232
|
}, callbackDelay = 10, }) {
|
|
189
233
|
const isUrlMatched = () => Boolean(urls.includes(window.location.hostname) || urls.includes('*'));
|
|
234
|
+
const getEnabledInjectedProviders = () => {
|
|
235
|
+
if (!isUrlMatched()) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (providers.find((providerName) => checkIfInjectedProviderConnected({ providerName }))) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const enabledProviders = getEnabledProviders({ providers });
|
|
242
|
+
if (!enabledProviders || enabledProviders.length === 0) {
|
|
243
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
244
|
+
console.log('inject Provider disabled, skip hackConnectButton (DEV only log)');
|
|
245
|
+
}
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
249
|
+
console.log('mutation triggered: hackConnectButton (DEV only log)');
|
|
250
|
+
}
|
|
251
|
+
return enabledProviders;
|
|
252
|
+
};
|
|
190
253
|
const run = () => {
|
|
191
254
|
// ignore web site run in iframe
|
|
192
255
|
if (window.top !== window) {
|
|
@@ -203,18 +266,13 @@ function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOpt
|
|
|
203
266
|
const callback = throttle((mutationList, observer) => {
|
|
204
267
|
setTimeout(() => {
|
|
205
268
|
var _a, _b;
|
|
206
|
-
if (!isUrlMatched()) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (providers.find((providerName) => checkIfInjectedProviderConnected({ providerName }))) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
213
|
-
console.log('mutation triggered: hackConnectButton (DEV only log)');
|
|
214
|
-
}
|
|
215
269
|
try {
|
|
270
|
+
const enabledProviders = getEnabledInjectedProviders();
|
|
216
271
|
(_a = observer === null || observer === void 0 ? void 0 : observer.disconnect) === null || _a === void 0 ? void 0 : _a.call(observer);
|
|
217
|
-
|
|
272
|
+
if (!enabledProviders) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
replaceMethod === null || replaceMethod === void 0 ? void 0 : replaceMethod({ providers: enabledProviders });
|
|
218
276
|
}
|
|
219
277
|
catch (error) {
|
|
220
278
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -254,7 +312,11 @@ function hackConnectButton({ urls, replaceMethod, providers, mutationObserverOpt
|
|
|
254
312
|
}
|
|
255
313
|
setTimeout(() => {
|
|
256
314
|
try {
|
|
257
|
-
|
|
315
|
+
const enabledProviders = getEnabledInjectedProviders();
|
|
316
|
+
if (!enabledProviders) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
replaceMethod === null || replaceMethod === void 0 ? void 0 : replaceMethod({ providers: enabledProviders });
|
|
258
320
|
}
|
|
259
321
|
catch (error) {
|
|
260
322
|
// noop
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createNewImageToContainer, hackConnectButton } from '../hackConnectButton';
|
|
2
|
+
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
3
|
+
import { WALLET_CONNECT_INFO } from '../consts';
|
|
4
|
+
hackConnectButton({
|
|
5
|
+
urls: ['dydx.trade'],
|
|
6
|
+
providers: [IInjectedProviderNames.ethereum],
|
|
7
|
+
replaceMethod() {
|
|
8
|
+
const replaceFunc = ({ findName, icon, text, }) => {
|
|
9
|
+
const buttons = Array.from(document.querySelectorAll('div[role="dialog"] div > div > button'));
|
|
10
|
+
const btn = buttons.find((item) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = item.querySelector('div')) === null || _a === void 0 ? void 0 : _a.innerText.includes(findName);
|
|
13
|
+
});
|
|
14
|
+
const datasetKey = 'onekey_auto_created_icon_img';
|
|
15
|
+
if (btn && !btn.querySelector(`[data-${datasetKey}]`)) {
|
|
16
|
+
createNewImageToContainer({
|
|
17
|
+
container: btn,
|
|
18
|
+
icon,
|
|
19
|
+
removeSvg: true,
|
|
20
|
+
onCreated(img) {
|
|
21
|
+
img.style.width = '20px';
|
|
22
|
+
img.style.height = '20px';
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const textNode = btn.querySelector('div');
|
|
26
|
+
if (textNode) {
|
|
27
|
+
textNode.innerText = text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
replaceFunc({
|
|
32
|
+
findName: 'MetaMask',
|
|
33
|
+
icon: WALLET_CONNECT_INFO.metamask.icon,
|
|
34
|
+
text: WALLET_CONNECT_INFO.metamask.text,
|
|
35
|
+
});
|
|
36
|
+
replaceFunc({
|
|
37
|
+
findName: 'WalletConnect',
|
|
38
|
+
icon: WALLET_CONNECT_INFO.walletconnect.icon,
|
|
39
|
+
text: WALLET_CONNECT_INFO.walletconnect.text,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -3,11 +3,16 @@ import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
|
3
3
|
import { WALLET_CONNECT_INFO } from '../consts';
|
|
4
4
|
hackConnectButton({
|
|
5
5
|
urls: ['magiceden.io', 'www.magiceden.io'],
|
|
6
|
-
providers: [
|
|
7
|
-
|
|
6
|
+
providers: [
|
|
7
|
+
IInjectedProviderNames.ethereum,
|
|
8
|
+
IInjectedProviderNames.solana,
|
|
9
|
+
IInjectedProviderNames.btc,
|
|
10
|
+
],
|
|
11
|
+
replaceMethod(options) {
|
|
12
|
+
var _a, _b, _c;
|
|
8
13
|
const replaceFunc = ({ findName, findIconText, icon, text, }) => {
|
|
9
14
|
var _a;
|
|
10
|
-
const img = document.querySelector(`#headlessui-portal-root
|
|
15
|
+
const img = document.querySelector(`#headlessui-portal-root div > button > div > img[alt="${findIconText}"]`);
|
|
11
16
|
if (img && img.src) {
|
|
12
17
|
img.src = icon;
|
|
13
18
|
const span = (_a = img.nextSibling) === null || _a === void 0 ? void 0 : _a.querySelector('span');
|
|
@@ -16,29 +21,42 @@ hackConnectButton({
|
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.providers) === null || _a === void 0 ? void 0 : _a.includes(IInjectedProviderNames.ethereum)) {
|
|
25
|
+
replaceFunc({
|
|
26
|
+
findName: 'MetaMask',
|
|
27
|
+
findIconText: 'MetaMask icon',
|
|
28
|
+
icon: WALLET_CONNECT_INFO.metamask.icon,
|
|
29
|
+
text: WALLET_CONNECT_INFO.metamask.text,
|
|
30
|
+
});
|
|
31
|
+
// The magiceden bug will probably be fixed later
|
|
32
|
+
replaceFunc({
|
|
33
|
+
findName: 'MetaMask',
|
|
34
|
+
findIconText: 'MetaMask icon',
|
|
35
|
+
icon: WALLET_CONNECT_INFO.metamask.icon,
|
|
36
|
+
text: WALLET_CONNECT_INFO.metamask.text,
|
|
37
|
+
});
|
|
38
|
+
replaceFunc({
|
|
39
|
+
findName: 'WalletConnect',
|
|
40
|
+
findIconText: 'WalletConnect icon',
|
|
41
|
+
icon: WALLET_CONNECT_INFO.walletconnect.icon,
|
|
42
|
+
text: WALLET_CONNECT_INFO.walletconnect.text,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.providers) === null || _b === void 0 ? void 0 : _b.includes(IInjectedProviderNames.solana)) {
|
|
46
|
+
replaceFunc({
|
|
47
|
+
findName: 'Phantom',
|
|
48
|
+
findIconText: 'Phantom icon',
|
|
49
|
+
icon: WALLET_CONNECT_INFO.phantom.icon,
|
|
50
|
+
text: WALLET_CONNECT_INFO.phantom.text,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if ((_c = options === null || options === void 0 ? void 0 : options.providers) === null || _c === void 0 ? void 0 : _c.includes(IInjectedProviderNames.btc)) {
|
|
54
|
+
replaceFunc({
|
|
55
|
+
findName: 'Unisat',
|
|
56
|
+
findIconText: 'Unisat icon',
|
|
57
|
+
icon: WALLET_CONNECT_INFO.unisat.icon,
|
|
58
|
+
text: WALLET_CONNECT_INFO.unisat.text,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
43
61
|
},
|
|
44
62
|
});
|
|
@@ -4,7 +4,8 @@ import { WALLET_CONNECT_INFO } from '../consts';
|
|
|
4
4
|
hackConnectButton({
|
|
5
5
|
urls: ['opensea.io', 'www.opensea.io'],
|
|
6
6
|
providers: [IInjectedProviderNames.ethereum, IInjectedProviderNames.solana],
|
|
7
|
-
replaceMethod() {
|
|
7
|
+
replaceMethod(options) {
|
|
8
|
+
var _a, _b;
|
|
8
9
|
const replaceFunc = ({ findName, icon, text, }) => {
|
|
9
10
|
var _a, _b;
|
|
10
11
|
const listDom = (_a = window.document.querySelector('div[data-testid="wallet-modal"] ul')) === null || _a === void 0 ? void 0 : _a.childNodes;
|
|
@@ -28,20 +29,24 @@ hackConnectButton({
|
|
|
28
29
|
span.innerText = text;
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.providers) === null || _a === void 0 ? void 0 : _a.includes(IInjectedProviderNames.ethereum)) {
|
|
33
|
+
replaceFunc({
|
|
34
|
+
findName: 'MetaMask',
|
|
35
|
+
icon: WALLET_CONNECT_INFO.metamask.icon,
|
|
36
|
+
text: WALLET_CONNECT_INFO.metamask.text,
|
|
37
|
+
});
|
|
38
|
+
replaceFunc({
|
|
39
|
+
findName: 'WalletConnect',
|
|
40
|
+
icon: WALLET_CONNECT_INFO.walletconnect.icon,
|
|
41
|
+
text: WALLET_CONNECT_INFO.walletconnect.text,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.providers) === null || _b === void 0 ? void 0 : _b.includes(IInjectedProviderNames.solana)) {
|
|
45
|
+
replaceFunc({
|
|
46
|
+
findName: 'Phantom',
|
|
47
|
+
icon: WALLET_CONNECT_INFO.phantom.icon,
|
|
48
|
+
text: WALLET_CONNECT_INFO.phantom.text,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
46
51
|
},
|
|
47
52
|
});
|
|
@@ -5,7 +5,8 @@ hackConnectButton({
|
|
|
5
5
|
urls: ['rarible.com', 'www.rarible.com'],
|
|
6
6
|
providers: [IInjectedProviderNames.ethereum, IInjectedProviderNames.solana],
|
|
7
7
|
callbackDelay: 0,
|
|
8
|
-
replaceMethod() {
|
|
8
|
+
replaceMethod(options) {
|
|
9
|
+
var _a, _b;
|
|
9
10
|
const replaceFunc = ({ findName, icon, text, }) => {
|
|
10
11
|
const spans = Array.from(document.querySelectorAll('.ScrollbarsCustom ~ div > div > button > span > span > span > span'));
|
|
11
12
|
const span = spans.find((item) => item.innerHTML === findName);
|
|
@@ -17,20 +18,24 @@ hackConnectButton({
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.providers) === null || _a === void 0 ? void 0 : _a.includes(IInjectedProviderNames.ethereum)) {
|
|
22
|
+
replaceFunc({
|
|
23
|
+
findName: 'MetaMask',
|
|
24
|
+
icon: WALLET_CONNECT_INFO.metamask.icon,
|
|
25
|
+
text: WALLET_CONNECT_INFO.metamask.text,
|
|
26
|
+
});
|
|
27
|
+
replaceFunc({
|
|
28
|
+
findName: 'WalletConnect',
|
|
29
|
+
icon: WALLET_CONNECT_INFO.walletconnect.icon,
|
|
30
|
+
text: WALLET_CONNECT_INFO.walletconnect.text,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.providers) === null || _b === void 0 ? void 0 : _b.includes(IInjectedProviderNames.solana)) {
|
|
34
|
+
replaceFunc({
|
|
35
|
+
findName: 'Phantom',
|
|
36
|
+
icon: WALLET_CONNECT_INFO.phantom.icon,
|
|
37
|
+
text: WALLET_CONNECT_INFO.phantom.text,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
35
40
|
},
|
|
36
41
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hackConnectButton } from '../hackConnectButton';
|
|
2
2
|
import { IInjectedProviderNames } from '@onekeyfe/cross-inpage-provider-types';
|
|
3
3
|
import { WALLET_CONNECT_INFO } from '../consts';
|
|
4
4
|
hackConnectButton({
|
|
5
|
-
urls: ['zapper.
|
|
5
|
+
urls: ['zapper.xyz', 'zapper.fi', 'www.zapper.xyz'],
|
|
6
6
|
providers: [IInjectedProviderNames.ethereum],
|
|
7
7
|
mutationObserverOptions: {
|
|
8
8
|
attributes: true,
|
|
@@ -12,32 +12,19 @@ hackConnectButton({
|
|
|
12
12
|
},
|
|
13
13
|
replaceMethod() {
|
|
14
14
|
const replaceFunc = ({ findName, icon, text, }) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const buttons = Array.from(shadowRoot.querySelectorAll('.wallets-container button'));
|
|
21
|
-
const btn = buttons.find((item) => item.innerHTML.includes(findName));
|
|
22
|
-
if (btn) {
|
|
23
|
-
const replaceImg = () => {
|
|
24
|
-
const imgContainer = btn.querySelector('div.icon');
|
|
25
|
-
if (imgContainer) {
|
|
26
|
-
createNewImageToContainer({
|
|
27
|
-
container: imgContainer,
|
|
28
|
-
icon,
|
|
29
|
-
removeSvg: true,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const span = btn.querySelector('span.name');
|
|
34
|
-
if (span && span.innerHTML === findName) {
|
|
35
|
-
span.innerHTML = text;
|
|
36
|
-
// shadowRoot update image, need some delay to replace image
|
|
37
|
-
setTimeout(replaceImg, 1000);
|
|
38
|
-
}
|
|
39
|
-
replaceImg();
|
|
15
|
+
const buttons = Array.from(document.querySelectorAll('.ReactModal__Content--after-open div > button > div:first-child'));
|
|
16
|
+
const btnContent = buttons.reverse().find((item) => item.innerText.includes(findName));
|
|
17
|
+
if (btnContent) {
|
|
18
|
+
while (btnContent.firstChild) {
|
|
19
|
+
btnContent.removeChild(btnContent.firstChild);
|
|
40
20
|
}
|
|
21
|
+
const image = document.createElement('img');
|
|
22
|
+
image.src = icon;
|
|
23
|
+
image.style.width = '32px';
|
|
24
|
+
image.style.height = '32px';
|
|
25
|
+
btnContent.appendChild(image);
|
|
26
|
+
const newText = document.createTextNode(text);
|
|
27
|
+
btnContent.appendChild(newText);
|
|
41
28
|
}
|
|
42
29
|
};
|
|
43
30
|
replaceFunc({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProviderEthereum, shimWeb3 } from '@onekeyfe/onekey-eth-provider';
|
|
2
2
|
import { ProviderPrivate } from '@onekeyfe/onekey-private-provider';
|
|
3
|
-
import { ProviderSolana } from '@onekeyfe/onekey-solana-provider';
|
|
3
|
+
import { ProviderSolana, registerSolanaWallet } from '@onekeyfe/onekey-solana-provider';
|
|
4
4
|
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';
|
|
@@ -101,7 +101,7 @@ function injectWeb3Provider() {
|
|
|
101
101
|
defineWindowProperty('getOfflineSigner', cosmos.getOfflineSigner.bind(cosmos));
|
|
102
102
|
defineWindowProperty('getOfflineSignerOnlyAmino', cosmos.getOfflineSignerOnlyAmino.bind(cosmos));
|
|
103
103
|
defineWindowProperty('getOfflineSignerAuto', cosmos.getOfflineSignerAuto.bind(cosmos));
|
|
104
|
-
// Lightning Network
|
|
104
|
+
// Lightning Network
|
|
105
105
|
defineWindowProperty('webln', webln);
|
|
106
106
|
defineWindowProperty('nostr', nostr);
|
|
107
107
|
// ** shim or inject real web3
|
|
@@ -113,6 +113,12 @@ function injectWeb3Provider() {
|
|
|
113
113
|
shimWeb3(ethereum);
|
|
114
114
|
// TODO use initializeInpageProvider.ts
|
|
115
115
|
window.dispatchEvent(new Event('ethereum#initialized'));
|
|
116
|
+
// Solana Standard Wallet
|
|
117
|
+
if (checkWalletSwitchEnable('onekey-solana')) {
|
|
118
|
+
registerSolanaWallet(solana, {
|
|
119
|
+
icon: WALLET_CONNECT_INFO.onekey.icon,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
116
122
|
// Sui Standard Wallet
|
|
117
123
|
if (checkWalletSwitchEnable('onekey-sui')) {
|
|
118
124
|
registerSuiWallet(sui, {
|
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.48",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,23 +28,23 @@
|
|
|
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-btc-provider": "1.1.
|
|
35
|
-
"@onekeyfe/onekey-cardano-provider": "1.1.
|
|
36
|
-
"@onekeyfe/onekey-conflux-provider": "1.1.
|
|
37
|
-
"@onekeyfe/onekey-cosmos-provider": "1.1.
|
|
38
|
-
"@onekeyfe/onekey-eth-provider": "1.1.
|
|
39
|
-
"@onekeyfe/onekey-nostr-provider": "1.1.
|
|
40
|
-
"@onekeyfe/onekey-polkadot-provider": "1.1.
|
|
41
|
-
"@onekeyfe/onekey-private-provider": "1.1.
|
|
42
|
-
"@onekeyfe/onekey-solana-provider": "1.1.
|
|
43
|
-
"@onekeyfe/onekey-starcoin-provider": "1.1.
|
|
44
|
-
"@onekeyfe/onekey-sui-provider": "1.1.
|
|
45
|
-
"@onekeyfe/onekey-tron-provider": "1.1.
|
|
46
|
-
"@onekeyfe/onekey-webln-provider": "1.1.
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.48",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.48",
|
|
33
|
+
"@onekeyfe/onekey-aptos-provider": "1.1.48",
|
|
34
|
+
"@onekeyfe/onekey-btc-provider": "1.1.48",
|
|
35
|
+
"@onekeyfe/onekey-cardano-provider": "1.1.48",
|
|
36
|
+
"@onekeyfe/onekey-conflux-provider": "1.1.48",
|
|
37
|
+
"@onekeyfe/onekey-cosmos-provider": "1.1.48",
|
|
38
|
+
"@onekeyfe/onekey-eth-provider": "1.1.48",
|
|
39
|
+
"@onekeyfe/onekey-nostr-provider": "1.1.48",
|
|
40
|
+
"@onekeyfe/onekey-polkadot-provider": "1.1.48",
|
|
41
|
+
"@onekeyfe/onekey-private-provider": "1.1.48",
|
|
42
|
+
"@onekeyfe/onekey-solana-provider": "1.1.48",
|
|
43
|
+
"@onekeyfe/onekey-starcoin-provider": "1.1.48",
|
|
44
|
+
"@onekeyfe/onekey-sui-provider": "1.1.48",
|
|
45
|
+
"@onekeyfe/onekey-tron-provider": "1.1.48",
|
|
46
|
+
"@onekeyfe/onekey-webln-provider": "1.1.48",
|
|
47
47
|
"web3": "^1.7.3"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "6a43a23aaf1a7ba4bd6e3efa04e52fe6dbd63101"
|
|
50
50
|
}
|