@subwallet/extension-base 1.1.53-beta.0 → 1.1.54-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.
Files changed (96) hide show
  1. package/background/KoniTypes.d.ts +1 -9
  2. package/background/KoniTypes.js +0 -1
  3. package/background/errors/TransactionError.js +0 -9
  4. package/cjs/background/KoniTypes.js +0 -1
  5. package/cjs/background/errors/TransactionError.js +0 -9
  6. package/cjs/koni/api/staking/bonding/utils.js +6 -35
  7. package/cjs/koni/background/handlers/Extension.js +0 -85
  8. package/cjs/koni/background/handlers/State.js +5 -25
  9. package/cjs/packageInfo.js +1 -1
  10. package/cjs/services/balance-service/index.js +3 -6
  11. package/cjs/services/chain-service/constants.js +1 -1
  12. package/cjs/services/chain-service/index.js +18 -43
  13. package/cjs/services/chain-service/utils/index.js +2 -7
  14. package/cjs/services/chain-service/utils/patch.js +1 -1
  15. package/cjs/services/earning-service/constants/chains.js +2 -4
  16. package/cjs/services/earning-service/handlers/native-staking/astar.js +3 -4
  17. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -22
  18. package/cjs/services/transaction-service/index.js +0 -20
  19. package/cjs/services/transaction-service/utils.js +0 -6
  20. package/cjs/types/fee/index.js +1 -27
  21. package/cjs/utils/index.js +0 -12
  22. package/koni/api/staking/bonding/utils.d.ts +1 -3
  23. package/koni/api/staking/bonding/utils.js +6 -32
  24. package/koni/background/handlers/Extension.d.ts +0 -5
  25. package/koni/background/handlers/Extension.js +0 -85
  26. package/koni/background/handlers/State.d.ts +0 -2
  27. package/koni/background/handlers/State.js +6 -26
  28. package/package.json +7 -64
  29. package/packageInfo.js +1 -1
  30. package/services/balance-service/index.js +3 -6
  31. package/services/base/types.d.ts +0 -4
  32. package/services/chain-service/constants.js +1 -1
  33. package/services/chain-service/index.d.ts +0 -4
  34. package/services/chain-service/index.js +0 -24
  35. package/services/chain-service/utils/index.d.ts +5 -6
  36. package/services/chain-service/utils/index.js +2 -5
  37. package/services/chain-service/utils/patch.js +1 -1
  38. package/services/earning-service/constants/chains.d.ts +0 -1
  39. package/services/earning-service/constants/chains.js +0 -1
  40. package/services/earning-service/handlers/native-staking/astar.js +3 -4
  41. package/services/earning-service/handlers/native-staking/relay-chain.js +5 -24
  42. package/services/event-service/types.d.ts +0 -1
  43. package/services/transaction-service/index.js +0 -20
  44. package/services/transaction-service/utils.d.ts +0 -2
  45. package/services/transaction-service/utils.js +2 -6
  46. package/types/fee/index.d.ts +49 -2
  47. package/types/fee/index.js +1 -5
  48. package/types/yield/info/chain/target.d.ts +0 -2
  49. package/types/yield/info/pallet.d.ts +0 -4
  50. package/utils/index.d.ts +0 -1
  51. package/utils/index.js +1 -2
  52. package/background/errors/SwapError.d.ts +0 -6
  53. package/background/errors/SwapError.js +0 -57
  54. package/cjs/background/errors/SwapError.js +0 -64
  55. package/cjs/koni/api/dotsama/balance.js +0 -464
  56. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  57. package/cjs/services/balance-service/helpers/subscribe/balance.js +0 -140
  58. package/cjs/services/chain-service/utils.js +0 -506
  59. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  60. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  61. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  62. package/cjs/services/storage-service/index.js +0 -241
  63. package/cjs/services/swap-service/handler/base-handler.js +0 -171
  64. package/cjs/services/swap-service/handler/chainflip-handler.js +0 -407
  65. package/cjs/services/swap-service/handler/hydradx-handler.js +0 -444
  66. package/cjs/services/swap-service/index.js +0 -249
  67. package/cjs/services/swap-service/utils.js +0 -126
  68. package/cjs/types/balance.js +0 -1
  69. package/cjs/types/fee/evm.js +0 -1
  70. package/cjs/types/fee/fee.js +0 -70
  71. package/cjs/types/service-base.js +0 -1
  72. package/cjs/types/swap/index.js +0 -50
  73. package/cjs/types.js +0 -1
  74. package/cjs/utils/address.js +0 -34
  75. package/cjs/utils/keyring.js +0 -57
  76. package/cjs/utils/swap.js +0 -78
  77. package/services/swap-service/handler/base-handler.d.ts +0 -38
  78. package/services/swap-service/handler/base-handler.js +0 -162
  79. package/services/swap-service/handler/chainflip-handler.d.ts +0 -30
  80. package/services/swap-service/handler/chainflip-handler.js +0 -399
  81. package/services/swap-service/handler/hydradx-handler.d.ts +0 -36
  82. package/services/swap-service/handler/hydradx-handler.js +0 -435
  83. package/services/swap-service/index.d.ts +0 -32
  84. package/services/swap-service/index.js +0 -240
  85. package/services/swap-service/utils.d.ts +0 -18
  86. package/services/swap-service/utils.js +0 -105
  87. package/types/fee/evm.d.ts +0 -49
  88. package/types/fee/evm.js +0 -1
  89. package/types/fee/fee.d.ts +0 -32
  90. package/types/fee/fee.js +0 -63
  91. package/types/service-base.d.ts +0 -10
  92. package/types/service-base.js +0 -1
  93. package/types/swap/index.d.ts +0 -166
  94. package/types/swap/index.js +0 -41
  95. package/utils/swap.d.ts +0 -3
  96. package/utils/swap.js +0 -70
