@onekeyfe/inpage-providers-hub 2.2.38 → 2.2.40
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/builtInPerpInjected/HyperliquidBuilderStore.d.ts +16 -0
- package/dist/builtInPerpInjected/HyperliquidBuilderStore.js +40 -8
- package/dist/builtInPerpInjected/hijackMethods.js +53 -12
- package/dist/builtInPerpInjected/hyperLiquidOneKeyWalletApi.js +42 -24
- package/dist/cjs/builtInPerpInjected/HyperliquidBuilderStore.js +40 -8
- package/dist/cjs/builtInPerpInjected/hijackMethods.js +53 -12
- package/dist/cjs/builtInPerpInjected/hyperLiquidOneKeyWalletApi.js +41 -23
- package/package.json +23 -23
|
@@ -1,12 +1,28 @@
|
|
|
1
|
+
export type IHyperliquidBuilderCustomSettings = {
|
|
2
|
+
hideNavBar?: boolean;
|
|
3
|
+
hideNavBarConnectButton?: boolean;
|
|
4
|
+
hideNotOneKeyWalletConnectButton?: boolean;
|
|
5
|
+
};
|
|
1
6
|
export declare class HyperliquidBuilderStore {
|
|
2
7
|
private static store;
|
|
3
8
|
private static _expectBuilderAddress;
|
|
4
9
|
private static _expectMaxBuilderFee;
|
|
10
|
+
private static _customSettings;
|
|
5
11
|
static get expectBuilderAddress(): string | undefined;
|
|
6
12
|
static set expectBuilderAddress(value: string | undefined);
|
|
7
13
|
static get expectMaxBuilderFee(): number | undefined;
|
|
8
14
|
static set expectMaxBuilderFee(value: number | undefined);
|
|
15
|
+
static get customSettings(): {
|
|
16
|
+
hideNavBar?: boolean;
|
|
17
|
+
hideNavBarConnectButton?: boolean;
|
|
18
|
+
hideNotOneKeyWalletConnectButton?: boolean;
|
|
19
|
+
} | undefined;
|
|
20
|
+
static set customSettings(value: IHyperliquidBuilderCustomSettings | undefined);
|
|
9
21
|
static updateBuilderInfo(address: string, fee: number): void;
|
|
22
|
+
static getAvailableBuilderInfo(): {
|
|
23
|
+
address: string;
|
|
24
|
+
fee: number;
|
|
25
|
+
} | undefined;
|
|
10
26
|
static flush(): void;
|
|
11
27
|
static storeUpdateByOneKeyWallet: boolean;
|
|
12
28
|
}
|
|
@@ -1,42 +1,74 @@
|
|
|
1
|
+
import { isNumber } from 'lodash-es';
|
|
1
2
|
import { LocalStorageStore } from '../utils/LocalStorageStore';
|
|
2
3
|
const prefix = 'hyperliquid.k_config_v3.'; //builder
|
|
3
|
-
const
|
|
4
|
-
|
|
4
|
+
const storageKeys = {
|
|
5
|
+
expectBuilderAddress: 'a',
|
|
6
|
+
expectMaxBuilderFee: 'f',
|
|
7
|
+
customSettings: 's',
|
|
8
|
+
};
|
|
5
9
|
export class HyperliquidBuilderStore {
|
|
6
10
|
static get expectBuilderAddress() {
|
|
7
11
|
if (this._expectBuilderAddress === undefined) {
|
|
8
|
-
this._expectBuilderAddress = this.store.get(
|
|
12
|
+
this._expectBuilderAddress = this.store.get(storageKeys.expectBuilderAddress);
|
|
9
13
|
}
|
|
10
14
|
return this._expectBuilderAddress;
|
|
11
15
|
}
|
|
12
16
|
static set expectBuilderAddress(value) {
|
|
13
17
|
this._expectBuilderAddress = value;
|
|
14
18
|
if (value === undefined) {
|
|
15
|
-
this.store.remove(
|
|
19
|
+
this.store.remove(storageKeys.expectBuilderAddress);
|
|
16
20
|
}
|
|
17
21
|
else {
|
|
18
|
-
this.store.set(
|
|
22
|
+
this.store.set(storageKeys.expectBuilderAddress, value);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
static get expectMaxBuilderFee() {
|
|
22
26
|
if (this._expectMaxBuilderFee === undefined) {
|
|
23
|
-
this._expectMaxBuilderFee = this.store.get(
|
|
27
|
+
this._expectMaxBuilderFee = this.store.get(storageKeys.expectMaxBuilderFee);
|
|
24
28
|
}
|
|
25
29
|
return this._expectMaxBuilderFee;
|
|
26
30
|
}
|
|
27
31
|
static set expectMaxBuilderFee(value) {
|
|
28
32
|
this._expectMaxBuilderFee = value;
|
|
29
33
|
if (value === undefined) {
|
|
30
|
-
this.store.remove(
|
|
34
|
+
this.store.remove(storageKeys.expectMaxBuilderFee);
|
|
31
35
|
}
|
|
32
36
|
else {
|
|
33
|
-
this.store.set(
|
|
37
|
+
this.store.set(storageKeys.expectMaxBuilderFee, value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static get customSettings() {
|
|
41
|
+
if (this._customSettings === undefined) {
|
|
42
|
+
this._customSettings = this.store.get(storageKeys.customSettings);
|
|
43
|
+
}
|
|
44
|
+
return this._customSettings;
|
|
45
|
+
}
|
|
46
|
+
static set customSettings(value) {
|
|
47
|
+
this._customSettings = value;
|
|
48
|
+
if (value === undefined) {
|
|
49
|
+
this.store.remove(storageKeys.customSettings);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.store.set(storageKeys.customSettings, value);
|
|
34
53
|
}
|
|
35
54
|
}
|
|
36
55
|
static updateBuilderInfo(address, fee) {
|
|
37
56
|
this.expectBuilderAddress = address;
|
|
38
57
|
this.expectMaxBuilderFee = fee;
|
|
39
58
|
}
|
|
59
|
+
static getAvailableBuilderInfo() {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
if ((HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.storeUpdateByOneKeyWallet) &&
|
|
62
|
+
(HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectBuilderAddress) &&
|
|
63
|
+
isNumber(HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectMaxBuilderFee) &&
|
|
64
|
+
(HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectMaxBuilderFee) >= 0) {
|
|
65
|
+
return {
|
|
66
|
+
address: (_b = (_a = HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectBuilderAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a),
|
|
67
|
+
fee: HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectMaxBuilderFee,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
40
72
|
static flush() {
|
|
41
73
|
this.store.flush();
|
|
42
74
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import providersHubUtils from '../utils/providersHubUtils';
|
|
6
6
|
import { HyperliquidBuilderStore } from './HyperliquidBuilderStore';
|
|
7
7
|
import hyperLiquidDappDetecter from './hyperLiquidDappDetecter';
|
|
8
|
-
import { isNumber } from 'lodash-es';
|
|
9
8
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
10
9
|
const originalConsoleLog = providersHubUtils.consoleLog;
|
|
11
10
|
function hijackReactUseContext() {
|
|
@@ -40,7 +39,6 @@ function hijackReactUseContext() {
|
|
|
40
39
|
if (isReactLike) {
|
|
41
40
|
// @ts-ignore
|
|
42
41
|
const wrappedUseContext = function (context) {
|
|
43
|
-
var _a, _b;
|
|
44
42
|
// @ts-ignore
|
|
45
43
|
const result = value.call(this, context);
|
|
46
44
|
// hyperliquid.order_builder_info: undefined
|
|
@@ -50,16 +48,15 @@ function hijackReactUseContext() {
|
|
|
50
48
|
if (result &&
|
|
51
49
|
(result === null || result === void 0 ? void 0 : result['hyperliquid.order_type']) &&
|
|
52
50
|
(result === null || result === void 0 ? void 0 : result['hyperliquid.limit_order_tif']) &&
|
|
53
|
-
(result === null || result === void 0 ? void 0 : result['hyperliquid.locale-setting'])
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
51
|
+
(result === null || result === void 0 ? void 0 : result['hyperliquid.locale-setting'])) {
|
|
52
|
+
const builderInfo = HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.getAvailableBuilderInfo();
|
|
53
|
+
if (builderInfo) {
|
|
54
|
+
// originalConsoleLog('useContext>>>>result', result);
|
|
55
|
+
result['hyperliquid.order_builder_info'] = {
|
|
56
|
+
builderAddress: builderInfo.address,
|
|
57
|
+
feeRate: builderInfo.fee / 1e5,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
63
60
|
}
|
|
64
61
|
return result;
|
|
65
62
|
};
|
|
@@ -78,10 +75,54 @@ function hijackReactUseContext() {
|
|
|
78
75
|
enumerable: false,
|
|
79
76
|
});
|
|
80
77
|
}
|
|
78
|
+
function isHyperLiquidObjectLike(obj) {
|
|
79
|
+
if (!obj || typeof obj !== 'object') {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const requiredFields = ['grouping', 'orders', 'type'];
|
|
83
|
+
const hasAllRequiredFields = requiredFields.every((field) => Object.prototype.hasOwnProperty.call(obj, field));
|
|
84
|
+
if (!hasAllRequiredFields) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return Boolean(typeof obj.grouping === 'string' &&
|
|
88
|
+
obj.grouping === 'na' &&
|
|
89
|
+
Array.isArray(obj.orders) &&
|
|
90
|
+
obj.orders.length > 0 &&
|
|
91
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'a') &&
|
|
92
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'b') &&
|
|
93
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'p') &&
|
|
94
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'r') &&
|
|
95
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 's') &&
|
|
96
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 't') &&
|
|
97
|
+
typeof obj.type === 'string' &&
|
|
98
|
+
obj.type === 'order');
|
|
99
|
+
}
|
|
100
|
+
function hijackObjectKeys() {
|
|
101
|
+
const originalObjectKeys = Object.keys;
|
|
102
|
+
Object.keys = function (obj) {
|
|
103
|
+
try {
|
|
104
|
+
if (obj && isHyperLiquidObjectLike(obj) === true) {
|
|
105
|
+
const builderInfo = HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.getAvailableBuilderInfo();
|
|
106
|
+
if (builderInfo) {
|
|
107
|
+
// "builder":{"b":"0x11111","f":35}
|
|
108
|
+
obj.builder = {
|
|
109
|
+
b: builderInfo.address,
|
|
110
|
+
f: builderInfo.fee,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
originalConsoleLog('hijackObjectKeys____error', e);
|
|
117
|
+
}
|
|
118
|
+
return originalObjectKeys(obj);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
81
121
|
export default {
|
|
82
122
|
run() {
|
|
83
123
|
if (hyperLiquidDappDetecter.isBuiltInHyperLiquidSite()) {
|
|
84
124
|
hijackReactUseContext();
|
|
125
|
+
hijackObjectKeys();
|
|
85
126
|
}
|
|
86
127
|
},
|
|
87
128
|
};
|
|
@@ -14,7 +14,7 @@ import { isNumber, isString } from 'lodash-es';
|
|
|
14
14
|
import { hackConnectButton } from '../connectButtonHack/hackConnectButton';
|
|
15
15
|
import providersHubUtils from '../utils/providersHubUtils';
|
|
16
16
|
import { HYPERLIQUID_HOSTNAME } from './consts';
|
|
17
|
-
import { HyperliquidBuilderStore } from './HyperliquidBuilderStore';
|
|
17
|
+
import { HyperliquidBuilderStore, } from './HyperliquidBuilderStore';
|
|
18
18
|
import hyperLiquidDappDetecter from './hyperLiquidDappDetecter';
|
|
19
19
|
function getEthereum() {
|
|
20
20
|
var _a;
|
|
@@ -55,6 +55,15 @@ function saveBuilderFeeConfigToStorage({ result, fromSource, }) {
|
|
|
55
55
|
console.error(error);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
if (result === null || result === void 0 ? void 0 : result.customSettings) {
|
|
59
|
+
providersHubUtils.consoleLog('BuiltInPerpInjected___saveBuilderFeeConfigToStorage>>>>result.customSettings22211', result.customSettings);
|
|
60
|
+
try {
|
|
61
|
+
HyperliquidBuilderStore.customSettings = result.customSettings;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
58
67
|
if ((result === null || result === void 0 ? void 0 : result.expectBuilderAddress) &&
|
|
59
68
|
isNumber(result === null || result === void 0 ? void 0 : result.expectMaxBuilderFee) &&
|
|
60
69
|
(result === null || result === void 0 ? void 0 : result.expectMaxBuilderFee) >= 0) {
|
|
@@ -104,34 +113,41 @@ function hackConnectionButton() {
|
|
|
104
113
|
urls: [HYPERLIQUID_HOSTNAME],
|
|
105
114
|
providers: [IInjectedProviderNames.ethereum],
|
|
106
115
|
replaceMethod() {
|
|
116
|
+
var _a;
|
|
117
|
+
const customSettings = HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.customSettings;
|
|
107
118
|
const hideNavigationBar = () => {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
ele.
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
120
|
+
let navBarRightContainer;
|
|
121
|
+
if ((_a = customSettings === null || customSettings === void 0 ? void 0 : customSettings.hideNavBar) !== null && _a !== void 0 ? _a : true) {
|
|
122
|
+
const siteIcon = (_e = (_d = (_c = (_b = window === null || window === void 0 ? void 0 : window.document) === null || _b === void 0 ? void 0 : _b.querySelectorAll) === null || _c === void 0 ? void 0 : _c.call(_b, 'a[href="/trade"]>svg')) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.parentElement;
|
|
123
|
+
const navBarItems = (_f = siteIcon === null || siteIcon === void 0 ? void 0 : siteIcon.nextElementSibling) === null || _f === void 0 ? void 0 : _f.childNodes;
|
|
124
|
+
navBarRightContainer = (_g = siteIcon === null || siteIcon === void 0 ? void 0 : siteIcon.nextElementSibling) === null || _g === void 0 ? void 0 : _g.nextElementSibling;
|
|
125
|
+
navBarItems === null || navBarItems === void 0 ? void 0 : navBarItems.forEach((item, index) => {
|
|
126
|
+
var _a;
|
|
127
|
+
try {
|
|
128
|
+
const ele = item;
|
|
129
|
+
if (index >= 1) {
|
|
130
|
+
const href = (_a = ele === null || ele === void 0 ? void 0 : ele.querySelector('a')) === null || _a === void 0 ? void 0 : _a.getAttribute('href');
|
|
131
|
+
if (ele && !(href === null || href === void 0 ? void 0 : href.includes('/trade'))) {
|
|
132
|
+
ele.style.display = 'none';
|
|
133
|
+
}
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
button.
|
|
136
|
+
catch (error) {
|
|
137
|
+
console.error(error);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if ((_h = customSettings === null || customSettings === void 0 ? void 0 : customSettings.hideNavBarConnectButton) !== null && _h !== void 0 ? _h : false) {
|
|
142
|
+
if (navBarRightContainer) {
|
|
143
|
+
const button = navBarRightContainer.querySelector('button');
|
|
144
|
+
if (button && ((_k = (_j = button === null || button === void 0 ? void 0 : button.textContent) === null || _j === void 0 ? void 0 : _j.toLowerCase()) === null || _k === void 0 ? void 0 : _k.trim()) === 'connect') {
|
|
145
|
+
button.style.display = 'none';
|
|
146
|
+
}
|
|
131
147
|
}
|
|
132
148
|
}
|
|
133
149
|
};
|
|
134
|
-
const
|
|
150
|
+
const hideNotOneKeyWalletConnectButton = () => {
|
|
135
151
|
var _a;
|
|
136
152
|
const buttons = Array.from((_a = document === null || document === void 0 ? void 0 : document.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(document, 'div.modal button'));
|
|
137
153
|
const oneKeyButton = buttons.find((button) => { var _a, _b, _c; return (_c = (_b = (_a = button === null || button === void 0 ? void 0 : button.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes) === null || _c === void 0 ? void 0 : _c.call(_b, 'onekey'); });
|
|
@@ -159,7 +175,9 @@ function hackConnectionButton() {
|
|
|
159
175
|
console.error(error);
|
|
160
176
|
}
|
|
161
177
|
try {
|
|
162
|
-
|
|
178
|
+
if ((_a = customSettings === null || customSettings === void 0 ? void 0 : customSettings.hideNotOneKeyWalletConnectButton) !== null && _a !== void 0 ? _a : true) {
|
|
179
|
+
hideNotOneKeyWalletConnectButton();
|
|
180
|
+
}
|
|
163
181
|
}
|
|
164
182
|
catch (error) {
|
|
165
183
|
console.error(error);
|
|
@@ -1,45 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HyperliquidBuilderStore = void 0;
|
|
4
|
+
const lodash_es_1 = require("lodash-es");
|
|
4
5
|
const LocalStorageStore_1 = require("../utils/LocalStorageStore");
|
|
5
6
|
const prefix = 'hyperliquid.k_config_v3.'; //builder
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const storageKeys = {
|
|
8
|
+
expectBuilderAddress: 'a',
|
|
9
|
+
expectMaxBuilderFee: 'f',
|
|
10
|
+
customSettings: 's',
|
|
11
|
+
};
|
|
8
12
|
class HyperliquidBuilderStore {
|
|
9
13
|
static get expectBuilderAddress() {
|
|
10
14
|
if (this._expectBuilderAddress === undefined) {
|
|
11
|
-
this._expectBuilderAddress = this.store.get(
|
|
15
|
+
this._expectBuilderAddress = this.store.get(storageKeys.expectBuilderAddress);
|
|
12
16
|
}
|
|
13
17
|
return this._expectBuilderAddress;
|
|
14
18
|
}
|
|
15
19
|
static set expectBuilderAddress(value) {
|
|
16
20
|
this._expectBuilderAddress = value;
|
|
17
21
|
if (value === undefined) {
|
|
18
|
-
this.store.remove(
|
|
22
|
+
this.store.remove(storageKeys.expectBuilderAddress);
|
|
19
23
|
}
|
|
20
24
|
else {
|
|
21
|
-
this.store.set(
|
|
25
|
+
this.store.set(storageKeys.expectBuilderAddress, value);
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
static get expectMaxBuilderFee() {
|
|
25
29
|
if (this._expectMaxBuilderFee === undefined) {
|
|
26
|
-
this._expectMaxBuilderFee = this.store.get(
|
|
30
|
+
this._expectMaxBuilderFee = this.store.get(storageKeys.expectMaxBuilderFee);
|
|
27
31
|
}
|
|
28
32
|
return this._expectMaxBuilderFee;
|
|
29
33
|
}
|
|
30
34
|
static set expectMaxBuilderFee(value) {
|
|
31
35
|
this._expectMaxBuilderFee = value;
|
|
32
36
|
if (value === undefined) {
|
|
33
|
-
this.store.remove(
|
|
37
|
+
this.store.remove(storageKeys.expectMaxBuilderFee);
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
36
|
-
this.store.set(
|
|
40
|
+
this.store.set(storageKeys.expectMaxBuilderFee, value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
static get customSettings() {
|
|
44
|
+
if (this._customSettings === undefined) {
|
|
45
|
+
this._customSettings = this.store.get(storageKeys.customSettings);
|
|
46
|
+
}
|
|
47
|
+
return this._customSettings;
|
|
48
|
+
}
|
|
49
|
+
static set customSettings(value) {
|
|
50
|
+
this._customSettings = value;
|
|
51
|
+
if (value === undefined) {
|
|
52
|
+
this.store.remove(storageKeys.customSettings);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.store.set(storageKeys.customSettings, value);
|
|
37
56
|
}
|
|
38
57
|
}
|
|
39
58
|
static updateBuilderInfo(address, fee) {
|
|
40
59
|
this.expectBuilderAddress = address;
|
|
41
60
|
this.expectMaxBuilderFee = fee;
|
|
42
61
|
}
|
|
62
|
+
static getAvailableBuilderInfo() {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
if ((HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.storeUpdateByOneKeyWallet) &&
|
|
65
|
+
(HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectBuilderAddress) &&
|
|
66
|
+
(0, lodash_es_1.isNumber)(HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectMaxBuilderFee) &&
|
|
67
|
+
(HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectMaxBuilderFee) >= 0) {
|
|
68
|
+
return {
|
|
69
|
+
address: (_b = (_a = HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectBuilderAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a),
|
|
70
|
+
fee: HyperliquidBuilderStore === null || HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore.expectMaxBuilderFee,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
43
75
|
static flush() {
|
|
44
76
|
this.store.flush();
|
|
45
77
|
}
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
const providersHubUtils_1 = __importDefault(require("../utils/providersHubUtils"));
|
|
11
11
|
const HyperliquidBuilderStore_1 = require("./HyperliquidBuilderStore");
|
|
12
12
|
const hyperLiquidDappDetecter_1 = __importDefault(require("./hyperLiquidDappDetecter"));
|
|
13
|
-
const lodash_es_1 = require("lodash-es");
|
|
14
13
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
15
14
|
const originalConsoleLog = providersHubUtils_1.default.consoleLog;
|
|
16
15
|
function hijackReactUseContext() {
|
|
@@ -45,7 +44,6 @@ function hijackReactUseContext() {
|
|
|
45
44
|
if (isReactLike) {
|
|
46
45
|
// @ts-ignore
|
|
47
46
|
const wrappedUseContext = function (context) {
|
|
48
|
-
var _a, _b;
|
|
49
47
|
// @ts-ignore
|
|
50
48
|
const result = value.call(this, context);
|
|
51
49
|
// hyperliquid.order_builder_info: undefined
|
|
@@ -55,16 +53,15 @@ function hijackReactUseContext() {
|
|
|
55
53
|
if (result &&
|
|
56
54
|
(result === null || result === void 0 ? void 0 : result['hyperliquid.order_type']) &&
|
|
57
55
|
(result === null || result === void 0 ? void 0 : result['hyperliquid.limit_order_tif']) &&
|
|
58
|
-
(result === null || result === void 0 ? void 0 : result['hyperliquid.locale-setting'])
|
|
59
|
-
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
56
|
+
(result === null || result === void 0 ? void 0 : result['hyperliquid.locale-setting'])) {
|
|
57
|
+
const builderInfo = HyperliquidBuilderStore_1.HyperliquidBuilderStore === null || HyperliquidBuilderStore_1.HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore_1.HyperliquidBuilderStore.getAvailableBuilderInfo();
|
|
58
|
+
if (builderInfo) {
|
|
59
|
+
// originalConsoleLog('useContext>>>>result', result);
|
|
60
|
+
result['hyperliquid.order_builder_info'] = {
|
|
61
|
+
builderAddress: builderInfo.address,
|
|
62
|
+
feeRate: builderInfo.fee / 1e5,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
68
65
|
}
|
|
69
66
|
return result;
|
|
70
67
|
};
|
|
@@ -83,10 +80,54 @@ function hijackReactUseContext() {
|
|
|
83
80
|
enumerable: false,
|
|
84
81
|
});
|
|
85
82
|
}
|
|
83
|
+
function isHyperLiquidObjectLike(obj) {
|
|
84
|
+
if (!obj || typeof obj !== 'object') {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const requiredFields = ['grouping', 'orders', 'type'];
|
|
88
|
+
const hasAllRequiredFields = requiredFields.every((field) => Object.prototype.hasOwnProperty.call(obj, field));
|
|
89
|
+
if (!hasAllRequiredFields) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return Boolean(typeof obj.grouping === 'string' &&
|
|
93
|
+
obj.grouping === 'na' &&
|
|
94
|
+
Array.isArray(obj.orders) &&
|
|
95
|
+
obj.orders.length > 0 &&
|
|
96
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'a') &&
|
|
97
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'b') &&
|
|
98
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'p') &&
|
|
99
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 'r') &&
|
|
100
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 's') &&
|
|
101
|
+
Object.prototype.hasOwnProperty.call(obj.orders[0], 't') &&
|
|
102
|
+
typeof obj.type === 'string' &&
|
|
103
|
+
obj.type === 'order');
|
|
104
|
+
}
|
|
105
|
+
function hijackObjectKeys() {
|
|
106
|
+
const originalObjectKeys = Object.keys;
|
|
107
|
+
Object.keys = function (obj) {
|
|
108
|
+
try {
|
|
109
|
+
if (obj && isHyperLiquidObjectLike(obj) === true) {
|
|
110
|
+
const builderInfo = HyperliquidBuilderStore_1.HyperliquidBuilderStore === null || HyperliquidBuilderStore_1.HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore_1.HyperliquidBuilderStore.getAvailableBuilderInfo();
|
|
111
|
+
if (builderInfo) {
|
|
112
|
+
// "builder":{"b":"0x11111","f":35}
|
|
113
|
+
obj.builder = {
|
|
114
|
+
b: builderInfo.address,
|
|
115
|
+
f: builderInfo.fee,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
originalConsoleLog('hijackObjectKeys____error', e);
|
|
122
|
+
}
|
|
123
|
+
return originalObjectKeys(obj);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
86
126
|
exports.default = {
|
|
87
127
|
run() {
|
|
88
128
|
if (hyperLiquidDappDetecter_1.default.isBuiltInHyperLiquidSite()) {
|
|
89
129
|
hijackReactUseContext();
|
|
130
|
+
hijackObjectKeys();
|
|
90
131
|
}
|
|
91
132
|
},
|
|
92
133
|
};
|
|
@@ -60,6 +60,15 @@ function saveBuilderFeeConfigToStorage({ result, fromSource, }) {
|
|
|
60
60
|
console.error(error);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
if (result === null || result === void 0 ? void 0 : result.customSettings) {
|
|
64
|
+
providersHubUtils_1.default.consoleLog('BuiltInPerpInjected___saveBuilderFeeConfigToStorage>>>>result.customSettings22211', result.customSettings);
|
|
65
|
+
try {
|
|
66
|
+
HyperliquidBuilderStore_1.HyperliquidBuilderStore.customSettings = result.customSettings;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
63
72
|
if ((result === null || result === void 0 ? void 0 : result.expectBuilderAddress) &&
|
|
64
73
|
(0, lodash_es_1.isNumber)(result === null || result === void 0 ? void 0 : result.expectMaxBuilderFee) &&
|
|
65
74
|
(result === null || result === void 0 ? void 0 : result.expectMaxBuilderFee) >= 0) {
|
|
@@ -109,34 +118,41 @@ function hackConnectionButton() {
|
|
|
109
118
|
urls: [consts_1.HYPERLIQUID_HOSTNAME],
|
|
110
119
|
providers: [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum],
|
|
111
120
|
replaceMethod() {
|
|
121
|
+
var _a;
|
|
122
|
+
const customSettings = HyperliquidBuilderStore_1.HyperliquidBuilderStore === null || HyperliquidBuilderStore_1.HyperliquidBuilderStore === void 0 ? void 0 : HyperliquidBuilderStore_1.HyperliquidBuilderStore.customSettings;
|
|
112
123
|
const hideNavigationBar = () => {
|
|
113
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
ele.
|
|
124
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
125
|
+
let navBarRightContainer;
|
|
126
|
+
if ((_a = customSettings === null || customSettings === void 0 ? void 0 : customSettings.hideNavBar) !== null && _a !== void 0 ? _a : true) {
|
|
127
|
+
const siteIcon = (_e = (_d = (_c = (_b = window === null || window === void 0 ? void 0 : window.document) === null || _b === void 0 ? void 0 : _b.querySelectorAll) === null || _c === void 0 ? void 0 : _c.call(_b, 'a[href="/trade"]>svg')) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.parentElement;
|
|
128
|
+
const navBarItems = (_f = siteIcon === null || siteIcon === void 0 ? void 0 : siteIcon.nextElementSibling) === null || _f === void 0 ? void 0 : _f.childNodes;
|
|
129
|
+
navBarRightContainer = (_g = siteIcon === null || siteIcon === void 0 ? void 0 : siteIcon.nextElementSibling) === null || _g === void 0 ? void 0 : _g.nextElementSibling;
|
|
130
|
+
navBarItems === null || navBarItems === void 0 ? void 0 : navBarItems.forEach((item, index) => {
|
|
131
|
+
var _a;
|
|
132
|
+
try {
|
|
133
|
+
const ele = item;
|
|
134
|
+
if (index >= 1) {
|
|
135
|
+
const href = (_a = ele === null || ele === void 0 ? void 0 : ele.querySelector('a')) === null || _a === void 0 ? void 0 : _a.getAttribute('href');
|
|
136
|
+
if (ele && !(href === null || href === void 0 ? void 0 : href.includes('/trade'))) {
|
|
137
|
+
ele.style.display = 'none';
|
|
138
|
+
}
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
button.
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.error(error);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if ((_h = customSettings === null || customSettings === void 0 ? void 0 : customSettings.hideNavBarConnectButton) !== null && _h !== void 0 ? _h : false) {
|
|
147
|
+
if (navBarRightContainer) {
|
|
148
|
+
const button = navBarRightContainer.querySelector('button');
|
|
149
|
+
if (button && ((_k = (_j = button === null || button === void 0 ? void 0 : button.textContent) === null || _j === void 0 ? void 0 : _j.toLowerCase()) === null || _k === void 0 ? void 0 : _k.trim()) === 'connect') {
|
|
150
|
+
button.style.display = 'none';
|
|
151
|
+
}
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
};
|
|
139
|
-
const
|
|
155
|
+
const hideNotOneKeyWalletConnectButton = () => {
|
|
140
156
|
var _a;
|
|
141
157
|
const buttons = Array.from((_a = document === null || document === void 0 ? void 0 : document.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(document, 'div.modal button'));
|
|
142
158
|
const oneKeyButton = buttons.find((button) => { var _a, _b, _c; return (_c = (_b = (_a = button === null || button === void 0 ? void 0 : button.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes) === null || _c === void 0 ? void 0 : _c.call(_b, 'onekey'); });
|
|
@@ -164,7 +180,9 @@ function hackConnectionButton() {
|
|
|
164
180
|
console.error(error);
|
|
165
181
|
}
|
|
166
182
|
try {
|
|
167
|
-
|
|
183
|
+
if ((_a = customSettings === null || customSettings === void 0 ? void 0 : customSettings.hideNotOneKeyWalletConnectButton) !== null && _a !== void 0 ? _a : true) {
|
|
184
|
+
hideNotOneKeyWalletConnectButton();
|
|
185
|
+
}
|
|
168
186
|
}
|
|
169
187
|
catch (error) {
|
|
170
188
|
console.error(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/inpage-providers-hub",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.40",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -27,27 +27,27 @@
|
|
|
27
27
|
"start": "tsc --watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@onekeyfe/cross-inpage-provider-core": "2.2.
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-types": "2.2.
|
|
32
|
-
"@onekeyfe/onekey-algo-provider": "2.2.
|
|
33
|
-
"@onekeyfe/onekey-alph-provider": "2.2.
|
|
34
|
-
"@onekeyfe/onekey-aptos-provider": "2.2.
|
|
35
|
-
"@onekeyfe/onekey-bfc-provider": "2.2.
|
|
36
|
-
"@onekeyfe/onekey-btc-provider": "2.2.
|
|
37
|
-
"@onekeyfe/onekey-cardano-provider": "2.2.
|
|
38
|
-
"@onekeyfe/onekey-conflux-provider": "2.2.
|
|
39
|
-
"@onekeyfe/onekey-cosmos-provider": "2.2.
|
|
40
|
-
"@onekeyfe/onekey-eth-provider": "2.2.
|
|
41
|
-
"@onekeyfe/onekey-neo-provider": "2.2.
|
|
42
|
-
"@onekeyfe/onekey-nostr-provider": "2.2.
|
|
43
|
-
"@onekeyfe/onekey-polkadot-provider": "2.2.
|
|
44
|
-
"@onekeyfe/onekey-private-provider": "2.2.
|
|
45
|
-
"@onekeyfe/onekey-scdo-provider": "2.2.
|
|
46
|
-
"@onekeyfe/onekey-solana-provider": "2.2.
|
|
47
|
-
"@onekeyfe/onekey-sui-provider": "2.2.
|
|
48
|
-
"@onekeyfe/onekey-ton-provider": "2.2.
|
|
49
|
-
"@onekeyfe/onekey-tron-provider": "2.2.
|
|
50
|
-
"@onekeyfe/onekey-webln-provider": "2.2.
|
|
30
|
+
"@onekeyfe/cross-inpage-provider-core": "2.2.40",
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-types": "2.2.40",
|
|
32
|
+
"@onekeyfe/onekey-algo-provider": "2.2.40",
|
|
33
|
+
"@onekeyfe/onekey-alph-provider": "2.2.40",
|
|
34
|
+
"@onekeyfe/onekey-aptos-provider": "2.2.40",
|
|
35
|
+
"@onekeyfe/onekey-bfc-provider": "2.2.40",
|
|
36
|
+
"@onekeyfe/onekey-btc-provider": "2.2.40",
|
|
37
|
+
"@onekeyfe/onekey-cardano-provider": "2.2.40",
|
|
38
|
+
"@onekeyfe/onekey-conflux-provider": "2.2.40",
|
|
39
|
+
"@onekeyfe/onekey-cosmos-provider": "2.2.40",
|
|
40
|
+
"@onekeyfe/onekey-eth-provider": "2.2.40",
|
|
41
|
+
"@onekeyfe/onekey-neo-provider": "2.2.40",
|
|
42
|
+
"@onekeyfe/onekey-nostr-provider": "2.2.40",
|
|
43
|
+
"@onekeyfe/onekey-polkadot-provider": "2.2.40",
|
|
44
|
+
"@onekeyfe/onekey-private-provider": "2.2.40",
|
|
45
|
+
"@onekeyfe/onekey-scdo-provider": "2.2.40",
|
|
46
|
+
"@onekeyfe/onekey-solana-provider": "2.2.40",
|
|
47
|
+
"@onekeyfe/onekey-sui-provider": "2.2.40",
|
|
48
|
+
"@onekeyfe/onekey-ton-provider": "2.2.40",
|
|
49
|
+
"@onekeyfe/onekey-tron-provider": "2.2.40",
|
|
50
|
+
"@onekeyfe/onekey-webln-provider": "2.2.40",
|
|
51
51
|
"lodash-es": "^4.17.21",
|
|
52
52
|
"preact": "^10.25.1"
|
|
53
53
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"@types/lodash-es": "^4.17.12",
|
|
56
56
|
"@types/node": "^20.12.7"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "dfd04061b595dc8280b7a3d248dd7833cc3440fa"
|
|
59
59
|
}
|