@subwallet/extension-base 1.1.57-0 → 1.1.59-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/cjs/constants/staking.js +1 -1
- package/cjs/koni/api/nft/config.js +6 -4
- package/cjs/koni/api/staking/bonding/utils.js +7 -3
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +7 -5
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +2 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +4 -4
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +2 -2
- package/cjs/services/history-service/index.js +8 -2
- package/cjs/services/history-service/subscan-history.js +5 -2
- package/constants/staking.js +1 -1
- package/koni/api/nft/config.js +6 -4
- package/koni/api/staking/bonding/utils.d.ts +1 -1
- package/koni/api/staking/bonding/utils.js +7 -3
- package/package.json +7 -7
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +7 -5
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.js +2 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +4 -4
- package/services/earning-service/handlers/nomination-pool/index.js +2 -2
- package/services/history-service/index.js +8 -2
- package/services/history-service/subscan-history.d.ts +1 -1
- package/services/history-service/subscan-history.js +5 -2
package/cjs/constants/staking.js
CHANGED
|
@@ -167,16 +167,18 @@ if (!_utils.RuntimeInfo.protocol || !_utils.RuntimeInfo.protocol.startsWith('htt
|
|
|
167
167
|
provider: PINATA_IPFS_GATEWAY,
|
|
168
168
|
weight: 1 // Rate limit too low
|
|
169
169
|
}, {
|
|
170
|
+
provider: IPFS_IO,
|
|
171
|
+
weight: 5
|
|
172
|
+
});
|
|
173
|
+
} else if (!_utils.RuntimeInfo.protocol.startsWith('https')) {
|
|
174
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
170
175
|
provider: NFT_STORAGE_GATEWAY,
|
|
171
176
|
weight: 50
|
|
172
|
-
}, {
|
|
173
|
-
provider: GATEWAY_IPFS_IO,
|
|
174
|
-
weight: 5
|
|
175
177
|
}, {
|
|
176
178
|
provider: DWEB_LINK,
|
|
177
179
|
weight: 5
|
|
178
180
|
}, {
|
|
179
|
-
provider:
|
|
181
|
+
provider: GATEWAY_IPFS_IO,
|
|
180
182
|
weight: 5
|
|
181
183
|
});
|
|
182
184
|
}
|
|
@@ -382,11 +382,15 @@ function getAvgValidatorEraReward(supportedDays, eraRewardHistory) {
|
|
|
382
382
|
}
|
|
383
383
|
return sumEraReward.dividedBy(new _bignumber.default(supportedDays - failEra));
|
|
384
384
|
}
|
|
385
|
-
function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras) {
|
|
386
|
-
|
|
385
|
+
function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras, liveDay) {
|
|
386
|
+
const maxSupportDay = maxSupportedEras / erasPerDay;
|
|
387
|
+
if (liveDay && liveDay <= 30) {
|
|
388
|
+
return Math.min(liveDay - 1, maxSupportDay);
|
|
389
|
+
}
|
|
390
|
+
if (maxSupportDay > 30) {
|
|
387
391
|
return 30;
|
|
388
392
|
} else {
|
|
389
|
-
return
|
|
393
|
+
return maxSupportDay;
|
|
390
394
|
}
|
|
391
395
|
}
|
|
392
396
|
function getValidatorPointsMap(eraRewardMap) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -19,7 +19,7 @@ exports.API_MAX_RETRY = API_MAX_RETRY;
|
|
|
19
19
|
const _API_OPTIONS_CHAIN_GROUP = {
|
|
20
20
|
acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
|
|
21
21
|
turing: ['turingStaging', 'turing'],
|
|
22
|
-
avail: ['kate'],
|
|
22
|
+
avail: ['kate', 'availTuringTest'],
|
|
23
23
|
goldberg: ['goldberg_testnet']
|
|
24
24
|
};
|
|
25
25
|
exports._API_OPTIONS_CHAIN_GROUP = _API_OPTIONS_CHAIN_GROUP;
|
|
@@ -40,7 +40,7 @@ const _BALANCE_CHAIN_GROUP = {
|
|
|
40
40
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
41
41
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
42
42
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network'],
|
|
43
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya'],
|
|
43
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain'],
|
|
44
44
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
45
45
|
// perhaps there are some runtime updates
|
|
46
46
|
centrifuge: ['centrifuge'],
|
|
@@ -103,7 +103,8 @@ const _STAKING_ERA_LENGTH_MAP = {
|
|
|
103
103
|
manta_network: 6,
|
|
104
104
|
krest_network: 4,
|
|
105
105
|
polimec: 6,
|
|
106
|
-
enjin_relaychain: 24
|
|
106
|
+
enjin_relaychain: 24,
|
|
107
|
+
availTuringTest: 24
|
|
107
108
|
};
|
|
108
109
|
exports._STAKING_ERA_LENGTH_MAP = _STAKING_ERA_LENGTH_MAP;
|
|
109
110
|
const _EXPECTED_BLOCK_TIME = {
|
|
@@ -133,7 +134,8 @@ const _EXPECTED_BLOCK_TIME = {
|
|
|
133
134
|
calamari: 12,
|
|
134
135
|
calamari_test: 12,
|
|
135
136
|
manta_network: 12,
|
|
136
|
-
enjin_relaychain: 6
|
|
137
|
+
enjin_relaychain: 6,
|
|
138
|
+
availTuringTest: 20
|
|
137
139
|
};
|
|
138
140
|
exports._EXPECTED_BLOCK_TIME = _EXPECTED_BLOCK_TIME;
|
|
139
141
|
const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
@@ -237,7 +239,7 @@ const _TRANSFER_CHAIN_GROUP = {
|
|
|
237
239
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
238
240
|
// crab: ['crab', 'pangolin'],
|
|
239
241
|
bitcountry: ['pioneer', 'bitcountry', 'bifrost', 'bifrost_dot'],
|
|
240
|
-
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet'],
|
|
242
|
+
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet', 'dbcchain'],
|
|
241
243
|
riochain: ['riochain'],
|
|
242
244
|
sora_substrate: ['sora_substrate'],
|
|
243
245
|
avail: ['kate', 'goldberg_testnet'],
|
|
@@ -12,7 +12,7 @@ var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
|
12
12
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
13
13
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
14
14
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
15
|
-
const ChainListVersion = '0.2.
|
|
15
|
+
const ChainListVersion = '0.2.57';
|
|
16
16
|
async function fetchPatchData(slug) {
|
|
17
17
|
try {
|
|
18
18
|
const fetchPromise = (0, _crossFetch.default)(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
|
|
@@ -8,13 +8,13 @@ exports._STAKING_CHAIN_GROUP = exports.ST_LIQUID_TOKEN_ABI = exports.MaxEraRewar
|
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
10
10
|
const _STAKING_CHAIN_GROUP = {
|
|
11
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet'],
|
|
11
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet', 'availTuringTest'],
|
|
12
12
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari', 'manta_network', 'polimec'],
|
|
13
13
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
14
14
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum', 'krest_network'],
|
|
15
15
|
// amplitude and kilt only share some common logic
|
|
16
16
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
17
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet'],
|
|
17
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet', 'availTuringTest'],
|
|
18
18
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
19
19
|
aleph: ['aleph', 'alephTest'],
|
|
20
20
|
// A0 has distinct tokenomics
|
|
@@ -64,9 +64,9 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
64
64
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
65
65
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
66
66
|
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
67
|
-
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from epochDuration
|
|
67
|
+
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from babe.epochDuration * blockTime * staking.sessionsPerEra
|
|
68
68
|
|
|
69
|
-
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras));
|
|
69
|
+
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
70
70
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
71
71
|
const [_EraStakeInfo, _totalIssuance, _auctionCounter, _minNominatorBond, _counterForNominators, _minimumActiveStake, ..._eraReward] = await Promise.all([substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$que2 = substrateApi.api.query.auctions) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.auctionCounter(), substrateApi.api.query.staking.minNominatorBond(), substrateApi.api.query.staking.counterForNominators(), ((_substrateApi$api$que3 = substrateApi.api.query) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.staking) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.minimumActiveStake) && ((_substrateApi$api$que5 = substrateApi.api.query) === null || _substrateApi$api$que5 === void 0 ? void 0 : (_substrateApi$api$que6 = _substrateApi$api$que5.staking) === null || _substrateApi$api$que6 === void 0 ? void 0 : _substrateApi$api$que6.minimumActiveStake()), substrateApi.api.query.staking.erasValidatorReward.multi([...Array(supportedDays).keys()].map(i => i + startEra))]);
|
|
72
72
|
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
@@ -151,7 +151,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
151
151
|
let nominationStatus = _types.EarningStatus.NOT_EARNING;
|
|
152
152
|
let eraStakerOtherList = [];
|
|
153
153
|
let identity;
|
|
154
|
-
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
154
|
+
if (['kusama', 'polkadot', 'westend', 'availTuringTest'].includes(this.chain)) {
|
|
155
155
|
// todo: review all relaychains later
|
|
156
156
|
const [[_identity], _eraStaker] = await Promise.all([(0, _utils3.parseIdentity)(substrateApi, validatorAddress), substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress)]);
|
|
157
157
|
identity = _identity;
|
|
@@ -305,7 +305,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
305
305
|
const endEraForPoints = parseInt(activeEra) - 1;
|
|
306
306
|
let startEraForPoints = endEraForPoints - maxEraRewardPointsEras + 1;
|
|
307
307
|
let _eraStakersPromise;
|
|
308
|
-
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
308
|
+
if (['kusama', 'polkadot', 'westend', 'availTuringTest'].includes(this.chain)) {
|
|
309
309
|
// todo: review all relaychains later
|
|
310
310
|
_eraStakersPromise = chainApi.api.query.staking.erasStakersOverview.entries(parseInt(currentEra));
|
|
311
311
|
} else {
|
|
@@ -89,7 +89,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
89
89
|
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
90
90
|
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from epochDuration, blockTime, sessionsPerEra
|
|
91
91
|
|
|
92
|
-
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras));
|
|
92
|
+
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
93
93
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
94
94
|
const [_EraStakeInfo, _totalIssuance, _auctionCounter, _minPoolJoin, ..._eraReward] = await Promise.all([substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$que2 = substrateApi.api.query.auctions) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.auctionCounter(), (_substrateApi$api$que3 = substrateApi.api.query) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.nominationPools) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.minJoinBond(), substrateApi.api.query.staking.erasValidatorReward.multi([...Array(supportedDays).keys()].map(i => i + startEra))]);
|
|
95
95
|
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
@@ -167,7 +167,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
167
167
|
const validatorList = nominations.targets;
|
|
168
168
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
169
169
|
let eraStakerOtherList = [];
|
|
170
|
-
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
170
|
+
if (['kusama', 'polkadot', 'westend', 'availTuringTest'].includes(this.chain)) {
|
|
171
171
|
// todo: review all relaychains later
|
|
172
172
|
const _eraStaker = await substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress);
|
|
173
173
|
eraStakerOtherList = _eraStaker.flatMap(paged => paged[1].toPrimitive().others);
|
|
@@ -109,7 +109,10 @@ class HistoryService {
|
|
|
109
109
|
Object.keys(rsMap).forEach(hash => {
|
|
110
110
|
// only push item that does not have same hash with another item
|
|
111
111
|
if (!excludeTransferExtrinsicHash.includes(hash) && rsMap[hash].length === 1) {
|
|
112
|
-
|
|
112
|
+
const item = (0, _subscanHistory.parseSubscanTransferData)(address, rsMap[hash][0], chainInfo);
|
|
113
|
+
if (item) {
|
|
114
|
+
result.push(item);
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
});
|
|
115
118
|
this.addHistoryItems(result).catch(e => {
|
|
@@ -126,7 +129,10 @@ class HistoryService {
|
|
|
126
129
|
Object.keys(rsMap).forEach(hash => {
|
|
127
130
|
// only push item that does not have same hash with another item
|
|
128
131
|
if (rsMap[hash].length === 1) {
|
|
129
|
-
|
|
132
|
+
const item = (0, _subscanHistory.parseSubscanTransferData)(address, rsMap[hash][0], chainInfo);
|
|
133
|
+
if (item) {
|
|
134
|
+
result.push(item);
|
|
135
|
+
}
|
|
130
136
|
}
|
|
131
137
|
});
|
|
132
138
|
this.addHistoryItems(result).catch(e => {
|
|
@@ -77,20 +77,23 @@ function parseSubscanTransferData(address, transferItem, chainInfo) {
|
|
|
77
77
|
const nativeSymbol = ((_chainInfo$substrateI4 = chainInfo.substrateInfo) === null || _chainInfo$substrateI4 === void 0 ? void 0 : _chainInfo$substrateI4.symbol) || ((_chainInfo$evmInfo4 = chainInfo.evmInfo) === null || _chainInfo$evmInfo4 === void 0 ? void 0 : _chainInfo$evmInfo4.symbol) || '';
|
|
78
78
|
const from = autoFormatAddress(transferItem.from);
|
|
79
79
|
const to = autoFormatAddress(transferItem.to);
|
|
80
|
+
if (!transferItem.from_account_display || !transferItem.to_account_display) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
80
83
|
return {
|
|
81
84
|
address,
|
|
82
85
|
origin: 'subscan',
|
|
83
86
|
time: transferItem.block_timestamp * 1000,
|
|
84
87
|
chainType,
|
|
85
88
|
from,
|
|
86
|
-
fromName: transferItem.from_account_display.display,
|
|
89
|
+
fromName: transferItem.from_account_display.display || transferItem.from_account_display.address,
|
|
87
90
|
direction: (0, _utils.isSameAddress)(address, from) ? _KoniTypes.TransactionDirection.SEND : _KoniTypes.TransactionDirection.RECEIVED,
|
|
88
91
|
blockNumber: transferItem.block_num,
|
|
89
92
|
blockHash: '',
|
|
90
93
|
chain: chainInfo.slug,
|
|
91
94
|
type: _KoniTypes.ExtrinsicType.TRANSFER_BALANCE,
|
|
92
95
|
to,
|
|
93
|
-
toName: transferItem.to_account_display.display,
|
|
96
|
+
toName: transferItem.to_account_display.display || transferItem.to_account_display.address,
|
|
94
97
|
extrinsicHash: transferItem.hash,
|
|
95
98
|
amount: {
|
|
96
99
|
value: transferItem.amount,
|
package/constants/staking.js
CHANGED
package/koni/api/nft/config.js
CHANGED
|
@@ -127,16 +127,18 @@ if (!RuntimeInfo.protocol || !RuntimeInfo.protocol.startsWith('http') || Runtime
|
|
|
127
127
|
provider: PINATA_IPFS_GATEWAY,
|
|
128
128
|
weight: 1 // Rate limit too low
|
|
129
129
|
}, {
|
|
130
|
+
provider: IPFS_IO,
|
|
131
|
+
weight: 5
|
|
132
|
+
});
|
|
133
|
+
} else if (!RuntimeInfo.protocol.startsWith('https')) {
|
|
134
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
130
135
|
provider: NFT_STORAGE_GATEWAY,
|
|
131
136
|
weight: 50
|
|
132
|
-
}, {
|
|
133
|
-
provider: GATEWAY_IPFS_IO,
|
|
134
|
-
weight: 5
|
|
135
137
|
}, {
|
|
136
138
|
provider: DWEB_LINK,
|
|
137
139
|
weight: 5
|
|
138
140
|
}, {
|
|
139
|
-
provider:
|
|
141
|
+
provider: GATEWAY_IPFS_IO,
|
|
140
142
|
weight: 5
|
|
141
143
|
});
|
|
142
144
|
}
|
|
@@ -157,7 +157,7 @@ export declare function getWithdrawalInfo(nominatorMetadata: NominatorMetadata):
|
|
|
157
157
|
export declare function getEarningStatusByNominations(bnTotalActiveStake: BN, nominationList: NominationInfo[]): EarningStatus;
|
|
158
158
|
export declare function getValidatorLabel(chain: string): "dApp" | "Validator" | "Collator";
|
|
159
159
|
export declare function getAvgValidatorEraReward(supportedDays: number, eraRewardHistory: Codec[]): BigNumber;
|
|
160
|
-
export declare function getSupportedDaysByHistoryDepth(erasPerDay: number, maxSupportedEras: number):
|
|
160
|
+
export declare function getSupportedDaysByHistoryDepth(erasPerDay: number, maxSupportedEras: number, liveDay?: number): number;
|
|
161
161
|
export declare function getValidatorPointsMap(eraRewardMap: Record<string, PalletStakingEraRewardPoints>): Record<string, BigNumber>;
|
|
162
162
|
export declare function getTopValidatorByPoints(validatorPointsList: Record<string, BigNumber>): string[];
|
|
163
163
|
export declare const getMinStakeErrorMessage: (chainInfo: _ChainInfo, bnMinStake: BN) => string;
|
|
@@ -343,11 +343,15 @@ export function getAvgValidatorEraReward(supportedDays, eraRewardHistory) {
|
|
|
343
343
|
}
|
|
344
344
|
return sumEraReward.dividedBy(new BigNumber(supportedDays - failEra));
|
|
345
345
|
}
|
|
346
|
-
export function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras) {
|
|
347
|
-
|
|
346
|
+
export function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras, liveDay) {
|
|
347
|
+
const maxSupportDay = maxSupportedEras / erasPerDay;
|
|
348
|
+
if (liveDay && liveDay <= 30) {
|
|
349
|
+
return Math.min(liveDay - 1, maxSupportDay);
|
|
350
|
+
}
|
|
351
|
+
if (maxSupportDay > 30) {
|
|
348
352
|
return 30;
|
|
349
353
|
} else {
|
|
350
|
-
return
|
|
354
|
+
return maxSupportDay;
|
|
351
355
|
}
|
|
352
356
|
}
|
|
353
357
|
export function getValidatorPointsMap(eraRewardMap) {
|
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.59-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1873,17 +1873,17 @@
|
|
|
1873
1873
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1874
1874
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1875
1875
|
"@substrate/connect": "^0.8.9",
|
|
1876
|
-
"@subwallet/chain-list": "0.2.
|
|
1877
|
-
"@subwallet/extension-base": "^1.1.
|
|
1878
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1879
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1880
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1876
|
+
"@subwallet/chain-list": "0.2.57",
|
|
1877
|
+
"@subwallet/extension-base": "^1.1.59-0",
|
|
1878
|
+
"@subwallet/extension-chains": "^1.1.59-0",
|
|
1879
|
+
"@subwallet/extension-dapp": "^1.1.59-0",
|
|
1880
|
+
"@subwallet/extension-inject": "^1.1.59-0",
|
|
1881
1881
|
"@subwallet/keyring": "^0.1.5",
|
|
1882
1882
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
1883
1883
|
"@walletconnect/sign-client": "^2.8.4",
|
|
1884
1884
|
"@walletconnect/types": "^2.8.4",
|
|
1885
1885
|
"@walletconnect/utils": "^2.8.4",
|
|
1886
|
-
"avail-js-sdk": "^0.
|
|
1886
|
+
"avail-js-sdk": "^0.2.11",
|
|
1887
1887
|
"axios": "^1.6.2",
|
|
1888
1888
|
"bignumber.js": "^9.1.1",
|
|
1889
1889
|
"bn.js": "^5.2.1",
|
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.59-0'
|
|
11
11
|
};
|
|
@@ -10,7 +10,7 @@ export const API_MAX_RETRY = 2;
|
|
|
10
10
|
export const _API_OPTIONS_CHAIN_GROUP = {
|
|
11
11
|
acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
|
|
12
12
|
turing: ['turingStaging', 'turing'],
|
|
13
|
-
avail: ['kate'],
|
|
13
|
+
avail: ['kate', 'availTuringTest'],
|
|
14
14
|
goldberg: ['goldberg_testnet']
|
|
15
15
|
};
|
|
16
16
|
export const _PREDEFINED_SINGLE_MODES = {
|
|
@@ -29,7 +29,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
29
29
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
30
30
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
31
31
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network'],
|
|
32
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya'],
|
|
32
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain'],
|
|
33
33
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
34
34
|
// perhaps there are some runtime updates
|
|
35
35
|
centrifuge: ['centrifuge'],
|
|
@@ -90,7 +90,8 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
90
90
|
manta_network: 6,
|
|
91
91
|
krest_network: 4,
|
|
92
92
|
polimec: 6,
|
|
93
|
-
enjin_relaychain: 24
|
|
93
|
+
enjin_relaychain: 24,
|
|
94
|
+
availTuringTest: 24
|
|
94
95
|
};
|
|
95
96
|
export const _EXPECTED_BLOCK_TIME = {
|
|
96
97
|
// in seconds
|
|
@@ -119,7 +120,8 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
119
120
|
calamari: 12,
|
|
120
121
|
calamari_test: 12,
|
|
121
122
|
manta_network: 12,
|
|
122
|
-
enjin_relaychain: 6
|
|
123
|
+
enjin_relaychain: 6,
|
|
124
|
+
availTuringTest: 20
|
|
123
125
|
};
|
|
124
126
|
export const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
125
127
|
moonbeam: {
|
|
@@ -219,7 +221,7 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
219
221
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
220
222
|
// crab: ['crab', 'pangolin'],
|
|
221
223
|
bitcountry: ['pioneer', 'bitcountry', 'bifrost', 'bifrost_dot'],
|
|
222
|
-
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet'],
|
|
224
|
+
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet', 'dbcchain'],
|
|
223
225
|
riochain: ['riochain'],
|
|
224
226
|
sora_substrate: ['sora_substrate'],
|
|
225
227
|
avail: ['kate', 'goldberg_testnet'],
|
|
@@ -5,7 +5,7 @@ import fetch from 'cross-fetch';
|
|
|
5
5
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
6
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
7
7
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.57';
|
|
9
9
|
export async function fetchPatchData(slug) {
|
|
10
10
|
try {
|
|
11
11
|
const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export const _STAKING_CHAIN_GROUP = {
|
|
5
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet'],
|
|
5
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet', 'availTuringTest'],
|
|
6
6
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari', 'manta_network', 'polimec'],
|
|
7
7
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
8
8
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum', 'krest_network'],
|
|
9
9
|
// amplitude and kilt only share some common logic
|
|
10
10
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
11
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet'],
|
|
11
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet', 'availTuringTest'],
|
|
12
12
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
13
13
|
aleph: ['aleph', 'alephTest'],
|
|
14
14
|
// A0 has distinct tokenomics
|
|
@@ -57,9 +57,9 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
57
57
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
58
58
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
59
59
|
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
60
|
-
const erasPerDay = 24 / _STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from epochDuration
|
|
60
|
+
const erasPerDay = 24 / _STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from babe.epochDuration * blockTime * staking.sessionsPerEra
|
|
61
61
|
|
|
62
|
-
const supportedDays = getSupportedDaysByHistoryDepth(erasPerDay, parseInt(maxSupportedEras));
|
|
62
|
+
const supportedDays = getSupportedDaysByHistoryDepth(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
63
63
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
64
64
|
const [_EraStakeInfo, _totalIssuance, _auctionCounter, _minNominatorBond, _counterForNominators, _minimumActiveStake, ..._eraReward] = await Promise.all([substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$que2 = substrateApi.api.query.auctions) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.auctionCounter(), substrateApi.api.query.staking.minNominatorBond(), substrateApi.api.query.staking.counterForNominators(), ((_substrateApi$api$que3 = substrateApi.api.query) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.staking) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.minimumActiveStake) && ((_substrateApi$api$que5 = substrateApi.api.query) === null || _substrateApi$api$que5 === void 0 ? void 0 : (_substrateApi$api$que6 = _substrateApi$api$que5.staking) === null || _substrateApi$api$que6 === void 0 ? void 0 : _substrateApi$api$que6.minimumActiveStake()), substrateApi.api.query.staking.erasValidatorReward.multi([...Array(supportedDays).keys()].map(i => i + startEra))]);
|
|
65
65
|
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
@@ -144,7 +144,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
144
144
|
let nominationStatus = EarningStatus.NOT_EARNING;
|
|
145
145
|
let eraStakerOtherList = [];
|
|
146
146
|
let identity;
|
|
147
|
-
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
147
|
+
if (['kusama', 'polkadot', 'westend', 'availTuringTest'].includes(this.chain)) {
|
|
148
148
|
// todo: review all relaychains later
|
|
149
149
|
const [[_identity], _eraStaker] = await Promise.all([parseIdentity(substrateApi, validatorAddress), substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress)]);
|
|
150
150
|
identity = _identity;
|
|
@@ -298,7 +298,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
298
298
|
const endEraForPoints = parseInt(activeEra) - 1;
|
|
299
299
|
let startEraForPoints = endEraForPoints - maxEraRewardPointsEras + 1;
|
|
300
300
|
let _eraStakersPromise;
|
|
301
|
-
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
301
|
+
if (['kusama', 'polkadot', 'westend', 'availTuringTest'].includes(this.chain)) {
|
|
302
302
|
// todo: review all relaychains later
|
|
303
303
|
_eraStakersPromise = chainApi.api.query.staking.erasStakersOverview.entries(parseInt(currentEra));
|
|
304
304
|
} else {
|
|
@@ -81,7 +81,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
81
81
|
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
82
82
|
const erasPerDay = 24 / _STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from epochDuration, blockTime, sessionsPerEra
|
|
83
83
|
|
|
84
|
-
const supportedDays = getSupportedDaysByHistoryDepth(erasPerDay, parseInt(maxSupportedEras));
|
|
84
|
+
const supportedDays = getSupportedDaysByHistoryDepth(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
85
85
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
86
86
|
const [_EraStakeInfo, _totalIssuance, _auctionCounter, _minPoolJoin, ..._eraReward] = await Promise.all([substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$que2 = substrateApi.api.query.auctions) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.auctionCounter(), (_substrateApi$api$que3 = substrateApi.api.query) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.nominationPools) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.minJoinBond(), substrateApi.api.query.staking.erasValidatorReward.multi([...Array(supportedDays).keys()].map(i => i + startEra))]);
|
|
87
87
|
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
@@ -159,7 +159,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
159
159
|
const validatorList = nominations.targets;
|
|
160
160
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
161
161
|
let eraStakerOtherList = [];
|
|
162
|
-
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
162
|
+
if (['kusama', 'polkadot', 'westend', 'availTuringTest'].includes(this.chain)) {
|
|
163
163
|
// todo: review all relaychains later
|
|
164
164
|
const _eraStaker = await substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress);
|
|
165
165
|
eraStakerOtherList = _eraStaker.flatMap(paged => paged[1].toPrimitive().others);
|
|
@@ -102,7 +102,10 @@ export class HistoryService {
|
|
|
102
102
|
Object.keys(rsMap).forEach(hash => {
|
|
103
103
|
// only push item that does not have same hash with another item
|
|
104
104
|
if (!excludeTransferExtrinsicHash.includes(hash) && rsMap[hash].length === 1) {
|
|
105
|
-
|
|
105
|
+
const item = parseSubscanTransferData(address, rsMap[hash][0], chainInfo);
|
|
106
|
+
if (item) {
|
|
107
|
+
result.push(item);
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
});
|
|
108
111
|
this.addHistoryItems(result).catch(e => {
|
|
@@ -119,7 +122,10 @@ export class HistoryService {
|
|
|
119
122
|
Object.keys(rsMap).forEach(hash => {
|
|
120
123
|
// only push item that does not have same hash with another item
|
|
121
124
|
if (rsMap[hash].length === 1) {
|
|
122
|
-
|
|
125
|
+
const item = parseSubscanTransferData(address, rsMap[hash][0], chainInfo);
|
|
126
|
+
if (item) {
|
|
127
|
+
result.push(item);
|
|
128
|
+
}
|
|
123
129
|
}
|
|
124
130
|
});
|
|
125
131
|
this.addHistoryItems(result).catch(e => {
|
|
@@ -2,4 +2,4 @@ import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
|
2
2
|
import { TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { ExtrinsicItem, TransferItem } from '@subwallet/extension-base/services/subscan-service/types';
|
|
4
4
|
export declare function parseSubscanExtrinsicData(address: string, extrinsicItem: ExtrinsicItem, chainInfo: _ChainInfo): TransactionHistoryItem | null;
|
|
5
|
-
export declare function parseSubscanTransferData(address: string, transferItem: TransferItem, chainInfo: _ChainInfo): TransactionHistoryItem;
|
|
5
|
+
export declare function parseSubscanTransferData(address: string, transferItem: TransferItem, chainInfo: _ChainInfo): TransactionHistoryItem | null;
|
|
@@ -70,20 +70,23 @@ export function parseSubscanTransferData(address, transferItem, chainInfo) {
|
|
|
70
70
|
const nativeSymbol = ((_chainInfo$substrateI4 = chainInfo.substrateInfo) === null || _chainInfo$substrateI4 === void 0 ? void 0 : _chainInfo$substrateI4.symbol) || ((_chainInfo$evmInfo4 = chainInfo.evmInfo) === null || _chainInfo$evmInfo4 === void 0 ? void 0 : _chainInfo$evmInfo4.symbol) || '';
|
|
71
71
|
const from = autoFormatAddress(transferItem.from);
|
|
72
72
|
const to = autoFormatAddress(transferItem.to);
|
|
73
|
+
if (!transferItem.from_account_display || !transferItem.to_account_display) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
73
76
|
return {
|
|
74
77
|
address,
|
|
75
78
|
origin: 'subscan',
|
|
76
79
|
time: transferItem.block_timestamp * 1000,
|
|
77
80
|
chainType,
|
|
78
81
|
from,
|
|
79
|
-
fromName: transferItem.from_account_display.display,
|
|
82
|
+
fromName: transferItem.from_account_display.display || transferItem.from_account_display.address,
|
|
80
83
|
direction: isSameAddress(address, from) ? TransactionDirection.SEND : TransactionDirection.RECEIVED,
|
|
81
84
|
blockNumber: transferItem.block_num,
|
|
82
85
|
blockHash: '',
|
|
83
86
|
chain: chainInfo.slug,
|
|
84
87
|
type: ExtrinsicType.TRANSFER_BALANCE,
|
|
85
88
|
to,
|
|
86
|
-
toName: transferItem.to_account_display.display,
|
|
89
|
+
toName: transferItem.to_account_display.display || transferItem.to_account_display.address,
|
|
87
90
|
extrinsicHash: transferItem.hash,
|
|
88
91
|
amount: {
|
|
89
92
|
value: transferItem.amount,
|