@@ -23,7 +23,6 @@ export declare class ChainService {
23
23
  private assetRegistrySubject;
24
24
  private multiChainAssetMapSubject;
25
25
  private xcmRefMapSubject;
26
- private swapRefMapSubject;
27
26
  private assetLogoMapSubject;
28
27
  private chainLogoMapSubject;
29
28
  private assetMapPatch;
@@ -32,9 +31,7 @@ export declare class ChainService {
32
31
  private assetSettingSubject;
33
32
  private logger;
34
33
  constructor(dbService: DatabaseService, eventService: EventService);
35
- subscribeSwapRefMap(): Subject<Record<string, _AssetRef>>;
36
34
  get xcmRefMap(): Record<string, _AssetRef>;
37
- get swapRefMap(): Record<string, _AssetRef>;
38
35
  getEvmApi(slug: string): import("./handler/EvmApi").EvmApi;
39
36
  getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
40
37
  getSubstrateApiMap(): Record<string, import("./handler/SubstrateApi").SubstrateApi>;
@@ -93,7 +90,6 @@ export declare class ChainService {
93
90
  autoEnableTokens(): Promise<void>;
94
91
  handleLatestData(): void;
95
92
  private initApis;
96
- initSingleApi(slug: string): Promise<boolean>;
97
93
  private initApiForChain;
98
94
  private destroyApiForChain;
99
95
  enableChain(chainSlug: string): Promise<boolean>;
@@ -35,7 +35,6 @@ export class ChainService {
35
35
  assetRegistrySubject = new Subject();
36
36
  multiChainAssetMapSubject = new Subject();
37
37
  xcmRefMapSubject = new Subject();
38
- swapRefMapSubject = new Subject();
39
38
  assetLogoMapSubject = new BehaviorSubject(AssetLogoMap);
40
39
  chainLogoMapSubject = new BehaviorSubject(ChainLogoMap);
41
40
  assetMapPatch = JSON.stringify({});
@@ -51,7 +50,6 @@ export class ChainService {
51
50
  this.chainStateMapSubject.next(this.dataMap.chainStateMap);
52
51
  this.assetRegistrySubject.next(this.dataMap.assetRegistry);
53
52
  this.xcmRefMapSubject.next(this.xcmRefMap);
54
- this.swapRefMapSubject.next(this.swapRefMap);
55
53
  if (MODULE_SUPPORT.MANTA_ZK) {
56
54
  console.log('Init Manta ZK');
57
55
  this.mantaChainHandler = new MantaPrivateHandler(dbService);
@@ -60,9 +58,6 @@ export class ChainService {
60
58
  this.evmChainHandler = new EvmChainHandler(this);
61
59
  this.logger = createLogger('chain-service');
62
60
  }
63
- subscribeSwapRefMap() {
64
- return this.swapRefMapSubject;
65
- }
66
61
 
67
62
  // Getter
68
63
  get xcmRefMap() {
@@ -74,15 +69,6 @@ export class ChainService {
74
69
  });
75
70
  return result;
76
71
  }
77
- get swapRefMap() {
78
- const result = {};
79
- Object.entries(this.dataMap.assetRefMap).forEach(([key, assetRef]) => {
80
- if (assetRef.path === _AssetRefPath.SWAP) {
81
- result[key] = assetRef;
82
- }
83
- });
84
- return result;
85
- }
86
72
  getEvmApi(slug) {
87
73
  return this.evmChainHandler.getEvmApiByChain(slug);
88
74
  }
@@ -495,7 +481,6 @@ export class ChainService {
495
481
  });
496
482
  this.dataMap.assetRefMap = updatedAssetRefMap;
497
483
  this.xcmRefMapSubject.next(this.xcmRefMap);
498
- this.swapRefMapSubject.next(this.swapRefMap);
499
484
  this.logger.log('Finished updating latest asset ref');
500
485
  }
501
486
  handleLatestPriceId(latestPriceIds) {
@@ -609,15 +594,6 @@ export class ChainService {
609
594
  }
610
595
  }));
611
596
  }
