@subwallet/extension-base 1.1.38-1 → 1.1.40-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +1 -0
- package/background/types.d.ts +1 -0
- package/cjs/koni/api/nft/unique_network_nft/index.js +4 -0
- package/cjs/koni/background/handlers/Extension.js +48 -12
- package/cjs/koni/background/handlers/State.js +6 -5
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/balance.js +1 -1
- package/cjs/services/chain-service/health-check/constants/index.js +36 -0
- package/cjs/services/chain-service/health-check/utils/asset-info.js +282 -0
- package/cjs/services/chain-service/health-check/utils/chain-info.js +36 -0
- package/cjs/services/chain-service/health-check/utils/index.js +38 -0
- package/cjs/services/chain-service/health-check/utils/provider.js +186 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +42 -26
- package/cjs/services/earning-service/service.js +9 -2
- package/cjs/services/transaction-service/index.js +6 -4
- package/cjs/utils/eth/mergeTransactionAndSignature.js +8 -3
- package/cjs/utils/index.js +6 -5
- package/cjs/utils/staticData/index.js +5 -5
- package/koni/api/nft/unique_network_nft/index.d.ts +1 -0
- package/koni/api/nft/unique_network_nft/index.js +5 -1
- package/koni/api/staking/bonding/utils.d.ts +0 -1
- package/koni/background/handlers/Extension.js +48 -12
- package/koni/background/handlers/State.js +2 -1
- package/package.json +41 -16
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/balance.js +1 -1
- package/services/chain-service/health-check/constants/index.d.ts +4 -0
- package/services/chain-service/health-check/constants/index.js +26 -0
- package/services/chain-service/health-check/utils/asset-info.d.ts +14 -0
- package/services/chain-service/health-check/utils/asset-info.js +269 -0
- package/services/chain-service/health-check/utils/chain-info.d.ts +8 -0
- package/services/chain-service/health-check/utils/chain-info.js +28 -0
- package/services/chain-service/health-check/utils/index.d.ts +3 -0
- package/services/chain-service/health-check/utils/index.js +6 -0
- package/services/chain-service/health-check/utils/provider.d.ts +25 -0
- package/services/chain-service/health-check/utils/provider.js +172 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +42 -26
- package/services/earning-service/handlers/special.d.ts +0 -1
- package/services/earning-service/service.js +10 -3
- package/services/transaction-service/index.js +6 -4
- package/types/balance.d.ts +0 -1
- package/types/yield/info/pallet.d.ts +4 -1
- package/utils/eth/mergeTransactionAndSignature.js +8 -3
- package/utils/index.d.ts +1 -2
- package/utils/index.js +6 -5
- package/utils/staticData/buyServiceInfos.json +0 -1
- package/utils/staticData/buyTokenConfigs.json +0 -15
- package/utils/staticData/chains.json +192 -89
- package/utils/staticData/crowdloanFunds.json +433 -58
- package/utils/staticData/index.d.ts +1 -2
- package/utils/staticData/index.js +4 -3
- package/utils/staticData/marketingCampaigns.json +1 -298
- package/utils/staticData/termAndCondition.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
3
2
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
4
3
|
import { ExtrinsicType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
@@ -280,7 +280,21 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
280
280
|
const currentEra = _era.toString();
|
|
281
281
|
const allValidators = [];
|
|
282
282
|
const validatorInfoList = [];
|
|
283
|
-
const [_totalEraStake, _eraStakers, _minBond, _stakingRewards] = await Promise.all([chainApi.api.query.staking.erasTotalStake(parseInt(currentEra)), chainApi.api.query.staking.erasStakers.entries(parseInt(currentEra)), chainApi.api.query.staking.minNominatorBond(), ((_chainApi$api$query$s = chainApi.api.query.stakingRewards) === null || _chainApi$api$query$s === void 0 ? void 0 : _chainApi$api$query$s.data) && chainApi.api.query.stakingRewards.data()]);
|
|
283
|
+
const [_totalEraStake, _eraStakers, _minBond, _stakingRewards, _validators] = await Promise.all([chainApi.api.query.staking.erasTotalStake(parseInt(currentEra)), chainApi.api.query.staking.erasStakers.entries(parseInt(currentEra)), chainApi.api.query.staking.minNominatorBond(), ((_chainApi$api$query$s = chainApi.api.query.stakingRewards) === null || _chainApi$api$query$s === void 0 ? void 0 : _chainApi$api$query$s.data) && chainApi.api.query.stakingRewards.data(), chainApi.api.query.staking.validators.entries()]);
|
|
284
|
+
|
|
285
|
+
// filter blocked validators
|
|
286
|
+
const validators = _validators;
|
|
287
|
+
const blockValidatorList = [];
|
|
288
|
+
for (const validator of validators) {
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
290
|
+
const validatorAddress = validator[0].toHuman()[0];
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
292
|
+
const validatorPrefs = validator[1].toHuman();
|
|
293
|
+
const isBlocked = validatorPrefs.blocked;
|
|
294
|
+
if (isBlocked) {
|
|
295
|
+
blockValidatorList.push(validatorAddress);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
284
298
|
const stakingRewards = _stakingRewards === null || _stakingRewards === void 0 ? void 0 : _stakingRewards.toPrimitive();
|
|
285
299
|
const unlimitedNominatorRewarded = chainApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
286
300
|
const maxNominatorRewarded = (chainApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
@@ -296,32 +310,34 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
296
310
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
297
311
|
const rawValidatorStat = item[1].toHuman();
|
|
298
312
|
const validatorAddress = rawValidatorInfo[1];
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
313
|
+
if (!blockValidatorList.includes(validatorAddress)) {
|
|
314
|
+
const rawTotalStake = rawValidatorStat.total;
|
|
315
|
+
const rawOwnStake = rawValidatorStat.own;
|
|
316
|
+
const bnTotalStake = new BN(rawTotalStake.replaceAll(',', ''));
|
|
317
|
+
const bnOwnStake = new BN(rawOwnStake.replaceAll(',', ''));
|
|
318
|
+
const otherStake = bnTotalStake.sub(bnOwnStake);
|
|
319
|
+
totalStakeMap[validatorAddress] = bnTotalStake;
|
|
320
|
+
let nominatorCount = 0;
|
|
321
|
+
if ('others' in rawValidatorStat) {
|
|
322
|
+
const others = rawValidatorStat.others;
|
|
323
|
+
nominatorCount = others.length;
|
|
324
|
+
}
|
|
325
|
+
allValidators.push(validatorAddress);
|
|
326
|
+
validatorInfoList.push({
|
|
327
|
+
address: validatorAddress,
|
|
328
|
+
totalStake: bnTotalStake.toString(),
|
|
329
|
+
ownStake: bnOwnStake.toString(),
|
|
330
|
+
otherStake: otherStake.toString(),
|
|
331
|
+
nominatorCount,
|
|
332
|
+
// to be added later
|
|
333
|
+
commission: 0,
|
|
334
|
+
expectedReturn: 0,
|
|
335
|
+
blocked: false,
|
|
336
|
+
isVerified: false,
|
|
337
|
+
minBond,
|
|
338
|
+
isCrowded: unlimitedNominatorRewarded ? false : nominatorCount > parseInt(maxNominatorRewarded)
|
|
339
|
+
});
|
|
309
340
|
}
|
|
310
|
-
allValidators.push(validatorAddress);
|
|
311
|
-
validatorInfoList.push({
|
|
312
|
-
address: validatorAddress,
|
|
313
|
-
totalStake: bnTotalStake.toString(),
|
|
314
|
-
ownStake: bnOwnStake.toString(),
|
|
315
|
-
otherStake: otherStake.toString(),
|
|
316
|
-
nominatorCount,
|
|
317
|
-
// to be added later
|
|
318
|
-
commission: 0,
|
|
319
|
-
expectedReturn: 0,
|
|
320
|
-
blocked: false,
|
|
321
|
-
isVerified: false,
|
|
322
|
-
minBond,
|
|
323
|
-
isCrowded: unlimitedNominatorRewarded ? false : nominatorCount > parseInt(maxNominatorRewarded)
|
|
324
|
-
});
|
|
325
341
|
}
|
|
326
342
|
const extraInfoMap = {};
|
|
327
343
|
await Promise.all(allValidators.map(async address => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
3
2
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
3
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
@@ -5,7 +5,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
5
5
|
import { BasicTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { CRON_REFRESH_CHAIN_STAKING_METADATA, CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL } from '@subwallet/extension-base/constants';
|
|
7
7
|
import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
8
|
-
import { _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
+
import { _isChainEnabled, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
9
|
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
10
10
|
import BaseLiquidStakingPoolHandler from '@subwallet/extension-base/services/earning-service/handlers/liquid-staking/base';
|
|
11
11
|
import { YieldPoolType } from '@subwallet/extension-base/types';
|
|
@@ -127,13 +127,20 @@ export default class EarningService {
|
|
|
127
127
|
this.eventService.onLazy((events, eventTypes) => {
|
|
128
128
|
(async () => {
|
|
129
129
|
const removedAddresses = [];
|
|
130
|
+
const removeChains = [];
|
|
130
131
|
events.forEach(event => {
|
|
131
132
|
if (event.type === 'account.remove') {
|
|
132
133
|
removedAddresses.push(event.data[0]);
|
|
133
134
|
}
|
|
135
|
+
if (event.type === 'chain.updateState') {
|
|
136
|
+
const chainState = this.state.getChainStateByKey(event.data[0]);
|
|
137
|
+
if (chainState && !_isChainEnabled(chainState)) {
|
|
138
|
+
removeChains.push(event.data[0]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
134
141
|
});
|
|
135
|
-
if (
|
|
136
|
-
await this.removeYieldPositions(
|
|
142
|
+
if (removeChains.length || removedAddresses.length) {
|
|
143
|
+
await this.removeYieldPositions(removeChains, removedAddresses);
|
|
137
144
|
}
|
|
138
145
|
|
|
139
146
|
// Account changed or chain changed (active or inactive)
|
|
@@ -339,13 +339,14 @@ export default class TransactionService {
|
|
|
339
339
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
340
340
|
const transaction = this.getTransaction(id);
|
|
341
341
|
const extrinsicType = transaction.extrinsicType;
|
|
342
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
342
343
|
const formattedTransactionAddress = reformatAddress(transaction.address);
|
|
343
344
|
const historyItem = {
|
|
344
345
|
origin: 'app',
|
|
345
346
|
chain: transaction.chain,
|
|
346
347
|
direction: TransactionDirection.SEND,
|
|
347
348
|
type: transaction.extrinsicType,
|
|
348
|
-
from:
|
|
349
|
+
from: transaction.address,
|
|
349
350
|
to: '',
|
|
350
351
|
chainType: transaction.chainType,
|
|
351
352
|
address: formattedTransactionAddress,
|
|
@@ -361,7 +362,6 @@ export default class TransactionService {
|
|
|
361
362
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
362
363
|
startBlock: startBlock || 0
|
|
363
364
|
};
|
|
364
|
-
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
365
365
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
366
366
|
const baseNativeAmount = {
|
|
367
367
|
value: '0',
|
|
@@ -861,7 +861,8 @@ export default class TransactionService {
|
|
|
861
861
|
to: transaction.to !== undefined ? transaction.to : '',
|
|
862
862
|
value: addHexPrefix(anyNumberToBN(transaction.value).toString(16)),
|
|
863
863
|
data: transaction.data,
|
|
864
|
-
chainId: _getEvmChainId(chainInfo)
|
|
864
|
+
chainId: _getEvmChainId(chainInfo),
|
|
865
|
+
type: 2
|
|
865
866
|
};
|
|
866
867
|
} else {
|
|
867
868
|
var _transaction$nonce2;
|
|
@@ -872,7 +873,8 @@ export default class TransactionService {
|
|
|
872
873
|
to: transaction.to !== undefined ? transaction.to : '',
|
|
873
874
|
value: addHexPrefix(anyNumberToBN(transaction.value).toString(16)),
|
|
874
875
|
data: transaction.data,
|
|
875
|
-
chainId: _getEvmChainId(chainInfo)
|
|
876
|
+
chainId: _getEvmChainId(chainInfo),
|
|
877
|
+
type: 0
|
|
876
878
|
};
|
|
877
879
|
}
|
|
878
880
|
return ethers.Transaction.from(txObject).unsignedSerialized;
|
package/types/balance.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { BN } from '@polkadot/util';
|
|
3
2
|
export interface PalletNominationPoolsPoolMember {
|
|
4
3
|
poolId: number;
|
|
@@ -122,6 +121,10 @@ export interface PalletStakingNominations {
|
|
|
122
121
|
submittedIn: number;
|
|
123
122
|
suppressed: boolean;
|
|
124
123
|
}
|
|
124
|
+
export interface PalletStakingValidatorPrefs {
|
|
125
|
+
commission: string;
|
|
126
|
+
blocked: boolean;
|
|
127
|
+
}
|
|
125
128
|
export interface UnlockingChunk {
|
|
126
129
|
value: number;
|
|
127
130
|
era: number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { BN_ZERO } from '@subwallet/extension-base/utils';
|
|
5
|
+
import { anyNumberToBN } from '@subwallet/extension-base/utils/eth';
|
|
4
6
|
import { addHexPrefix } from 'ethereumjs-util';
|
|
5
7
|
import { ethers } from 'ethers';
|
|
6
8
|
export const mergeTransactionAndSignature = (tx, _rawSignature) => {
|
|
@@ -11,7 +13,8 @@ export const mergeTransactionAndSignature = (tx, _rawSignature) => {
|
|
|
11
13
|
v: parseInt(`0x${_signature.substring(128)}`)
|
|
12
14
|
};
|
|
13
15
|
let transaction;
|
|
14
|
-
|
|
16
|
+
const max = anyNumberToBN(tx.maxFeePerGas);
|
|
17
|
+
if (max.gt(BN_ZERO)) {
|
|
15
18
|
transaction = {
|
|
16
19
|
nonce: tx.nonce,
|
|
17
20
|
maxFeePerGas: addHexPrefix(tx.maxFeePerGas.toString(16)),
|
|
@@ -21,7 +24,8 @@ export const mergeTransactionAndSignature = (tx, _rawSignature) => {
|
|
|
21
24
|
value: addHexPrefix(tx.value.toString(16)),
|
|
22
25
|
data: tx.data,
|
|
23
26
|
chainId: tx.chainId,
|
|
24
|
-
signature: signature
|
|
27
|
+
signature: signature,
|
|
28
|
+
type: 2
|
|
25
29
|
};
|
|
26
30
|
} else {
|
|
27
31
|
transaction = {
|
|
@@ -32,7 +36,8 @@ export const mergeTransactionAndSignature = (tx, _rawSignature) => {
|
|
|
32
36
|
value: addHexPrefix(tx.value.toString(16)),
|
|
33
37
|
data: tx.data,
|
|
34
38
|
chainId: tx.chainId,
|
|
35
|
-
signature: signature
|
|
39
|
+
signature: signature,
|
|
40
|
+
type: 0
|
|
36
41
|
};
|
|
37
42
|
}
|
|
38
43
|
return ethers.Transaction.from(transaction).serialized;
|
package/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { CrowdloanParaState, NetworkJson } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
2
|
import { AccountAuthType, AccountJson } from '@subwallet/extension-base/background/types';
|
|
4
3
|
import { BN } from '@polkadot/util';
|
|
@@ -38,7 +37,7 @@ export declare function isSameAddress(address1: string, address2: string): boole
|
|
|
38
37
|
export declare function getDomainFromUrl(url: string): string;
|
|
39
38
|
export declare function waitTimeout(ms: number): Promise<void>;
|
|
40
39
|
export declare const stripUrl: (url: string) => string;
|
|
41
|
-
export declare const baseParseIPFSUrl: (input: string) => string | undefined;
|
|
40
|
+
export declare const baseParseIPFSUrl: (input: string, customDomain?: string) => string | undefined;
|
|
42
41
|
export declare const swParseIPFSUrl: (input: string) => string | undefined;
|
|
43
42
|
export declare function wait(milliseconds: number): Promise<void>;
|
|
44
43
|
export * from './account';
|
package/utils/index.js
CHANGED
|
@@ -286,7 +286,8 @@ export const stripUrl = url => {
|
|
|
286
286
|
const parts = url.split('/');
|
|
287
287
|
return parts[2];
|
|
288
288
|
};
|
|
289
|
-
export const baseParseIPFSUrl = input => {
|
|
289
|
+
export const baseParseIPFSUrl = (input, customDomain) => {
|
|
290
|
+
const selectedDomain = customDomain || getRandomIpfsGateway();
|
|
290
291
|
if (!input || input.length === 0) {
|
|
291
292
|
return undefined;
|
|
292
293
|
}
|
|
@@ -297,17 +298,17 @@ export const baseParseIPFSUrl = input => {
|
|
|
297
298
|
return input;
|
|
298
299
|
}
|
|
299
300
|
if (input.startsWith('/ipfs/')) {
|
|
300
|
-
return
|
|
301
|
+
return selectedDomain + input.split('/ipfs/')[1];
|
|
301
302
|
}
|
|
302
303
|
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
303
304
|
// just the IPFS hash
|
|
304
|
-
return
|
|
305
|
+
return selectedDomain + input;
|
|
305
306
|
}
|
|
306
307
|
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
307
308
|
// starts with ipfs://
|
|
308
|
-
return
|
|
309
|
+
return selectedDomain + input.split('ipfs://')[1];
|
|
309
310
|
}
|
|
310
|
-
return
|
|
311
|
+
return selectedDomain + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
311
312
|
};
|
|
312
313
|
|
|
313
314
|
export const swParseIPFSUrl = input => {
|
|
@@ -679,20 +679,5 @@
|
|
|
679
679
|
"slug": "arbitrum_one-ERC20-USDC-0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
680
680
|
"symbol": "USDC",
|
|
681
681
|
"support": "ETHEREUM"
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
"serviceInfo": {
|
|
685
|
-
"transak": {
|
|
686
|
-
"network": "polygon",
|
|
687
|
-
"symbol": "USDC",
|
|
688
|
-
"isSuspended": false
|
|
689
|
-
}
|
|
690
|
-
},
|
|
691
|
-
"network": "polygon",
|
|
692
|
-
"slug": "polygon-ERC20-USDC-0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
693
|
-
"symbol": "USDC",
|
|
694
|
-
"support": "ETHEREUM"
|
|
695
682
|
}
|
|
696
683
|
]
|
|
697
|
-
|
|
698
|
-
|