@subwallet/extension-base 1.0.1 → 1.0.2-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 +10 -3
- package/background/KoniTypes.js +6 -0
- package/cjs/background/KoniTypes.js +8 -1
- package/cjs/constants/index.js +6 -3
- package/cjs/koni/api/dotsama/balance.js +11 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +6 -2
- package/cjs/koni/api/staking/bonding/astar.js +40 -243
- package/cjs/koni/api/staking/bonding/index.js +4 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +16 -10
- package/cjs/koni/api/staking/bonding/relayChain.js +62 -7
- package/cjs/koni/api/staking/bonding/utils.js +29 -3
- package/cjs/koni/api/xcm/index.js +0 -111
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/xTokens.js +2 -4
- package/cjs/koni/background/cron.js +61 -62
- package/cjs/koni/background/handlers/Extension.js +143 -149
- package/cjs/koni/background/handlers/State.js +129 -91
- package/cjs/koni/background/handlers/Tabs.js +40 -38
- package/cjs/koni/background/subscription.js +48 -43
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +5 -0
- package/cjs/services/chain-service/constants.js +1 -11
- package/cjs/services/chain-service/index.js +39 -5
- package/cjs/services/chain-service/utils.js +4 -0
- package/cjs/services/event-service/index.js +71 -0
- package/cjs/services/event-service/types.js +1 -0
- package/cjs/services/history-service/index.js +36 -17
- package/cjs/services/history-service/subsquid-multi-chain-history.js +7 -2
- package/cjs/services/keyring-service/index.js +101 -0
- package/cjs/services/migration-service/index.js +13 -10
- package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
- package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
- package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
- package/cjs/services/migration-service/scripts/index.js +13 -4
- package/cjs/services/price-service/coingecko.js +16 -3
- package/cjs/services/price-service/index.js +15 -17
- package/cjs/services/request-service/constants.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +39 -12
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/storage-service/DatabaseService.js +1 -1
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/cjs/services/storage-service/db-stores/Nft.js +4 -1
- package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
- package/cjs/services/subscan-service/index.js +107 -0
- package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
- package/cjs/services/subscan-service/types.js +1 -0
- package/cjs/services/transaction-service/index.js +45 -10
- package/cjs/services/transaction-service/utils.js +4 -6
- package/cjs/utils/address.js +9 -1
- package/cjs/utils/index.js +24 -13
- package/constants/index.d.ts +1 -0
- package/constants/index.js +1 -0
- package/koni/api/dotsama/balance.js +11 -0
- package/koni/api/staking/bonding/amplitude.d.ts +1 -1
- package/koni/api/staking/bonding/amplitude.js +8 -4
- package/koni/api/staking/bonding/astar.d.ts +2 -11
- package/koni/api/staking/bonding/astar.js +35 -229
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +4 -4
- package/koni/api/staking/bonding/paraChain.d.ts +1 -1
- package/koni/api/staking/bonding/paraChain.js +17 -11
- package/koni/api/staking/bonding/relayChain.d.ts +1 -1
- package/koni/api/staking/bonding/relayChain.js +63 -8
- package/koni/api/staking/bonding/utils.d.ts +13 -1
- package/koni/api/staking/bonding/utils.js +27 -3
- package/koni/api/xcm/index.js +1 -112
- package/koni/api/xcm/polkadotXcm.js +1 -1
- package/koni/api/xcm/xTokens.js +3 -5
- package/koni/background/cron.js +60 -60
- package/koni/background/handlers/Extension.js +71 -76
- package/koni/background/handlers/State.d.ts +16 -14
- package/koni/background/handlers/State.js +126 -91
- package/koni/background/handlers/Tabs.js +22 -19
- package/koni/background/subscription.d.ts +1 -1
- package/koni/background/subscription.js +49 -44
- package/package.json +56 -16
- package/packageInfo.js +1 -1
- package/page/index.d.ts +2 -0
- package/page/index.js +4 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +0 -9
- package/services/chain-service/index.d.ts +6 -4
- package/services/chain-service/index.js +39 -7
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +3 -0
- package/services/event-service/index.d.ts +22 -0
- package/services/event-service/index.js +59 -0
- package/services/event-service/types.d.ts +32 -0
- package/services/event-service/types.js +1 -0
- package/services/history-service/index.d.ts +5 -3
- package/services/history-service/index.js +36 -17
- package/services/history-service/subsquid-multi-chain-history.js +7 -2
- package/services/keyring-service/index.d.ts +19 -0
- package/services/keyring-service/index.js +93 -0
- package/services/migration-service/index.js +11 -9
- package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
- package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
- package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
- package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
- package/services/migration-service/scripts/MigrateSettings.js +23 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +10 -3
- package/services/price-service/coingecko.js +16 -3
- package/services/price-service/index.d.ts +5 -3
- package/services/price-service/index.js +15 -17
- package/services/request-service/constants.d.ts +1 -0
- package/services/request-service/constants.js +6 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
- package/services/request-service/handler/AuthRequestHandler.js +40 -13
- package/services/request-service/index.d.ts +7 -1
- package/services/request-service/index.js +3 -0
- package/services/storage-service/DatabaseService.js +1 -1
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/services/storage-service/db-stores/Nft.d.ts +2 -1
- package/services/storage-service/db-stores/Nft.js +4 -1
- package/services/storage-service/db-stores/Transaction.js +10 -7
- package/services/subscan-service/index.d.ts +20 -0
- package/services/subscan-service/index.js +99 -0
- package/services/subscan-service/subscan-chain-map.d.ts +5 -0
- package/services/subscan-service/subscan-chain-map.js +63 -0
- package/services/subscan-service/types.d.ts +27 -0
- package/services/subscan-service/types.js +1 -0
- package/services/transaction-service/event-parser/index.d.ts +2 -2
- package/services/transaction-service/index.d.ts +4 -2
- package/services/transaction-service/index.js +45 -10
- package/services/transaction-service/utils.js +5 -6
- package/utils/address.d.ts +1 -0
- package/utils/address.js +9 -2
- package/utils/index.d.ts +1 -0
- package/utils/index.js +21 -12
- package/cjs/background/errors/EvmRpcError.js +0 -21
- package/cjs/background/errors/SubWalletProviderError.js +0 -17
- package/cjs/constants/ethereum.js +0 -19
- package/cjs/errors/SubWalletProviderError.js +0 -17
- package/cjs/koni/api/xcm/astar.js +0 -160
- package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
- package/cjs/koni/api/xcm/statemintXcm.js +0 -197
- package/cjs/koni/api/xcm/substrateXcm.js +0 -213
- package/cjs/koni/migration/Base.js +0 -20
- package/cjs/koni/migration/index.js +0 -45
- package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
- package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
- package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
- package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
- package/cjs/koni/migration/scripts/index.js +0 -22
- package/cjs/koni/page/index.js +0 -16
- package/cjs/services/asset-service/index.js +0 -91
- package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
- package/cjs/stores/Balance.js +0 -18
- package/cjs/stores/Crowdloan.js +0 -18
- package/cjs/stores/CustomEvmToken.js +0 -18
- package/cjs/stores/NetworkMap.js +0 -18
- package/cjs/stores/Nft.js +0 -18
- package/cjs/stores/NftCollection.js +0 -18
- package/cjs/stores/Price.js +0 -18
- package/cjs/stores/Staking.js +0 -18
- package/cjs/stores/StakingReward.js +0 -18
- package/cjs/utils/eth/parseTransactionData.js +0 -284
- package/koni/page/index.d.ts +0 -2
- package/koni/page/index.js +0 -9
- /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
|
@@ -19,6 +19,8 @@ exports.getRelayWithdrawalExtrinsic = getRelayWithdrawalExtrinsic;
|
|
|
19
19
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
20
20
|
var _utils = require("@subwallet/extension-base/koni/api/staking/bonding/utils");
|
|
21
21
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
22
|
+
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
23
|
+
var _utils3 = require("@subwallet/extension-base/utils");
|
|
22
24
|
var _util = require("@polkadot/util");
|
|
23
25
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
24
26
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -66,30 +68,51 @@ async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi)
|
|
|
66
68
|
const chain = chainInfo.slug;
|
|
67
69
|
const chainApi = await substrateApi.isReady;
|
|
68
70
|
const [_ledger, _nominations, _currentEra, _bonded] = await Promise.all([chainApi.api.query.staking.ledger(address), chainApi.api.query.staking.nominators(address), chainApi.api.query.staking.currentEra(), chainApi.api.query.staking.bonded(address)]);
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
+
const _maxNominatorRewardedPerValidator = chainApi.api.consts.staking.maxNominatorRewardedPerValidator.toString();
|
|
72
|
+
const maxNominatorRewardedPerValidator = parseInt(_maxNominatorRewardedPerValidator);
|
|
73
|
+
const ledger = _ledger.toPrimitive();
|
|
74
|
+
const nominations = _nominations.toPrimitive();
|
|
71
75
|
const currentEra = _currentEra.toString();
|
|
72
76
|
const bonded = _bonded.toHuman();
|
|
73
77
|
if (!ledger) {
|
|
74
78
|
return;
|
|
75
79
|
}
|
|
80
|
+
let stakingStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
76
81
|
const activeStake = ledger.active.toString();
|
|
77
82
|
const nominationList = [];
|
|
78
83
|
const unstakingList = [];
|
|
79
84
|
if (nominations) {
|
|
80
85
|
const validatorList = nominations.targets;
|
|
81
86
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
82
|
-
|
|
87
|
+
let nominationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
88
|
+
const [_identityInfo, _eraStaker] = await Promise.all([chainApi.api.query.identity.identityOf(validatorAddress), chainApi.api.query.staking.erasStakers(currentEra, validatorAddress)]);
|
|
89
|
+
const eraStaker = _eraStaker.toPrimitive();
|
|
90
|
+
const identityInfo = _identityInfo.toHuman();
|
|
83
91
|
const identity = (0, _utils.parseIdentity)(identityInfo);
|
|
92
|
+
const topNominators = eraStaker.others.map(nominator => {
|
|
93
|
+
return nominator.who;
|
|
94
|
+
});
|
|
95
|
+
if (topNominators.slice(0, maxNominatorRewardedPerValidator).includes((0, _utils3.reformatAddress)(address, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo)))) {
|
|
96
|
+
// if address in top nominators
|
|
97
|
+
nominationStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
98
|
+
}
|
|
84
99
|
nominationList.push({
|
|
85
100
|
chain,
|
|
86
101
|
validatorAddress,
|
|
102
|
+
status: nominationStatus,
|
|
87
103
|
validatorIdentity: identity,
|
|
88
104
|
activeStake: '0' // relaychain allocates stake accordingly
|
|
89
105
|
});
|
|
90
106
|
}));
|
|
91
107
|
}
|
|
92
108
|
|
|
109
|
+
for (const nomination of nominationList) {
|
|
110
|
+
if (nomination.status === _KoniTypes.StakingStatus.EARNING_REWARD) {
|
|
111
|
+
// only need 1 earning nomination to count
|
|
112
|
+
stakingStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
93
116
|
ledger.unlocking.forEach(unlockingChunk => {
|
|
94
117
|
const isClaimable = unlockingChunk.era - parseInt(currentEra) <= 0;
|
|
95
118
|
const remainingEra = unlockingChunk.era - (parseInt(currentEra) + 1);
|
|
@@ -104,6 +127,7 @@ async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi)
|
|
|
104
127
|
return {
|
|
105
128
|
chain,
|
|
106
129
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
130
|
+
status: stakingStatus,
|
|
107
131
|
address: address,
|
|
108
132
|
activeStake,
|
|
109
133
|
nominations: nominationList,
|
|
@@ -114,17 +138,39 @@ async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi)
|
|
|
114
138
|
async function getRelayChainPoolMemberMetadata(chainInfo, address, substrateApi) {
|
|
115
139
|
const chainApi = await substrateApi.isReady;
|
|
116
140
|
const [_poolMemberInfo, _currentEra] = await Promise.all([chainApi.api.query.nominationPools.poolMembers(address), chainApi.api.query.staking.currentEra()]);
|
|
141
|
+
const _maxNominatorRewardedPerValidator = chainApi.api.consts.staking.maxNominatorRewardedPerValidator.toString();
|
|
142
|
+
const maxNominatorRewardedPerValidator = parseInt(_maxNominatorRewardedPerValidator);
|
|
143
|
+
const poolsPalletId = chainApi.api.consts.nominationPools.palletId.toString();
|
|
117
144
|
const poolMemberInfo = _poolMemberInfo.toPrimitive();
|
|
118
145
|
const currentEra = _currentEra.toString();
|
|
119
146
|
if (!poolMemberInfo) {
|
|
120
147
|
return;
|
|
121
148
|
}
|
|
149
|
+
let stakingStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
122
150
|
const _poolMetadata = await chainApi.api.query.nominationPools.metadata(poolMemberInfo.poolId);
|
|
123
151
|
const poolMetadata = _poolMetadata.toPrimitive();
|
|
124
152
|
const poolName = (0, _utils.transformPoolName)(poolMetadata.isUtf8 ? poolMetadata.toUtf8() : poolMetadata.toString());
|
|
153
|
+
const poolStashAccount = (0, _utils.parsePoolStashAddress)(chainApi.api, 0, poolMemberInfo.poolId, poolsPalletId);
|
|
154
|
+
const _nominations = await chainApi.api.query.staking.nominators(poolStashAccount);
|
|
155
|
+
const nominations = _nominations.toJSON();
|
|
156
|
+
if (nominations) {
|
|
157
|
+
const validatorList = nominations.targets;
|
|
158
|
+
await Promise.all(validatorList.map(async validatorAddress => {
|
|
159
|
+
const _eraStaker = await chainApi.api.query.staking.erasStakers(currentEra, validatorAddress);
|
|
160
|
+
const eraStaker = _eraStaker.toPrimitive();
|
|
161
|
+
const topNominators = eraStaker.others.map(nominator => {
|
|
162
|
+
return nominator.who;
|
|
163
|
+
}).slice(0, maxNominatorRewardedPerValidator);
|
|
164
|
+
if (topNominators.includes((0, _utils3.reformatAddress)(poolStashAccount, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo)))) {
|
|
165
|
+
// if address in top nominators
|
|
166
|
+
stakingStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
125
170
|
const joinedPoolInfo = {
|
|
126
171
|
activeStake: poolMemberInfo.points.toString(),
|
|
127
172
|
chain: chainInfo.slug,
|
|
173
|
+
status: stakingStatus,
|
|
128
174
|
validatorIdentity: poolName,
|
|
129
175
|
validatorAddress: poolMemberInfo.poolId.toString(),
|
|
130
176
|
// use poolId
|
|
@@ -147,6 +193,7 @@ async function getRelayChainPoolMemberMetadata(chainInfo, address, substrateApi)
|
|
|
147
193
|
chain: chainInfo.slug,
|
|
148
194
|
type: _KoniTypes.StakingType.POOLED,
|
|
149
195
|
address,
|
|
196
|
+
status: stakingStatus,
|
|
150
197
|
activeStake: poolMemberInfo.points.toString(),
|
|
151
198
|
nominations: [joinedPoolInfo],
|
|
152
199
|
// can only join 1 pool at a time
|
|
@@ -255,23 +302,31 @@ async function getRelayPoolsInfo(chain, substrateApi) {
|
|
|
255
302
|
}));
|
|
256
303
|
return nominationPools;
|
|
257
304
|
}
|
|
258
|
-
async function getRelayBondingExtrinsic(substrateApi, amount, targetValidators,
|
|
259
|
-
let bondDest = arguments.length >
|
|
305
|
+
async function getRelayBondingExtrinsic(substrateApi, amount, targetValidators, chainInfo, address, nominatorMetadata) {
|
|
306
|
+
let bondDest = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'Staked';
|
|
260
307
|
const chainApi = await substrateApi.isReady;
|
|
261
308
|
const binaryAmount = new _util.BN(amount);
|
|
262
309
|
let bondTx;
|
|
263
310
|
let nominateTx;
|
|
311
|
+
const validatorParamList = targetValidators.map(validator => {
|
|
312
|
+
return validator.address;
|
|
313
|
+
});
|
|
314
|
+
if (!nominatorMetadata) {
|
|
315
|
+
bondTx = chainApi.api.tx.staking.bond(address, binaryAmount, bondDest);
|
|
316
|
+
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
317
|
+
return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
|
|
318
|
+
}
|
|
264
319
|
if (!nominatorMetadata.isBondedBefore) {
|
|
265
320
|
// first time
|
|
266
321
|
bondTx = chainApi.api.tx.staking.bond(nominatorMetadata.address, binaryAmount, bondDest);
|
|
267
|
-
nominateTx = chainApi.api.tx.staking.nominate(
|
|
322
|
+
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
268
323
|
return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
|
|
269
324
|
} else {
|
|
270
325
|
if (binaryAmount.gt(_util.BN_ZERO)) {
|
|
271
326
|
bondTx = chainApi.api.tx.staking.bondExtra(binaryAmount);
|
|
272
327
|
}
|
|
273
328
|
if (nominatorMetadata.isBondedBefore && targetValidators.length > 0) {
|
|
274
|
-
nominateTx = chainApi.api.tx.staking.nominate(
|
|
329
|
+
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
275
330
|
}
|
|
276
331
|
}
|
|
277
332
|
if (bondTx && !nominateTx) {
|
|
@@ -14,12 +14,14 @@ exports.getBondedValidators = getBondedValidators;
|
|
|
14
14
|
exports.getCommission = getCommission;
|
|
15
15
|
exports.getInflationParams = getInflationParams;
|
|
16
16
|
exports.getParaCurrentInflation = getParaCurrentInflation;
|
|
17
|
-
exports.
|
|
17
|
+
exports.getStakingAvailableActionsByChain = getStakingAvailableActionsByChain;
|
|
18
|
+
exports.getStakingAvailableActionsByNominator = getStakingAvailableActionsByNominator;
|
|
18
19
|
exports.getWithdrawalInfo = getWithdrawalInfo;
|
|
19
20
|
exports.isActionFromValidator = isActionFromValidator;
|
|
20
21
|
exports.isShowNominationByValidator = isShowNominationByValidator;
|
|
21
22
|
exports.isUnstakeAll = isUnstakeAll;
|
|
22
23
|
exports.parseIdentity = parseIdentity;
|
|
24
|
+
exports.parsePoolStashAddress = parsePoolStashAddress;
|
|
23
25
|
exports.transformPoolName = transformPoolName;
|
|
24
26
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
25
27
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
@@ -34,6 +36,15 @@ exports.PalletParachainStakingRequestType = PalletParachainStakingRequestType;
|
|
|
34
36
|
PalletParachainStakingRequestType["DECREASE"] = "decrease";
|
|
35
37
|
PalletParachainStakingRequestType["BOND_LESS"] = "bondLess";
|
|
36
38
|
})(PalletParachainStakingRequestType || (exports.PalletParachainStakingRequestType = PalletParachainStakingRequestType = {}));
|
|
39
|
+
function parsePoolStashAddress(api, index, poolId, poolsPalletId) {
|
|
40
|
+
const ModPrefix = (0, _util.stringToU8a)('modl');
|
|
41
|
+
const U32Opts = {
|
|
42
|
+
bitLength: 32,
|
|
43
|
+
isLe: true
|
|
44
|
+
};
|
|
45
|
+
const EmptyH256 = new Uint8Array(32);
|
|
46
|
+
return api.registry.createType('AccountId32', (0, _util.u8aConcat)(ModPrefix, poolsPalletId, new Uint8Array([index]), (0, _util.bnToU8a)(new _util.BN(poolId.toString()), U32Opts), EmptyH256)).toString();
|
|
47
|
+
}
|
|
37
48
|
function transformPoolName(input) {
|
|
38
49
|
return input.replace(/[^\x20-\x7E]/g, '');
|
|
39
50
|
}
|
|
@@ -153,7 +164,9 @@ function getBondedValidators(nominations) {
|
|
|
153
164
|
function isUnstakeAll(selectedValidator, nominations, unstakeAmount) {
|
|
154
165
|
let isUnstakeAll = false;
|
|
155
166
|
for (const nomination of nominations) {
|
|
156
|
-
|
|
167
|
+
const parsedValidatorAddress = (0, _utils.reformatAddress)(nomination.validatorAddress, 0);
|
|
168
|
+
const parsedSelectedValidator = (0, _utils.reformatAddress)(selectedValidator, 0);
|
|
169
|
+
if (parsedValidatorAddress === parsedSelectedValidator) {
|
|
157
170
|
if (unstakeAmount === nomination.activeStake) {
|
|
158
171
|
isUnstakeAll = true;
|
|
159
172
|
}
|
|
@@ -171,7 +184,20 @@ exports.StakingAction = StakingAction;
|
|
|
171
184
|
StakingAction["CLAIM_REWARD"] = "CLAIM_REWARD";
|
|
172
185
|
StakingAction["CANCEL_UNSTAKE"] = "CANCEL_UNSTAKE";
|
|
173
186
|
})(StakingAction || (exports.StakingAction = StakingAction = {}));
|
|
174
|
-
function
|
|
187
|
+
function getStakingAvailableActionsByChain(chain, type) {
|
|
188
|
+
if (type === _KoniTypes.StakingType.POOLED) {
|
|
189
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CLAIM_REWARD];
|
|
190
|
+
}
|
|
191
|
+
if (_constants._STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
192
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CANCEL_UNSTAKE];
|
|
193
|
+
} else if (_constants._STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
194
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CLAIM_REWARD];
|
|
195
|
+
} else if (_constants._STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
|
|
196
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW];
|
|
197
|
+
}
|
|
198
|
+
return [StakingAction.STAKE, StakingAction.UNSTAKE, StakingAction.WITHDRAW, StakingAction.CANCEL_UNSTAKE];
|
|
199
|
+
}
|
|
200
|
+
function getStakingAvailableActionsByNominator(nominatorMetadata) {
|
|
175
201
|
const result = [StakingAction.STAKE];
|
|
176
202
|
const bnActiveStake = new _util.BN(nominatorMetadata.activeStake);
|
|
177
203
|
if (nominatorMetadata.activeStake && bnActiveStake.gt(_util.BN_ZERO)) {
|
|
@@ -35,115 +35,4 @@ const createXcmExtrinsic = async _ref => {
|
|
|
35
35
|
console.log('XCM extrinsic: ', extrinsic.toHex());
|
|
36
36
|
return extrinsic;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
// TODO: add + refine logic for more chains
|
|
40
|
-
// export function updateXcmResponseTxResult (
|
|
41
|
-
// networkKey: string,
|
|
42
|
-
// tokenInfo: _ChainAsset,
|
|
43
|
-
// response: TransactionResponse,
|
|
44
|
-
// records: EventRecord[]
|
|
45
|
-
// ) {
|
|
46
|
-
// if (!response.txResult) {
|
|
47
|
-
// response.txResult = { change: '0' };
|
|
48
|
-
// }
|
|
49
|
-
//
|
|
50
|
-
// let isFeeUseMainTokenSymbol = true;
|
|
51
|
-
//
|
|
52
|
-
// for (let index = 0; index < records.length; index++) {
|
|
53
|
-
// const record = records[index];
|
|
54
|
-
//
|
|
55
|
-
// if (_XCM_CHAIN_GROUP.acala.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
56
|
-
// if (record.event.section === 'currencies' &&
|
|
57
|
-
// record.event.method.toLowerCase() === 'transferred') {
|
|
58
|
-
// if (index === 0) {
|
|
59
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
60
|
-
// response.txResult.fee = record.event.data[3]?.toString() || '0';
|
|
61
|
-
// response.txResult.feeSymbol = tokenInfo.symbol;
|
|
62
|
-
//
|
|
63
|
-
// isFeeUseMainTokenSymbol = false;
|
|
64
|
-
// } else {
|
|
65
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
66
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
67
|
-
// }
|
|
68
|
-
// }
|
|
69
|
-
//
|
|
70
|
-
// if (record.event.section === 'tokens' &&
|
|
71
|
-
// record.event.method.toLowerCase() === 'withdrawn') {
|
|
72
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
73
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
74
|
-
// }
|
|
75
|
-
// } else if (_XCM_CHAIN_GROUP.kintsugi.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
76
|
-
// if (record.event.section === 'tokens' &&
|
|
77
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
78
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
79
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
80
|
-
// }
|
|
81
|
-
// } else if (_XCM_CHAIN_GROUP.genshiro.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
82
|
-
// if (record.event.section === 'eqBalances' &&
|
|
83
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
84
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
85
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
86
|
-
// }
|
|
87
|
-
// } else if (_XCM_CHAIN_GROUP.bifrost.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
88
|
-
// if (record.event.section === 'tokens' &&
|
|
89
|
-
// record.event.method.toLowerCase() === 'withdrawn') {
|
|
90
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
91
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
92
|
-
// } else if (record.event.section === 'balances' &&
|
|
93
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
94
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
95
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
96
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
97
|
-
// }
|
|
98
|
-
// } else if (_XCM_CHAIN_GROUP.astar.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
99
|
-
// if (record.event.section === 'assets' &&
|
|
100
|
-
// record.event.method.toLowerCase() === 'burned') {
|
|
101
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
102
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
103
|
-
// }
|
|
104
|
-
// } else if (_XCM_CHAIN_GROUP.moonbeam.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
105
|
-
// if (record.event.section === 'assets' &&
|
|
106
|
-
// record.event.method.toLowerCase() === 'burned') {
|
|
107
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
108
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
109
|
-
// }
|
|
110
|
-
// } else if (_XCM_CHAIN_GROUP.statemine.includes(networkKey)) {
|
|
111
|
-
// if (!_isNativeToken(tokenInfo)) {
|
|
112
|
-
// if (record.event.section === 'assets' &&
|
|
113
|
-
// record.event.method.toLowerCase() === 'transferred') {
|
|
114
|
-
// response.txResult.change = record.event.data[3]?.toString() || '0';
|
|
115
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
116
|
-
// }
|
|
117
|
-
// } else {
|
|
118
|
-
// if (record.event.section === 'balances' &&
|
|
119
|
-
// record.event.method.toLowerCase() === 'withdraw') {
|
|
120
|
-
// response.txResult.change = record.event.data[1]?.toString() || '0';
|
|
121
|
-
// response.txResult.changeSymbol = tokenInfo.symbol;
|
|
122
|
-
// }
|
|
123
|
-
// }
|
|
124
|
-
// } else {
|
|
125
|
-
// if (record.event.section === 'balances' &&
|
|
126
|
-
// record.event.method.toLowerCase() === 'transfer') {
|
|
127
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
128
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
129
|
-
// } else if (record.event.section === 'xTokens' &&
|
|
130
|
-
// record.event.method.toLowerCase() === 'transferred') {
|
|
131
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
132
|
-
// response.txResult.change = record.event.data[2]?.toString() || '0';
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
//
|
|
136
|
-
// if (isFeeUseMainTokenSymbol && record.event.section === 'balances' && record.event.method.toLowerCase() === 'withdraw') {
|
|
137
|
-
// if (!response.txResult.fee) {
|
|
138
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
139
|
-
// response.txResult.fee = record.event.data[1]?.toString() || '0';
|
|
140
|
-
// }
|
|
141
|
-
// } else if (isFeeUseMainTokenSymbol && record.event.section === 'tokens' && record.event.method.toLowerCase() === 'withdrawn') {
|
|
142
|
-
// if (!response.txResult.fee) {
|
|
143
|
-
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
144
|
-
// response.txResult.fee = record.event.data[2]?.toString() || '0';
|
|
145
|
-
// }
|
|
146
|
-
// }
|
|
147
|
-
// }
|
|
148
|
-
// }
|
|
149
38
|
exports.createXcmExtrinsic = createXcmExtrinsic;
|
|
@@ -48,7 +48,7 @@ function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destination
|
|
|
48
48
|
const assetLocation = getAssetLocation(tokenInfo, value);
|
|
49
49
|
let method = 'limitedReserveTransferAssets';
|
|
50
50
|
if (['astar', 'shiden'].includes(originChainInfo.slug)) {
|
|
51
|
-
method = '
|
|
51
|
+
method = 'limitedReserveWithdrawAssets';
|
|
52
52
|
} else if ((0, _utils2._isSubstrateRelayChain)(destinationChainInfo)) {
|
|
53
53
|
method = 'limitedTeleportAssets';
|
|
54
54
|
}
|
|
@@ -11,7 +11,6 @@ var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
|
11
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
12
|
|
|
13
13
|
function getCurrencyId(tokenInfo) {
|
|
14
|
-
var _tokenInfo$metadata2;
|
|
15
14
|
if (['acala', 'karura'].includes(tokenInfo.originChain) && (0, _utils2._isNativeToken)(tokenInfo)) {
|
|
16
15
|
return (0, _utils2._getXcmAssetMultilocation)(tokenInfo);
|
|
17
16
|
} else if (['moonbeam', 'moonbase', 'moonriver'].includes(tokenInfo.originChain)) {
|
|
@@ -21,10 +20,9 @@ function getCurrencyId(tokenInfo) {
|
|
|
21
20
|
[tokenType]: assetId
|
|
22
21
|
};
|
|
23
22
|
} else if (['pioneer'].includes(tokenInfo.originChain)) {
|
|
24
|
-
|
|
25
|
-
return (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.multilocation;
|
|
23
|
+
return (0, _utils2._getXcmAssetMultilocation)(tokenInfo);
|
|
26
24
|
}
|
|
27
|
-
return (
|
|
25
|
+
return (0, _utils2._getTokenOnChainInfo)(tokenInfo);
|
|
28
26
|
}
|
|
29
27
|
function getMultiLocationForXtokensPallet(originChainInfo, destinationChainInfo, toAddress) {
|
|
30
28
|
const xcmType = (0, _utils2._getXcmTransferType)(originChainInfo, destinationChainInfo);
|
|
@@ -59,73 +59,74 @@ class KoniCron {
|
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
init = () => {
|
|
62
|
-
this.state.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
62
|
+
const currentAccountInfo = this.state.keyringService.currentAccount;
|
|
63
|
+
if (!(currentAccountInfo !== null && currentAccountInfo !== void 0 && currentAccountInfo.address)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
67
|
+
this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap());
|
|
68
|
+
this.refreshStakingReward(currentAccountInfo.address);
|
|
69
|
+
this.refreshStakingRewardFastInterval(currentAccountInfo.address);
|
|
70
|
+
this.updateChainStakingMetadata(this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap());
|
|
71
|
+
this.updateNominatorMetadata(currentAccountInfo.address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap());
|
|
72
|
+
} else {
|
|
73
|
+
this.setStakingRewardReady();
|
|
74
|
+
}
|
|
76
75
|
};
|
|
77
76
|
start = () => {
|
|
78
77
|
if (this.status === 'running') {
|
|
79
78
|
return;
|
|
80
79
|
}
|
|
81
80
|
this.logger.log('Starting cron jobs');
|
|
82
|
-
this.state.
|
|
83
|
-
|
|
81
|
+
const currentAccountInfo = this.state.keyringService.currentAccount;
|
|
82
|
+
if (!(currentAccountInfo !== null && currentAccountInfo !== void 0 && currentAccountInfo.address)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
86
|
+
this.resetNft(currentAccountInfo.address);
|
|
87
|
+
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
88
|
+
this.addCron('recoverApiMap', this.recoverApiMap, _constants.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL, false);
|
|
89
|
+
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
90
|
+
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
91
|
+
this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap()), _constants.CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
92
|
+
this.addCron('updateNominatorMetadata', this.updateNominatorMetadata(currentAccountInfo.address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap()), _constants.CRON_REFRESH_CHAIN_NOMINATOR_METADATA);
|
|
93
|
+
} else {
|
|
94
|
+
this.setStakingRewardReady();
|
|
95
|
+
}
|
|
96
|
+
const reloadEvents = ['account.add', 'account.remove', 'account.updateCurrent', 'chain.add', 'chain.update', 'chain.enable', 'asset.update', 'asset.enable', 'transaction.done', 'transaction.failed'];
|
|
97
|
+
this.state.eventService.onLazy((events, eventTypes) => {
|
|
98
|
+
var _serviceInfo$currentA;
|
|
99
|
+
const serviceInfo = this.state.getServiceInfo();
|
|
100
|
+
const needReload = eventTypes.some(eT => reloadEvents.includes(eT));
|
|
101
|
+
if (!needReload) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.logger.log('ServiceInfo updated, restarting...');
|
|
105
|
+
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
|
|
106
|
+
if (!address) {
|
|
84
107
|
return;
|
|
85
108
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
this.resetStakingReward();
|
|
110
|
+
this.resetNft(address);
|
|
111
|
+
this.removeCron('refreshNft');
|
|
112
|
+
this.removeCron('refreshStakingReward');
|
|
113
|
+
this.removeCron('refreshPoolingStakingReward');
|
|
114
|
+
this.removeCron('checkStatusApiMap');
|
|
115
|
+
this.removeCron('recoverApiMap');
|
|
116
|
+
this.removeCron('updateChainStakingMetadata');
|
|
117
|
+
this.removeCron('updateNominatorMetadata');
|
|
118
|
+
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
119
|
+
// only add cron job if there's at least 1 active network
|
|
120
|
+
this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
89
121
|
this.addCron('recoverApiMap', this.recoverApiMap, _constants.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL, false);
|
|
90
|
-
this.addCron('refreshStakingReward', this.refreshStakingReward(
|
|
91
|
-
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(
|
|
92
|
-
this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(
|
|
93
|
-
this.addCron('updateNominatorMetadata', this.updateNominatorMetadata(
|
|
122
|
+
this.addCron('refreshStakingReward', this.refreshStakingReward(address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
123
|
+
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
124
|
+
this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), _constants.CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
125
|
+
this.addCron('updateNominatorMetadata', this.updateNominatorMetadata(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), _constants.CRON_REFRESH_CHAIN_NOMINATOR_METADATA);
|
|
94
126
|
} else {
|
|
95
127
|
this.setStakingRewardReady();
|
|
96
128
|
}
|
|
97
129
|
});
|
|
98
|
-
this.serviceSubscription = this.state.subscribeServiceInfo().subscribe({
|
|
99
|
-
next: serviceInfo => {
|
|
100
|
-
var _serviceInfo$currentA;
|
|
101
|
-
this.logger.log('ServiceInfo updated, restarting...');
|
|
102
|
-
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
|
|
103
|
-
if (!address) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.resetStakingReward();
|
|
107
|
-
this.resetNft(address);
|
|
108
|
-
this.removeCron('refreshNft');
|
|
109
|
-
this.removeCron('refreshStakingReward');
|
|
110
|
-
this.removeCron('refreshPoolingStakingReward');
|
|
111
|
-
this.removeCron('refreshPrice');
|
|
112
|
-
this.removeCron('checkStatusApiMap');
|
|
113
|
-
this.removeCron('recoverApiMap');
|
|
114
|
-
this.removeCron('updateChainStakingMetadata');
|
|
115
|
-
this.removeCron('updateNominatorMetadata');
|
|
116
|
-
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
117
|
-
// only add cron job if there's at least 1 active network
|
|
118
|
-
this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
119
|
-
this.addCron('recoverApiMap', this.recoverApiMap, _constants.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL, false);
|
|
120
|
-
this.addCron('refreshStakingReward', this.refreshStakingReward(address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
121
|
-
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
122
|
-
this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), _constants.CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
123
|
-
this.addCron('updateNominatorMetadata', this.updateNominatorMetadata(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), _constants.CRON_REFRESH_CHAIN_NOMINATOR_METADATA);
|
|
124
|
-
} else {
|
|
125
|
-
this.setStakingRewardReady();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
130
|
this.status = 'running';
|
|
130
131
|
};
|
|
131
132
|
stop = () => {
|
|
@@ -141,6 +142,7 @@ class KoniCron {
|
|
|
141
142
|
this.status = 'stopped';
|
|
142
143
|
};
|
|
143
144
|
recoverApiMap = () => {
|
|
145
|
+
var _this$subscriptions;
|
|
144
146
|
const apiMap = this.state.getApiMap();
|
|
145
147
|
for (const [networkKey, apiProp] of Object.entries(apiMap.substrate)) {
|
|
146
148
|
if (!apiProp.isApiConnected) {
|
|
@@ -152,13 +154,10 @@ class KoniCron {
|
|
|
152
154
|
this.state.refreshWeb3Api(key);
|
|
153
155
|
});
|
|
154
156
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
} = _ref2;
|
|
160
|
-
((_this$subscriptions = this.subscriptions) === null || _this$subscriptions === void 0 ? void 0 : _this$subscriptions.subscribeBalancesAndCrowdloans) && this.subscriptions.subscribeBalancesAndCrowdloans(address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
161
|
-
});
|
|
157
|
+
const {
|
|
158
|
+
address
|
|
159
|
+
} = this.state.keyringService.currentAccount;
|
|
160
|
+
((_this$subscriptions = this.subscriptions) === null || _this$subscriptions === void 0 ? void 0 : _this$subscriptions.subscribeBalancesAndCrowdloans) && this.subscriptions.subscribeBalancesAndCrowdloans(address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
162
161
|
};
|
|
163
162
|
refreshNft = (address, apiMap, smartContractNfts, chainInfoMap) => {
|
|
164
163
|
return () => {
|
|
@@ -168,7 +167,7 @@ class KoniCron {
|
|
|
168
167
|
};
|
|
169
168
|
resetNft = newAddress => {
|
|
170
169
|
this.logger.log('Reset Nft state');
|
|
171
|
-
this.state.resetNft(newAddress)
|
|
170
|
+
this.state.resetNft(newAddress);
|
|
172
171
|
};
|
|
173
172
|
resetStakingReward = () => {
|
|
174
173
|
this.logger.log('Reset Staking Reward State');
|