@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
@@ -281,23 +281,11 @@ class RelayNativeStakingPoolHandler extends _base.default {
281
281
  if (!poolInfo || !poolInfo.statistic) {
282
282
  return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR));
283
283
  }
284
- const [_era, _activeEraInfo] = await Promise.all([chainApi.api.query.staking.currentEra(), chainApi.api.query.staking.activeEra()]);
284
+ const _era = await chainApi.api.query.staking.currentEra();
285
285
  const currentEra = _era.toString();
286
- const activeEraInfo = _activeEraInfo.toPrimitive();
287
- const activeEra = activeEraInfo.index;
288
286
  const allValidators = [];
289
287
  const validatorInfoList = [];
290
- const maxEraRewardPointsEras = _constants2.MaxEraRewardPointsEras;
291
- const endEraForPoints = parseInt(activeEra) - 1;
292
- let startEraForPoints = endEraForPoints - maxEraRewardPointsEras + 1;
293
- 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))]);
294
- const eraRewardMap = {};
295
- for (const item of _eraRewardPoints[0]) {
296
- eraRewardMap[startEraForPoints] = item.toHuman();
297
- startEraForPoints++;
298
- }
299
- const validatorPointsMap = (0, _utils.getValidatorPointsMap)(eraRewardMap);
300
- const topValidatorList = (0, _utils.getTopValidatorByPoints)(validatorPointsMap);
288
+ 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()]);
301
289
 
302
290
  // filter blocked validators
303
291
  const validators = _validators;
@@ -328,11 +316,6 @@ class RelayNativeStakingPoolHandler extends _base.default {
328
316
  const rawValidatorStat = item[1].toHuman();
329
317
  const validatorAddress = rawValidatorInfo[1];
330
318
  if (!blockValidatorList.includes(validatorAddress)) {
331
- var _validatorPointsMap$v;
332
- let isTopQuartile = false;
333
- if (topValidatorList.includes(validatorAddress)) {
334
- isTopQuartile = true;
335
- }
336
319
  const rawTotalStake = rawValidatorStat.total;
337
320
  const rawOwnStake = rawValidatorStat.own;
338
321
  const bnTotalStake = new _util.BN(rawTotalStake.replaceAll(',', ''));
@@ -357,9 +340,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
357
340
  blocked: false,
358
341
  isVerified: false,
359
342
  minBond,
360
- isCrowded: unlimitedNominatorRewarded ? false : nominatorCount > parseInt(maxNominatorRewarded),
361
- eraRewardPoint: ((_validatorPointsMap$v = validatorPointsMap[validatorAddress]) !== null && _validatorPointsMap$v !== void 0 ? _validatorPointsMap$v : _util.BN_ZERO).toString(),
362
- topQuartile: isTopQuartile
343
+ isCrowded: unlimitedNominatorRewarded ? false : nominatorCount > parseInt(maxNominatorRewarded)
363
344
  });
364
345
  }
365
346
  }
@@ -646,18 +646,6 @@ class TransactionService {
646
646
  };
647
647
  break;
648
648
  }
649
- case _KoniTypes.ExtrinsicType.SWAP:
650
- {
651
- const data = (0, _utils3.parseTransactionData)(transaction.data); // TODO: switch by provider
652
- const inputAsset = this.state.chainService.getAssetBySlug(data.quote.pair.from);
653
- historyItem.amount = {
654
- value: data.quote.fromAmount,
655
- symbol: (0, _utils._getAssetSymbol)(inputAsset),
656
- decimals: (0, _utils._getAssetDecimals)(inputAsset)
657
- };
658
- historyItem.additionalInfo = data;
659
- break;
660
- }
661
649
  case _KoniTypes.ExtrinsicType.UNKNOWN:
662
650
  break;
663
651
  }
@@ -754,14 +742,6 @@ class TransactionService {
754
742
  }