612
- async initSingleApi(slug) {
613
- const chainInfoMap = this.getChainInfoMap();
614
- const chainStateMap = this.getChainStateMap();
615
- if (!chainStateMap[slug].active) {
616
- return false;
617
- }
618
- await this.initApiForChain(chainInfoMap[slug]);
619
- return true;
620
- }
621
597
  async initApiForChain(chainInfo) {
622
598
  const {
623
599
  endpoint,
@@ -51,15 +51,14 @@ export declare function _isSubstrateRelayChain(chainInfo: _ChainInfo): boolean;
51
51
  export declare function _isSubstrateParaChain(chainInfo: _ChainInfo): boolean;
52
52
  export declare function _getEvmAbiExplorer(chainInfo: _ChainInfo): string;
53
53
  export declare function _isAssetValuable(assetInfo: _ChainAsset): boolean;
54
- export declare function _getMultiChainAsset(assetInfo?: _ChainAsset): string;
55
- export declare function _getAssetPriceId(assetInfo?: _ChainAsset): string;
56
- export declare function _getAssetName(assetInfo?: _ChainAsset): string;
54
+ export declare function _getMultiChainAsset(assetInfo: _ChainAsset): string;
55
+ export declare function _getAssetPriceId(assetInfo: _ChainAsset): string;
57
56
  export declare function _getMultiChainAssetPriceId(multiChainAsset: _MultiChainAsset): string;
58
- export declare function _getAssetSymbol(assetInfo?: _ChainAsset): string;
57
+ export declare function _getAssetSymbol(assetInfo: _ChainAsset): string;
59
58
  export declare function _getMultiChainAssetSymbol(multiChainAsset: _MultiChainAsset): string;
60
- export declare function _getAssetOriginChain(assetInfo?: _ChainAsset): string;
59
+ export declare function _getAssetOriginChain(assetInfo: _ChainAsset): string;
61
60
  export declare function _getChainName(chainInfo: _ChainInfo): string;
62
- export declare function _getAssetDecimals(assetInfo?: _ChainAsset): number;
61
+ export declare function _getAssetDecimals(assetInfo: _ChainAsset): number;
63
62
  export declare function _getBlockExplorerFromChain(chainInfo: _ChainInfo): string | undefined;
64
63
  export declare function _parseMetadataForSmartContractAsset(contractAddress: string): Record<string, string>;
65
64
  export declare function _isChainTestNet(chainInfo: _ChainInfo): boolean;
@@ -280,9 +280,6 @@ export function _getMultiChainAsset(assetInfo) {
280
280
  export function _getAssetPriceId(assetInfo) {
281
281
  return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.priceId) || '';
282
282
  }
283
- export function _getAssetName(assetInfo) {
284
- return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.name) || '';
285
- }
286
283
  export function _getMultiChainAssetPriceId(multiChainAsset) {
287
284
  return (multiChainAsset === null || multiChainAsset === void 0 ? void 0 : multiChainAsset.priceId) || '';
288
285
  }
@@ -293,13 +290,13 @@ export function _getMultiChainAssetSymbol(multiChainAsset) {
293
290
  return multiChainAsset.symbol;
294
291
  }
295
292
  export function _getAssetOriginChain(assetInfo) {
296
- return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.originChain) || '';
293
+ return assetInfo.originChain;
297
294
  }
