@subwallet/extension-base 1.3.2-0 → 1.3.4-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 (124) hide show
  1. package/background/KoniTypes.d.ts +13 -0
  2. package/background/KoniTypes.js +1 -0
  3. package/cjs/background/KoniTypes.js +1 -0
  4. package/cjs/constants/blocked-actions-list.js +1 -2
  5. package/cjs/constants/index.js +16 -1
  6. package/cjs/constants/remind-notification-time.js +14 -0
  7. package/cjs/core/logic-validation/transfer.js +12 -6
  8. package/cjs/core/substrate/xcm-parser.js +13 -1
  9. package/cjs/koni/api/contract-handler/utils/index.js +20 -1
  10. package/cjs/koni/api/nft/assethub_nft/index.js +30 -7
  11. package/cjs/koni/background/handlers/Extension.js +110 -23
  12. package/cjs/koni/background/handlers/State.js +5 -2
  13. package/cjs/packageInfo.js +1 -1
  14. package/cjs/services/balance-service/helpers/process.js +2 -1
  15. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +11 -12
  16. package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
  17. package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
  18. package/cjs/services/chain-service/handler/EvmApi.js +12 -21
  19. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +29 -0
  20. package/cjs/services/chain-service/index.js +44 -13
  21. package/cjs/services/chain-service/utils/index.js +20 -0
  22. package/cjs/services/earning-service/handlers/base.js +14 -4
  23. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +10 -2
  24. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +2 -0
  25. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
  26. package/cjs/services/earning-service/handlers/native-staking/tao.js +25 -38
  27. package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -4
  28. package/cjs/services/earning-service/service.js +5 -0
  29. package/cjs/services/earning-service/utils/index.js +0 -11
  30. package/cjs/services/inapp-notification-service/consts.js +31 -0
  31. package/cjs/services/inapp-notification-service/index.js +260 -0
  32. package/cjs/services/inapp-notification-service/interfaces.js +32 -0
  33. package/cjs/services/inapp-notification-service/utils.js +197 -0
  34. package/cjs/services/keyring-service/context/account-context.js +9 -0
  35. package/cjs/services/keyring-service/context/state.js +4 -0
  36. package/cjs/services/setting-service/SettingService.js +9 -1
  37. package/cjs/services/setting-service/constants.js +16 -1
  38. package/cjs/services/storage-service/DatabaseService.js +42 -3
  39. package/cjs/services/storage-service/databases/index.js +3 -0
  40. package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
  41. package/cjs/services/transaction-service/index.js +13 -0
  42. package/cjs/services/transaction-service/utils.js +3 -0
  43. package/cjs/types/avail-bridge/index.js +1 -0
  44. package/cjs/types/notification/index.js +1 -0
  45. package/cjs/utils/account/transform.js +9 -5
  46. package/cjs/utils/staticData/index.js +7 -2
  47. package/constants/blocked-actions-list.js +1 -2
  48. package/constants/index.d.ts +2 -0
  49. package/constants/index.js +3 -1
  50. package/constants/remind-notification-time.d.ts +2 -0
  51. package/constants/remind-notification-time.js +7 -0
  52. package/core/logic-validation/transfer.js +12 -6
  53. package/core/substrate/xcm-parser.d.ts +1 -0
  54. package/core/substrate/xcm-parser.js +12 -1
  55. package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
  56. package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
  57. package/koni/api/contract-handler/utils/index.d.ts +4 -0
  58. package/koni/api/contract-handler/utils/index.js +15 -0
  59. package/koni/api/nft/assethub_nft/index.d.ts +2 -0
  60. package/koni/api/nft/assethub_nft/index.js +30 -7
  61. package/koni/background/handlers/Extension.d.ts +7 -0
  62. package/koni/background/handlers/Extension.js +112 -25
  63. package/koni/background/handlers/State.d.ts +2 -0
  64. package/koni/background/handlers/State.js +5 -2
  65. package/package.json +54 -6
  66. package/packageInfo.js +1 -1
  67. package/services/balance-service/helpers/process.js +2 -1
  68. package/services/balance-service/helpers/subscribe/substrate/index.js +5 -6
  69. package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
  70. package/services/balance-service/transfer/xcm/availBridge.js +186 -0
  71. package/services/balance-service/transfer/xcm/index.d.ts +8 -8
  72. package/services/balance-service/transfer/xcm/index.js +46 -5
  73. package/services/chain-service/handler/EvmApi.js +12 -21
  74. package/services/chain-service/handler/SubstrateChainHandler.d.ts +2 -0
  75. package/services/chain-service/handler/SubstrateChainHandler.js +29 -0
  76. package/services/chain-service/index.d.ts +2 -0
  77. package/services/chain-service/index.js +45 -14
  78. package/services/chain-service/types.d.ts +2 -1
  79. package/services/chain-service/utils/index.d.ts +3 -0
  80. package/services/chain-service/utils/index.js +14 -0
  81. package/services/earning-service/handlers/base.d.ts +2 -0
  82. package/services/earning-service/handlers/base.js +11 -1
  83. package/services/earning-service/handlers/native-staking/amplitude.js +10 -2
  84. package/services/earning-service/handlers/native-staking/para-chain.js +2 -0
  85. package/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
  86. package/services/earning-service/handlers/native-staking/tao.d.ts +15 -11
  87. package/services/earning-service/handlers/native-staking/tao.js +21 -38
  88. package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
  89. package/services/earning-service/handlers/nomination-pool/index.js +9 -4
  90. package/services/earning-service/service.d.ts +2 -0
  91. package/services/earning-service/service.js +5 -0
  92. package/services/earning-service/utils/index.d.ts +0 -2
  93. package/services/earning-service/utils/index.js +0 -10
  94. package/services/inapp-notification-service/consts.d.ts +18 -0
  95. package/services/inapp-notification-service/consts.js +22 -0
  96. package/services/inapp-notification-service/index.d.ts +37 -0
  97. package/services/inapp-notification-service/index.js +252 -0
  98. package/services/inapp-notification-service/interfaces.d.ts +77 -0
  99. package/services/inapp-notification-service/interfaces.js +24 -0
  100. package/services/inapp-notification-service/utils.d.ts +55 -0
  101. package/services/inapp-notification-service/utils.js +173 -0
  102. package/services/keyring-service/context/account-context.d.ts +3 -0
  103. package/services/keyring-service/context/account-context.js +9 -0
  104. package/services/keyring-service/context/state.d.ts +1 -0
  105. package/services/keyring-service/context/state.js +4 -0
  106. package/services/setting-service/SettingService.js +9 -1
  107. package/services/setting-service/constants.d.ts +2 -0
  108. package/services/setting-service/constants.js +15 -0
  109. package/services/storage-service/DatabaseService.d.ts +15 -0
  110. package/services/storage-service/DatabaseService.js +42 -3
  111. package/services/storage-service/databases/index.d.ts +2 -0
  112. package/services/storage-service/databases/index.js +3 -0
  113. package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
  114. package/services/storage-service/db-stores/InappNotification.js +73 -0
  115. package/services/transaction-service/index.js +13 -0
  116. package/services/transaction-service/utils.js +3 -0
  117. package/types/avail-bridge/index.d.ts +6 -0
  118. package/types/avail-bridge/index.js +1 -0
  119. package/types/notification/index.d.ts +9 -0
  120. package/types/notification/index.js +1 -0
  121. package/utils/account/transform.js +9 -5
  122. package/utils/staticData/index.d.ts +5 -1
  123. package/utils/staticData/index.js +5 -2
  124. package/utils/staticData/remindNotificationTime.json +1 -0