755
743
  } else if ([_KoniTypes.ExtrinsicType.STAKING_BOND, _KoniTypes.ExtrinsicType.STAKING_UNBOND, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
756
744
  this.state.eventService.emit('transaction.submitStaking', transaction.chain);
757
- } else if (transaction.extrinsicType === _KoniTypes.ExtrinsicType.SWAP) {
758
- const inputData = (0, _utils3.parseTransactionData)(transaction.data);
759
- const toAssetSlug = inputData.quote.pair.to;
760
-
761
- // todo: consider async
762
- this.state.chainService.updateAssetSetting(toAssetSlug, {
763
- visible: true
764
- }, true).catch(console.error);
765
745
  }
766
746
  }
767
747
  onSuccess(_ref4) {
@@ -3,11 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getChainflipExplorerLink = getChainflipExplorerLink;
7
6
  exports.getExplorerLink = getExplorerLink;
8
7
  exports.parseTransactionData = parseTransactionData;
9
8
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
10
- var _utils2 = require("@subwallet/extension-base/services/swap-service/utils");
11
9
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
12
10
  // SPDX-License-Identifier: Apache-2.0
13
11
 
@@ -55,8 +53,4 @@ function getExplorerLink(chainInfo, value, type) {
55
53
  return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
56
54
  }
57
55
  return undefined;
58
- }
59
- function getChainflipExplorerLink(data, chainInfo) {
60
- const chainflipDomain = (0, _utils._isChainTestNet)(chainInfo) ? _utils2.CHAIN_FLIP_TESTNET_EXPLORER : _utils2.CHAIN_FLIP_MAINNET_EXPLORER;
61
- return `${chainflipDomain}/channels/${data.depositChannelId}`;
62
56
  }
@@ -1,27 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _evm = require("./evm");
7
- Object.keys(_evm).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _evm[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _evm[key];
14
- }
15
- });
16
- });
17
- var _fee = require("./fee");
18
- Object.keys(_fee).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _fee[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _fee[key];
25
- }
26
- });
27
- });
1
+ "use strict";
@@ -236,18 +236,6 @@ Object.keys(_fetchEvmChainInfo).forEach(function (key) {
236
236
  }
237
237
  });
238
238
  });
239
- var _swap = require("./swap");
240
- Object.keys(_swap).forEach(function (key) {
241
- if (key === "default" || key === "__esModule") return;
242
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
243
- if (key in exports && exports[key] === _swap[key]) return;
244
- Object.defineProperty(exports, key, {
245
- enumerable: true,
246
- get: function () {
247
- return _swap[key];
248
- }
249
- });
250
- });
251
239
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
252
240
  // SPDX-License-Identifier: Apache-2.0
253
241
 
