@onekeyfe/inpage-providers-hub 2.2.39 → 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 +4 -0
- package/dist/builtInPerpInjected/HyperliquidBuilderStore.js +14 -0
- package/dist/builtInPerpInjected/hijackMethods.js +53 -12
- package/dist/cjs/builtInPerpInjected/HyperliquidBuilderStore.js +14 -0
- package/dist/cjs/builtInPerpInjected/hijackMethods.js +53 -12
- package/package.json +23 -23
|
@@ -19,6 +19,10 @@ export declare class HyperliquidBuilderStore {
|
|
|
19
19
|
} | undefined;
|
|
20
20
|
static set customSettings(value: IHyperliquidBuilderCustomSettings | undefined);
|
|
21
21
|
static updateBuilderInfo(address: string, fee: number): void;
|
|
22
|
+
static getAvailableBuilderInfo(): {
|
|
23
|
+
address: string;
|
|
24
|
+
fee: number;
|
|
25
|
+
} | undefined;
|
|
22
26
|
static flush(): void;
|
|
23
27
|
static storeUpdateByOneKeyWallet: boolean;
|
|
24
28
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNumber } from 'lodash-es';
|
|
1
2
|
import { LocalStorageStore } from '../utils/LocalStorageStore';
|
|
2
3
|
const prefix = 'hyperliquid.k_config_v3.'; //builder
|
|
3
4
|
const storageKeys = {
|
|
@@ -55,6 +56,19 @@ export class HyperliquidBuilderStore {
|
|
|
55
56
|
this.expectBuilderAddress = address;
|
|
56
57
|
this.expectMaxBuilderFee = fee;
|
|
57
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
|
+
}
|
|
58
72
|
static flush() {
|
|
59
73
|
this.store.flush();
|
|
60
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
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
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
7
|
const storageKeys = {
|
|
@@ -58,6 +59,19 @@ class HyperliquidBuilderStore {
|
|
|
58
59
|
this.expectBuilderAddress = address;
|
|
59
60
|
this.expectMaxBuilderFee = fee;
|
|
60
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
|
+
}
|
|
61
75
|
static flush() {
|
|
62
76
|
this.store.flush();
|
|
63
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
|
};
|
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
|
}
|