@@ -6,12 +6,15 @@ import { RequestOptimalTransferProcess } from '@subwallet/extension-base/service
6
6
  import { TonTransactionConfig } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
7
7
  import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
8
8
  import { _ChainState, _EvmApi, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse, EnableChainParams, EnableMultiChainParams } from '@subwallet/extension-base/services/chain-service/types';
9
+ import { _NotificationInfo, NotificationSetup } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
9
10
  import { AppBannerData, AppConfirmationData, AppPopupData } from '@subwallet/extension-base/services/mkt-campaign-service/types';
10
11
  import { AuthUrls } from '@subwallet/extension-base/services/request-service/types';
11
12
  import { CrowdloanContributionsResponse } from '@subwallet/extension-base/services/subscan-service/types';
12
13
  import { SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
13
14
  import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
14
15
  import { AccountJson, AccountsWithCurrentAddress, AddressJson, BalanceJson, BaseRequestSign, BuyServiceInfo, BuyTokenInfo, CommonOptimalPath, CurrentAccountInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleYieldStepParams, InternalRequestSign, LeavePoolAdditionalData, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestBounceableValidate, RequestChangeTonWalletContractVersion, RequestCheckCrossChainTransfer, RequestCheckPublicAndSecretKey, RequestCheckTransfer, RequestCrossChainTransfer, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestEarlyValidateYield, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestGetYieldPoolTargets, RequestInputAccountSubscribe, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMetadataHash, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, RequestShortenMetadata, RequestStakeCancelWithdrawal, RequestStakeClaimReward, 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, StorageDataInterface, SubmitYieldStepData, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapSubmitParams, SwapTxData, TokenSpendingApprovalParams, UnlockDotTransactionNft, UnstakingStatus, ValidateSwapProcessParams, ValidateYieldProcessParams, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
16
+ import { RequestClaimAvailBridge } from '@subwallet/extension-base/types/avail-bridge';
17
+ import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
15
18
  import { InjectedAccount, InjectedAccountWithMeta, MetadataDefBase } from '@subwallet/extension-inject/types';
16
19
  import { KeyringPair$Meta } from '@subwallet/keyring/types';
17
20
  import { KeyringOptions } from '@subwallet/ui-keyring/options/types';
@@ -303,6 +306,7 @@ export interface UiSettings {
303
306
  timeAutoLock: number;
304
307
  unlockType: WalletUnlockType;
305
308
  enableChainPatrol: boolean;
309
+ notificationSetup: NotificationSetup;
306
310
  walletReference: string;
307
311
  }
308
312
  export declare type RequestSettingsType = UiSettings;
@@ -381,6 +385,7 @@ export declare enum ExtrinsicType {
381
385
  UNSTAKE_VMANTA = "earn.unstake_vmanta",
382
386
  TOKEN_SPENDING_APPROVAL = "token.spending_approval",
383
387
  SWAP = "swap",
388
+ CLAIM_AVAIL_BRIDGE = "claim.claim_avail_bridge",
384
389
  EVM_EXECUTE = "evm.execute",
385
390
  UNKNOWN = "unknown"
386
391
  }
@@ -420,6 +425,7 @@ export interface ExtrinsicDataTypeMap {
420
425
  [ExtrinsicType.REDEEM_STDOT]: RequestYieldLeave;
421
426
  [ExtrinsicType.REDEEM_VMANTA]: RequestYieldLeave;
422
427
  [ExtrinsicType.TOKEN_SPENDING_APPROVAL]: TokenSpendingApprovalParams;
428
+ [ExtrinsicType.CLAIM_AVAIL_BRIDGE]: RequestClaimAvailBridge;
423
429
  [ExtrinsicType.EVM_EXECUTE]: TransactionConfig;
424
430
  [ExtrinsicType.CROWDLOAN]: any;
425
431
  [ExtrinsicType.SWAP]: SwapTxData;
@@ -1540,6 +1546,7 @@ export interface KoniRequestSignatures {
1540
1546
  'pri(settings.saveAutoLockTime)': [RequestChangeTimeAutoLock, boolean];
1541
1547
  'pri(settings.saveUnlockType)': [RequestUnlockType, boolean];
1542
1548
  'pri(settings.saveEnableChainPatrol)': [RequestChangeEnableChainPatrol, boolean];
1549
+ 'pri(settings.saveNotificationSetup)': [NotificationSetup, boolean];
1543
1550
  'pri(settings.saveLanguage)': [RequestChangeLanguage, boolean];
1544
1551
  'pri(settings.savePriceCurrency)': [RequestChangePriceCurrency, boolean];
1545
1552
  'pri(settings.saveShowZeroBalance)': [RequestChangeShowZeroBalance, boolean];
@@ -1655,6 +1662,12 @@ export interface KoniRequestSignatures {
1655
1662
  'pri(swapService.handleSwapStep)': [SwapSubmitParams, SWTransactionResponse];
1656
1663
  'pri(swapService.getLatestQuote)': [SwapRequest, SwapQuoteResponse];
1657
1664
  'pri(swapService.validateSwapProcess)': [ValidateSwapProcessParams, TransactionError[]];
1665
+ 'pri(inappNotification.subscribeUnreadNotificationCountMap)': [null, Record<string, number>, Record<string, number>];
1666
+ 'pri(inappNotification.markAllReadNotification)': [string, null];
1667
+ 'pri(inappNotification.switchReadNotificationStatus)': [RequestSwitchStatusParams, null];
1668
+ 'pri(inappNotification.fetch)': [GetNotificationParams, _NotificationInfo[]];
1669
+ 'pri(inappNotification.get)': [string, _NotificationInfo];
1670
+ 'pri(availBridge.submitClaimAvailBridgeOnAvail)': [RequestClaimAvailBridge, SWTransactionResponse];
1658
1671
  'pri(ledger.generic.allow)': [null, string[], string[]];
1659
1672
  }
1660
1673
  export interface ApplicationMetadataType {
@@ -102,6 +102,7 @@ export let ExtrinsicType;
102
102
  ExtrinsicType["UNSTAKE_VMANTA"] = "earn.unstake_vmanta";
103
103
  ExtrinsicType["TOKEN_SPENDING_APPROVAL"] = "token.spending_approval";
104
104
  ExtrinsicType["SWAP"] = "swap";
105
+ ExtrinsicType["CLAIM_AVAIL_BRIDGE"] = "claim.claim_avail_bridge";
105
106
  ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
106
107
  ExtrinsicType["UNKNOWN"] = "unknown";
107
108
  })(ExtrinsicType || (ExtrinsicType = {}));
@@ -117,6 +117,7 @@ exports.ExtrinsicType = ExtrinsicType;
117
117
  ExtrinsicType["UNSTAKE_VMANTA"] = "earn.unstake_vmanta";
118
118
  ExtrinsicType["TOKEN_SPENDING_APPROVAL"] = "token.spending_approval";
119
119
  ExtrinsicType["SWAP"] = "swap";
120
+ ExtrinsicType["CLAIM_AVAIL_BRIDGE"] = "claim.claim_avail_bridge";
120
121
  ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
121
122
  ExtrinsicType["UNKNOWN"] = "unknown";
122
123
  })(ExtrinsicType || (exports.ExtrinsicType = ExtrinsicType = {}));
@@ -8,8 +8,7 @@ var _utils = require("@subwallet/extension-base/utils");
8
8
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
9
  // SPDX-License-Identifier: Apache-2.0
10
10
 
11
- const BLOCKED_ACTIONS_AND_FEATURES_PROMISE = (0, _utils.fetchStaticData)('blocked-actions-features');
12
11
  const fetchLastestBlockedActionsAndFeatures = async () => {
13
- return await BLOCKED_ACTIONS_AND_FEATURES_PROMISE;
12
+ return await (0, _utils.fetchStaticData)('blocked-actions-features');
14
13
  };
15
14
  exports.fetchLastestBlockedActionsAndFeatures = fetchLastestBlockedActionsAndFeatures;
@@ -26,6 +26,7 @@ var _exportNames = {
26
26
  BITTENSOR_REFRESH_STAKE_INFO: true,
27
27
  BITTENSOR_REFRESH_STAKE_APY: true,
28
28
  CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL: true,
29
+ CRON_LISTEN_AVAIL_BRIDGE_CLAIM: true,
29
30
  ALL_ACCOUNT_KEY: true,
30
31
  ALL_NETWORK_KEY: true,
31
32
  ALL_GENESIS_HASH: true,
@@ -40,7 +41,7 @@ var _exportNames = {
40
41
  ORDINAL_METHODS: true,
41
42
  PERMISSIONS_TO_REVOKE: true
42
43
  };
43
- exports.XCM_MIN_AMOUNT_RATIO = exports.XCM_FEE_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.PERMISSIONS_TO_REVOKE = exports.ORDINAL_METHODS = exports.ORDINAL_COLLECTION = exports.NETWORK_MULTI_GAS_FEE = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_MKT_CAMPAIGN_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.BITTENSOR_REFRESH_STAKE_INFO = exports.BITTENSOR_REFRESH_STAKE_APY = exports.BASE_SECOND_INTERVAL = exports.BASE_MINUTE_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ALL_ACCOUNT_AUTH_TYPES = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
44
+ exports.XCM_MIN_AMOUNT_RATIO = exports.XCM_FEE_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.PERMISSIONS_TO_REVOKE = exports.ORDINAL_METHODS = exports.ORDINAL_COLLECTION = exports.NETWORK_MULTI_GAS_FEE = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_MKT_CAMPAIGN_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_LISTEN_AVAIL_BRIDGE_CLAIM = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.BITTENSOR_REFRESH_STAKE_INFO = exports.BITTENSOR_REFRESH_STAKE_APY = exports.BASE_SECOND_INTERVAL = exports.BASE_MINUTE_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ALL_ACCOUNT_AUTH_TYPES = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
44
45
  var _blockedActionsList = require("./blocked-actions-list");
45
46
  Object.keys(_blockedActionsList).forEach(function (key) {
46
47
  if (key === "default" || key === "__esModule") return;
@@ -101,6 +102,18 @@ Object.keys(_storage).forEach(function (key) {
101
102
  }
102
103
  });
103
104
  });
105
+ var _remindNotificationTime = require("./remind-notification-time");
106
+ Object.keys(_remindNotificationTime).forEach(function (key) {
107
+ if (key === "default" || key === "__esModule") return;
108
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
109
+ if (key in exports && exports[key] === _remindNotificationTime[key]) return;
110
+ Object.defineProperty(exports, key, {
111
+ enumerable: true,
112
+ get: function () {
113
+ return _remindNotificationTime[key];
114
+ }
115
+ });
116
+ });
104
117
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
105
118
  // SPDX-License-Identifier: Apache-2.0
106
119
 
@@ -148,6 +161,8 @@ const BITTENSOR_REFRESH_STAKE_APY = 300000;
148
161
  exports.BITTENSOR_REFRESH_STAKE_APY = BITTENSOR_REFRESH_STAKE_APY;
149
162
  const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
150
163
  exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL;
164
+ const CRON_LISTEN_AVAIL_BRIDGE_CLAIM = 1800000;
165
+ exports.CRON_LISTEN_AVAIL_BRIDGE_CLAIM = CRON_LISTEN_AVAIL_BRIDGE_CLAIM;
151
166
  const ALL_ACCOUNT_KEY = 'ALL';
152
167
  exports.ALL_ACCOUNT_KEY = ALL_ACCOUNT_KEY;
153
168
  const ALL_NETWORK_KEY = 'all';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchLastestRemindNotificationTime = void 0;
7
+ var _utils = require("@subwallet/extension-base/utils");
8
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
+ // SPDX-License-Identifier: Apache-2.0
10
+
11
+ const fetchLastestRemindNotificationTime = async () => {
12
+ return await (0, _utils.fetchStaticData)('config/remind-notification-time');
13
+ };
14
+ exports.fetchLastestRemindNotificationTime = fetchLastestRemindNotificationTime;
@@ -359,14 +359,20 @@ async function estimateFeeForTransaction(validationResponse, transaction, chainI
359
359
  } else if ((0, _helpers.isTonTransaction)(transaction)) {
360
360
  estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
361
361
  } else {
362
- const gasLimit = await evmApi.api.eth.estimateGas(transaction);
362
+ const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
363
363
  const priority = await (0, _utils3.calculateGasFeeParams)(evmApi, chainInfo.slug);
364
- if (priority.baseGasFee) {
365
- const maxFee = priority.maxFeePerGas; // TODO: Need review
366
-
367
- estimateFee.value = maxFee.multipliedBy(gasLimit).toFixed(0);
364
+ if (transaction.maxFeePerGas) {
365
+ estimateFee.value = new _bignumber.default(transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
366
+ } else if (transaction.gasPrice) {
367
+ estimateFee.value = new _bignumber.default((transaction.gasPrice || 0).toString()).multipliedBy(gasLimit).toFixed(0);
368
368
  } else {
369
- estimateFee.value = new _bignumber.default(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
369
+ if (priority.baseGasFee) {
370
+ const maxFee = priority.maxFeePerGas; // TODO: Need review
371
+
372
+ estimateFee.value = maxFee.multipliedBy(gasLimit).toFixed(0);
373
+ } else {
374
+ estimateFee.value = new _bignumber.default(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
375
+ }
370
376
  }
371
377
  estimateFee.tooHigh = priority.busyNetwork;
372
378
  }
@@ -9,11 +9,13 @@ exports._getXcmDestWeight = _getXcmDestWeight;
9
9
  exports._getXcmMultiAssets = _getXcmMultiAssets;
10
10
  exports._getXcmMultiLocation = _getXcmMultiLocation;
11
11
  exports._getXcmUnstableWarning = _getXcmUnstableWarning;
12
+ exports._isAvailBridgeXcm = _isAvailBridgeXcm;
12
13
  exports._isMythosFromHydrationToMythos = _isMythosFromHydrationToMythos;
13
14
  exports._isSnowBridgeXcm = _isSnowBridgeXcm;
14
15
  exports._isXcmTransferUnstable = _isXcmTransferUnstable;
15
16
  exports._isXcmWithinSameConsensus = _isXcmWithinSameConsensus;
16
17
  var _chainList = require("@subwallet/chain-list");
18
+ var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
17
19
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
18
20
  var _utilCrypto = require("@polkadot/util-crypto");
19
21
  // Copyright 2019-2022 @subwallet/extension-base
@@ -87,8 +89,13 @@ function getSnowBridgeUnstableWarning(originChainInfo) {
87
89
  function getMythosFromHydrationToMythosWarning() {
88
90
  return 'Cross-chain transfer of this token requires a high transaction fee. Do you want to continue?';
89
91
  }
92
+ function getAvailBridgeWarning() {
93
+ return 'Cross-chain transfer of this token may take up to 90 minutes, and you’ll need to manually claim the funds on the destination network to complete the transfer. Do you still want to continue?';
94
+ }
90
95
  function _getXcmUnstableWarning(originChainInfo, destChainInfo, assetSlug) {
91
- if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
96
+ if (_isAvailBridgeXcm(originChainInfo, destChainInfo)) {
97
+ return getAvailBridgeWarning();
98
+ } else if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
92
99
  return getSnowBridgeUnstableWarning(originChainInfo);
93
100
  } else if (_isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug)) {
94
101
  return getMythosFromHydrationToMythosWarning();
@@ -102,6 +109,11 @@ function _isXcmWithinSameConsensus(originChainInfo, destChainInfo) {
102
109
  function _isSnowBridgeXcm(originChainInfo, destChainInfo) {
103
110
  return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) && ((0, _utils._isPureEvmChain)(originChainInfo) || (0, _utils._isPureEvmChain)(destChainInfo));
104
111
  }
112
+ function _isAvailBridgeXcm(originChainInfo, destChainInfo) {
113
+ const isAvailBridgeFromEvm = (0, _utils._isPureEvmChain)(originChainInfo) && (0, _availBridge.isAvailChainBridge)(destChainInfo.slug);
114
+ const isAvailBridgeFromAvail = (0, _availBridge.isAvailChainBridge)(originChainInfo.slug) && (0, _utils._isPureEvmChain)(destChainInfo);
115
+ return isAvailBridgeFromEvm || isAvailBridgeFromAvail;
116
+ }
105
117
  function _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) {
106
118
  return originChainInfo.slug === 'hydradx_main' && destChainInfo.slug === 'mythos' && assetSlug === 'hydradx_main-LOCAL-MYTH';
107
119
  }
@@ -3,8 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports._TEST_ERC721_ABI = exports._SNOWBRIDGE_GATEWAY_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._PINK_PSP34_ABI = exports._NEUROGUNS_PSP34_ABI = exports._ERC721_ABI = exports._ERC20_ABI = exports._AZERO_DOMAIN_REGISTRY_ABI = void 0;
6
+ exports._TEST_ERC721_ABI = exports._SNOWBRIDGE_GATEWAY_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._PINK_PSP34_ABI = exports._NEUROGUNS_PSP34_ABI = exports._ERC721_ABI = exports._ERC20_ABI = exports._AZERO_DOMAIN_REGISTRY_ABI = exports._AVAIL_TEST_BRIDGE_GATEWAY_ABI = exports._AVAIL_BRIDGE_GATEWAY_ABI = void 0;
7
+ exports.getAvailBridgeGatewayContract = getAvailBridgeGatewayContract;
7
8
  exports.getSnowBridgeGatewayContract = getSnowBridgeGatewayContract;
9
+ exports.isAvailBridgeGatewayContract = isAvailBridgeGatewayContract;
8
10
  exports.isSnowBridgeGatewayContract = isSnowBridgeGatewayContract;
9
11
  var _chainList = require("@subwallet/chain-list");
10
12
  // Copyright 2019-2022 @subwallet/extension-base
@@ -36,7 +38,13 @@ const _AZERO_DOMAIN_REGISTRY_ABI = require('./azero_domain_registry_abi.json');
36
38
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
37
39
  exports._AZERO_DOMAIN_REGISTRY_ABI = _AZERO_DOMAIN_REGISTRY_ABI;
38
40
  const _SNOWBRIDGE_GATEWAY_ABI = require('./snowbridge_gateway_abi.json');
41
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
39
42
  exports._SNOWBRIDGE_GATEWAY_ABI = _SNOWBRIDGE_GATEWAY_ABI;
43
+ const _AVAIL_BRIDGE_GATEWAY_ABI = require('./avail_bridge_abi.json');
44
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
45
+ exports._AVAIL_BRIDGE_GATEWAY_ABI = _AVAIL_BRIDGE_GATEWAY_ABI;
46
+ const _AVAIL_TEST_BRIDGE_GATEWAY_ABI = require('./avail_test_bridge_abi.json');
47
+ exports._AVAIL_TEST_BRIDGE_GATEWAY_ABI = _AVAIL_TEST_BRIDGE_GATEWAY_ABI;
40
48
  const SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x27ca963C279c93801941e1eB8799c23f407d68e7';
41
49
  const SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd';
42
50
  function getSnowBridgeGatewayContract(chain) {
@@ -47,4 +55,15 @@ function getSnowBridgeGatewayContract(chain) {
47
55
  }
48
56
  function isSnowBridgeGatewayContract(contractAddress) {
49
57
  return [SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
58
+ }
59
+ const AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x054fd961708D8E2B9c10a63F6157c74458889F0a';
60
+ const AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x967F7DdC4ec508462231849AE81eeaa68Ad01389';
61
+ function getAvailBridgeGatewayContract(chain) {
62
+ if (chain === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
63
+ return AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
64
+ }
65
+ return AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
66
+ }
67
+ function isAvailBridgeGatewayContract(contractAddress) {
68
+ return [AVAILBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, AVAILBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
50
69
  }
@@ -30,6 +30,21 @@ class AssetHubNftsPalletApi extends _nft.BaseNftApi {
30
30
  }
31
31
  }).then(res => res.json());
32
32
  }
33
+ processImageUrl(image, isKodadot, isTokenInfo) {
34
+ if (!image) {
35
+ return undefined;
36
+ }
37
+ if (isKodadot) {
38
+ return isTokenInfo ? image.replace('ipfs://ipfs/', 'https://image.w.kodadot.xyz/ipfs/') : image.replace('ipfs://', 'https://image.w.kodadot.xyz/ipfs/');
39
+ }
40
+ return this.parseUrl(image);
41
+ }
42
+ parseTokenInfo(tokenInfo, classId) {
43
+ if (classId === '244' && tokenInfo) {
44
+ return JSON.parse(tokenInfo);
45
+ }
46
+ return tokenInfo;
47
+ }
33
48
 
34
49
  /**
35
50
  * Retrieve id of NFTs
@@ -87,8 +102,6 @@ class AssetHubNftsPalletApi extends _nft.BaseNftApi {
87
102
  return this.getMetadata(collectionMetadata === null || collectionMetadata === void 0 ? void 0 : collectionMetadata.data);
88
103
  }
89
104
  async handleNft(address, params) {
90
- // const start = performance.now();
91
-
92
105
  const assetIds = await this.getNfts([address]);
93
106
  try {
94
107
  if (!assetIds || assetIds.length === 0) {
@@ -97,18 +110,28 @@ class AssetHubNftsPalletApi extends _nft.BaseNftApi {
97
110
  const collectionIds = [];
98
111
  const nftIds = [];
99
112
  await Promise.all(assetIds.map(async assetId => {
113
+ var _tokenInfo2, _tokenInfo3, _tokenInfo4;
100
114
  const parsedClassId = this.parseTokenId(assetId.classId);
101
115
  const parsedTokenId = this.parseTokenId(assetId.tokenId);
102
116
  if (!collectionIds.includes(parsedClassId)) {
103
117
  collectionIds.push(parsedClassId);
104
118
  }
105
119
  nftIds.push(parsedTokenId);
106
- const [tokenInfo, collectionMeta] = await Promise.all([this.getTokenDetails(assetId), this.getCollectionDetail(parseInt(parsedClassId))]);
120
+ let [tokenInfo, collectionMeta] = await Promise.all([this.getTokenDetails(assetId), this.getCollectionDetail(parseInt(parsedClassId))]);
121
+ const isKodadot = assetId.classId === '244';
122
+ tokenInfo = this.parseTokenInfo(tokenInfo, assetId.classId);
123
+ if (tokenInfo) {
124
+ var _tokenInfo;
125
+ tokenInfo.image = this.processImageUrl((_tokenInfo = tokenInfo) === null || _tokenInfo === void 0 ? void 0 : _tokenInfo.image, isKodadot, true);
126
+ }
127
+ if (collectionMeta) {
128
+ collectionMeta.image = this.processImageUrl(collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image, isKodadot, false);
129
+ }
107
130
  const parsedNft = {
108
131
  id: parsedTokenId,
109
- name: tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.name,
110
- description: tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.description,
111
- image: tokenInfo && tokenInfo.image ? this.parseUrl(tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.image) : undefined,
132
+ name: (_tokenInfo2 = tokenInfo) === null || _tokenInfo2 === void 0 ? void 0 : _tokenInfo2.name,
133
+ description: (_tokenInfo3 = tokenInfo) === null || _tokenInfo3 === void 0 ? void 0 : _tokenInfo3.description,
134
+ image: (_tokenInfo4 = tokenInfo) === null || _tokenInfo4 === void 0 ? void 0 : _tokenInfo4.image,
112
135
  collectionId: this.parseTokenId(parsedClassId),
113
136
  chain: this.chain,
114
137
  owner: address,
@@ -119,7 +142,7 @@ class AssetHubNftsPalletApi extends _nft.BaseNftApi {
119
142
  collectionId: parsedClassId,
120
143
  chain: this.chain,
121
144
  collectionName: collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.name,
122
- image: collectionMeta && collectionMeta.image ? this.parseUrl(collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image) : undefined
145
+ image: collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image
123
146
  };
124
147
  params.updateCollection(this.chain, parsedCollection);
125
148
  }));
@@ -32,6 +32,7 @@ var _smartContract = require("@subwallet/extension-base/services/balance-service
32
32
  var _token = require("@subwallet/extension-base/services/balance-service/transfer/token");
33
33
  var _tonTransfer = require("@subwallet/extension-base/services/balance-service/transfer/ton-transfer");
34
34
  var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
35
+ var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
35
36
  var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
36
37
  var _types2 = require("@subwallet/extension-base/services/chain-service/types");
37
38
  var _utils4 = require("@subwallet/extension-base/services/chain-service/utils");
@@ -807,6 +808,10 @@ class KoniExtension {
807
808
  this.#koniState.updateSetting('enableChainPatrol', enable);
808
809
  return true;
809
810
  }
811
+ saveNotificationSetup(request) {
812
+ this.#koniState.updateSetting('notificationSetup', request);
813
+ return true;
814
+ }
810
815
  setShowZeroBalance(_ref22) {
811
816
  let {
812
817
  show
@@ -1111,8 +1116,8 @@ class KoniExtension {
1111
1116
  owner,
1112
1117
  spenderAddress
1113
1118
  } = params;
1114
- if (!(0, _utils.isSnowBridgeGatewayContract)(spenderAddress)) {
1115
- throw new Error('Only SnowBridge is supported'); // todo: support all ERC20 spending approval
1119
+ if (!(0, _utils.isSnowBridgeGatewayContract)(spenderAddress) && !(0, _utils.isAvailBridgeGatewayContract)(spenderAddress)) {
1120
+ throw new Error('Only SnowBridge and AvailBridge is supported'); // todo: support all ERC20 spending approval
1116
1121
  }
1117
1122
 
1118
1123
  const evmApi = this.#koniState.getEvmApi(chain);
@@ -1287,32 +1292,35 @@ class KoniExtension {
1287
1292
  return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
1288
1293
  }
1289
1294
  const chainInfoMap = this.#koniState.getChainInfoMap();
1290
- const isSnowBridgeEvmTransfer = (0, _utils4._isPureEvmChain)(chainInfoMap[originNetworkKey]) && (0, _xcmParser._isSnowBridgeXcm)(chainInfoMap[originNetworkKey], chainInfoMap[destinationNetworkKey]);
1295
+ const isAvailBridgeFromEvm = (0, _utils4._isPureEvmChain)(chainInfoMap[originNetworkKey]) && (0, _availBridge.isAvailChainBridge)(destinationNetworkKey);
1296
+ const isAvailBridgeFromAvail = (0, _availBridge.isAvailChainBridge)(originNetworkKey) && (0, _utils4._isPureEvmChain)(chainInfoMap[destinationNetworkKey]);
1297
+ const isSnowBridgeEvmTransfer = (0, _utils4._isPureEvmChain)(chainInfoMap[originNetworkKey]) && (0, _xcmParser._isSnowBridgeXcm)(chainInfoMap[originNetworkKey], chainInfoMap[destinationNetworkKey]) && !isAvailBridgeFromEvm;
1291
1298
  let additionalValidator;
1292
1299
  let eventsHandler;
1293
1300
  if (fromKeyPair && destinationTokenInfo) {
1301
+ const evmApi = this.#koniState.getEvmApi(originNetworkKey);
1302
+ const substrateApi = this.#koniState.getSubstrateApi(originNetworkKey);
1303
+ const params = {
1304
+ destinationTokenInfo,
1305
+ originTokenInfo,
1306
+ sendingValue: value,
1307
+ sender: from,
1308
+ recipient: to,
1309
+ chainInfoMap,
1310
+ substrateApi,
1311
+ evmApi
1312
+ };
1313
+ let funcCreateExtrinsic;
1294
1314
  if (isSnowBridgeEvmTransfer) {
1295
- const evmApi = this.#koniState.getEvmApi(originNetworkKey);
1296
- extrinsic = await (0, _xcm.createSnowBridgeExtrinsic)({
1297
- destinationTokenInfo,
1298
- originTokenInfo,
1299
- sendingValue: value,
1300
- sender: from,
1301
- recipient: to,
1302
- chainInfoMap,
1303
- evmApi
1304
- });
1315
+ funcCreateExtrinsic = _xcm.createSnowBridgeExtrinsic;
1316
+ } else if (isAvailBridgeFromEvm) {
1317
+ funcCreateExtrinsic = _xcm.createAvailBridgeTxFromEth;
1318
+ } else if (isAvailBridgeFromAvail) {
1319
+ funcCreateExtrinsic = _xcm.createAvailBridgeExtrinsicFromAvail;
1305
1320
  } else {
1306
- const substrateApi = this.#koniState.getSubstrateApi(originNetworkKey);
1307
- extrinsic = await (0, _xcm.createXcmExtrinsic)({
1308
- destinationTokenInfo,
1309
- originTokenInfo,
1310
- sendingValue: value,
1311
- recipient: to,
1312
- chainInfoMap,
1313
- substrateApi
1314
- });
1321
+ funcCreateExtrinsic = _xcm.createXcmExtrinsic;
1315
1322
  }
1323
+ extrinsic = await funcCreateExtrinsic(params);
1316
1324
  additionalValidator = async inputTransaction => {
1317
1325
  const {
1318
1326
  value: senderTransferable
@@ -1368,7 +1376,7 @@ class KoniExtension {
1368
1376
  transaction: extrinsic,
1369
1377
  data: inputData,
1370
1378
  extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
1371
- chainType: !isSnowBridgeEvmTransfer ? _KoniTypes.ChainType.SUBSTRATE : _KoniTypes.ChainType.EVM,
1379
+ chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm ? _KoniTypes.ChainType.SUBSTRATE : _KoniTypes.ChainType.EVM,
1372
1380
  transferNativeAmount: (0, _utils4._isNativeToken)(originTokenInfo) ? value : '0',
1373
1381
  ignoreWarnings,
1374
1382
  isTransferAll: transferAll,
@@ -3394,6 +3402,65 @@ class KoniExtension {
3394
3402
  }
3395
3403
  /* Swap service */
3396
3404
 
3405
+ /* Notification service */
3406
+ async subscribeUnreadNotificationCountMap(id, port) {
3407
+ const cb = (0, _subscriptions.createSubscription)(id, port);
3408
+ const callback = rs => {
3409
+ cb(rs);
3410
+ };
3411
+ const subscription = this.#koniState.inappNotificationService.subscribeUnreadNotificationsCountMap(callback);
3412
+ this.createUnsubscriptionHandle(id, subscription.unsubscribe);
3413
+ port.onDisconnect.addListener(() => {
3414
+ this.cancelSubscription(id);
3415
+ });
3416
+ return await this.#koniState.inappNotificationService.getUnreadNotificationsCountMap();
3417
+ }
3418
+ markAllReadNotification(proxyId) {
3419
+ return this.#koniState.inappNotificationService.markAllRead(proxyId);
3420
+ }
3421
+ switchReadNotificationStatus(params) {
3422
+ return this.#koniState.inappNotificationService.switchReadStatus(params);
3423
+ }
3424
+ async fetchInappNotifications(params) {
3425
+ return this.#koniState.inappNotificationService.fetchNotificationsByParams(params);
3426
+ }
3427
+ async getInappNotification(id) {
3428
+ const result = await this.#koniState.inappNotificationService.getNotificationById(id);
3429
+ if (!result) {
3430
+ throw new Error('Notification not found');
3431
+ }
3432
+ return result;
3433
+ }
3434
+ /* Notification service */
3435
+
3436
+ async submitClaimAvailBridge(data) {
3437
+ const {
3438
+ address,
3439
+ chain,
3440
+ notification
3441
+ } = data;
3442
+ const extrinsicType = _KoniTypes.ExtrinsicType.CLAIM_AVAIL_BRIDGE;
3443
+ let transaction = null;
3444
+ let chainType;
3445
+ if ((0, _keyring.isSubstrateAddress)(address)) {
3446
+ const substrateApi = this.#koniState.getSubstrateApi(chain);
3447
+ transaction = await (0, _availBridge.getClaimTxOnAvail)(notification, substrateApi);
3448
+ chainType = _KoniTypes.ChainType.SUBSTRATE;
3449
+ } else {
3450
+ const evmApi = this.#koniState.getEvmApi(chain);
3451
+ transaction = await (0, _availBridge.getClaimTxOnEthereum)(chain, notification, evmApi);
3452
+ chainType = _KoniTypes.ChainType.EVM;
3453
+ }
3454
+ return await this.#koniState.transactionService.handleTransaction({
3455
+ address,
3456
+ chain,
3457
+ transaction,
3458
+ data,
3459
+ extrinsicType,
3460
+ chainType
3461
+ });
3462
+ }
3463
+
3397
3464
  /* Ledger */
3398
3465
 
3399
3466
  async subscribeLedgerGenericAllowChains(id, port) {
@@ -3492,6 +3559,8 @@ class KoniExtension {
3492
3559
  return this.setUnlockType(request);
3493
3560
  case 'pri(settings.saveEnableChainPatrol)':
3494
3561
  return this.setEnableChainPatrol(request);
3562
+ case 'pri(settings.saveNotificationSetup)':
3563
+ return this.saveNotificationSetup(request);
3495
3564
  case 'pri(settings.saveShowZeroBalance)':
3496
3565
  return this.setShowZeroBalance(request);
3497
3566
  case 'pri(settings.saveLanguage)':
@@ -3959,6 +4028,24 @@ class KoniExtension {
3959
4028
  return this.handleSwapStep(request);
3960
4029
  /* Swap service */
3961
4030
 
4031
+ /* Notification service */
4032
+ case 'pri(inappNotification.subscribeUnreadNotificationCountMap)':
4033
+ return await this.subscribeUnreadNotificationCountMap(id, port);
4034
+ case 'pri(inappNotification.markAllReadNotification)':
4035
+ return this.markAllReadNotification(request);
4036
+ case 'pri(inappNotification.switchReadNotificationStatus)':
4037
+ return this.switchReadNotificationStatus(request);
4038
+ case 'pri(inappNotification.fetch)':
4039
+ return this.fetchInappNotifications(request);
4040
+ case 'pri(inappNotification.get)':
4041
+ return this.getInappNotification(request);
4042
+ /* Notification service */
4043
+
4044
+ /* Avail Bridge */
4045
+ case 'pri(availBridge.submitClaimAvailBridgeOnAvail)':
4046
+ return this.submitClaimAvailBridge(request);
4047
+ /* Avail Bridge */
4048
+
3962
4049
  /* Ledger */
3963
4050
  case 'pri(ledger.generic.allow)':
3964
4051
  return this.subscribeLedgerGenericAllowChains(id, port);
@@ -23,6 +23,7 @@ var _eventService = require("@subwallet/extension-base/services/event-service");
23
23
  var _service2 = _interopRequireDefault(require("@subwallet/extension-base/services/fee-service/service"));
24
24
  var _utils2 = require("@subwallet/extension-base/services/fee-service/utils");
25
25
  var _historyService = require("@subwallet/extension-base/services/history-service");
26
+ var _inappNotificationService = require("@subwallet/extension-base/services/inapp-notification-service");
26
27
  var _keyringService = require("@subwallet/extension-base/services/keyring-service");
27
28
  var _migrationService = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service"));
28
29
  var _mintCampaignService = _interopRequireDefault(require("@subwallet/extension-base/services/mint-campaign-service"));
@@ -110,6 +111,7 @@ class KoniState {
110
111
  this.earningService = new _service.default(this);
111
112
  this.feeService = new _service2.default(this);
112
113
  this.swapService = new _swapService.SwapService(this);
114
+ this.inappNotificationService = new _inappNotificationService.InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
113
115
  this.subscription = new _subscription.KoniSubscription(this, this.dbService);
114
116
  this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
115
117
  this.logger = (0, _util.logger)('State');
@@ -212,6 +214,7 @@ class KoniState {
212
214
  await this.balanceService.init();
213
215
  await this.earningService.init();
214
216
  await this.swapService.init();
217
+ await this.inappNotificationService.init();
215
218
  this.onReady();
216
219
  this.onAccountAdd();
217
220
  this.onAccountRemove();
@@ -1200,7 +1203,7 @@ class KoniState {
1200
1203
  this.campaignService.stop();
1201
1204
  await Promise.all([this.cron.stop(), this.subscription.stop()]);
1202
1205
  await this.pauseAllNetworks(undefined, 'IDLE mode');
1203
- await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop()]);
1206
+ await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop()]);
1204
1207
 
1205
1208
  // Complete sleeping
1206
1209
  sleeping.resolve();
@@ -1233,7 +1236,7 @@ class KoniState {
1233
1236
  }
1234
1237
 
1235
1238
  // Start services
1236
- await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start()]);
1239
+ await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start()]);
1237
1240
 
1238
1241
  // Complete starting
1239
1242
  starting.resolve();
@@ -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.2-0'
16
+ version: '1.3.4-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -21,8 +21,9 @@ function getDefaultTransferProcess() {
21
21
  };
22
22
  }
23
23
  async function getSnowbridgeTransferProcessFromEvm(address, evmApi, tokenInfo, amount) {
24
+ // todo: refactor, AvailBridge also go into this function
24
25
  if (![_chainList.COMMON_CHAIN_SLUGS.ETHEREUM, _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA].includes(tokenInfo.originChain)) {
25
- throw new Error('Snowbridge only has support for Ethereum');
26
+ throw new Error('Snowbridge or AvailBridge only has support for Ethereum');
26
27
  }
27
28
  const result = {
28
29
  totalFee: [_serviceBase.MOCK_STEP_FEE],