@@ -1,7 +1,7 @@
1
1
  import { _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { NominationInfo, NominatorMetadata, StakingType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
3
3
  import { _SubstrateInflationParams } from '@subwallet/extension-base/services/chain-service/constants';
4
- import { EarningStatus, PalletStakingEraRewardPoints, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
4
+ import { EarningStatus, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
5
5
  import BigNumber from 'bignumber.js';
6
6
  import { ApiPromise } from '@polkadot/api';
7
7
  import { Codec } from '@polkadot/types/types';
@@ -158,8 +158,6 @@ export declare function getEarningStatusByNominations(bnTotalActiveStake: BN, no
158
158
  export declare function getValidatorLabel(chain: string): "dApp" | "Validator" | "Collator";
159
159
  export declare function getAvgValidatorEraReward(supportedDays: number, eraRewardHistory: Codec[]): BigNumber;
160
160
  export declare function getSupportedDaysByHistoryDepth(erasPerDay: number, maxSupportedEras: number): 15 | 30;
161
- export declare function getValidatorPointsMap(eraRewardMap: Record<string, PalletStakingEraRewardPoints>): Record<string, BigNumber>;
162
- export declare function getTopValidatorByPoints(validatorPointsList: Record<string, BigNumber>): string[];
163
161
  export declare const getMinStakeErrorMessage: (chainInfo: _ChainInfo, bnMinStake: BN) => string;
164
162
  export declare const getMaxValidatorErrorMessage: (chainInfo: _ChainInfo, max: number) => string;
165
163
  export declare const getExistUnstakeErrorMessage: (chain: string, type?: StakingType, isStakeMore?: boolean) => string;
@@ -197,13 +197,13 @@ export function getYieldAvailableActionsByPosition(yieldPosition, yieldPoolInfo,
197
197
  const result = [];
198
198
  if ([YieldPoolType.NATIVE_STAKING, YieldPoolType.NOMINATION_POOL].includes(yieldPoolInfo.type)) {
199
199
  result.push(YieldAction.STAKE);
200
- const bnActiveStake = new BigNumber(yieldPosition.activeStake);
201
- if (yieldPosition.activeStake && bnActiveStake.gt('0')) {
200
+ const bnActiveStake = new BN(yieldPosition.activeStake);
201
+ if (yieldPosition.activeStake && bnActiveStake.gt(BN_ZERO)) {
202
202
  result.push(YieldAction.UNSTAKE);
203
203
  const isAstarNetwork = _STAKING_CHAIN_GROUP.astar.includes(yieldPosition.chain);
204
204
  const isAmplitudeNetwork = _STAKING_CHAIN_GROUP.amplitude.includes(yieldPosition.chain);
205
- const bnUnclaimedReward = new BigNumber(unclaimedReward || '0');
206
- if ((yieldPosition.type === YieldPoolType.NOMINATION_POOL || isAmplitudeNetwork) && bnUnclaimedReward.gt('0') || isAstarNetwork) {
205
+ const bnUnclaimedReward = new BN(unclaimedReward || '0');
206
+ if ((yieldPosition.type === YieldPoolType.NOMINATION_POOL || isAmplitudeNetwork) && bnUnclaimedReward.gt(BN_ZERO) || isAstarNetwork) {
207
207
  result.push(YieldAction.CLAIM_REWARD);
208
208
  }
209
209
  }
@@ -216,8 +216,8 @@ export function getYieldAvailableActionsByPosition(yieldPosition, yieldPoolInfo,
216
216
  }
217
217
  } else if (yieldPoolInfo.type === YieldPoolType.LIQUID_STAKING) {
218
218
  result.push(YieldAction.START_EARNING);
219
- const activeBalance = new BigNumber(yieldPosition.activeStake);
220
- if (activeBalance.gt('0')) {
219
+ const activeBalance = new BN(yieldPosition.activeStake || '0');
220
+ if (activeBalance.gt(BN_ZERO)) {
221
221
  result.push(YieldAction.UNSTAKE);
222
222
  }
223
223
  const hasWithdrawal = yieldPosition.unstakings.some(unstakingInfo => unstakingInfo.status === UnstakingStatus.CLAIMABLE);
@@ -350,32 +350,6 @@ export function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras) {
350
350
  return 15;
351
351
  }
352
352
  }
353
- export function getValidatorPointsMap(eraRewardMap) {
354
- // mapping store validator and totalPoints
355
- const validatorTotalPointsMap = {};
356
- Object.values(eraRewardMap).forEach(info => {
357
- const individual = info.individual;
358
- Object.entries(individual).forEach(([validator, rawPoints]) => {
359
- const points = rawPoints.replaceAll(',', '');
360
- if (!validatorTotalPointsMap[validator]) {
361
- validatorTotalPointsMap[validator] = new BigNumber(points);
362
- } else {
363
- validatorTotalPointsMap[validator] = validatorTotalPointsMap[validator].plus(points);
364
- }
365
- });
366
- });
367
- return validatorTotalPointsMap;
368
- }
369
- export function getTopValidatorByPoints(validatorPointsList) {
370
- const sortValidatorPointsList = Object.fromEntries(Object.entries(validatorPointsList).sort((a, b) => a[1].minus(b[1]).toNumber()).reverse());
371
-
372
- // keep 50% first validator
373
- const entries = Object.entries(sortValidatorPointsList);
374
- const endIndex = Math.ceil(entries.length / 2);
375
- const top50PercentEntries = entries.slice(0, endIndex);
376
- const top50PercentRecord = Object.fromEntries(top50PercentEntries);
377
- return Object.keys(top50PercentRecord);
378
- }
379
353
  export const getMinStakeErrorMessage = (chainInfo, bnMinStake) => {
380
354
  const tokenInfo = _getChainNativeTokenBasicInfo(chainInfo);
381
355
  const number = formatNumber(bnMinStake.toString(), tokenInfo.decimals || 0, balanceFormatter);
@@ -237,10 +237,5 @@ export default class KoniExtension {
237
237
  private completeCampaignBanner;
238
238
  private subscribeBuyTokens;
239
239
  private subscribeBuyServices;
240
- private subscribeSwapPairs;
241
- private handleSwapRequest;
242
- private getLatestSwapQuote;
243
- private validateSwapProcess;
244
- private handleSwapStep;
245
240
  handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
246
241
  }
@@ -3943,78 +3943,6 @@ export default class KoniExtension {
3943
3943
 
3944
3944
  /* Buy service */
3945
3945
 
3946
- /* Swap service */
3947
- async subscribeSwapPairs(id, port) {
3948
- const cb = createSubscription(id, port);
3949
- let ready = false;
3950
- await this.#koniState.swapService.waitForStarted();
3951
- const callback = rs => {
3952
- if (ready) {
3953
- cb(rs);
3954
- }
3955
- };
3956
- const subscription = this.#koniState.swapService.subscribeSwapPairs(callback);
3957
- this.createUnsubscriptionHandle(id, subscription.unsubscribe);
3958
- port.onDisconnect.addListener(() => {
3959
- this.cancelSubscription(id);
3960
- });
3961
- ready = true;
3962
- return this.#koniState.swapService.getSwapPairs();
3963
- }
3964
- async handleSwapRequest(request) {
3965
- return this.#koniState.swapService.handleSwapRequest(request);
3966
- }
3967
- async getLatestSwapQuote(swapRequest) {
3968
- return this.#koniState.swapService.getLatestQuotes(swapRequest);
3969
- }
3970
- async validateSwapProcess(params) {
3971
- return this.#koniState.swapService.validateSwapProcess(params);
3972
- }
3973
- async handleSwapStep(inputData) {
3974
- const {
3975
- address,
3976
- process,
3977
- quote,
3978
- recipient
3979
- } = inputData;
3980
- if (!quote || !address || !process) {
3981
- return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]);
3982
- }
3983
- const isLastStep = inputData.currentStep + 1 === process.steps.length;
3984
- const swapValidations = await this.#koniState.swapService.validateSwapProcess({
3985
- address,
3986
- process,
3987
- selectedQuote: quote,
3988
- recipient
3989
- });
3990
- if (swapValidations.length > 0) {
3991
- return this.#koniState.transactionService.generateBeforeHandleResponseErrors(swapValidations);
3992
- }
3993
-
3994
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
3995
- const {
3996
- chainType,
3997
- extrinsic,
3998
- extrinsicType,
3999
- transferNativeAmount,
4000
- txChain,
4001
- txData
4002
- } = await this.#koniState.swapService.handleSwapProcess(inputData);
4003
- return await this.#koniState.transactionService.handleTransaction({
4004
- address,
4005
- chain: txChain,
4006
- transaction: extrinsic,
4007
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
4008
- data: txData,
4009
- extrinsicType,
4010
- // change this depends on step
4011
- chainType,
4012
- resolveOnDone: !isLastStep,
4013
- transferNativeAmount
4014
- });
4015
- }
4016
- /* Swap service */
4017
-
4018
3946
  // --------------------------------------------------------------
4019
3947
  // eslint-disable-next-line @typescript-eslint/require-await
4020
3948
  async handle(id, type, request, port) {
@@ -4544,19 +4472,6 @@ export default class KoniExtension {
4544
4472
  case 'pri(database.exportJson)':
4545
4473
  return this.#koniState.dbService.getExportJson();
4546
4474
  /* Database */
4547
-
4548
- /* Swap service */
4549
- case 'pri(swapService.subscribePairs)':
4550
- return this.subscribeSwapPairs(id, port);
4551
- case 'pri(swapService.handleSwapRequest)':
4552
- return this.handleSwapRequest(request);
4553
- case 'pri(swapService.getLatestQuote)':
4554
- return this.getLatestSwapQuote(request);
4555
- case 'pri(swapService.validateSwapProcess)':
4556
- return this.validateSwapProcess(request);
4557
- case 'pri(swapService.handleSwapStep)':
4558
- return this.handleSwapStep(request);
4559
- /* Swap service */
4560
4475
  // Default
4561
4476
  default:
4562
4477
  throw new Error(`Unable to handle message of type ${type}`);
@@ -21,7 +21,6 @@ import { AuthUrls, MetaRequest, SignRequest } from '@subwallet/extension-base/se
21
21
  import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
22
22
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
23
23
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
24
- import { SwapService } from '@subwallet/extension-base/services/swap-service';
25
24
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
26
25
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
27
26
  import { BalanceMap, EvmFeeInfo } from '@subwallet/extension-base/types';
@@ -72,7 +71,6 @@ export default class KoniState {
72
71
  readonly buyService: BuyService;
73
72
  readonly earningService: EarningService;
74
73
  readonly feeService: FeeService;
75
- readonly swapService: SwapService;
76
74
  private generalStatus;
77
75
  private waitSleeping;
78
76
  private waitStarting;
@@ -28,11 +28,10 @@ import SettingService from '@subwallet/extension-base/services/setting-service/S
28
28
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
29
29
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
30
30
  import { SUBSCAN_API_CHAIN_MAP } from '@subwallet/extension-base/services/subscan-service/subscan-chain-map';
31
- import { SwapService } from '@subwallet/extension-base/services/swap-service';
32
31
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
33
32
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
34
33
  import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
35
- import { isAccountAll, stripUrl, TARGET_ENV, wait } from '@subwallet/extension-base/utils';
34
+ import { isAccountAll, stripUrl, TARGET_ENV } from '@subwallet/extension-base/utils';
36
35
  import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
37
36
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
38
37
  import { decodePair } from '@subwallet/keyring/pair/decode';
@@ -105,7 +104,6 @@ export default class KoniState {
105
104
  this.transactionService = new TransactionService(this);
106
105
  this.earningService = new EarningService(this);
107
106
  this.feeService = new FeeService(this);
108
- this.swapService = new SwapService(this);
109
107
  this.subscription = new KoniSubscription(this, this.dbService);
110
108
  this.cron = new KoniCron(this, this.subscription, this.dbService);
111
109
  this.logger = createLogger('State');
@@ -228,7 +226,6 @@ export default class KoniState {
228
226
  this.eventService.emit('chain.ready', true);
229
227
  await this.balanceService.init();
230
228
  await this.earningService.init();
231
- await this.swapService.init();
232
229
  this.onReady();
233
230
  this.onAccountAdd();
234
231
  this.onAccountRemove();
@@ -1204,34 +1201,17 @@ export default class KoniState {
1204
1201
  maxFeePerGas: autoFormatNumber(transactionParams.maxFeePerGas),
1205
1202
  data: transactionParams.data
1206
1203
  };
1207
- const getTransactionGas = async () => {
1208
- try {
1209
- transaction.gas = await web3.eth.estimateGas({
1210
- ...transaction
1211
- });
1212
- } catch (e) {
1213
- // @ts-ignore
1214
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1215
- throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, e === null || e === void 0 ? void 0 : e.message);
1216
- }
1217
- };
1218
1204
 
1219
1205
  // Calculate transaction data
1220
1206
  try {
1221
- await Promise.race([getTransactionGas(), wait(3000).then(async () => {
1222
- if (!transaction.gas) {
1223
- await this.chainService.initSingleApi(networkKey);
1224
- await getTransactionGas();
1225
- }
1226
- })]);
1207
+ transaction.gas = await web3.eth.estimateGas({
1208
+ ...transaction
1209
+ });
1227
1210
  } catch (e) {
1228
1211
  // @ts-ignore
1229
1212
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1230
1213
  throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, e === null || e === void 0 ? void 0 : e.message);
1231
1214
  }
1232
- if (!transaction.gas) {
1233
- throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS);
1234
- }
1235
1215
  let estimateGas;
1236
1216
 
1237
1217
  // TODO: Review, If not override, transaction maybe fail because fee too low
@@ -1416,7 +1396,7 @@ export default class KoniState {
1416
1396
  // Stopping services
1417
1397
  await Promise.all([this.cron.stop(), this.subscription.stop()]);
1418
1398
  await this.pauseAllNetworks(undefined, 'IDLE mode');
1419
- await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop()]);
1399
+ await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop()]);
1420
1400
 
1421
1401
  // Complete sleeping
1422
1402
  sleeping.resolve();
@@ -1448,7 +1428,7 @@ export default class KoniState {
1448
1428
  }
1449
1429
 
1450
1430
  // Start services
1451
- await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start()]);
1431
+ await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start()]);
1452
1432
 
