@subwallet/extension-base 1.3.74-1 → 1.3.76-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 (39) hide show
  1. package/background/KoniTypes.d.ts +9 -1
  2. package/background/KoniTypes.js +1 -0
  3. package/cjs/background/KoniTypes.js +1 -0
  4. package/cjs/constants/environment.js +4 -2
  5. package/cjs/koni/background/handlers/Extension.js +70 -37
  6. package/cjs/koni/background/handlers/State.js +82 -0
  7. package/cjs/packageInfo.js +1 -1
  8. package/cjs/services/balance-service/index.js +6 -1
  9. package/cjs/services/chain-service/index.js +1 -1
  10. package/cjs/services/earning-service/handlers/native-staking/dtao.js +85 -113
  11. package/cjs/services/earning-service/handlers/native-staking/tanssi.js +2 -1
  12. package/cjs/services/earning-service/handlers/native-staking/tao.js +85 -100
  13. package/cjs/services/earning-service/service.js +17 -2
  14. package/cjs/services/subscan-service/index.js +34 -6
  15. package/cjs/services/substrate-proxy-service/constant.js +1 -1
  16. package/cjs/utils/account/transform.js +3 -3
  17. package/constants/environment.d.ts +1 -0
  18. package/constants/environment.js +2 -1
  19. package/koni/background/handlers/Extension.d.ts +3 -0
  20. package/koni/background/handlers/Extension.js +33 -1
  21. package/koni/background/handlers/State.d.ts +5 -0
  22. package/koni/background/handlers/State.js +82 -0
  23. package/package.json +6 -6
  24. package/packageInfo.js +1 -1
  25. package/services/balance-service/index.js +6 -1
  26. package/services/chain-service/index.js +1 -1
  27. package/services/earning-service/handlers/native-staking/dtao.d.ts +2 -10
  28. package/services/earning-service/handlers/native-staking/dtao.js +86 -116
  29. package/services/earning-service/handlers/native-staking/tanssi.js +2 -1
  30. package/services/earning-service/handlers/native-staking/tao.d.ts +4 -3
  31. package/services/earning-service/handlers/native-staking/tao.js +84 -101
  32. package/services/earning-service/service.d.ts +2 -1
  33. package/services/earning-service/service.js +17 -2
  34. package/services/subscan-service/index.d.ts +2 -0
  35. package/services/subscan-service/index.js +33 -5
  36. package/services/substrate-proxy-service/constant.js +1 -1
  37. package/types/yield/actions/join/submit.d.ts +8 -1
  38. package/types/yield/info/account/info.d.ts +11 -5
  39. package/utils/account/transform.js +3 -3
@@ -17,7 +17,7 @@ import { AuthUrls } from '@subwallet/extension-base/services/request-service/typ
17
17
  import { CrowdloanContributionsResponse } from '@subwallet/extension-base/services/subscan-service/types';