298
295
  export function _getChainName(chainInfo) {
299
296
  return chainInfo.name;
300
297
  }
301
298
  export function _getAssetDecimals(assetInfo) {
302
- return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.decimals) || 0;
299
+ return assetInfo.decimals || 0;
303
300
  }
304
301
  export function _getBlockExplorerFromChain(chainInfo) {
305
302
  let blockExplorer;
@@ -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.55-beta.3';
8
+ const ChainListVersion = '0.2.54';
9
9
  export async function fetchPatchData(slug) {
10
10
  try {
11
11
  const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
@@ -13,7 +13,6 @@ export declare const _STAKING_CHAIN_GROUP: {
13
13
  krest_network: string[];
14
14
  manta: string[];
15
15
  };
16
- export declare const MaxEraRewardPointsEras = 14;
17
16
  export declare const ST_LIQUID_TOKEN_ABI: Record<string, any>;
18
17
  export declare const MANTA_VALIDATOR_POINTS_PER_BLOCK = 20;
19
18
  export declare const MANTA_MIN_DELEGATION = 500;
@@ -18,7 +18,6 @@ export const _STAKING_CHAIN_GROUP = {
18
18
  krest_network: ['krest_network'],
19
19
  manta: ['manta_network']
20
20
  };
21
- export const MaxEraRewardPointsEras = 14;
22
21
 
23
22
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
24
23
  export const ST_LIQUID_TOKEN_ABI = require("./abis/st_liquid_token_abi.json");
@@ -242,12 +242,11 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
242
242
  };
243
243
  }
244
244
  async subscribePoolPosition(useAddresses, resultCallback) {
245
- var _substrateApi$api$que;
246
245
  let cancel = false;
247
246
  const substrateApi = await this.substrateApi.isReady;
248
247
  const defaultInfo = this.baseInfo;
249
248
  const chainInfo = this.chainInfo;
250
- const unsub = await ((_substrateApi$api$que = substrateApi.api.query.dappsStaking) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.ledger.multi(useAddresses, async ledgers => {
249
+ const unsub = await substrateApi.api.query.dappsStaking.ledger.multi(useAddresses, async ledgers => {
251
250
  if (cancel) {
252
251
  unsub();
253
252
  return;
@@ -281,10 +280,10 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
281
280
  }
282
281
  }));
283
282
  }
284
- }));
283
+ });
285
284
  return () => {
286
285
  cancel = true;
287
- unsub && unsub();
286
+ unsub();
288
287
  };
289
288
  }