1453
1433
  // Complete starting
1454
1434
  starting.resolve();
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.53-beta.0",
20
+ "version": "1.1.54-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -44,11 +44,6 @@
44
44
  "require": "./cjs/background/errors/ProviderError.js",
45
45
  "default": "./background/errors/ProviderError.js"
46
46
  },
47
- "./background/errors/SwapError": {
48
- "types": "./background/errors/SwapError.d.ts",
49
- "require": "./cjs/background/errors/SwapError.js",
50
- "default": "./background/errors/SwapError.js"
51
- },
52
47
  "./background/errors/SWError": {
53
48
  "types": "./background/errors/SWError.d.ts",
54
49
  "require": "./cjs/background/errors/SWError.js",
@@ -1360,31 +1355,6 @@
1360
1355
  "require": "./cjs/services/subscan-service/types.js",
1361
1356
  "default": "./services/subscan-service/types.js"
1362
1357
  },
1363
- "./services/swap-service": {
1364
- "types": "./services/swap-service/index.d.ts",
1365
- "require": "./cjs/services/swap-service/index.js",
1366
- "default": "./services/swap-service/index.js"
1367
- },
1368
- "./services/swap-service/handler/base-handler": {
1369
- "types": "./services/swap-service/handler/base-handler.d.ts",
1370
- "require": "./cjs/services/swap-service/handler/base-handler.js",
1371
- "default": "./services/swap-service/handler/base-handler.js"
1372
- },
1373
- "./services/swap-service/handler/chainflip-handler": {
1374
- "types": "./services/swap-service/handler/chainflip-handler.d.ts",
1375
- "require": "./cjs/services/swap-service/handler/chainflip-handler.js",
1376
- "default": "./services/swap-service/handler/chainflip-handler.js"
1377
- },
1378
- "./services/swap-service/handler/hydradx-handler": {
1379
- "types": "./services/swap-service/handler/hydradx-handler.d.ts",
1380
- "require": "./cjs/services/swap-service/handler/hydradx-handler.js",
1381
- "default": "./services/swap-service/handler/hydradx-handler.js"
1382
- },
1383
- "./services/swap-service/utils": {
1384
- "types": "./services/swap-service/utils.d.ts",
1385
- "require": "./cjs/services/swap-service/utils.js",
1386
- "default": "./services/swap-service/utils.js"
1387
- },
1388
1358
  "./services/transaction-service": {
1389
1359
  "types": "./services/transaction-service/index.d.ts",
1390
1360
  "require": "./cjs/services/transaction-service/index.js",
@@ -1590,31 +1560,11 @@
1590
1560
  "require": "./cjs/types/fee/index.js",
1591
1561
  "default": "./types/fee/index.js"
1592
1562
  },