18
18
  import { BitcoinTransactionData, SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
19
19
  import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
20
- import { AccountChainType, AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BalanceType, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalTransferPath, CurrentAccountInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleSubstrateProxyWrappedTxResponse, HandleYieldStepParams, InternalRequestSign, LeavePoolAdditionalData, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestBounceableValidate, RequestChangeAllowOneSign, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, RequestEarningImpact, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetAmountForPair, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestGetTokensCanPayFee, RequestGetYieldPoolTargets, RequestInputAccountSubscribe, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMetadataHash, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, RequestShortenMetadata, RequestStakeCancelWithdrawal, RequestStakeClaimReward, RequestSubmitProcessTransaction, RequestSubscribeProcessById, RequestTransfer, RequestUnlockDotCheckCanMint, RequestUnlockDotSubscribeMintedData, RequestYieldLeave, RequestYieldStepSubmit, RequestYieldWithdrawal, ResponseAccountBatchExportV2, ResponseAccountCreateSuriV2, ResponseAccountNameValidate, ResponseBatchJsonGetAccountInfo, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseEarlyValidateYield, ResponseExportAccountProxyMnemonic, ResponseGetAllTonWalletContractVersion, ResponseGetDeriveAccounts, ResponseGetDeriveSuggestion, ResponseGetYieldPoolTargets, ResponseInputAccountSubscribe, ResponseJsonGetAccountInfo, ResponseMetadataHash, ResponseMnemonicCreateV2, ResponseMnemonicValidateV2, ResponsePrivateKeyValidateV2, ResponseShortenMetadata, ResponseSubscribeProcessAlive, ResponseSubscribeProcessById, StorageDataInterface, SubmitChangeValidatorStaking, SubmitYieldJoinData, SubmitYieldStepData, SubnetYieldPositionInfo, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapRequestV2, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
20
+ import { AccountChainType, AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BalanceType, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalTransferPath, CurrentAccountInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleSubstrateProxyWrappedTxResponse, HandleYieldStepParams, InternalRequestSign, LeavePoolAdditionalData, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestBounceableValidate, RequestChangeAllowOneSign, RequestChangeBittensorRootClaimType, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, RequestEarningImpact, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetAmountForPair, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestGetTokensCanPayFee, RequestGetYieldPoolTargets, RequestInputAccountSubscribe, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMetadataHash, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, RequestShortenMetadata, RequestStakeCancelWithdrawal, RequestStakeClaimReward, RequestSubmitProcessTransaction, RequestSubscribeProcessById, RequestTransfer, RequestUnlockDotCheckCanMint, RequestUnlockDotSubscribeMintedData, RequestYieldLeave, RequestYieldStepSubmit, RequestYieldWithdrawal, ResponseAccountBatchExportV2, ResponseAccountCreateSuriV2, ResponseAccountNameValidate, ResponseBatchJsonGetAccountInfo, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseEarlyValidateYield, ResponseExportAccountProxyMnemonic, ResponseGetAllTonWalletContractVersion, ResponseGetDeriveAccounts, ResponseGetDeriveSuggestion, ResponseGetYieldPoolTargets, ResponseInputAccountSubscribe, ResponseJsonGetAccountInfo, ResponseMetadataHash, ResponseMnemonicCreateV2, ResponseMnemonicValidateV2, ResponsePrivateKeyValidateV2, ResponseShortenMetadata, ResponseSubscribeProcessAlive, ResponseSubscribeProcessById, StorageDataInterface, SubmitChangeValidatorStaking, SubmitYieldJoinData, SubmitYieldStepData, SubnetYieldPositionInfo, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapRequestV2, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
21
21
  import { RequestSubmitSignPsbtTransfer, RequestSubmitTransfer, RequestSubmitTransferWithId, RequestSubscribeTransfer, ResponseSubscribeTransfer, ResponseSubscribeTransferConfirmation } from '@subwallet/extension-base/types/balance/transfer';
22
22
  import { RequestClaimBridge } from '@subwallet/extension-base/types/bridge';
23
23
  import { ApprovePendingTxRequest, CancelPendingTxRequest, ExecutePendingTxRequest, InitMultisigTxRequest, InitMultisigTxResponse, RequestGetSignableAccountInfos, ResponseGetSignableAccountInfos } from '@subwallet/extension-base/types/multisig';
@@ -397,6 +397,9 @@ export declare type RequestSaveBrowserConfig = {
397
397
  export declare type RequestSaveOSConfig = {
398
398
  osConfig: OSConfig;
399
399
  };
400
+ export interface RequestSaveSubscanApiKey {
401
+ apiKey: string;
402
+ }
400
403
  export interface RandomTestRequest {
401
404
  start: number;
402
405
  end: number;
@@ -430,6 +433,7 @@ export declare enum ExtrinsicType {
430
433
  STAKING_CANCEL_UNSTAKE = "staking.cancel_unstake",
431
434
  JOIN_YIELD_POOL = "earn.join_pool",
432
435
  CHANGE_EARNING_VALIDATOR = "earn.nominate",
436
+ CHANGE_BITTENSOR_ROOT_CLAIM_TYPE = "earn.change_bittensor_root_claim_type",
433
437
  MINT_VDOT = "earn.mint_vdot",
434
438
  MINT_LDOT = "earn.mint_ldot",
435
439
  MINT_SDOT = "earn.mint_sdot",
@@ -480,6 +484,7 @@ export interface ExtrinsicDataTypeMap {
480
484
  [ExtrinsicType.STAKING_CANCEL_COMPOUNDING]: RequestTuringCancelStakeCompound;
481
485
  [ExtrinsicType.STAKING_CANCEL_UNSTAKE]: RequestStakeCancelWithdrawal;
482
486
  [ExtrinsicType.STAKING_POOL_WITHDRAW]: any;
487
+ [ExtrinsicType.CHANGE_BITTENSOR_ROOT_CLAIM_TYPE]: RequestChangeBittensorRootClaimType;
483
488
  [ExtrinsicType.JOIN_YIELD_POOL]: RequestYieldStepSubmit;
484
489
  [ExtrinsicType.MINT_VDOT]: SubmitYieldStepData;
485
490
  [ExtrinsicType.MINT_LDOT]: SubmitYieldStepData;
@@ -1976,6 +1981,8 @@ export interface KoniRequestSignatures {
1976
1981
  'pri(settings.saveAppConfig)': [RequestSaveAppConfig, boolean];
1977
1982
  'pri(settings.saveBrowserConfig)': [RequestSaveBrowserConfig, boolean];
1978
1983
  'pri(settings.saveOSConfig)': [RequestSaveOSConfig, boolean];
1984
+ 'pri(settings.saveSubscanApiKey)': [RequestSaveSubscanApiKey, boolean];
1985
+ 'pri(settings.getSubscanApiKey)': [null, string | null];
1979
1986
  'pri(yield.subscribePoolInfo)': [null, YieldPoolInfo[], YieldPoolInfo[]];
1980
1987
  'pri(yield.subscribeYieldPosition)': [null, YieldPositionInfo[], YieldPositionInfo[]];
1981
1988
  'pri(yield.subscribeYieldReward)': [null, EarningRewardJson, EarningRewardJson];
@@ -1997,6 +2004,7 @@ export interface KoniRequestSignatures {
1997
2004
  'pri(yield.claimReward.submit)': [RequestStakeClaimReward, SWTransactionResponse];
1998
2005
  'pri(yield.getEarningImpact)': [RequestEarningImpact, EarningImpactResult];
1999
2006
  'pri(yield.changeValidator.submit)': [SubmitYieldJoinData, SWTransactionResponse];
2007
+ 'pri(yield.changeBittensorRootClaimType.submit)': [RequestChangeBittensorRootClaimType, SWTransactionResponse];
2000
2008
  'pri(transaction.history.getSubscription)': [null, TransactionHistoryItem[], TransactionHistoryItem[]];
2001
2009
  'pri(transaction.history.subscribe)': [RequestSubscribeHistory, ResponseSubscribeHistory, TransactionHistoryItem[]];
2002
2010
  'pri(transfer.getMaxTransferable)': [RequestMaxTransferable, AmountData];
@@ -94,6 +94,7 @@ export let ExtrinsicType;
94
94
  ExtrinsicType["STAKING_CANCEL_UNSTAKE"] = "staking.cancel_unstake";
95
95
  ExtrinsicType["JOIN_YIELD_POOL"] = "earn.join_pool";
96
96
  ExtrinsicType["CHANGE_EARNING_VALIDATOR"] = "earn.nominate";
97
+ ExtrinsicType["CHANGE_BITTENSOR_ROOT_CLAIM_TYPE"] = "earn.change_bittensor_root_claim_type";
97
98
  ExtrinsicType["MINT_VDOT"] = "earn.mint_vdot";
98
99
  ExtrinsicType["MINT_LDOT"] = "earn.mint_ldot";
99
100
  ExtrinsicType["MINT_SDOT"] = "earn.mint_sdot";
@@ -109,6 +109,7 @@ exports.ExtrinsicType = ExtrinsicType;
109
109
  ExtrinsicType["STAKING_CANCEL_UNSTAKE"] = "staking.cancel_unstake";
110
110
  ExtrinsicType["JOIN_YIELD_POOL"] = "earn.join_pool";
111
111
  ExtrinsicType["CHANGE_EARNING_VALIDATOR"] = "earn.nominate";
112
+ ExtrinsicType["CHANGE_BITTENSOR_ROOT_CLAIM_TYPE"] = "earn.change_bittensor_root_claim_type";
112
113
  ExtrinsicType["MINT_VDOT"] = "earn.mint_vdot";
113
114
  ExtrinsicType["MINT_LDOT"] = "earn.mint_ldot";
114
115
  ExtrinsicType["MINT_SDOT"] = "earn.mint_sdot";
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isProductionMode = exports.SW_EXTERNAL_SERVICES_API = exports.BACKEND_API_URL = exports.APP_VERSION = void 0;
6
+ exports.isProductionMode = exports.SW_EXTERNAL_SERVICES_API = exports.SUBSCAN_GATEWAY_URL = exports.BACKEND_API_URL = exports.APP_VERSION = void 0;
7
7
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
9
 
@@ -16,4 +16,6 @@ exports.isProductionMode = isProductionMode;
16
16
  const BACKEND_API_URL = process.env.SUBWALLET_API || (isProductionMode ? 'https://sw-services.subwallet.app/api' : 'https://be-dev.subwallet.app/api');
17
17
  exports.BACKEND_API_URL = BACKEND_API_URL;
18
18
  const SW_EXTERNAL_SERVICES_API = process.env.SW_EXTERNAL_SERVICES_API || (isProductionMode ? 'https://external-services.subwallet.app' : 'https://external-services-dev.subwallet.app');
19
- exports.SW_EXTERNAL_SERVICES_API = SW_EXTERNAL_SERVICES_API;
19
+ exports.SW_EXTERNAL_SERVICES_API = SW_EXTERNAL_SERVICES_API;
20
+ const SUBSCAN_GATEWAY_URL = process.env.SUBSCAN_GATEWAY_URL || 'https://gateway-dev.konistudio.xyz';
21
+ exports.SUBSCAN_GATEWAY_URL = SUBSCAN_GATEWAY_URL;
@@ -3884,14 +3884,23 @@ class KoniExtension {
3884
3884
  this.#koniState.saveEnvConfig('osConfig', request.osConfig);
3885
3885
  return true;
3886
3886
  }
3887
+ async saveSubscanApiKey(_ref60) {
3888
+ let {
3889
+ apiKey
3890
+ } = _ref60;
3891
+ return await this.#koniState.saveSubscanApiKey(apiKey);
3892
+ }
3893
+ async getSubscanApiKey() {
3894
+ return await this.#koniState.getSubscanApiKey();
3895
+ }
3887
3896
 
3888
3897
  /// Wallet connect
3889
3898
 
3890
3899
  // Connect
3891
- async connectWalletConnect(_ref60) {
3900
+ async connectWalletConnect(_ref61) {
3892
3901
  let {
3893
3902
  uri
3894
- } = _ref60;
3903
+ } = _ref61;
3895
3904
  await this.#koniState.walletConnectService.connect(uri);
3896
3905
  return true;
3897
3906
  }
@@ -3904,11 +3913,11 @@ class KoniExtension {
3904
3913
  });
3905
3914
  return this.#koniState.requestService.allConnectWCRequests;
3906
3915
  }
3907
- async approveWalletConnectSession(_ref61) {
3916
+ async approveWalletConnectSession(_ref62) {
3908
3917
  let {
3909
3918
  accounts: selectedAccounts,
3910
3919
  id
3911
- } = _ref61;
3920
+ } = _ref62;
3912
3921
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3913
3922
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
3914
3923
  throw new Error('The proposal has been expired');
@@ -3920,8 +3929,8 @@ class KoniExtension {
3920
3929
  const availableNamespaces = {};
3921
3930
  const namespaces = {};
3922
3931
  const chainInfoMap = this.#koniState.getChainInfoMap();
3923
- Object.entries(requiredNamespaces).forEach(_ref62 => {
3924
- let [key, namespace] = _ref62;
3932
+ Object.entries(requiredNamespaces).forEach(_ref63 => {
3933
+ let [key, namespace] = _ref63;
3925
3934
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3926
3935
  if (namespace.chains) {
3927
3936
  const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
@@ -3934,8 +3943,8 @@ class KoniExtension {
3934
3943
  throw new Error((0, _utils1.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
3935
3944
  }
3936
3945
  });
3937
- Object.entries(optionalNamespaces).forEach(_ref63 => {
3938
- let [key, namespace] = _ref63;
3946
+ Object.entries(optionalNamespaces).forEach(_ref64 => {
3947
+ let [key, namespace] = _ref64;
3939
3948
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3940
3949
  if (namespace.chains) {
3941
3950
  const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
@@ -3959,8 +3968,8 @@ class KoniExtension {
3959
3968
  }
3960
3969
  }
3961
3970
  });
3962
- Object.entries(availableNamespaces).forEach(_ref64 => {
3963
- let [key, namespace] = _ref64;
3971
+ Object.entries(availableNamespaces).forEach(_ref65 => {
3972
+ let [key, namespace] = _ref65;
3964
3973
  if (namespace.chains) {
3965
3974
  const accounts = selectedAccounts.filter(address => {
3966
3975
  const [_namespace] = address.split(':');
@@ -3984,10 +3993,10 @@ class KoniExtension {
3984
3993
  request.resolve();
3985
3994
  return true;
3986
3995
  }
3987
- async rejectWalletConnectSession(_ref65) {
3996
+ async rejectWalletConnectSession(_ref66) {
3988
3997
  let {
3989
3998
  id
3990
- } = _ref65;
3999
+ } = _ref66;
3991
4000
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3992
4001
  const wcId = request.request.id;
3993
4002
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
@@ -4009,10 +4018,10 @@ class KoniExtension {
4009
4018
  });
4010
4019
  return this.#koniState.walletConnectService.sessions;
4011
4020
  }
4012
- async disconnectWalletConnectSession(_ref66) {
4021
+ async disconnectWalletConnectSession(_ref67) {
4013
4022
  let {
4014
4023
  topic
4015
- } = _ref66;
4024
+ } = _ref67;
4016
4025
  await this.#koniState.walletConnectService.disconnect(topic);
4017
4026
  return true;
4018
4027
  }
@@ -4025,18 +4034,18 @@ class KoniExtension {
4025
4034
  });
4026
4035
  return this.#koniState.requestService.allNotSupportWCRequests;
4027
4036
  }
4028
- approveWalletConnectNotSupport(_ref67) {
4037
+ approveWalletConnectNotSupport(_ref68) {
4029
4038
  let {
4030
4039
  id
4031
- } = _ref67;
4040
+ } = _ref68;
4032
4041
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
4033
4042
  request.resolve();
4034
4043
  return true;
4035
4044
  }
4036
- rejectWalletConnectNotSupport(_ref68) {
4045
+ rejectWalletConnectNotSupport(_ref69) {
4037
4046
  let {
4038
4047
  id
4039
- } = _ref68;
4048
+ } = _ref69;
4040
4049
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
4041
4050
  request.reject(new Error('USER_REJECTED'));
4042
4051
  return true;
@@ -4044,11 +4053,11 @@ class KoniExtension {
4044
4053
 
4045
4054
  /// Manta
4046
4055
 
4047
- async enableMantaPay(_ref69) {
4056
+ async enableMantaPay(_ref70) {
4048
4057
  let {
4049
4058
  address,
4050
4059
  password
4051
- } = _ref69;
4060
+ } = _ref70;
4052
4061
  // always takes the current account
4053
4062
  function timeout() {
4054
4063
  return new Promise(resolve => setTimeout(resolve, 1500));
@@ -4138,11 +4147,11 @@ class KoniExtension {
4138
4147
  async disableMantaPay(address) {
4139
4148
  return this.#koniState.disableMantaPay(address);
4140
4149
  }
4141
- async isTonBounceableAddress(_ref70) {
4150
+ async isTonBounceableAddress(_ref71) {
4142
4151
  let {
4143
4152
  address,
4144
4153
  chain
4145
- } = _ref70;
4154
+ } = _ref71;
4146
4155
  try {
4147
4156
  const tonApi = this.#koniState.getTonApi(chain);
4148
4157
  const state = await tonApi.getAccountState(address);
@@ -4188,10 +4197,10 @@ class KoniExtension {
4188
4197
 
4189
4198
  /* Metadata */
4190
4199
 
4191
- async findRawMetadata(_ref71) {
4200
+ async findRawMetadata(_ref72) {
4192
4201
  let {
4193
4202
  genesisHash
4194
- } = _ref71;
4203
+ } = _ref72;
4195
4204
  const {
4196
4205
  metadata,
4197
4206
  specVersion,
@@ -4205,20 +4214,20 @@ class KoniExtension {
4205
4214
  userExtensions
4206
4215
  };
4207
4216
  }
4208
- async calculateMetadataHash(_ref72) {
4217
+ async calculateMetadataHash(_ref73) {
4209
4218
  let {
4210
4219
  chain
4211
- } = _ref72;
4220
+ } = _ref73;
4212
4221
  const hash = await this.#koniState.calculateMetadataHash(chain);
4213
4222
  return {
4214
4223
  metadataHash: hash || ''
4215
4224
  };
4216
4225
  }
4217
- async shortenMetadata(_ref73) {
4226
+ async shortenMetadata(_ref74) {
4218
4227
  let {
4219
4228
  chain,
4220
4229
  txBlob
4221
- } = _ref73;
4230
+ } = _ref74;
4222
4231
  const shorten = await this.#koniState.shortenMetadata(chain, txBlob);
4223
4232
  return {
4224
4233
  txMetadata: shorten || ''
@@ -4592,21 +4601,39 @@ class KoniExtension {
4592
4601
  chainType: _KoniTypes.ChainType.SUBSTRATE
4593
4602
  });
4594
4603
  }
4595
-
4604
+ async handleChangeBittensorRootClaimType(params) {
4605
+ const {
4606
+ address,
4607
+ slug
4608
+ } = params;
4609
+ const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
4610
+ if (!poolHandler) {
4611
+ return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_types5.BasicTxErrorType.INVALID_PARAMS)]);
4612
+ }
4613
+ const extrinsic = await this.#koniState.earningService.handleChangeRootClaimType(params);
4614
+ return await this.#koniState.transactionService.handleTransaction({
4615
+ address,
4616
+ chain: poolHandler.chain,
4617
+ transaction: extrinsic,
4618
+ data: params,
4619
+ extrinsicType: _KoniTypes.ExtrinsicType.CHANGE_BITTENSOR_ROOT_CLAIM_TYPE,
4620
+ chainType: _KoniTypes.ChainType.SUBSTRATE
4621
+ });
4622
+ }
4596
4623
  /* Campaign */
4597
4624
 
4598
- unlockDotCheckCanMint(_ref74) {
4625
+ unlockDotCheckCanMint(_ref75) {
4599
4626
  let {
4600
4627
  address,
4601
4628
  network,
4602
4629
  slug
4603
- } = _ref74;
4630
+ } = _ref75;
4604
4631
  return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
4605
4632
  }
4606
- unlockDotSubscribeMintedData(id, port, _ref75) {
4633
+ unlockDotSubscribeMintedData(id, port, _ref76) {
4607
4634
  let {
4608
4635
  transactionId
4609
- } = _ref75;
4636
+ } = _ref76;
4610
4637
  const cb = (0, _subscriptions.createSubscription)(id, port);
4611
4638
  const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
4612
4639
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
@@ -4638,10 +4665,10 @@ class KoniExtension {
4638
4665
  });
4639
4666
  return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
4640
4667
  }
4641
- async completeCampaignBanner(_ref76) {
4668
+ async completeCampaignBanner(_ref77) {
4642
4669
  let {
4643
4670
  slug
4644
- } = _ref76;
4671
+ } = _ref77;
4645
4672
  const campaign = await this.#koniState.dbService.getCampaign(slug);
4646
4673
  if (campaign) {
4647
4674
  await this.#koniState.dbService.upsertCampaign({
@@ -5176,8 +5203,8 @@ class KoniExtension {
5176
5203
  resolve();
5177
5204
  }
5178
5205
  };
5179
- this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(_ref77 => {
5180
- let [_unsub, rs] = _ref77;
5206
+ this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(_ref78 => {
5207
+ let [_unsub, rs] = _ref78;
5181
5208
  unsub = _unsub;
5182
5209
  onRs(rs);
5183
5210
  }).catch(console.error);
@@ -5579,6 +5606,8 @@ class KoniExtension {
5579
5606
  return await this.yieldGetEarningImpact(request);
5580
5607
  case 'pri(yield.changeValidator.submit)':
5581
5608
  return await this.handleYieldChangeValidator(request);
5609
+ case 'pri(yield.changeBittensorRootClaimType.submit)':
5610
+ return await this.handleChangeBittensorRootClaimType(request);
5582
5611
  /* Others */
5583
5612
 
5584
5613
  /* Actions */
@@ -5838,6 +5867,10 @@ class KoniExtension {
5838
5867
  return this.saveBrowserConfig(request);
5839
5868
  case 'pri(settings.saveOSConfig)':
5840
5869
  return this.saveOSConfig(request);
5870
+ case 'pri(settings.saveSubscanApiKey)':
5871
+ return await this.saveSubscanApiKey(request);
5872
+ case 'pri(settings.getSubscanApiKey)':
5873
+ return await this.getSubscanApiKey();
5841
5874
 
5842
5875
  /// Keyring state
5843
5876
  case 'pri(keyring.subscribe)':
@@ -69,6 +69,8 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
69
69
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
70
70
  const passworder = require('browser-passworder');
71
71
  const ERROR_CONFIRMATION_TYPE = ['errorConnectNetwork'];
72
+ const SUBSCAN_API_KEY_STORAGE = 'subscan_api_key';
73
+ const SUBSCAN_SECRET_STORAGE = 'subscan_secret';
72
74
 
73
75
  // List of providers passed into constructor. This is the list of providers
74
76
  // exposed by the extension.
@@ -228,6 +230,8 @@ class KoniState {
228
230
  }
229
231
  afterChainServiceInit() {
230
232
  this.subscanService.setSubscanChainMap(this.chainService.getSubscanChainMap());
233
+ // Sync Subscan API key
234
+ this.syncSubscanApiKey().catch(console.error);
231
235
  }
232
236
  async init() {
233
237
  await this.eventService.waitCryptoReady;
@@ -1612,6 +1616,84 @@ class KoniState {
1612
1616
  return null;
1613
1617
  }
1614
1618
  }
1619
+ async getExtensionSecret() {
1620
+ const result = await _storage.SWStorage.instance.getItem(SUBSCAN_SECRET_STORAGE);
1621
+ let secret = result;
1622
+ if (!secret) {
1623
+ secret = crypto.randomUUID();
1624
+ await _storage.SWStorage.instance.setItem(SUBSCAN_SECRET_STORAGE, secret);
1625
+ }
1626
+ return secret;
1627
+ }
1628
+
1629
+ // Generate password used to encrypt/decrypt Subscan API key
1630
+ // Password = extensionId + extension secret
1631
+ // -> Bind encrypted data to THIS extension instance
1632
+ // -> Prevent other extensions/apps from decrypting the stored API key
1633
+ async getSubscanApiCipherPassword() {
1634
+ var _chrome, _chrome$runtime;
1635
+ const secret = await this.getExtensionSecret();
1636
+ const extensionId = ((_chrome = chrome) === null || _chrome === void 0 ? void 0 : (_chrome$runtime = _chrome.runtime) === null || _chrome$runtime === void 0 ? void 0 : _chrome$runtime.id) || 'subwallet';
1637
+ return `${extensionId}:${secret}`;
1638
+ }
1639
+ async saveSubscanApiKey(apiKey) {
1640
+ try {
1641
+ // Get cipher password used for encryption
1642
+ const cipherPassword = await this.getSubscanApiCipherPassword();
1643
+
1644
+ // Encrypt API key before saving to storage
1645
+ // -> Avoid storing API key as plain text
1646
+ // -> Prevent leakage if storage is inspected
1647
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
1648
+ const encryptedData = await passworder.encrypt(cipherPassword, {
1649
+ apiKey
1650
+ });
1651
+
1652
+ // Persist encrypted API key to extension storage
1653
+ await _storage.SWStorage.instance.setItem(SUBSCAN_API_KEY_STORAGE, JSON.stringify(encryptedData));
1654
+
1655
+ // Sync API key to Subscan service instance
1656
+ // -> Ensure API calls immediately use the latest key
1657
+ await this.syncSubscanApiKey();
1658
+ return true;
1659
+ } catch (e) {
1660
+ console.error(e);
1661
+ return false;
1662
+ }
1663
+ }
1664
+ async getSubscanApiKey() {
1665
+ try {
1666
+ // Read encrypted API key from storage
1667
+ const encryptedData = await _storage.SWStorage.instance.getItem(SUBSCAN_API_KEY_STORAGE);
1668
+ if (!encryptedData) {
1669
+ return null;
1670
+ }
1671
+
1672
+ // Recreate cipher password for decryption
1673
+ const cipherPassword = await this.getSubscanApiCipherPassword();
1674
+
1675
+ // Decrypt stored API key
1676
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
1677
+ const decryptedData = await passworder.decrypt(cipherPassword, JSON.parse(encryptedData));
1678
+
1679
+ // Return API key if exists
1680
+ return decryptedData.apiKey || null;
1681
+ } catch (e) {
1682
+ console.error(e);
1683
+ return null;
1684
+ }
1685
+ }
1686
+
1687
+ // Sync decrypted API key to Subscan service
1688
+ // -> Allows service layer to use API key for authenticated requests
1689
+ async syncSubscanApiKey() {
1690
+ try {
1691
+ const apiKey = await this.getSubscanApiKey();
1692
+ this.subscanService.setApiKey(apiKey);
1693
+ } catch (e) {
1694
+ console.error('Failed to sync Subscan API key:', e);
1695
+ }
1696
+ }
1615
1697
  onCheckToRemindUser() {
1616
1698
  this.onHandleRemindExportAccount().catch(console.error);
1617
1699
  }
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.3.74-1'
16
+ version: '1.3.76-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -810,7 +810,12 @@ class BalanceService {
810
810
  /** Return token slugs with balance in substrate chain - only work with substrate chains that have subscanSlug **/
811
811
  async getSubstrateTokensBalanceByChain(address, chainSlug, assetsByChain) {
812
812
  const tokenBalanceSlugs = [];
813
- const balanceData = await this.state.subscanService.getMultiChainBalance(address);
813
+
814
+ // Do not block chain enabling flow when balance detection fails.
815
+ const balanceData = await this.state.subscanService.getMultiChainBalance(address).catch(e => {
816
+ console.error(e);
817
+ return [];
818
+ });
814
819
  if (!balanceData) {
815
820
  return [];
816
821
  }
@@ -1446,10 +1446,10 @@ class ChainService {
1446
1446
  paraId: params.chainSpec.paraId,
1447
1447
  symbol: params.chainEditInfo.symbol,
1448
1448
  genesisHash: params.chainSpec.genesisHash,
1449
+ supportProxy: false,
1449
1450
  relaySlug: null,
1450
1451
  hasNativeNft: false,
1451
1452
  supportStaking: params.chainSpec.paraId === null,
1452
- supportProxy: false,
1453
1453
  supportMultisig: false,
1454
1454
  supportSmartContract: null
1455
1455
  };