@subwallet/extension-base 1.1.5-0 → 1.1.6-1
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 +1 -0
- package/cjs/koni/api/nft/config.js +1 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +18 -17
- package/cjs/koni/api/staking/bonding/paraChain.js +11 -17
- package/cjs/koni/background/handlers/Extension.js +11 -3
- package/cjs/koni/background/handlers/Tabs.js +1 -5
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/SubWalleEvmProvider.js +18 -7
- package/cjs/services/chain-service/constants.js +5 -3
- package/cjs/services/migration-service/scripts/MigrateWalletReference.js +31 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/setting-service/constants.js +2 -1
- package/cjs/services/storage-service/db-stores/Nft.js +2 -2
- package/cjs/services/storage-service/db-stores/Staking.js +2 -2
- package/koni/api/nft/config.d.ts +1 -1
- package/koni/api/nft/config.js +1 -1
- package/koni/api/staking/bonding/amplitude.js +18 -17
- package/koni/api/staking/bonding/paraChain.js +11 -17
- package/koni/api/staking/bonding/utils.d.ts +3 -3
- package/koni/background/handlers/Extension.js +11 -3
- package/koni/background/handlers/Tabs.js +1 -5
- package/package.json +13 -7
- package/packageInfo.js +1 -1
- package/page/SubWalleEvmProvider.d.ts +2 -1
- package/page/SubWalleEvmProvider.js +18 -7
- package/services/chain-service/constants.js +5 -3
- package/services/migration-service/scripts/MigrateWalletReference.d.ts +4 -0
- package/services/migration-service/scripts/MigrateWalletReference.js +23 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/setting-service/constants.js +2 -1
- package/services/storage-service/db-stores/Nft.js +2 -2
- package/services/storage-service/db-stores/Staking.js +2 -2
|
@@ -53,7 +53,7 @@ const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
|
53
53
|
exports.IPFS_GATEWAY_4EVERLAND = IPFS_GATEWAY_4EVERLAND;
|
|
54
54
|
const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
55
55
|
exports.IPFS_FLEEK = IPFS_FLEEK;
|
|
56
|
-
const IPFS_HARDBIN = 'https://hardbin.com/ipfs';
|
|
56
|
+
const IPFS_HARDBIN = 'https://hardbin.com/ipfs/';
|
|
57
57
|
exports.IPFS_HARDBIN = IPFS_HARDBIN;
|
|
58
58
|
let SUPPORTED_NFT_NETWORKS;
|
|
59
59
|
exports.SUPPORTED_NFT_NETWORKS = SUPPORTED_NFT_NETWORKS;
|
|
@@ -213,23 +213,24 @@ async function getAmplitudeCollatorsInfo(chain, substrateApi) {
|
|
|
213
213
|
const delegatorReturn = parseFloat(rawDelegatorReturn.split('%')[0]);
|
|
214
214
|
const allCollators = [];
|
|
215
215
|
for (const _collator of _allCollators) {
|
|
216
|
-
const collatorInfo = _collator[1].
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
216
|
+
const collatorInfo = _collator[1].toPrimitive();
|
|
217
|
+
const bnTotalStake = new _util.BN(collatorInfo.total);
|
|
218
|
+
const bnOwnStake = new _util.BN(collatorInfo.stake);
|
|
219
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
220
|
+
allCollators.push({
|
|
221
|
+
address: collatorInfo.id,
|
|
222
|
+
totalStake: bnTotalStake.toString(),
|
|
223
|
+
ownStake: bnOwnStake.toString(),
|
|
224
|
+
otherStake: bnOtherStake.toString(),
|
|
225
|
+
nominatorCount: collatorInfo.delegators.length,
|
|
226
|
+
commission: 0,
|
|
227
|
+
expectedReturn: delegatorReturn,
|
|
228
|
+
blocked: false,
|
|
229
|
+
isVerified: false,
|
|
230
|
+
minBond: '0',
|
|
231
|
+
chain,
|
|
232
|
+
isCrowded: collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator)
|
|
233
|
+
});
|
|
233
234
|
}
|
|
234
235
|
return allCollators;
|
|
235
236
|
}
|
|
@@ -44,7 +44,7 @@ function validateParaChainUnbondingCondition(amount, nominatorMetadata, chainSta
|
|
|
44
44
|
const bnRemainingStake = bnActiveStake.sub(new _util.BN(amount));
|
|
45
45
|
const bnChainMinStake = new _util.BN(chainStakingMetadata.minStake || '0');
|
|
46
46
|
const bnCollatorMinStake = new _util.BN(targetNomination.validatorMinStake || '0');
|
|
47
|
-
const bnMinStake = bnCollatorMinStake
|
|
47
|
+
const bnMinStake = _util.BN.max(bnCollatorMinStake, bnChainMinStake);
|
|
48
48
|
if (targetNomination.hasUnstaking) {
|
|
49
49
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.EXIST_UNSTAKING_REQUEST));
|
|
50
50
|
}
|
|
@@ -101,9 +101,10 @@ function validateParaChainBondingCondition(chainInfo, amount, selectedCollators,
|
|
|
101
101
|
}
|
|
102
102
|
function subscribeParaChainStakingMetadata(chain, substrateApi, callback) {
|
|
103
103
|
return substrateApi.api.query.parachainStaking.round(_round => {
|
|
104
|
+
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$con3;
|
|
104
105
|
const roundObj = _round.toHuman();
|
|
105
106
|
const round = (0, _utils3.parseRawNumber)(roundObj.current);
|
|
106
|
-
const maxDelegations = substrateApi.api.consts.parachainStaking.maxDelegationsPerDelegator.toString();
|
|
107
|
+
const maxDelegations = (_substrateApi$api$con = substrateApi.api.consts) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.parachainStaking) === null || _substrateApi$api$con2 === void 0 ? void 0 : (_substrateApi$api$con3 = _substrateApi$api$con2.maxDelegationsPerDelegator) === null || _substrateApi$api$con3 === void 0 ? void 0 : _substrateApi$api$con3.toString();
|
|
107
108
|
const unstakingDelay = substrateApi.api.consts.parachainStaking.delegationBondLessDelay.toString();
|
|
108
109
|
const unstakingPeriod = parseInt(unstakingDelay) * (_constants._STAKING_ERA_LENGTH_MAP[chain] || _constants._STAKING_ERA_LENGTH_MAP.default);
|
|
109
110
|
callback(chain, {
|
|
@@ -332,17 +333,21 @@ async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
332
333
|
const _collatorAddress = collator[0].toHuman();
|
|
333
334
|
const collatorAddress = _collatorAddress[0];
|
|
334
335
|
const collatorInfo = collator[1].toPrimitive();
|
|
336
|
+
const bnTotalStake = new _util.BN(collatorInfo.totalCounted);
|
|
337
|
+
const bnOwnStake = new _util.BN(collatorInfo.bond);
|
|
338
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
339
|
+
const bnMinBond = new _util.BN(collatorInfo.lowestTopDelegationAmount);
|
|
335
340
|
allCollators.push({
|
|
336
341
|
commission: 0,
|
|
337
342
|
expectedReturn: 0,
|
|
338
343
|
address: collatorAddress,
|
|
339
|
-
totalStake:
|
|
340
|
-
ownStake:
|
|
341
|
-
otherStake:
|
|
344
|
+
totalStake: bnTotalStake.toString(),
|
|
345
|
+
ownStake: bnOwnStake.toString(),
|
|
346
|
+
otherStake: bnOtherStake.toString(),
|
|
342
347
|
nominatorCount: collatorInfo.delegationCount,
|
|
343
348
|
blocked: false,
|
|
344
349
|
isVerified: false,
|
|
345
|
-
minBond:
|
|
350
|
+
minBond: bnMinBond.toString(),
|
|
346
351
|
chain,
|
|
347
352
|
isCrowded: parseInt(maxDelegationPerCollator) > 0
|
|
348
353
|
});
|
|
@@ -354,10 +359,6 @@ async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
354
359
|
]);
|
|
355
360
|
const rawInfo = _info.toHuman();
|
|
356
361
|
const rawIdentity = _identity ? _identity.toHuman() : null;
|
|
357
|
-
const rawBond = rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.bond;
|
|
358
|
-
const bond = new _util.BN(rawBond.replaceAll(',', ''));
|
|
359
|
-
const delegationCount = (0, _utils3.parseRawNumber)(rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.delegationCount);
|
|
360
|
-
const minDelegation = (0, _utils3.parseRawNumber)(rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.lowestTopDelegationAmount);
|
|
361
362
|
const active = (rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.status) === 'Active';
|
|
362
363
|
let isReasonable = false;
|
|
363
364
|
let identity;
|
|
@@ -369,21 +370,14 @@ async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
369
370
|
extraInfoMap[collator.address] = {
|
|
370
371
|
identity,
|
|
371
372
|
isVerified: isReasonable,
|
|
372
|
-
bond: bond.toString(),
|
|
373
|
-
minDelegation: minDelegation.toString(),
|
|
374
|
-
delegationCount,
|
|
375
373
|
active
|
|
376
374
|
};
|
|
377
375
|
}));
|
|
378
376
|
for (const validator of allCollators) {
|
|
379
|
-
validator.minBond = extraInfoMap[validator.address].minDelegation.toString();
|
|
380
|
-
validator.ownStake = extraInfoMap[validator.address].bond.toString();
|
|
381
377
|
validator.blocked = !extraInfoMap[validator.address].active;
|
|
382
378
|
validator.identity = extraInfoMap[validator.address].identity;
|
|
383
379
|
validator.isVerified = extraInfoMap[validator.address].isVerified;
|
|
384
380
|
// @ts-ignore
|
|
385
|
-
validator.otherStake = (validator.totalStake - validator.ownStake).toString();
|
|
386
|
-
validator.nominatorCount = extraInfoMap[validator.address].delegationCount;
|
|
387
381
|
validator.commission = collatorCommission;
|
|
388
382
|
}
|
|
389
383
|
return allCollators;
|
|
@@ -1423,12 +1423,20 @@ class KoniExtension {
|
|
|
1423
1423
|
async subscribeHistory(id, port) {
|
|
1424
1424
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1425
1425
|
const historySubject = await this.#koniState.historyService.getHistorySubject();
|
|
1426
|
-
historySubject.subscribe(
|
|
1427
|
-
|
|
1426
|
+
const subscription = historySubject.subscribe(histories => {
|
|
1427
|
+
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address.toLowerCase());
|
|
1428
|
+
|
|
1429
|
+
// Re-filter
|
|
1430
|
+
cb(histories.filter(item => addresses.includes(item.address.toLowerCase())));
|
|
1431
|
+
});
|
|
1432
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1428
1433
|
port.onDisconnect.addListener(() => {
|
|
1429
1434
|
this.cancelSubscription(id);
|
|
1430
1435
|
});
|
|
1431
|
-
|
|
1436
|
+
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address.toLowerCase());
|
|
1437
|
+
|
|
1438
|
+
// Re-filter
|
|
1439
|
+
return historySubject.getValue().filter(item => addresses.includes(item.address.toLowerCase()));
|
|
1432
1440
|
}
|
|
1433
1441
|
|
|
1434
1442
|
// Save address to contact
|
|
@@ -894,11 +894,7 @@ class KoniTabs {
|
|
|
894
894
|
return true;
|
|
895
895
|
}
|
|
896
896
|
isEvmPublicRequest(type, request) {
|
|
897
|
-
|
|
898
|
-
return true;
|
|
899
|
-
} else {
|
|
900
|
-
return false;
|
|
901
|
-
}
|
|
897
|
+
return type === 'evm(request)' && ['eth_chainId', 'net_version'].includes(request === null || request === void 0 ? void 0 : request.method);
|
|
902
898
|
}
|
|
903
899
|
async addPspToken(id, url, _ref22) {
|
|
904
900
|
let {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -9,11 +9,11 @@ var _safeEventEmitter = _interopRequireDefault(require("@metamask/safe-event-emi
|
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
|
|
12
|
+
let subscribeFlag = false;
|
|
12
13
|
class SubWalletEvmProvider extends _safeEventEmitter.default {
|
|
13
14
|
isSubWallet = true;
|
|
14
15
|
isMetaMask = false;
|
|
15
16
|
_connected = false;
|
|
16
|
-
_subscribed = false;
|
|
17
17
|
constructor(sendMessage, version) {
|
|
18
18
|
super();
|
|
19
19
|
this.version = version;
|
|
@@ -27,7 +27,7 @@ class SubWalletEvmProvider extends _safeEventEmitter.default {
|
|
|
27
27
|
return this._connected;
|
|
28
28
|
}
|
|
29
29
|
subscribeExtensionEvents() {
|
|
30
|
-
if (
|
|
30
|
+
if (subscribeFlag) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
this.sendMessage('evm(events.subscribe)', null, _ref => {
|
|
@@ -49,19 +49,33 @@ class SubWalletEvmProvider extends _safeEventEmitter.default {
|
|
|
49
49
|
console.warn('Can not handle event', type, payload);
|
|
50
50
|
}
|
|
51
51
|
}).then(done => {
|
|
52
|
-
|
|
53
|
-
}).catch(
|
|
52
|
+
subscribeFlag = true;
|
|
53
|
+
}).catch(() => {
|
|
54
|
+
subscribeFlag = false;
|
|
55
|
+
});
|
|
56
|
+
subscribeFlag = true;
|
|
54
57
|
}
|
|
55
58
|
async enable() {
|
|
56
59
|
return this.request({
|
|
57
60
|
method: 'eth_requestAccounts'
|
|
58
61
|
});
|
|
59
62
|
}
|
|
63
|
+
on(eventName, listener) {
|
|
64
|
+
this.subscribeExtensionEvents();
|
|
65
|
+
super.on(eventName, listener);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
once(eventName, listener) {
|
|
69
|
+
this.subscribeExtensionEvents();
|
|
70
|
+
super.once(eventName, listener);
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
60
73
|
request(_ref2) {
|
|
61
74
|
let {
|
|
62
75
|
method,
|
|
63
76
|
params
|
|
64
77
|
} = _ref2;
|
|
78
|
+
// Subscribe events
|
|
65
79
|
switch (method) {
|
|
66
80
|
case 'eth_requestAccounts':
|
|
67
81
|
return new Promise((resolve, reject) => {
|
|
@@ -70,9 +84,6 @@ class SubWalletEvmProvider extends _safeEventEmitter.default {
|
|
|
70
84
|
origin,
|
|
71
85
|
accountAuthType: 'evm'
|
|
72
86
|
}).then(() => {
|
|
73
|
-
// Subscribe event
|
|
74
|
-
this.subscribeExtensionEvents();
|
|
75
|
-
|
|
76
87
|
// Return account list
|
|
77
88
|
this.request({
|
|
78
89
|
method: 'eth_accounts'
|
|
@@ -61,13 +61,13 @@ const _NFT_CHAIN_GROUP = {
|
|
|
61
61
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
62
62
|
exports._NFT_CHAIN_GROUP = _NFT_CHAIN_GROUP;
|
|
63
63
|
const _STAKING_CHAIN_GROUP = {
|
|
64
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend'],
|
|
64
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware'],
|
|
65
65
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
66
66
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
67
67
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
68
68
|
// amplitude and kilt only share some common logic
|
|
69
69
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
70
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph'],
|
|
70
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate'],
|
|
71
71
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
72
72
|
aleph: ['aleph', 'alephTest'],
|
|
73
73
|
// A0 has distinct tokenomics
|
|
@@ -100,7 +100,9 @@ const _STAKING_ERA_LENGTH_MAP = {
|
|
|
100
100
|
amplitude_test: 2,
|
|
101
101
|
pendulum: 2,
|
|
102
102
|
kilt: 2,
|
|
103
|
-
kilt_peregrine: 2
|
|
103
|
+
kilt_peregrine: 2,
|
|
104
|
+
edgeware: 6,
|
|
105
|
+
kate: 6
|
|
104
106
|
};
|
|
105
107
|
exports._STAKING_ERA_LENGTH_MAP = _STAKING_ERA_LENGTH_MAP;
|
|
106
108
|
const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
+
var _uuid = require("uuid");
|
|
10
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
class MigrateWalletReference extends _Base.default {
|
|
14
|
+
async run() {
|
|
15
|
+
try {
|
|
16
|
+
return new Promise(resolve => {
|
|
17
|
+
this.state.settingService.getSettings(currentSettings => {
|
|
18
|
+
const walletReference = (0, _uuid.v4)();
|
|
19
|
+
this.state.settingService.setSettings({
|
|
20
|
+
...currentSettings,
|
|
21
|
+
walletReference: walletReference
|
|
22
|
+
});
|
|
23
|
+
resolve();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = MigrateWalletReference;
|
|
@@ -15,6 +15,7 @@ var _MigrateLedgerAccount = _interopRequireDefault(require("./MigrateLedgerAccou
|
|
|
15
15
|
var _MigrateNetworkSettings = _interopRequireDefault(require("./MigrateNetworkSettings"));
|
|
16
16
|
var _MigrateSettings = _interopRequireDefault(require("./MigrateSettings"));
|
|
17
17
|
var _MigrateTransactionHistory = _interopRequireDefault(require("./MigrateTransactionHistory"));
|
|
18
|
+
var _MigrateWalletReference = _interopRequireDefault(require("./MigrateWalletReference"));
|
|
18
19
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
19
20
|
// SPDX-License-Identifier: Apache-2.0
|
|
20
21
|
|
|
@@ -30,7 +31,8 @@ var _default = {
|
|
|
30
31
|
'1.0.3-01': _MigrateAutoLock.default,
|
|
31
32
|
'1.0.3-02': _MigrateChainPatrol.default,
|
|
32
33
|
'1.0.9-01': _MigrateLedgerAccount.default,
|
|
33
|
-
'1.0.12-02': _MigrateEthProvider.default
|
|
34
|
+
'1.0.12-02': _MigrateEthProvider.default,
|
|
35
|
+
'1.1.6-01': _MigrateWalletReference.default
|
|
34
36
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
35
37
|
};
|
|
36
38
|
exports.default = _default;
|
|
@@ -35,6 +35,7 @@ const DEFAULT_SETTING = {
|
|
|
35
35
|
theme: DEFAULT_THEME,
|
|
36
36
|
camera: DEFAULT_CAMERA_ENABLE,
|
|
37
37
|
timeAutoLock: DEFAULT_AUTO_LOCK_TIME,
|
|
38
|
-
enableChainPatrol: DEFAULT_CHAIN_PATROL_ENABLE
|
|
38
|
+
enableChainPatrol: DEFAULT_CHAIN_PATROL_ENABLE,
|
|
39
|
+
walletReference: ''
|
|
39
40
|
};
|
|
40
41
|
exports.DEFAULT_SETTING = DEFAULT_SETTING;
|
|
@@ -14,11 +14,11 @@ class NftStore extends _BaseStoreWithAddressAndChain.default {
|
|
|
14
14
|
getNft(addresses) {
|
|
15
15
|
let chainList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
16
16
|
if (addresses.length) {
|
|
17
|
-
return this.table.where('address').anyOfIgnoreCase(addresses).and(item =>
|
|
17
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => chainList && chainList.includes(item.chain)).toArray();
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// return this.table.filter((item) => !chainHashes.length || chainHashes.includes(item.chainHash)).toArray();
|
|
21
|
-
return this.table.filter(item =>
|
|
21
|
+
return this.table.filter(item => chainList && chainList.includes(item.chain)).toArray();
|
|
22
22
|
}
|
|
23
23
|
subscribeNft(addresses) {
|
|
24
24
|
let chainList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
@@ -18,9 +18,9 @@ class StakingStore extends _BaseStoreWithAddressAndChain.default {
|
|
|
18
18
|
getStakings(addresses) {
|
|
19
19
|
let chainList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
20
20
|
if (addresses.length) {
|
|
21
|
-
return this.table.where('address').anyOfIgnoreCase(addresses).and(item =>
|
|
21
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => chainList && chainList.includes(item.chain) && parseFloat(item.balance) > 0).toArray();
|
|
22
22
|
}
|
|
23
|
-
return this.table.filter(item =>
|
|
23
|
+
return this.table.filter(item => chainList && chainList.includes(item.chain) && parseFloat(item.balance) > 0).toArray();
|
|
24
24
|
}
|
|
25
25
|
getStakingsByChains(chainList) {
|
|
26
26
|
return this.table.filter(item => chainList.includes(item.chain) && parseFloat(item.balance) > 0).toArray();
|
package/koni/api/nft/config.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const GATEWAY_IPFS_IO = "https://gateway.ipfs.io/ipfs/";
|
|
|
20
20
|
export declare const DWEB_LINK = "https://dweb.link/ipfs/";
|
|
21
21
|
export declare const IPFS_GATEWAY_4EVERLAND = "https://4everland.io/ipfs/";
|
|
22
22
|
export declare const IPFS_FLEEK = "https://ipfs.fleek.co/ipfs/";
|
|
23
|
-
export declare const IPFS_HARDBIN = "https://hardbin.com/ipfs";
|
|
23
|
+
export declare const IPFS_HARDBIN = "https://hardbin.com/ipfs/";
|
|
24
24
|
export declare enum SUPPORTED_NFT_NETWORKS {
|
|
25
25
|
karura = "karura",
|
|
26
26
|
acala = "acala",
|
package/koni/api/nft/config.js
CHANGED
|
@@ -24,7 +24,7 @@ export const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
|
24
24
|
export const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
25
25
|
export const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
26
26
|
export const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
27
|
-
export const IPFS_HARDBIN = 'https://hardbin.com/ipfs';
|
|
27
|
+
export const IPFS_HARDBIN = 'https://hardbin.com/ipfs/';
|
|
28
28
|
export let SUPPORTED_NFT_NETWORKS;
|
|
29
29
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
30
30
|
SUPPORTED_NFT_NETWORKS["karura"] = "karura";
|
|
@@ -199,23 +199,24 @@ export async function getAmplitudeCollatorsInfo(chain, substrateApi) {
|
|
|
199
199
|
const delegatorReturn = parseFloat(rawDelegatorReturn.split('%')[0]);
|
|
200
200
|
const allCollators = [];
|
|
201
201
|
for (const _collator of _allCollators) {
|
|
202
|
-
const collatorInfo = _collator[1].
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
202
|
+
const collatorInfo = _collator[1].toPrimitive();
|
|
203
|
+
const bnTotalStake = new BN(collatorInfo.total);
|
|
204
|
+
const bnOwnStake = new BN(collatorInfo.stake);
|
|
205
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
206
|
+
allCollators.push({
|
|
207
|
+
address: collatorInfo.id,
|
|
208
|
+
totalStake: bnTotalStake.toString(),
|
|
209
|
+
ownStake: bnOwnStake.toString(),
|
|
210
|
+
otherStake: bnOtherStake.toString(),
|
|
211
|
+
nominatorCount: collatorInfo.delegators.length,
|
|
212
|
+
commission: 0,
|
|
213
|
+
expectedReturn: delegatorReturn,
|
|
214
|
+
blocked: false,
|
|
215
|
+
isVerified: false,
|
|
216
|
+
minBond: '0',
|
|
217
|
+
chain,
|
|
218
|
+
isCrowded: collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator)
|
|
219
|
+
});
|
|
219
220
|
}
|
|
220
221
|
return allCollators;
|
|
221
222
|
}
|
|
@@ -26,7 +26,7 @@ export function validateParaChainUnbondingCondition(amount, nominatorMetadata, c
|
|
|
26
26
|
const bnRemainingStake = bnActiveStake.sub(new BN(amount));
|
|
27
27
|
const bnChainMinStake = new BN(chainStakingMetadata.minStake || '0');
|
|
28
28
|
const bnCollatorMinStake = new BN(targetNomination.validatorMinStake || '0');
|
|
29
|
-
const bnMinStake = bnCollatorMinStake
|
|
29
|
+
const bnMinStake = BN.max(bnCollatorMinStake, bnChainMinStake);
|
|
30
30
|
if (targetNomination.hasUnstaking) {
|
|
31
31
|
errors.push(new TransactionError(StakingTxErrorType.EXIST_UNSTAKING_REQUEST));
|
|
32
32
|
}
|
|
@@ -83,9 +83,10 @@ export function validateParaChainBondingCondition(chainInfo, amount, selectedCol
|
|
|
83
83
|
}
|
|
84
84
|
export function subscribeParaChainStakingMetadata(chain, substrateApi, callback) {
|
|
85
85
|
return substrateApi.api.query.parachainStaking.round(_round => {
|
|
86
|
+
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$con3;
|
|
86
87
|
const roundObj = _round.toHuman();
|
|
87
88
|
const round = parseRawNumber(roundObj.current);
|
|
88
|
-
const maxDelegations = substrateApi.api.consts.parachainStaking.maxDelegationsPerDelegator.toString();
|
|
89
|
+
const maxDelegations = (_substrateApi$api$con = substrateApi.api.consts) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.parachainStaking) === null || _substrateApi$api$con2 === void 0 ? void 0 : (_substrateApi$api$con3 = _substrateApi$api$con2.maxDelegationsPerDelegator) === null || _substrateApi$api$con3 === void 0 ? void 0 : _substrateApi$api$con3.toString();
|
|
89
90
|
const unstakingDelay = substrateApi.api.consts.parachainStaking.delegationBondLessDelay.toString();
|
|
90
91
|
const unstakingPeriod = parseInt(unstakingDelay) * (_STAKING_ERA_LENGTH_MAP[chain] || _STAKING_ERA_LENGTH_MAP.default);
|
|
91
92
|
callback(chain, {
|
|
@@ -314,17 +315,21 @@ export async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
314
315
|
const _collatorAddress = collator[0].toHuman();
|
|
315
316
|
const collatorAddress = _collatorAddress[0];
|
|
316
317
|
const collatorInfo = collator[1].toPrimitive();
|
|
318
|
+
const bnTotalStake = new BN(collatorInfo.totalCounted);
|
|
319
|
+
const bnOwnStake = new BN(collatorInfo.bond);
|
|
320
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
321
|
+
const bnMinBond = new BN(collatorInfo.lowestTopDelegationAmount);
|
|
317
322
|
allCollators.push({
|
|
318
323
|
commission: 0,
|
|
319
324
|
expectedReturn: 0,
|
|
320
325
|
address: collatorAddress,
|
|
321
|
-
totalStake:
|
|
322
|
-
ownStake:
|
|
323
|
-
otherStake:
|
|
326
|
+
totalStake: bnTotalStake.toString(),
|
|
327
|
+
ownStake: bnOwnStake.toString(),
|
|
328
|
+
otherStake: bnOtherStake.toString(),
|
|
324
329
|
nominatorCount: collatorInfo.delegationCount,
|
|
325
330
|
blocked: false,
|
|
326
331
|
isVerified: false,
|
|
327
|
-
minBond:
|
|
332
|
+
minBond: bnMinBond.toString(),
|
|
328
333
|
chain,
|
|
329
334
|
isCrowded: parseInt(maxDelegationPerCollator) > 0
|
|
330
335
|
});
|
|
@@ -336,10 +341,6 @@ export async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
336
341
|
]);
|
|
337
342
|
const rawInfo = _info.toHuman();
|
|
338
343
|
const rawIdentity = _identity ? _identity.toHuman() : null;
|
|
339
|
-
const rawBond = rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.bond;
|
|
340
|
-
const bond = new BN(rawBond.replaceAll(',', ''));
|
|
341
|
-
const delegationCount = parseRawNumber(rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.delegationCount);
|
|
342
|
-
const minDelegation = parseRawNumber(rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.lowestTopDelegationAmount);
|
|
343
344
|
const active = (rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.status) === 'Active';
|
|
344
345
|
let isReasonable = false;
|
|
345
346
|
let identity;
|
|
@@ -351,21 +352,14 @@ export async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
351
352
|
extraInfoMap[collator.address] = {
|
|
352
353
|
identity,
|
|
353
354
|
isVerified: isReasonable,
|
|
354
|
-
bond: bond.toString(),
|
|
355
|
-
minDelegation: minDelegation.toString(),
|
|
356
|
-
delegationCount,
|
|
357
355
|
active
|
|
358
356
|
};
|
|
359
357
|
}));
|
|
360
358
|
for (const validator of allCollators) {
|
|
361
|
-
validator.minBond = extraInfoMap[validator.address].minDelegation.toString();
|
|
362
|
-
validator.ownStake = extraInfoMap[validator.address].bond.toString();
|
|
363
359
|
validator.blocked = !extraInfoMap[validator.address].active;
|
|
364
360
|
validator.identity = extraInfoMap[validator.address].identity;
|
|
365
361
|
validator.isVerified = extraInfoMap[validator.address].isVerified;
|
|
366
362
|
// @ts-ignore
|
|
367
|
-
validator.otherStake = (validator.totalStake - validator.ownStake).toString();
|
|
368
|
-
validator.nominatorCount = extraInfoMap[validator.address].delegationCount;
|
|
369
363
|
validator.commission = collatorCommission;
|
|
370
364
|
}
|
|
371
365
|
return allCollators;
|
|
@@ -38,10 +38,10 @@ export interface ParachainStakingStakeOption {
|
|
|
38
38
|
amount: number;
|
|
39
39
|
}
|
|
40
40
|
export interface ParachainStakingCandidateMetadata {
|
|
41
|
-
bond:
|
|
41
|
+
bond: string;
|
|
42
42
|
delegationCount: number;
|
|
43
|
-
totalCounted:
|
|
44
|
-
lowestTopDelegationAmount:
|
|
43
|
+
totalCounted: string;
|
|
44
|
+
lowestTopDelegationAmount: string;
|
|
45
45
|
status: any | 'Active';
|
|
46
46
|
}
|
|
47
47
|
export declare enum PalletParachainStakingRequestType {
|
|
@@ -1371,12 +1371,20 @@ export default class KoniExtension {
|
|
|
1371
1371
|
async subscribeHistory(id, port) {
|
|
1372
1372
|
const cb = createSubscription(id, port);
|
|
1373
1373
|
const historySubject = await this.#koniState.historyService.getHistorySubject();
|
|
1374
|
-
historySubject.subscribe(
|
|
1375
|
-
|
|
1374
|
+
const subscription = historySubject.subscribe(histories => {
|
|
1375
|
+
const addresses = keyring.getAccounts().map(a => a.address.toLowerCase());
|
|
1376
|
+
|
|
1377
|
+
// Re-filter
|
|
1378
|
+
cb(histories.filter(item => addresses.includes(item.address.toLowerCase())));
|
|
1379
|
+
});
|
|
1380
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1376
1381
|
port.onDisconnect.addListener(() => {
|
|
1377
1382
|
this.cancelSubscription(id);
|
|
1378
1383
|
});
|
|
1379
|
-
|
|
1384
|
+
const addresses = keyring.getAccounts().map(a => a.address.toLowerCase());
|
|
1385
|
+
|
|
1386
|
+
// Re-filter
|
|
1387
|
+
return historySubject.getValue().filter(item => addresses.includes(item.address.toLowerCase()));
|
|
1380
1388
|
}
|
|
1381
1389
|
|
|
1382
1390
|
// Save address to contact
|
|
@@ -843,11 +843,7 @@ export default class KoniTabs {
|
|
|
843
843
|
return true;
|
|
844
844
|
}
|
|
845
845
|
isEvmPublicRequest(type, request) {
|
|
846
|
-
|
|
847
|
-
return true;
|
|
848
|
-
} else {
|
|
849
|
-
return false;
|
|
850
|
-
}
|
|
846
|
+
return type === 'evm(request)' && ['eth_chainId', 'net_version'].includes(request === null || request === void 0 ? void 0 : request.method);
|
|
851
847
|
}
|
|
852
848
|
async addPspToken(id, url, {
|
|
853
849
|
genesisHash,
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.6-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -695,6 +695,11 @@
|
|
|
695
695
|
"require": "./cjs/services/migration-service/scripts/MigrateTransactionHistory.js",
|
|
696
696
|
"default": "./services/migration-service/scripts/MigrateTransactionHistory.js"
|
|
697
697
|
},
|
|
698
|
+
"./services/migration-service/scripts/MigrateWalletReference": {
|
|
699
|
+
"types": "./services/migration-service/scripts/MigrateWalletReference.d.ts",
|
|
700
|
+
"require": "./cjs/services/migration-service/scripts/MigrateWalletReference.js",
|
|
701
|
+
"default": "./services/migration-service/scripts/MigrateWalletReference.js"
|
|
702
|
+
},
|
|
698
703
|
"./services/notification-service/NotificationService": {
|
|
699
704
|
"types": "./services/notification-service/NotificationService.d.ts",
|
|
700
705
|
"require": "./cjs/services/notification-service/NotificationService.js",
|
|
@@ -1183,11 +1188,11 @@
|
|
|
1183
1188
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1184
1189
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1185
1190
|
"@substrate/connect": "^0.7.26",
|
|
1186
|
-
"@subwallet/chain-list": "
|
|
1187
|
-
"@subwallet/extension-base": "^1.1.
|
|
1188
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1189
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1190
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1191
|
+
"@subwallet/chain-list": "0.2.9-beta.1",
|
|
1192
|
+
"@subwallet/extension-base": "^1.1.6-1",
|
|
1193
|
+
"@subwallet/extension-chains": "^1.1.6-1",
|
|
1194
|
+
"@subwallet/extension-dapp": "^1.1.6-1",
|
|
1195
|
+
"@subwallet/extension-inject": "^1.1.6-1",
|
|
1191
1196
|
"@subwallet/keyring": "^0.0.10",
|
|
1192
1197
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1193
1198
|
"@walletconnect/sign-client": "^2.8.4",
|
|
@@ -1212,8 +1217,9 @@
|
|
|
1212
1217
|
"json-rpc-engine": "^6.1.0",
|
|
1213
1218
|
"manta-extension-sdk": "^1.1.0",
|
|
1214
1219
|
"moment": "^2.29.4",
|
|
1215
|
-
"protobufjs": "^7.
|
|
1220
|
+
"protobufjs": "^7.2.4",
|
|
1216
1221
|
"rxjs": "^7.8.1",
|
|
1222
|
+
"uuid": "^9.0.0",
|
|
1217
1223
|
"web3": "^1.10.0",
|
|
1218
1224
|
"web3-core": "^1.10.0",
|
|
1219
1225
|
"web3-core-helpers": "^1.10.0",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.6-1'
|
|
11
11
|
};
|
|
@@ -12,12 +12,13 @@ export declare class SubWalletEvmProvider extends SafeEventEmitter implements Ev
|
|
|
12
12
|
readonly version: string;
|
|
13
13
|
protected sendMessage: SendRequest;
|
|
14
14
|
protected _connected: boolean;
|
|
15
|
-
protected _subscribed: boolean;
|
|
16
15
|
constructor(sendMessage: SendRequest, version: string);
|
|
17
16
|
get connected(): boolean;
|
|
18
17
|
isConnected(): boolean;
|
|
19
18
|
protected subscribeExtensionEvents(): void;
|
|
20
19
|
enable(): Promise<unknown>;
|
|
20
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
21
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
21
22
|
request<T>({ method, params }: RequestArguments): Promise<T>;
|
|
22
23
|
private _sendSync;
|
|
23
24
|
send<T>(method: string, params?: T[]): Promise<JsonRpcResponse<T>>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import SafeEventEmitter from '@metamask/safe-event-emitter';
|
|
5
|
+
let subscribeFlag = false;
|
|
5
6
|
export class SubWalletEvmProvider extends SafeEventEmitter {
|
|
6
7
|
isSubWallet = true;
|
|
7
8
|
isMetaMask = false;
|
|
8
9
|
_connected = false;
|
|
9
|
-
_subscribed = false;
|
|
10
10
|
constructor(sendMessage, version) {
|
|
11
11
|
super();
|
|
12
12
|
this.version = version;
|
|
@@ -20,7 +20,7 @@ export class SubWalletEvmProvider extends SafeEventEmitter {
|
|
|
20
20
|
return this._connected;
|
|
21
21
|
}
|
|
22
22
|
subscribeExtensionEvents() {
|
|
23
|
-
if (
|
|
23
|
+
if (subscribeFlag) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
this.sendMessage('evm(events.subscribe)', null, ({
|
|
@@ -41,18 +41,32 @@ export class SubWalletEvmProvider extends SafeEventEmitter {
|
|
|
41
41
|
console.warn('Can not handle event', type, payload);
|
|
42
42
|
}
|
|
43
43
|
}).then(done => {
|
|
44
|
-
|
|
45
|
-
}).catch(
|
|
44
|
+
subscribeFlag = true;
|
|
45
|
+
}).catch(() => {
|
|
46
|
+
subscribeFlag = false;
|
|
47
|
+
});
|
|
48
|
+
subscribeFlag = true;
|
|
46
49
|
}
|
|
47
50
|
async enable() {
|
|
48
51
|
return this.request({
|
|
49
52
|
method: 'eth_requestAccounts'
|
|
50
53
|
});
|
|
51
54
|
}
|
|
55
|
+
on(eventName, listener) {
|
|
56
|
+
this.subscribeExtensionEvents();
|
|
57
|
+
super.on(eventName, listener);
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
once(eventName, listener) {
|
|
61
|
+
this.subscribeExtensionEvents();
|
|
62
|
+
super.once(eventName, listener);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
52
65
|
request({
|
|
53
66
|
method,
|
|
54
67
|
params
|
|
55
68
|
}) {
|
|
69
|
+
// Subscribe events
|
|
56
70
|
switch (method) {
|
|
57
71
|
case 'eth_requestAccounts':
|
|
58
72
|
return new Promise((resolve, reject) => {
|
|
@@ -61,9 +75,6 @@ export class SubWalletEvmProvider extends SafeEventEmitter {
|
|
|
61
75
|
origin,
|
|
62
76
|
accountAuthType: 'evm'
|
|
63
77
|
}).then(() => {
|
|
64
|
-
// Subscribe event
|
|
65
|
-
this.subscribeExtensionEvents();
|
|
66
|
-
|
|
67
78
|
// Return account list
|
|
68
79
|
this.request({
|
|
69
80
|
method: 'eth_accounts'
|
|
@@ -49,13 +49,13 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
49
49
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
50
50
|
|
|
51
51
|
export const _STAKING_CHAIN_GROUP = {
|
|
52
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend'],
|
|
52
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware'],
|
|
53
53
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
54
54
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
55
55
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
56
56
|
// amplitude and kilt only share some common logic
|
|
57
57
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
58
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph'],
|
|
58
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate'],
|
|
59
59
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
60
60
|
aleph: ['aleph', 'alephTest'],
|
|
61
61
|
// A0 has distinct tokenomics
|
|
@@ -87,7 +87,9 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
87
87
|
amplitude_test: 2,
|
|
88
88
|
pendulum: 2,
|
|
89
89
|
kilt: 2,
|
|
90
|
-
kilt_peregrine: 2
|
|
90
|
+
kilt_peregrine: 2,
|
|
91
|
+
edgeware: 6,
|
|
92
|
+
kate: 6
|
|
91
93
|
};
|
|
92
94
|
export const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
93
95
|
moonbeam: {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
export default class MigrateWalletReference extends BaseMigrationJob {
|
|
7
|
+
async run() {
|
|
8
|
+
try {
|
|
9
|
+
return new Promise(resolve => {
|
|
10
|
+
this.state.settingService.getSettings(currentSettings => {
|
|
11
|
+
const walletReference = uuidv4();
|
|
12
|
+
this.state.settingService.setSettings({
|
|
13
|
+
...currentSettings,
|
|
14
|
+
walletReference: walletReference
|
|
15
|
+
});
|
|
16
|
+
resolve();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -11,6 +11,7 @@ import MigrateLedgerAccount from "./MigrateLedgerAccount.js";
|
|
|
11
11
|
import MigrateNetworkSettings from "./MigrateNetworkSettings.js";
|
|
12
12
|
import MigrateSettings from "./MigrateSettings.js";
|
|
13
13
|
import MigrateTransactionHistory from "./MigrateTransactionHistory.js";
|
|
14
|
+
import MigrateWalletReference from "./MigrateWalletReference.js";
|
|
14
15
|
export const EVERYTIME = '__everytime__';
|
|
15
16
|
export default {
|
|
16
17
|
'1.0.1-11': MigrateNetworkSettings,
|
|
@@ -22,6 +23,7 @@ export default {
|
|
|
22
23
|
'1.0.3-01': MigrateAutoLock,
|
|
23
24
|
'1.0.3-02': MigrateChainPatrol,
|
|
24
25
|
'1.0.9-01': MigrateLedgerAccount,
|
|
25
|
-
'1.0.12-02': MigrateEthProvider
|
|
26
|
+
'1.0.12-02': MigrateEthProvider,
|
|
27
|
+
'1.1.6-01': MigrateWalletReference
|
|
26
28
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
27
29
|
};
|
|
@@ -6,11 +6,11 @@ import { liveQuery } from 'dexie';
|
|
|
6
6
|
export default class NftStore extends BaseStoreWithAddressAndChain {
|
|
7
7
|
getNft(addresses, chainList = []) {
|
|
8
8
|
if (addresses.length) {
|
|
9
|
-
return this.table.where('address').anyOfIgnoreCase(addresses).and(item =>
|
|
9
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => chainList && chainList.includes(item.chain)).toArray();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
// return this.table.filter((item) => !chainHashes.length || chainHashes.includes(item.chainHash)).toArray();
|
|
13
|
-
return this.table.filter(item =>
|
|
13
|
+
return this.table.filter(item => chainList && chainList.includes(item.chain)).toArray();
|
|
14
14
|
}
|
|
15
15
|
subscribeNft(addresses, chainList = []) {
|
|
16
16
|
return liveQuery(() => this.getNft(addresses, chainList));
|
|
@@ -10,9 +10,9 @@ export default class StakingStore extends BaseStoreWithAddressAndChain {
|
|
|
10
10
|
}
|
|
11
11
|
getStakings(addresses, chainList = []) {
|
|
12
12
|
if (addresses.length) {
|
|
13
|
-
return this.table.where('address').anyOfIgnoreCase(addresses).and(item =>
|
|
13
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => chainList && chainList.includes(item.chain) && parseFloat(item.balance) > 0).toArray();
|
|
14
14
|
}
|
|
15
|
-
return this.table.filter(item =>
|
|
15
|
+
return this.table.filter(item => chainList && chainList.includes(item.chain) && parseFloat(item.balance) > 0).toArray();
|
|
16
16
|
}
|
|
17
17
|
getStakingsByChains(chainList) {
|
|
18
18
|
return this.table.filter(item => chainList.includes(item.chain) && parseFloat(item.balance) > 0).toArray();
|