1593
- "./types/fee/evm": {
1594
- "types": "./types/fee/evm.d.ts",
1595
- "require": "./cjs/types/fee/evm.js",
1596
- "default": "./types/fee/evm.js"
1597
- },
1598
- "./types/fee/fee": {
1599
- "types": "./types/fee/fee.d.ts",
1600
- "require": "./cjs/types/fee/fee.js",
1601
- "default": "./types/fee/fee.js"
1602
- },
1603
1563
  "./types/ordinal": {
1604
1564
  "types": "./types/ordinal.d.ts",
1605
1565
  "require": "./cjs/types/ordinal.js",
1606
1566
  "default": "./types/ordinal.js"
1607
1567
  },
1608
- "./types/service-base": {
1609
- "types": "./types/service-base.d.ts",
1610
- "require": "./cjs/types/service-base.js",
1611
- "default": "./types/service-base.js"
1612
- },
1613
- "./types/swap": {
1614
- "types": "./types/swap/index.d.ts",
1615
- "require": "./cjs/types/swap/index.js",
1616
- "default": "./types/swap/index.js"
1617
- },
1618
1568
  "./types/transaction": {
1619
1569
  "types": "./types/transaction.d.ts",
1620
1570
  "require": "./cjs/types/transaction.js",
@@ -1831,11 +1781,6 @@
1831
1781
  "./utils/staticData/crowdloanFunds.json": "./utils/staticData/crowdloanFunds.json",
1832
1782
  "./utils/staticData/marketingCampaigns.json": "./utils/staticData/marketingCampaigns.json",
1833
1783
  "./utils/staticData/termAndCondition.json": "./utils/staticData/termAndCondition.json",
1834
- "./utils/swap": {
1835
- "types": "./utils/swap.d.ts",
1836
- "require": "./cjs/utils/swap.js",
1837
- "default": "./utils/swap.js"
1838
- },
1839
1784
  "./utils/translate": {
1840
1785
  "types": "./utils/translate.d.ts",
1841
1786
  "require": "./cjs/utils/translate.js",
@@ -1846,12 +1791,10 @@
1846
1791
  "@acala-network/api": "^5.0.2",
1847
1792
  "@apollo/client": "^3.7.14",
1848
1793
  "@azns/resolver-core": "^1.4.0",
1849
- "@chainflip/sdk": "^1.3.0",
1850
1794
  "@equilab/api": "~1.14.25",
1851
1795
  "@ethereumjs/common": "^4.1.0",
1852
1796
  "@ethereumjs/tx": "^5.1.0",
1853
1797
  "@ethersproject/abi": "^5.7.0",
1854
- "@galacticcouncil/sdk": "^1.2.1",
1855
1798
  "@json-rpc-tools/utils": "^1.7.6",
1856
1799
  "@metamask/safe-event-emitter": "^2.0.0",
1857
1800
  "@metaverse-network-sdk/type-definitions": "^0.0.1-13",
@@ -1873,11 +1816,11 @@
1873
1816
  "@reduxjs/toolkit": "^1.9.1",
1874
1817
  "@sora-substrate/type-definitions": "^1.17.7",
1875
1818
  "@substrate/connect": "^0.7.26",
1876
- "@subwallet/chain-list": "0.2.55-beta.3",
1877
- "@subwallet/extension-base": "^1.1.53-0",
1878
- "@subwallet/extension-chains": "^1.1.53-0",
1879
- "@subwallet/extension-dapp": "^1.1.53-0",
1880
- "@subwallet/extension-inject": "^1.1.53-0",
1819
+ "@subwallet/chain-list": "0.2.54",
1820
+ "@subwallet/extension-base": "^1.1.54-0",
1821
+ "@subwallet/extension-chains": "^1.1.54-0",
1822
+ "@subwallet/extension-dapp": "^1.1.54-0",
1823
+ "@subwallet/extension-inject": "^1.1.54-0",
1881
1824
  "@subwallet/keyring": "^0.1.3",
1882
1825
  "@subwallet/ui-keyring": "^0.1.3",
1883
1826
  "@walletconnect/sign-client": "^2.8.4",
@@ -1914,4 +1857,4 @@
1914
1857
  "web3-eth-contract": "^1.10.0",
1915
1858
  "web3-utils": "^1.10.0"
1916
1859
  }
1917
- }
1860
+ }
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.53-0'
10
+ version: '1.1.54-0'
11
11
  };
