@subwallet/extension-base 1.3.45-1 → 1.3.47-0
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/background/KoniTypes.d.ts +5 -0
- package/background/KoniTypes.js +5 -0
- package/background/types.d.ts +2 -0
- package/cjs/background/KoniTypes.js +7 -1
- package/cjs/core/logic-validation/request.js +55 -28
- package/cjs/core/utils.js +22 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +3 -2
- package/cjs/koni/background/handlers/Extension.js +84 -61
- package/cjs/koni/background/handlers/State.js +3 -0
- package/cjs/koni/background/handlers/Tabs.js +11 -3
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/evm/index.js +64 -105
- package/cjs/page/index.js +5 -3
- package/cjs/page/substrate/Accounts.js +2 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +3 -76
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +8 -14
- package/cjs/services/buy-service/index.js +2 -0
- package/cjs/services/chain-service/index.js +3 -0
- package/cjs/services/chain-service/utils/index.js +34 -1
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +2 -1
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +32 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +18 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +40 -29
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +5 -0
- package/cjs/services/earning-service/handlers/native-staking/mythos.js +28 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +17 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +25 -2
- package/cjs/services/earning-service/handlers/native-staking/tao.js +5 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +6 -3
- package/cjs/services/earning-service/service.js +65 -22
- package/cjs/services/history-service/index.js +12 -7
- package/cjs/services/keyring-service/context/handlers/Json.js +2 -1
- package/cjs/services/keyring-service/context/handlers/Ledger.js +7 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +30 -6
- package/cjs/services/subscan-service/index.js +35 -104
- package/cjs/services/transaction-service/utils.js +10 -1
- package/cjs/strategy/api-request-strategy/index.js +1 -0
- package/cjs/strategy/api-request-strategy/utils/index.js +2 -2
- package/cjs/strategy/api-request-strategy-v2/index.js +138 -0
- package/cjs/strategy/api-request-strategy-v2/types.js +1 -0
- package/cjs/types/account/info/keyring.js +1 -0
- package/cjs/utils/account/analyze.js +5 -2
- package/cjs/utils/account/common.js +93 -2
- package/cjs/utils/account/transform.js +10 -0
- package/cjs/utils/asset.js +9 -2
- package/cjs/utils/gear/combine.js +4 -3
- package/cjs/utils/gear/vft.js +104 -135
- package/cjs/utils/staticData/index.js +7 -2
- package/core/logic-validation/request.js +31 -4
- package/core/types.d.ts +3 -2
- package/core/utils.js +24 -2
- package/koni/api/nft/ordinal_nft/index.js +3 -2
- package/koni/background/handlers/Extension.js +31 -8
- package/koni/background/handlers/State.js +4 -1
- package/koni/background/handlers/Tabs.js +11 -4
- package/package.json +21 -9
- package/packageInfo.js +1 -1
- package/page/evm/index.d.ts +9 -18
- package/page/evm/index.js +62 -101
- package/page/index.js +5 -3
- package/page/substrate/Accounts.js +2 -1
- package/services/balance-service/helpers/subscribe/index.d.ts +1 -11
- package/services/balance-service/helpers/subscribe/index.js +3 -74
- package/services/balance-service/helpers/subscribe/substrate/index.js +8 -14
- package/services/buy-service/index.js +2 -0
- package/services/chain-service/index.d.ts +1 -0
- package/services/chain-service/index.js +3 -0
- package/services/chain-service/utils/index.d.ts +10 -2
- package/services/chain-service/utils/index.js +29 -2
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +2 -1
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +32 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/astar.js +18 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +2 -0
- package/services/earning-service/handlers/native-staking/base.js +40 -29
- package/services/earning-service/handlers/native-staking/dtao.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/dtao.js +5 -0
- package/services/earning-service/handlers/native-staking/mythos.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/mythos.js +28 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +17 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +25 -2
- package/services/earning-service/handlers/native-staking/tao.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/tao.js +5 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -0
- package/services/earning-service/handlers/nomination-pool/index.js +6 -3
- package/services/earning-service/service.d.ts +3 -0
- package/services/earning-service/service.js +68 -25
- package/services/history-service/index.js +12 -7
- package/services/keyring-service/context/handlers/Json.js +2 -1
- package/services/keyring-service/context/handlers/Ledger.js +7 -2
- package/services/request-service/handler/AuthRequestHandler.d.ts +1 -0
- package/services/request-service/handler/AuthRequestHandler.js +30 -6
- package/services/request-service/types.d.ts +1 -0
- package/services/subscan-service/index.d.ts +13 -27
- package/services/subscan-service/index.js +26 -95
- package/services/transaction-service/utils.js +11 -2
- package/strategy/api-request-strategy/context/base.d.ts +2 -6
- package/strategy/api-request-strategy/index.js +1 -0
- package/strategy/api-request-strategy/types.d.ts +4 -2
- package/strategy/api-request-strategy/utils/index.js +2 -2
- package/strategy/api-request-strategy-v2/index.d.ts +22 -0
- package/strategy/api-request-strategy-v2/index.js +128 -0
- package/strategy/api-request-strategy-v2/types.d.ts +11 -0
- package/strategy/api-request-strategy-v2/types.js +1 -0
- package/types/account/action/subscribe.d.ts +3 -0
- package/types/account/info/keyring.d.ts +3 -0
- package/types/account/info/keyring.js +1 -0
- package/types/balance/transfer.d.ts +1 -0
- package/types/buy.d.ts +1 -1
- package/utils/account/analyze.js +5 -2
- package/utils/account/common.d.ts +13 -1
- package/utils/account/common.js +91 -2
- package/utils/account/transform.js +10 -0
- package/utils/asset.d.ts +2 -1
- package/utils/asset.js +7 -1
- package/utils/gear/combine.d.ts +2 -1
- package/utils/gear/combine.js +4 -4
- package/utils/gear/vft.d.ts +20 -9
- package/utils/gear/vft.js +104 -135
- package/utils/staticData/assetHubStaking.json +1 -0
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
|
@@ -23,6 +23,9 @@ class BaseNativeStakingPoolHandler extends _base.default {
|
|
|
23
23
|
withdraw: true,
|
|
24
24
|
claimReward: false
|
|
25
25
|
};
|
|
26
|
+
static generateSlug(symbol, chain) {
|
|
27
|
+
return `${symbol}___native_staking___${chain}`;
|
|
28
|
+
}
|
|
26
29
|
constructor(state, chain) {
|
|
27
30
|
super(state, chain);
|
|
28
31
|
const _chainAsset = this.nativeToken;
|
|
@@ -47,40 +50,48 @@ class BaseNativeStakingPoolHandler extends _base.default {
|
|
|
47
50
|
async getPoolRewardHistory(useAddresses, callBack) {
|
|
48
51
|
let cancel = false;
|
|
49
52
|
const haveSubscanService = this.state.subscanService.checkSupportedSubscanChain(this.chain);
|
|
53
|
+
const requestGroupId = this.state.subscanService.getGroupId();
|
|
50
54
|
if (haveSubscanService) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (items) {
|
|
59
|
-
for (const item of items) {
|
|
60
|
-
const now = new Date();
|
|
61
|
-
const isMillisecond = now.getTime().toString().length === item.block_timestamp.toString().length;
|
|
62
|
-
const timeStamp = isMillisecond ? item.block_timestamp : item.block_timestamp * 1000;
|
|
63
|
-
const data = {
|
|
64
|
-
slug: this.slug,
|
|
65
|
-
type: this.type,
|
|
66
|
-
chain: this.chain,
|
|
67
|
-
address: address,
|
|
68
|
-
group: this.group,
|
|
69
|
-
blockTimestamp: timeStamp,
|
|
70
|
-
amount: item.amount,
|
|
71
|
-
eventIndex: item.event_index
|
|
72
|
-
};
|
|
73
|
-
callBack(data);
|
|
74
|
-
}
|
|
55
|
+
this.checkAccountHaveStake(useAddresses).then(activeAddresses => {
|
|
56
|
+
for (const address of useAddresses) {
|
|
57
|
+
if (cancel) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (!activeAddresses.includes(address)) {
|
|
61
|
+
continue;
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
this.state.subscanService.getRewardHistoryList(requestGroupId, this.chain, address).then(rs => {
|
|
64
|
+
const items = rs === null || rs === void 0 ? void 0 : rs.list;
|
|
65
|
+
if (cancel) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (items) {
|
|
69
|
+
for (const item of items) {
|
|
70
|
+
const now = new Date();
|
|
71
|
+
const isMillisecond = now.getTime().toString().length === item.block_timestamp.toString().length;
|
|
72
|
+
const timeStamp = isMillisecond ? item.block_timestamp : item.block_timestamp * 1000;
|
|
73
|
+
const data = {
|
|
74
|
+
slug: this.slug,
|
|
75
|
+
type: this.type,
|
|
76
|
+
chain: this.chain,
|
|
77
|
+
address: address,
|
|
78
|
+
group: this.group,
|
|
79
|
+
blockTimestamp: timeStamp,
|
|
80
|
+
amount: item.amount,
|
|
81
|
+
eventIndex: item.event_index
|
|
82
|
+
};
|
|
83
|
+
callBack(data);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}).catch(console.error);
|
|
78
87
|
}
|
|
79
|
-
}
|
|
88
|
+
}).catch(console.error);
|
|
80
89
|
}
|
|
81
|
-
return () => {
|
|
90
|
+
return Promise.resolve(() => {
|
|
91
|
+
console.log('Cancel get pool reward history', requestGroupId);
|
|
82
92
|
cancel = false;
|
|
83
|
-
|
|
93
|
+
this.state.subscanService.cancelGroupRequest(requestGroupId);
|
|
94
|
+
});
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
/* Get pool reward */
|
|
@@ -372,6 +372,11 @@ class SubnetTaoStakingPoolHandler extends _basePara.default {
|
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
// Because not have subscan api
|
|
376
|
+
async checkAccountHaveStake(useAddresses) {
|
|
377
|
+
return Promise.resolve([]);
|
|
378
|
+
}
|
|
379
|
+
|
|
375
380
|
/* Subscribe pool position */
|
|
376
381
|
|
|
377
382
|
/* Get pool targets */
|
|
@@ -126,6 +126,34 @@ class MythosNativeStakingPoolHandler extends _basePara.default {
|
|
|
126
126
|
|
|
127
127
|
/* Subscribe pool position */
|
|
128
128
|
|
|
129
|
+
async checkAccountHaveStake(useAddresses) {
|
|
130
|
+
var _substrateApi$api$que, _substrateApi$api$que2, _substrateApi$api$que3;
|
|
131
|
+
const result = [];
|
|
132
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
133
|
+
const ledgers = await ((_substrateApi$api$que = substrateApi.api.query.collatorStaking) === null || _substrateApi$api$que === void 0 ? void 0 : (_substrateApi$api$que2 = _substrateApi$api$que.userStake) === null || _substrateApi$api$que2 === void 0 ? void 0 : (_substrateApi$api$que3 = _substrateApi$api$que2.multi) === null || _substrateApi$api$que3 === void 0 ? void 0 : _substrateApi$api$que3.call(_substrateApi$api$que2, useAddresses));
|
|
134
|
+
const _unstakings = await Promise.all(useAddresses.map(stakerAddress => {
|
|
135
|
+
var _substrateApi$api$que4, _substrateApi$api$que5;
|
|
136
|
+
return (_substrateApi$api$que4 = substrateApi.api.query.collatorStaking) === null || _substrateApi$api$que4 === void 0 ? void 0 : (_substrateApi$api$que5 = _substrateApi$api$que4.releaseQueues) === null || _substrateApi$api$que5 === void 0 ? void 0 : _substrateApi$api$que5.call(_substrateApi$api$que4, stakerAddress);
|
|
137
|
+
}));
|
|
138
|
+
if (!ledgers || !_unstakings) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
for (let i = 0; i < useAddresses.length; i++) {
|
|
142
|
+
const owner = useAddresses[i];
|
|
143
|
+
const _userStake = ledgers[i];
|
|
144
|
+
const userStake = _userStake.toPrimitive();
|
|
145
|
+
const _unstaking = _unstakings[i];
|
|
146
|
+
const unstakings = _unstaking.toPrimitive();
|
|
147
|
+
|
|
148
|
+
// TODO: Need to improve, check if can only load stake info
|
|
149
|
+
if (userStake && userStake.stake !== '0') {
|
|
150
|
+
result.push(owner);
|
|
151
|
+
} else if (unstakings && unstakings.some(unstake => unstake.amount !== '0')) {
|
|
152
|
+
result.push(owner);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
129
157
|
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
130
158
|
let cancel = false;
|
|
131
159
|
const substrateApi = await this.substrateApi.isReady;
|
|
@@ -275,6 +275,23 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
275
275
|
unsub();
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
|
+
async checkAccountHaveStake(useAddresses) {
|
|
279
|
+
var _substrateApi$api$que, _substrateApi$api$que2, _substrateApi$api$que3;
|
|
280
|
+
const result = [];
|
|
281
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
282
|
+
const ledgers = await ((_substrateApi$api$que = substrateApi.api.query.parachainStaking) === null || _substrateApi$api$que === void 0 ? void 0 : (_substrateApi$api$que2 = _substrateApi$api$que.delegatorState) === null || _substrateApi$api$que2 === void 0 ? void 0 : (_substrateApi$api$que3 = _substrateApi$api$que2.multi) === null || _substrateApi$api$que3 === void 0 ? void 0 : _substrateApi$api$que3.call(_substrateApi$api$que2, useAddresses));
|
|
283
|
+
if (!ledgers) {
|
|
284
|
+
return [];
|
|
285
|
+
}
|
|
286
|
+
for (let i = 0; i < useAddresses.length; i++) {
|
|
287
|
+
const owner = useAddresses[i];
|
|
288
|
+
const delegatorState = ledgers[i].toPrimitive();
|
|
289
|
+
if (delegatorState && delegatorState.total > 0) {
|
|
290
|
+
result.push(owner);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
278
295
|
|
|
279
296
|
/* Subscribe pool position */
|
|
280
297
|
|
|
@@ -290,6 +290,22 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
290
290
|
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
+
async checkAccountHaveStake(useAddresses) {
|
|
294
|
+
var _substrateApi$api$que22, _substrateApi$api$que23, _substrateApi$api$que24;
|
|
295
|
+
const result = [];
|
|
296
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
297
|
+
const ledgers = await ((_substrateApi$api$que22 = substrateApi.api.query.staking) === null || _substrateApi$api$que22 === void 0 ? void 0 : (_substrateApi$api$que23 = _substrateApi$api$que22.ledger) === null || _substrateApi$api$que23 === void 0 ? void 0 : (_substrateApi$api$que24 = _substrateApi$api$que23.multi) === null || _substrateApi$api$que24 === void 0 ? void 0 : _substrateApi$api$que24.call(_substrateApi$api$que23, useAddresses));
|
|
298
|
+
if (ledgers) {
|
|
299
|
+
for (let i = 0; i < useAddresses.length; i++) {
|
|
300
|
+
const address = useAddresses[i];
|
|
301
|
+
const _ledger = ledgers[i].toPrimitive();
|
|
302
|
+
if (_ledger.total > 0) {
|
|
303
|
+
result.push(address);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
293
309
|
|
|
294
310
|
/* Subscribe pool position */
|
|
295
311
|
|
|
@@ -659,8 +675,15 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
659
675
|
async handleYieldWithdraw(address, unstakingInfo) {
|
|
660
676
|
const chainApi = await this.substrateApi.isReady;
|
|
661
677
|
if (chainApi.api.tx.staking.withdrawUnbonded.meta.args.length === 1) {
|
|
662
|
-
|
|
663
|
-
|
|
678
|
+
let slashingSpanCount;
|
|
679
|
+
if (chainApi.api.query.staking.nominatorSlashInEra) {
|
|
680
|
+
const currentEra = await chainApi.api.query.staking.currentEra();
|
|
681
|
+
const slashingSpans = (await chainApi.api.query.staking.nominatorSlashInEra(currentEra.toPrimitive(), address)).toPrimitive();
|
|
682
|
+
slashingSpanCount = slashingSpans !== null ? slashingSpans.toString() : '0';
|
|
683
|
+
} else {
|
|
684
|
+
const _slashingSpans = (await chainApi.api.query.staking.slashingSpans(address)).toHuman();
|
|
685
|
+
slashingSpanCount = _slashingSpans !== null ? _slashingSpans.spanIndex : '0';
|
|
686
|
+
}
|
|
664
687
|
return chainApi.api.tx.staking.withdrawUnbonded(slashingSpanCount);
|
|
665
688
|
} else {
|
|
666
689
|
// @ts-ignore
|
|
@@ -387,6 +387,11 @@ class TaoNativeStakingPoolHandler extends _basePara.default {
|
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
+
// Because not have subscan api
|
|
391
|
+
async checkAccountHaveStake(useAddresses) {
|
|
392
|
+
return Promise.resolve([]);
|
|
393
|
+
}
|
|
394
|
+
|
|
390
395
|
/* Subscribe pool position */
|
|
391
396
|
|
|
392
397
|
/* Get pool targets */
|
|
@@ -29,6 +29,9 @@ class NominationPoolHandler extends _base.default {
|
|
|
29
29
|
withdraw: true,
|
|
30
30
|
claimReward: true
|
|
31
31
|
};
|
|
32
|
+
static generateSlug(symbol, chain) {
|
|
33
|
+
return `${symbol}___nomination_pool___${chain}`;
|
|
34
|
+
}
|
|
32
35
|
constructor(state, chain) {
|
|
33
36
|
super(state, chain);
|
|
34
37
|
const _chainAsset = this.nativeToken;
|
|
@@ -87,7 +90,8 @@ class NominationPoolHandler extends _base.default {
|
|
|
87
90
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
88
91
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
89
92
|
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
90
|
-
const
|
|
93
|
+
const eraInHours = _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
94
|
+
const erasPerDay = 24 / eraInHours; // Can be exactly calculate from epochDuration, blockTime, sessionsPerEra
|
|
91
95
|
|
|
92
96
|
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
93
97
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
@@ -569,8 +573,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
569
573
|
async handleYieldWithdraw(address, unstakingInfo) {
|
|
570
574
|
const chainApi = await this.substrateApi.isReady;
|
|
571
575
|
if (chainApi.api.tx.nominationPools.withdrawUnbonded.meta.args.length === 2) {
|
|
572
|
-
const
|
|
573
|
-
const slashingSpanCount = _slashingSpans !== null ? _slashingSpans.spanIndex : '0';
|
|
576
|
+
const slashingSpanCount = await chainApi.api.call.nominationPoolsApi.memberPendingSlash(address);
|
|
574
577
|
return chainApi.api.tx.nominationPools.withdrawUnbonded({
|
|
575
578
|
Id: address
|
|
576
579
|
}, slashingSpanCount);
|
|
@@ -30,6 +30,7 @@ const fetchPoolsData = async () => {
|
|
|
30
30
|
class EarningService {
|
|
31
31
|
handlers = {};
|
|
32
32
|
handlerCache = new Map();
|
|
33
|
+
inactivePoolSlug = new Set();
|
|
33
34
|
earningRewardSubject = new _rxjs.BehaviorSubject({
|
|
34
35
|
ready: false,
|
|
35
36
|
data: {}
|
|
@@ -43,6 +44,7 @@ class EarningService {
|
|
|
43
44
|
yieldPositionListSubject = new _rxjs.BehaviorSubject([]); // virtual list of yieldPositionSubject with filter values
|
|
44
45
|
|
|
45
46
|
useOnlineCacheOnly = true;
|
|
47
|
+
inactivePoolReady = (0, _utils2.createPromiseHandler)();
|
|
46
48
|
constructor(state) {
|
|
47
49
|
this.state = state;
|
|
48
50
|
this.dbService = state.dbService;
|
|
@@ -60,10 +62,23 @@ class EarningService {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
const minAmountPercent = {};
|
|
65
|
+
const ahMapChain = await this.state.chainService.fetchAhMapChain();
|
|
63
66
|
for (const chain of chains) {
|
|
64
67
|
const handlers = [];
|
|
68
|
+
const chainInfo = this.state.getChainInfo(chain);
|
|
69
|
+
const symbol = (0, _utils._getChainSubstrateTokenSymbol)(chainInfo);
|
|
65
70
|
if (_constants2._STAKING_CHAIN_GROUP.relay.includes(chain)) {
|
|
66
|
-
|
|
71
|
+
if (_constants2._STAKING_CHAIN_GROUP.assetHub.includes(chain)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const ahChain = ahMapChain[chain];
|
|
75
|
+
if (ahChain) {
|
|
76
|
+
handlers.push(new _handlers.RelayNativeStakingPoolHandler(this.state, ahChain));
|
|
77
|
+
const relaySlug = _handlers.RelayNativeStakingPoolHandler.generateSlug(symbol, chain);
|
|
78
|
+
this.inactivePoolSlug.add(relaySlug);
|
|
79
|
+
} else {
|
|
80
|
+
handlers.push(new _handlers.RelayNativeStakingPoolHandler(this.state, chain));
|
|
81
|
+
}
|
|
67
82
|
}
|
|
68
83
|
if (_constants2._STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
69
84
|
handlers.push(new _handlers.ParaNativeStakingPoolHandler(this.state, chain));
|
|
@@ -84,7 +99,14 @@ class EarningService {
|
|
|
84
99
|
handlers.push(new _mythos.default(this.state, chain));
|
|
85
100
|
}
|
|
86
101
|
if (_constants2._STAKING_CHAIN_GROUP.nominationPool.includes(chain)) {
|
|
87
|
-
|
|
102
|
+
const ahChain = ahMapChain[chain];
|
|
103
|
+
if (ahChain) {
|
|
104
|
+
handlers.push(new _handlers.NominationPoolHandler(this.state, ahChain));
|
|
105
|
+
const relaySlug = _handlers.NominationPoolHandler.generateSlug(symbol, chain);
|
|
106
|
+
this.inactivePoolSlug.add(relaySlug);
|
|
107
|
+
} else {
|
|
108
|
+
handlers.push(new _handlers.NominationPoolHandler(this.state, chain));
|
|
109
|
+
}
|
|
88
110
|
}
|
|
89
111
|
if (_constants2._STAKING_CHAIN_GROUP.liquidStaking.includes(chain)) {
|
|
90
112
|
if (chain === 'bifrost_dot') {
|
|
@@ -117,6 +139,7 @@ class EarningService {
|
|
|
117
139
|
}
|
|
118
140
|
minAmountPercent.default = _base.default.defaultMinAmountPercent;
|
|
119
141
|
this.minAmountPercentSubject.next(minAmountPercent);
|
|
142
|
+
this.inactivePoolReady.resolve();
|
|
120
143
|
|
|
121
144
|
// Emit earning ready
|
|
122
145
|
this.eventService.emit('earning.ready', true);
|
|
@@ -136,7 +159,7 @@ class EarningService {
|
|
|
136
159
|
next: data => {
|
|
137
160
|
const activeMap = this.state.getActiveChainInfoMap();
|
|
138
161
|
const activePositions = Object.values(data).filter(item => {
|
|
139
|
-
return !!activeMap[item.chain];
|
|
162
|
+
return !!activeMap[item.chain] && !this.inactivePoolSlug.has(item.slug);
|
|
140
163
|
});
|
|
141
164
|
this.yieldPositionListSubject.next(Object.values(activePositions));
|
|
142
165
|
}
|
|
@@ -319,7 +342,9 @@ class EarningService {
|
|
|
319
342
|
const yieldPoolInfo = {};
|
|
320
343
|
const existedYieldPoolInfo = await this.dbService.getYieldPools();
|
|
321
344
|
existedYieldPoolInfo.forEach(info => {
|
|
322
|
-
|
|
345
|
+
if (!this.inactivePoolSlug.has(info.slug)) {
|
|
346
|
+
yieldPoolInfo[info.slug] = info;
|
|
347
|
+
}
|
|
323
348
|
});
|
|
324
349
|
this.yieldPoolInfoSubject.next(yieldPoolInfo);
|
|
325
350
|
}
|
|
@@ -354,6 +379,10 @@ class EarningService {
|
|
|
354
379
|
}
|
|
355
380
|
async fetchingPoolsInfoOnline() {
|
|
356
381
|
const onlineData = await fetchPoolsData();
|
|
382
|
+
await this.inactivePoolReady.promise;
|
|
383
|
+
for (const inactiveSlug of this.inactivePoolSlug) {
|
|
384
|
+
delete onlineData[inactiveSlug];
|
|
385
|
+
}
|
|
357
386
|
Object.values(onlineData).forEach(item => {
|
|
358
387
|
this.updateYieldPoolInfo(item);
|
|
359
388
|
});
|
|
@@ -396,14 +425,11 @@ class EarningService {
|
|
|
396
425
|
async subscribePoolPositions(addresses, callback) {
|
|
397
426
|
let cancel = false;
|
|
398
427
|
await this.eventService.waitChainReady;
|
|
399
|
-
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
400
|
-
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
401
428
|
const activeChains = this.state.activeChainSlugs;
|
|
402
429
|
const unsubList = [];
|
|
403
430
|
for (const handler of Object.values(this.handlers)) {
|
|
404
431
|
if (activeChains.includes(handler.chain)) {
|
|
405
|
-
const
|
|
406
|
-
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
432
|
+
const [useAddresses] = (0, _utils2.filterAddressByChainInfo)(addresses, handler.chainInfo);
|
|
407
433
|
handler.subscribePoolPosition(useAddresses, callback).then(unsub => {
|
|
408
434
|
if (cancel) {
|
|
409
435
|
unsub();
|
|
@@ -451,7 +477,9 @@ class EarningService {
|
|
|
451
477
|
const existedYieldPosition = await this.dbService.getYieldNominationPoolPosition(addresses, this.state.activeChainSlugs);
|
|
452
478
|
const yieldPositionInfo = this.yieldPositionSubject.getValue();
|
|
453
479
|
existedYieldPosition.forEach(item => {
|
|
454
|
-
|
|
480
|
+
if (!this.inactivePoolSlug.has(item.slug)) {
|
|
481
|
+
yieldPositionInfo[this._getYieldPositionKey(item.slug, item.address)] = item;
|
|
482
|
+
}
|
|
455
483
|
});
|
|
456
484
|
this.yieldPositionSubject.next(yieldPositionInfo);
|
|
457
485
|
}
|
|
@@ -543,14 +571,11 @@ class EarningService {
|
|
|
543
571
|
async getPoolReward(addresses, callback) {
|
|
544
572
|
let cancel = false;
|
|
545
573
|
await this.eventService.waitChainReady;
|
|
546
|
-
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
547
|
-
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
548
574
|
const activeChains = this.state.activeChainSlugs;
|
|
549
575
|
const unsubList = [];
|
|
550
576
|
for (const handler of Object.values(this.handlers)) {
|
|
551
577
|
if (activeChains.includes(handler.chain)) {
|
|
552
|
-
const
|
|
553
|
-
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
578
|
+
const [useAddresses] = (0, _utils2.filterAddressByChainInfo)(addresses, handler.chainInfo);
|
|
554
579
|
handler.getPoolReward(useAddresses, callback).then(unsub => {
|
|
555
580
|
if (cancel) {
|
|
556
581
|
unsub();
|
|
@@ -599,14 +624,11 @@ class EarningService {
|
|
|
599
624
|
async fetchPoolRewardHistory(addresses, callback) {
|
|
600
625
|
let cancel = false;
|
|
601
626
|
await this.eventService.waitChainReady;
|
|
602
|
-
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
603
|
-
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
604
627
|
const activeChains = this.state.activeChainSlugs;
|
|
605
628
|
const unsubList = [];
|
|
606
629
|
for (const handler of Object.values(this.handlers)) {
|
|
607
630
|
if (activeChains.includes(handler.chain)) {
|
|
608
|
-
const
|
|
609
|
-
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
631
|
+
const [useAddresses] = (0, _utils2.filterAddressByChainInfo)(addresses, handler.chainInfo);
|
|
610
632
|
handler.getPoolRewardHistory(useAddresses, callback).then(unsub => {
|
|
611
633
|
if (cancel) {
|
|
612
634
|
unsub();
|
|
@@ -648,18 +670,39 @@ class EarningService {
|
|
|
648
670
|
if (!addresses.length) {
|
|
649
671
|
return;
|
|
650
672
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
673
|
+
let cancel = false;
|
|
674
|
+
let unsub;
|
|
675
|
+
this.unSubFetchEarningRewardHistory = () => {
|
|
676
|
+
if (!cancel) {
|
|
677
|
+
var _unsub2;
|
|
678
|
+
(_unsub2 = unsub) === null || _unsub2 === void 0 ? void 0 : _unsub2();
|
|
679
|
+
cancel = true;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
const fetchData = () => {
|
|
655
683
|
this.fetchPoolRewardHistory(addresses, result => {
|
|
684
|
+
if (cancel) {
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
656
687
|
this.updateEarningRewardHistory(result);
|
|
688
|
+
}).then(_unsub => {
|
|
689
|
+
if (!cancel) {
|
|
690
|
+
var _unsub3;
|
|
691
|
+
(_unsub3 = unsub) === null || _unsub3 === void 0 ? void 0 : _unsub3();
|
|
692
|
+
unsub = _unsub;
|
|
693
|
+
}
|
|
657
694
|
}).catch(console.error);
|
|
658
|
-
}
|
|
695
|
+
};
|
|
696
|
+
if (!cancel) {
|
|
697
|
+
fetchData();
|
|
698
|
+
}
|
|
699
|
+
this.earningsRewardHistoryInterval = setInterval(fetchData, _constants.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
659
700
|
}
|
|
660
701
|
runUnsubscribeEarningRewardHistoryInterval() {
|
|
702
|
+
var _this$unSubFetchEarni;
|
|
661
703
|
(0, _utils2.removeLazy)('updateEarningRewardHistory');
|
|
662
704
|
this.earningRewardHistoryQueue = [];
|
|
705
|
+
(_this$unSubFetchEarni = this.unSubFetchEarningRewardHistory) === null || _this$unSubFetchEarni === void 0 ? void 0 : _this$unSubFetchEarni.call(this);
|
|
663
706
|
this.earningsRewardHistoryInterval && clearInterval(this.earningsRewardHistoryInterval);
|
|
664
707
|
}
|
|
665
708
|
|
|
@@ -81,7 +81,7 @@ class HistoryService {
|
|
|
81
81
|
/**
|
|
82
82
|
* @todo: Must improve performance of this function
|
|
83
83
|
* */
|
|
84
|
-
fetchSubscanTransactionHistory(chain, addresses) {
|
|
84
|
+
fetchSubscanTransactionHistory(chain, addresses, groupId) {
|
|
85
85
|
if (!this.subscanService.checkSupportedSubscanChain(chain) || !addresses.length) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
@@ -94,7 +94,7 @@ class HistoryService {
|
|
|
94
94
|
// However, fetchAllPossibleTransferItems-sent must run after fetchAllPossibleExtrinsicItems,
|
|
95
95
|
// to avoid "duplicate Extrinsic Hash between items" problem
|
|
96
96
|
|
|
97
|
-
this.subscanService.fetchAllPossibleExtrinsicItems(chain, address, extrinsicItems => {
|
|
97
|
+
this.subscanService.fetchAllPossibleExtrinsicItems(groupId, chain, address, extrinsicItems => {
|
|
98
98
|
const result = [];
|
|
99
99
|
extrinsicItems.forEach(x => {
|
|
100
100
|
const item = (0, _subscanHistory.parseSubscanExtrinsicData)(address, x, chainInfo);
|
|
@@ -112,7 +112,7 @@ class HistoryService {
|
|
|
112
112
|
excludeTransferExtrinsicHash.push(x.extrinsic_hash);
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
|
-
this.subscanService.fetchAllPossibleTransferItems(chain, address, 'sent').then(rsMap => {
|
|
115
|
+
this.subscanService.fetchAllPossibleTransferItems(groupId, chain, address, 'sent').then(rsMap => {
|
|
116
116
|
const result = [];
|
|
117
117
|
Object.keys(rsMap).forEach(hash => {
|
|
118
118
|
// only push item that does not have same hash with another item
|
|
@@ -132,7 +132,7 @@ class HistoryService {
|
|
|
132
132
|
}).catch(e => {
|
|
133
133
|
console.log('fetchAllPossibleExtrinsicItems error', e);
|
|
134
134
|
});
|
|
135
|
-
this.subscanService.fetchAllPossibleTransferItems(chain, address, 'received').then(rsMap => {
|
|
135
|
+
this.subscanService.fetchAllPossibleTransferItems(groupId, chain, address, 'received').then(rsMap => {
|
|
136
136
|
const result = [];
|
|
137
137
|
Object.keys(rsMap).forEach(hash => {
|
|
138
138
|
// only push item that does not have same hash with another item
|
|
@@ -179,14 +179,19 @@ class HistoryService {
|
|
|
179
179
|
const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
|
|
180
180
|
const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
|
|
181
181
|
const bitcoinAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.BITCOIN], chainInfo);
|
|
182
|
+
const groupId = this.subscanService.getGroupId();
|
|
182
183
|
const subscription = this.historySubject.subscribe(items => {
|
|
183
184
|
cb(items.filter(filterHistoryItemByAddressAndChain(chain, addresses)));
|
|
184
185
|
});
|
|
186
|
+
const unsubscribe = () => {
|
|
187
|
+
subscription.unsubscribe();
|
|
188
|
+
this.subscanService.cancelGroupRequest(groupId);
|
|
189
|
+
};
|
|
185
190
|
if ((0, _utils._isChainSubstrateCompatible)(chainInfo)) {
|
|
186
191
|
if ((0, _utils._isChainEvmCompatible)(chainInfo)) {
|
|
187
|
-
this.fetchSubscanTransactionHistory(chain, evmAddresses);
|
|
192
|
+
this.fetchSubscanTransactionHistory(chain, evmAddresses, groupId);
|
|
188
193
|
} else {
|
|
189
|
-
this.fetchSubscanTransactionHistory(chain, substrateAddresses);
|
|
194
|
+
this.fetchSubscanTransactionHistory(chain, substrateAddresses, groupId);
|
|
190
195
|
}
|
|
191
196
|
} else if ((0, _utils._isChainBitcoinCompatible)(chainInfo)) {
|
|
192
197
|
this.fetchBitcoinTransactionHistory(chain, bitcoinAddresses).catch(e => {
|
|
@@ -194,7 +199,7 @@ class HistoryService {
|
|
|
194
199
|
});
|
|
195
200
|
}
|
|
196
201
|
return {
|
|
197
|
-
unsubscribe
|
|
202
|
+
unsubscribe,
|
|
198
203
|
value: this.historySubject.getValue().filter(filterHistoryItemByAddressAndChain(chain, addresses))
|
|
199
204
|
};
|
|
200
205
|
}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.AccountJsonHandler = void 0;
|
|
7
7
|
var _constants = require("@subwallet/extension-base/constants");
|
|
8
|
+
var _types = require("@subwallet/extension-base/types");
|
|
8
9
|
var _utils = require("@subwallet/extension-base/utils");
|
|
9
10
|
var _getId = require("@subwallet/extension-base/utils/getId");
|
|
10
11
|
var _keyring = require("@subwallet/keyring");
|
|
@@ -326,7 +327,7 @@ class AccountJsonHandler extends _Base.AccountBaseHandler {
|
|
|
326
327
|
let [, proxy] = _ref8;
|
|
327
328
|
return _proxyIds.includes(proxy.id);
|
|
328
329
|
}));
|
|
329
|
-
const addresses = Object.values(_account).filter(account => _proxyIds.includes(account.id)).flatMap(proxy => proxy.accounts.map(account => account.address));
|
|
330
|
+
const addresses = Object.values(_account).filter(account => _proxyIds.includes(account.id) && account.accountType !== _types.AccountProxyType.LEDGER).flatMap(proxy => proxy.accounts.map(account => account.address));
|
|
330
331
|
const rs = await _uiKeyring.keyring.backupAccounts(password, addresses);
|
|
331
332
|
if (Object.keys(modifyPairs).length && Object.keys(accountProxies).length) {
|
|
332
333
|
rs.accountProxies = accountProxies;
|
|
@@ -101,6 +101,7 @@ class AccountLedgerHandler extends _Base.AccountBaseHandler {
|
|
|
101
101
|
isEthereum,
|
|
102
102
|
isGeneric,
|
|
103
103
|
isLedgerRecovery,
|
|
104
|
+
isSubstrateECDSA,
|
|
104
105
|
name,
|
|
105
106
|
originGenesisHash
|
|
106
107
|
} = account;
|
|
@@ -112,9 +113,13 @@ class AccountLedgerHandler extends _Base.AccountBaseHandler {
|
|
|
112
113
|
genesisHash,
|
|
113
114
|
originGenesisHash,
|
|
114
115
|
isGeneric,
|
|
115
|
-
isLedgerRecovery
|
|
116
|
+
isLedgerRecovery,
|
|
117
|
+
isSubstrateECDSA
|
|
116
118
|
};
|
|
117
|
-
|
|
119
|
+
let type = 'sr25519';
|
|
120
|
+
if (isEthereum || isSubstrateECDSA) {
|
|
121
|
+
type = 'ethereum';
|
|
122
|
+
}
|
|
118
123
|
const pair = _uiKeyring.keyring.keyring.createFromAddress(address, {
|
|
119
124
|
...baseMeta,
|
|
120
125
|
isExternal: true,
|
|
@@ -55,6 +55,9 @@ class AuthRequestHandler {
|
|
|
55
55
|
} else if (!value.currentNetworkMap) {
|
|
56
56
|
value.currentNetworkMap = {};
|
|
57
57
|
}
|
|
58
|
+
if (existKeyBothConnectAuthType) {
|
|
59
|
+
value.canConnectSubstrateEcdsa = true;
|
|
60
|
+
}
|
|
58
61
|
acc[key] = {
|
|
59
62
|
...value
|
|
60
63
|
};
|
|
@@ -91,6 +94,18 @@ class AuthRequestHandler {
|
|
|
91
94
|
[v]: value
|
|
92
95
|
}), {});
|
|
93
96
|
}
|
|
97
|
+
getEcdsaAddressList() {
|
|
98
|
+
const addressList = Object.keys(this.keyringService.context.pairs);
|
|
99
|
+
const pairs = this.keyringService.context.pairs;
|
|
100
|
+
const ecdsaAddressList = new Set();
|
|
101
|
+
addressList.forEach(address => {
|
|
102
|
+
const pair = pairs[address];
|
|
103
|
+
if (pair && pair.json.meta.isSubstrateECDSA) {
|
|
104
|
+
ecdsaAddressList.add(address);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return ecdsaAddressList;
|
|
108
|
+
}
|
|
94
109
|
get numAuthRequestsV2() {
|
|
95
110
|
return Object.keys(this.#authRequestsV2).length;
|
|
96
111
|
}
|
|
@@ -201,6 +216,7 @@ class AuthRequestHandler {
|
|
|
201
216
|
}
|
|
202
217
|
authCompleteV2 = (id, url, resolve, reject) => {
|
|
203
218
|
const isAllowedMap = this.getAddressList();
|
|
219
|
+
const ecdsaAddressList = this.getEcdsaAddressList();
|
|
204
220
|
const complete = (result, cb, accounts) => {
|
|
205
221
|
const isAllowed = result === true;
|
|
206
222
|
let isCancelled = false;
|
|
@@ -221,6 +237,7 @@ class AuthRequestHandler {
|
|
|
221
237
|
idStr,
|
|
222
238
|
request: {
|
|
223
239
|
allowedAccounts,
|
|
240
|
+
canConnectSubstrateEcdsa,
|
|
224
241
|
origin
|
|
225
242
|
},
|
|
226
243
|
url
|
|
@@ -228,10 +245,9 @@ class AuthRequestHandler {
|
|
|
228
245
|
|
|
229
246
|
// Note: accountAuthTypes represents the accountAuthType of this request
|
|
230
247
|
// allowedAccounts is a list of connected accounts that exist for this origin during this request.
|
|
231
|
-
|
|
232
248
|
if (accountAuthTypes.length !== _constants.ALL_ACCOUNT_AUTH_TYPES.length) {
|
|
233
249
|
const backupAllowed = (allowedAccounts || []).filter(a => {
|
|
234
|
-
if ((0, _utilCrypto.isEthereumAddress)(a) && !accountAuthTypes.includes('evm')) {
|
|
250
|
+
if ((0, _utilCrypto.isEthereumAddress)(a) && (canConnectSubstrateEcdsa || !ecdsaAddressList.has(a)) && !accountAuthTypes.includes('evm')) {
|
|
235
251
|
return true;
|
|
236
252
|
}
|
|
237
253
|
if ((0, _keyring.isSubstrateAddress)(a) && !accountAuthTypes.includes('substrate')) {
|
|
@@ -294,7 +310,8 @@ class AuthRequestHandler {
|
|
|
294
310
|
currentNetworkMap: existed ? {
|
|
295
311
|
...defaultNetworkMap,
|
|
296
312
|
...existed.currentNetworkMap
|
|
297
|
-
} : defaultNetworkMap
|
|
313
|
+
} : defaultNetworkMap,
|
|
314
|
+
canConnectSubstrateEcdsa: canConnectSubstrateEcdsa || (existed === null || existed === void 0 ? void 0 : existed.canConnectSubstrateEcdsa)
|
|
298
315
|
};
|
|
299
316
|
this.setAuthorize(authorizeList, () => {
|
|
300
317
|
cb();
|
|
@@ -326,6 +343,7 @@ class AuthRequestHandler {
|
|
|
326
343
|
const idStr = (0, _utils2.stripUrl)(url);
|
|
327
344
|
const isAllowedDappConnectBothType = !!_constants2.DAPP_CONNECT_BOTH_TYPE_ACCOUNT_URL.find(url_ => url.includes(url_));
|
|
328
345
|
let accountAuthTypes = [...new Set(isAllowedDappConnectBothType ? ['evm', 'substrate'] : request.accountAuthTypes || ['substrate'])];
|
|
346
|
+
let canConnectSubstrateEcdsa = !!request.canConnectSubstrateEcdsa || isAllowedDappConnectBothType;
|
|
329
347
|
if (!authList) {
|
|
330
348
|
authList = {};
|
|
331
349
|
}
|
|
@@ -360,6 +378,9 @@ class AuthRequestHandler {
|
|
|
360
378
|
if (accountAuthTypes && _request.accountAuthTypes) {
|
|
361
379
|
const filteredAccountAuthTypes = new Set([..._request.accountAuthTypes, ...accountAuthTypes]);
|
|
362
380
|
accountAuthTypes = [...filteredAccountAuthTypes];
|
|
381
|
+
if (_request.request.canConnectSubstrateEcdsa) {
|
|
382
|
+
canConnectSubstrateEcdsa = true;
|
|
383
|
+
}
|
|
363
384
|
}
|
|
364
385
|
mergeKeys.push(key);
|
|
365
386
|
}
|
|
@@ -391,9 +412,10 @@ class AuthRequestHandler {
|
|
|
391
412
|
return allowed ? address : '';
|
|
392
413
|
}).filter(item => item !== '');
|
|
393
414
|
let allowedListByRequestType = [...request.allowedAccounts];
|
|
415
|
+
const ecdsaAddressList = this.getEcdsaAddressList();
|
|
394
416
|
allowedListByRequestType = accountAuthTypes.reduce((list, accountAuthType) => {
|
|
395
417
|
if (accountAuthType === 'evm') {
|
|
396
|
-
list.push(...allowedListByRequestType.filter(a => (0, _utilCrypto.isEthereumAddress)(a)));
|
|
418
|
+
list.push(...allowedListByRequestType.filter(a => (0, _utilCrypto.isEthereumAddress)(a) && (canConnectSubstrateEcdsa || !ecdsaAddressList.has(a))));
|
|
397
419
|
} else if (accountAuthType === 'substrate') {
|
|
398
420
|
list.push(...allowedListByRequestType.filter(a => (0, _keyring.isSubstrateAddress)(a)));
|
|
399
421
|
} else if (accountAuthType === 'ton') {
|
|
@@ -424,7 +446,8 @@ class AuthRequestHandler {
|
|
|
424
446
|
origin,
|
|
425
447
|
url,
|
|
426
448
|
accountAuthTypes: _constants.ALL_ACCOUNT_AUTH_TYPES,
|
|
427
|
-
currentNetworkMap: {}
|
|
449
|
+
currentNetworkMap: {},
|
|
450
|
+
canConnectSubstrateEcdsa
|
|
428
451
|
};
|
|
429
452
|
this.setAuthorize(authList);
|
|
430
453
|
return true;
|
|
@@ -436,7 +459,8 @@ class AuthRequestHandler {
|
|
|
436
459
|
idStr,
|
|
437
460
|
request: {
|
|
438
461
|
...request,
|
|
439
|
-
accountAuthTypes
|
|
462
|
+
accountAuthTypes,
|
|
463
|
+
canConnectSubstrateEcdsa
|
|
440
464
|
},
|
|
441
465
|
url,
|
|
442
466
|
accountAuthTypes: accountAuthTypes || ['substrate']
|