290
289
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
5
5
  import { BasicTxErrorType, ExtrinsicType, StakingTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
6
- import { calculateAlephZeroValidatorReturn, calculateChainStakedReturnV2, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getAvgValidatorEraReward, getCommission, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getSupportedDaysByHistoryDepth, getTopValidatorByPoints, getValidatorPointsMap } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
6
+ import { calculateAlephZeroValidatorReturn, calculateChainStakedReturnV2, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getAvgValidatorEraReward, getCommission, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getSupportedDaysByHistoryDepth } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
7
7
  import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
8
8
  import { _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
9
- import { _STAKING_CHAIN_GROUP, MaxEraRewardPointsEras } from '@subwallet/extension-base/services/earning-service/constants';
9
+ import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
10
10
  import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
11
11
  import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
12
12
  import { balanceFormatter, formatNumber, reformatAddress } from '@subwallet/extension-base/utils';
@@ -274,23 +274,11 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
274
274
  if (!poolInfo || !poolInfo.statistic) {
275
275
  return Promise.reject(new TransactionError(BasicTxErrorType.INTERNAL_ERROR));
276
276
  }
277
- const [_era, _activeEraInfo] = await Promise.all([chainApi.api.query.staking.currentEra(), chainApi.api.query.staking.activeEra()]);
277
+ const _era = await chainApi.api.query.staking.currentEra();
278
278
  const currentEra = _era.toString();
279
- const activeEraInfo = _activeEraInfo.toPrimitive();
280
- const activeEra = activeEraInfo.index;
281
279
  const allValidators = [];
282
280
  const validatorInfoList = [];
283
- const maxEraRewardPointsEras = MaxEraRewardPointsEras;
284
- const endEraForPoints = parseInt(activeEra) - 1;
285
- let startEraForPoints = endEraForPoints - maxEraRewardPointsEras + 1;
286
- const [_totalEraStake, _eraStakers, _minBond, _stakingRewards, _validators, ..._eraRewardPoints] = 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(), chainApi.api.query.staking.erasRewardPoints.multi([...Array(maxEraRewardPointsEras).keys()].map(i => i + startEraForPoints))]);
287
- const eraRewardMap = {};
288
- for (const item of _eraRewardPoints[0]) {
289
- eraRewardMap[startEraForPoints] = item.toHuman();
290
- startEraForPoints++;
291
- }
292
- const validatorPointsMap = getValidatorPointsMap(eraRewardMap);
293
- const topValidatorList = getTopValidatorByPoints(validatorPointsMap);
281
+ 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()]);
294
282
 
295
283
  // filter blocked validators
296
284
  const validators = _validators;
@@ -321,11 +309,6 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
321
309
  const rawValidatorStat = item[1].toHuman();
322
310
  const validatorAddress = rawValidatorInfo[1];
323
311
  if (!blockValidatorList.includes(validatorAddress)) {
324
- var _validatorPointsMap$v;
325
- let isTopQuartile = false;
326
- if (topValidatorList.includes(validatorAddress)) {
327
- isTopQuartile = true;
328
- }
329
312
  const rawTotalStake = rawValidatorStat.total;
330
313
  const rawOwnStake = rawValidatorStat.own;
331
314
  const bnTotalStake = new BN(rawTotalStake.replaceAll(',', ''));
@@ -350,9 +333,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
350
333
  blocked: false,
351
334
  isVerified: false,
352
335
  minBond,
353
- isCrowded: unlimitedNominatorRewarded ? false : nominatorCount > parseInt(maxNominatorRewarded),
354
- eraRewardPoint: ((_validatorPointsMap$v = validatorPointsMap[validatorAddress]) !== null && _validatorPointsMap$v !== void 0 ? _validatorPointsMap$v : BN_ZERO).toString(),
355
- topQuartile: isTopQuartile
336
+ isCrowded: unlimitedNominatorRewarded ? false : nominatorCount > parseInt(maxNominatorRewarded)
356
337
  });
357
338
  }
358
339
  }
@@ -38,7 +38,6 @@ export interface EventRegistry {
38
38
  'buy.tokens.ready': [boolean];
39
39
  'buy.services.ready': [boolean];
40
40
  'earning.ready': [boolean];
41
- 'swap.ready': [boolean];
42
41
  }
43
42
  export declare type EventType = keyof EventRegistry;
44
43
  export declare const COMMON_RELOAD_EVENTS: EventType[];