@@ -185,8 +185,7 @@ export class BalanceService {
185
185
  const chainInfoMap = this.state.chainService.getChainInfoMap();
186
186
  const evmApiMap = this.state.chainService.getEvmApiMap();
187
187
  const substrateApiMap = this.state.chainService.getSubstrateApiMap();
188
- let unsub = noop;
189
- unsub = subscribeBalance([address], [chain], [tSlug], assetMap, chainInfoMap, substrateApiMap, evmApiMap, result => {
188
+ const unsub = subscribeBalance([address], [chain], [tSlug], assetMap, chainInfoMap, substrateApiMap, evmApiMap, result => {
190
189
  const rs = result[0];
191
190
  if (rs.tokenSlug === tSlug) {
192
191
  hasError = false;
@@ -198,17 +197,15 @@ export class BalanceService {
198
197
  if (callback) {
199
198
  callback(balance);
200
199
  } else {
201
- var _unsub;
202
200
  // Auto unsubscribe if no callback
203
- (_unsub = unsub) === null || _unsub === void 0 ? void 0 : _unsub();
201
+ unsub();
204
202
  }
205
203
  resolve([unsub, balance]);
206
204
  }
207
205
  });
208
206
  setTimeout(() => {
209
207
  if (hasError) {
210
- var _unsub2;
211
- (_unsub2 = unsub) === null || _unsub2 === void 0 ? void 0 : _unsub2();
208
+ unsub();
212
209
  reject(new Error(t('Failed to get balance. Please check your internet connection or change your network endpoint')));
213
210
  }
214
211
  }, 9999);
@@ -1,4 +1,3 @@
1
- import { OptimalProcessParams, OptimalProcessResult } from '@subwallet/extension-base/types/service-base';
2
1
  import { PromiseHandler } from '@subwallet/extension-base/utils/promise';
3
2
  export declare enum ServiceStatus {
4
3
  NOT_INITIALIZED = "not_initialized",
@@ -33,6 +32,3 @@ export interface CronServiceInterface {
33
32
  startCron: () => Promise<void>;
34
33
  stopCron: () => Promise<void>;
35
34
  }
36
- export interface ServiceWithProcessInterface {
37
- generateOptimalProcess(params: OptimalProcessParams): Promise<OptimalProcessResult>;
38
- }
@@ -28,7 +28,7 @@ export const _BALANCE_CHAIN_GROUP = {
28
28
  kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
29
29
  genshiro: ['genshiro_testnet', 'genshiro'],
30
30
  equilibrium_parachain: ['equilibrium_parachain'],
31
- bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network'],
31
+ bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude', 'continuum_network'],
32
32
  statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya'],
33
33
  kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
34
34
  // perhaps there are some runtime updates