@@ -639,18 +639,6 @@ export default class TransactionService {
639
639
  };
640
640
  break;
641
641
  }
642
- case ExtrinsicType.SWAP:
643
- {
644
- const data = parseTransactionData(transaction.data); // TODO: switch by provider
645
- const inputAsset = this.state.chainService.getAssetBySlug(data.quote.pair.from);
646
- historyItem.amount = {
647
- value: data.quote.fromAmount,
648
- symbol: _getAssetSymbol(inputAsset),
649
- decimals: _getAssetDecimals(inputAsset)
650
- };
651
- historyItem.additionalInfo = data;
652
- break;
653
- }
654
642
  case ExtrinsicType.UNKNOWN:
655
643
  break;
656
644
  }
@@ -744,14 +732,6 @@ export default class TransactionService {
744
732
  }
745
733
  } else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW, ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
746
734
  this.state.eventService.emit('transaction.submitStaking', transaction.chain);
747
- } else if (transaction.extrinsicType === ExtrinsicType.SWAP) {
748
- const inputData = parseTransactionData(transaction.data);
749
- const toAssetSlug = inputData.quote.pair.to;
750
-
751
- // todo: consider async
752
- this.state.chainService.updateAssetSetting(toAssetSlug, {
753
- visible: true
754
- }, true).catch(console.error);
755
735
  }
756
736
  }
757
737
  onSuccess({
@@ -1,6 +1,4 @@
1
1
  import { _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { ExtrinsicDataTypeMap, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
3
- import { ChainflipSwapTxData } from '@subwallet/extension-base/types/swap';
4
3
  export declare function parseTransactionData<T extends ExtrinsicType>(data: unknown): ExtrinsicDataTypeMap[T];
5
4
  export declare function getExplorerLink(chainInfo: _ChainInfo, value: string, type: 'account' | 'tx'): string | undefined;
6
- export declare function getChainflipExplorerLink(data: ChainflipSwapTxData, chainInfo: _ChainInfo): string;
@@ -1,8 +1,8 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { _getBlockExplorerFromChain, _isChainTestNet, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
5
- import { CHAIN_FLIP_MAINNET_EXPLORER, CHAIN_FLIP_TESTNET_EXPLORER } from '@subwallet/extension-base/services/swap-service/utils';
4
+ import { _getBlockExplorerFromChain, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
5
+
6
6
  // @ts-ignore
7
7
  export function parseTransactionData(data) {
8
8
  // @ts-ignore
@@ -47,8 +47,4 @@ export function getExplorerLink(chainInfo, value, type) {
47
47
  return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
48
48
  }
49
49
  return undefined;
50
- }
51
- export function getChainflipExplorerLink(data, chainInfo) {
52
- const chainflipDomain = _isChainTestNet(chainInfo) ? CHAIN_FLIP_TESTNET_EXPLORER : CHAIN_FLIP_MAINNET_EXPLORER;
53
- return `${chainflipDomain}/channels/${data.depositChannelId}`;
54
50
  }
@@ -1,2 +1,49 @@
1
- export * from './evm';
2
- export * from './fee';
1
+ import BigN from 'bignumber.js';
2
+ interface BaseFeeInfo {
3
+ busyNetwork: boolean;
4
+ }
5
+ export interface EvmLegacyFeeInfo extends BaseFeeInfo {
6
+ gasPrice: string;
7
+ maxFeePerGas: undefined;
8
+ maxPriorityFeePerGas: undefined;
9
+ baseGasFee: undefined;
10
+ }
11
+ export interface EvmEIP1995FeeInfo extends BaseFeeInfo {
12
+ gasPrice: undefined;
13
+ maxFeePerGas: BigN;
14
+ maxPriorityFeePerGas: BigN;
15
+ baseGasFee: BigN;
16
+ }
17
+ export declare type EvmFeeInfo = EvmLegacyFeeInfo | EvmEIP1995FeeInfo;
18
+ export interface EvmLegacyFeeInfoCache extends BaseFeeInfo {
19
+ gasPrice: string;
20
+ maxFeePerGas: undefined;
21
+ maxPriorityFeePerGas: undefined;
22
+ baseGasFee: undefined;
23
+ }
24
+ export interface EvmEIP1995FeeInfoCache extends BaseFeeInfo {
25
+ gasPrice: undefined;
26
+ maxFeePerGas: string;
27
+ maxPriorityFeePerGas: string;
28
+ baseGasFee: string;
29
+ }
30
+ export declare type EvmFeeInfoCache = EvmLegacyFeeInfoCache | EvmEIP1995FeeInfoCache;
31
+ export interface InfuraFeeDetail {
32
+ suggestedMaxPriorityFeePerGas: string;
33
+ suggestedMaxFeePerGas: string;
34
+ minWaitTimeEstimate: number;
35
+ maxWaitTimeEstimate: number;
36
+ }
37
+ export interface InfuraFeeInfo {
38
+ low: InfuraFeeDetail;
39
+ medium: InfuraFeeDetail;
40
+ high: InfuraFeeDetail;
41
+ networkCongestion: number;
42
+ estimatedBaseFee: string;
43
+ latestPriorityFeeRange: [string, string];
44
+ historicalPriorityFeeRange: [string, string];
45
+ historicalBaseFeeRange: [string, string];
46
+ priorityFeeTrend: 'down' | 'up';
47
+ baseFeeTrend: 'down' | 'up';
48
+ }
49
+ export {};
@@ -1,5 +1 @@
1
- // Copyright 2019-2022 @subwallet/extension-base
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- export * from "./evm.js";
5
- export * from "./fee.js";
1
+ export {};
@@ -21,8 +21,6 @@ export interface ValidatorInfo {
21
21
  isVerified: boolean;
22
22
  icon?: string;
23
23
  isCrowded: boolean;
24
- eraRewardPoint?: string;
25
- topQuartile?: boolean;
26
24
  }
27
25
  export declare type YieldPoolTarget = NominationPoolInfo | ValidatorInfo;
28
26
  export interface RequestGetYieldPoolTargets {
@@ -140,10 +140,6 @@ export interface PalletStakingActiveEraInfo {
140
140
  index: string;
141
141
  start: string;
142
142
  }
143
- export interface PalletStakingEraRewardPoints {
144
- total: string;
145
- individual: Record<string, string>;
146
- }
147
143
  export interface RuntimeDispatchInfo {
148
144
  weight: {
149
145
  refTime: number;
package/utils/index.d.ts CHANGED
@@ -53,4 +53,3 @@ export * from './translate';
53
53
  export * from './object';
54
54
  export * from './fetchStaticData';
55
55
  export * from './fetchEvmChainInfo';
56
- export * from './swap';
package/utils/index.js CHANGED
@@ -354,5 +354,4 @@ export * from "./registry.js";
354
354
  export * from "./translate.js";
355
355
  export * from "./object.js";
356
356
  export * from "./fetchStaticData.js";
357
- export * from "./fetchEvmChainInfo.js";
358
- export * from "./swap.js";
357
+ export * from "./fetchEvmChainInfo.js";
@@ -1,6 +0,0 @@
1
- import { SWError } from '@subwallet/extension-base/background/errors/SWError';
2
- import { SwapErrorType } from '@subwallet/extension-base/types/swap';
3
- export declare class SwapError extends SWError {
4
- errorType: SwapErrorType;
5
- constructor(errorType: SwapErrorType, errMessage?: string, data?: unknown);
6
- }
@@ -1,57 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { SWError } from '@subwallet/extension-base/background/errors/SWError';
5
- import { detectTranslate } from '@subwallet/extension-base/utils';
6
- const defaultErrorMap = {
7
- ERROR_FETCHING_QUOTE: {
8
- message: detectTranslate('No swap quote found. Adjust your amount or try again later'),
9
- code: undefined
10
- },
11
- NOT_MEET_MIN_SWAP: {
12
- message: detectTranslate('Amount too low. Increase your amount and try again'),
13
- code: undefined
14
- },
15
- QUOTE_TIMEOUT: {
16
- message: detectTranslate('Quote timeout'),
17
- code: undefined
18
- },
19
- UNKNOWN: {
20
- message: detectTranslate('Undefined error. Check your Internet connection or contact support'),
21
- code: undefined
22
- },
23
- ASSET_NOT_SUPPORTED: {
24
- message: detectTranslate('This swap pair is not supported'),
25
- code: undefined
26
- },
27
- INVALID_RECIPIENT: {
28
- message: detectTranslate('Invalid recipient'),
29
- code: undefined
30
- },
31
- SWAP_EXCEED_ALLOWANCE: {
32
- message: detectTranslate('You cannot swap all your balance. Lower your amount and try again'),
33
- code: undefined
34
- },
35
- SWAP_NOT_ENOUGH_BALANCE: {
36
- message: detectTranslate('You must deposit more funds to swap'),
37
- code: undefined
38
- },
39
- NOT_ENOUGH_LIQUIDITY: {
40
- message: detectTranslate('There is not enough liquidity to complete the swap. Lower your amount and try again'),
41
- code: undefined
42
- },
43
- AMOUNT_CANNOT_BE_ZERO: {
44
- message: detectTranslate('Amount must be greater than 0'),
45
- code: undefined
46
- }
47
- };
48
- export class SwapError extends SWError {
49
- constructor(errorType, errMessage, data) {
50
- const {
51
- code,
52
- message
53
- } = defaultErrorMap[errorType];
54
- super(errorType, errMessage || message, code, data);
55
- this.errorType = errorType;
56
- }
57
- }
@@ -1,64 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SwapError = void 0;
7
- var _SWError = require("@subwallet/extension-base/background/errors/SWError");
8
- var _utils = require("@subwallet/extension-base/utils");
9
- // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- const defaultErrorMap = {
13
- ERROR_FETCHING_QUOTE: {
14
- message: (0, _utils.detectTranslate)('No swap quote found. Adjust your amount or try again later'),
15
- code: undefined
16
- },
17
- NOT_MEET_MIN_SWAP: {
18
- message: (0, _utils.detectTranslate)('Amount too low. Increase your amount and try again'),
19
- code: undefined
20
- },
21
- QUOTE_TIMEOUT: {
22
- message: (0, _utils.detectTranslate)('Quote timeout'),
23
- code: undefined
24
- },
25
- UNKNOWN: {
26
- message: (0, _utils.detectTranslate)('Undefined error. Check your Internet connection or contact support'),
27
- code: undefined
28
- },
29
- ASSET_NOT_SUPPORTED: {
30
- message: (0, _utils.detectTranslate)('This swap pair is not supported'),
31
- code: undefined
32
- },
33
- INVALID_RECIPIENT: {
34
- message: (0, _utils.detectTranslate)('Invalid recipient'),
35
- code: undefined
36
- },
37
- SWAP_EXCEED_ALLOWANCE: {
38
- message: (0, _utils.detectTranslate)('You cannot swap all your balance. Lower your amount and try again'),
39
- code: undefined
40
- },
41
- SWAP_NOT_ENOUGH_BALANCE: {
42
- message: (0, _utils.detectTranslate)('You must deposit more funds to swap'),
43
- code: undefined
44
- },
45
- NOT_ENOUGH_LIQUIDITY: {
46
- message: (0, _utils.detectTranslate)('There is not enough liquidity to complete the swap. Lower your amount and try again'),
47
- code: undefined
48
- },
49
- AMOUNT_CANNOT_BE_ZERO: {
50
- message: (0, _utils.detectTranslate)('Amount must be greater than 0'),
51
- code: undefined
52
- }
53
- };
54
- class SwapError extends _SWError.SWError {
55
- constructor(errorType, errMessage, data) {
56
- const {
57
- code,
58
- message
59
- } = defaultErrorMap[errorType];
60
- super(errorType, errMessage || message, code, data);
61
- this.errorType = errorType;
62
- }
63
- }
64
- exports.SwapError = SwapError;