@subwallet/extension-base 1.3.3-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 (114) 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/background/handlers/Extension.js +110 -23
  11. package/cjs/koni/background/handlers/State.js +5 -2
  12. package/cjs/packageInfo.js +1 -1
  13. package/cjs/services/balance-service/helpers/process.js +2 -1
  14. package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
  15. package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
  16. package/cjs/services/chain-service/handler/EvmApi.js +12 -21
  17. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +29 -0
  18. package/cjs/services/chain-service/index.js +44 -13
  19. package/cjs/services/chain-service/utils/index.js +20 -0
  20. package/cjs/services/earning-service/handlers/base.js +12 -3
  21. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +10 -2
  22. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +2 -0
  23. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
  24. package/cjs/services/earning-service/handlers/native-staking/tao.js +10 -2
  25. package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -4
  26. package/cjs/services/earning-service/service.js +5 -0
  27. package/cjs/services/inapp-notification-service/consts.js +31 -0
  28. package/cjs/services/inapp-notification-service/index.js +260 -0
  29. package/cjs/services/inapp-notification-service/interfaces.js +32 -0
  30. package/cjs/services/inapp-notification-service/utils.js +197 -0
  31. package/cjs/services/keyring-service/context/account-context.js +9 -0
  32. package/cjs/services/keyring-service/context/state.js +4 -0
  33. package/cjs/services/setting-service/SettingService.js +9 -1
  34. package/cjs/services/setting-service/constants.js +16 -1
  35. package/cjs/services/storage-service/DatabaseService.js +42 -3
  36. package/cjs/services/storage-service/databases/index.js +3 -0
  37. package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
  38. package/cjs/services/transaction-service/index.js +13 -0
  39. package/cjs/types/avail-bridge/index.js +1 -0
  40. package/cjs/types/notification/index.js +1 -0
  41. package/cjs/utils/account/transform.js +9 -5
  42. package/cjs/utils/staticData/index.js +7 -2
  43. package/constants/blocked-actions-list.js +1 -2
  44. package/constants/index.d.ts +2 -0
  45. package/constants/index.js +3 -1
  46. package/constants/remind-notification-time.d.ts +2 -0
  47. package/constants/remind-notification-time.js +7 -0
  48. package/core/logic-validation/transfer.js +12 -6
  49. package/core/substrate/xcm-parser.d.ts +1 -0
  50. package/core/substrate/xcm-parser.js +12 -1
  51. package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
  52. package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
  53. package/koni/api/contract-handler/utils/index.d.ts +4 -0
  54. package/koni/api/contract-handler/utils/index.js +15 -0
  55. package/koni/background/handlers/Extension.d.ts +7 -0
  56. package/koni/background/handlers/Extension.js +112 -25
  57. package/koni/background/handlers/State.d.ts +2 -0
  58. package/koni/background/handlers/State.js +5 -2
  59. package/package.json +54 -6
  60. package/packageInfo.js +1 -1
  61. package/services/balance-service/helpers/process.js +2 -1
  62. package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
  63. package/services/balance-service/transfer/xcm/availBridge.js +186 -0
  64. package/services/balance-service/transfer/xcm/index.d.ts +8 -8
  65. package/services/balance-service/transfer/xcm/index.js +46 -5
  66. package/services/chain-service/handler/EvmApi.js +12 -21
  67. package/services/chain-service/handler/SubstrateChainHandler.d.ts +2 -0
  68. package/services/chain-service/handler/SubstrateChainHandler.js +29 -0
  69. package/services/chain-service/index.d.ts +2 -0
  70. package/services/chain-service/index.js +45 -14
  71. package/services/chain-service/types.d.ts +2 -1
  72. package/services/chain-service/utils/index.d.ts +3 -0
  73. package/services/chain-service/utils/index.js +14 -0
  74. package/services/earning-service/handlers/base.d.ts +2 -0
  75. package/services/earning-service/handlers/base.js +9 -0
  76. package/services/earning-service/handlers/native-staking/amplitude.js +10 -2
  77. package/services/earning-service/handlers/native-staking/para-chain.js +2 -0
  78. package/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
  79. package/services/earning-service/handlers/native-staking/tao.d.ts +4 -0
  80. package/services/earning-service/handlers/native-staking/tao.js +5 -1
  81. package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
  82. package/services/earning-service/handlers/nomination-pool/index.js +9 -4
  83. package/services/earning-service/service.d.ts +2 -0
  84. package/services/earning-service/service.js +5 -0
  85. package/services/inapp-notification-service/consts.d.ts +18 -0
  86. package/services/inapp-notification-service/consts.js +22 -0
  87. package/services/inapp-notification-service/index.d.ts +37 -0
  88. package/services/inapp-notification-service/index.js +252 -0
  89. package/services/inapp-notification-service/interfaces.d.ts +77 -0
  90. package/services/inapp-notification-service/interfaces.js +24 -0
  91. package/services/inapp-notification-service/utils.d.ts +55 -0
  92. package/services/inapp-notification-service/utils.js +173 -0
  93. package/services/keyring-service/context/account-context.d.ts +3 -0
  94. package/services/keyring-service/context/account-context.js +9 -0
  95. package/services/keyring-service/context/state.d.ts +1 -0
  96. package/services/keyring-service/context/state.js +4 -0
  97. package/services/setting-service/SettingService.js +9 -1
  98. package/services/setting-service/constants.d.ts +2 -0
  99. package/services/setting-service/constants.js +15 -0
  100. package/services/storage-service/DatabaseService.d.ts +15 -0
  101. package/services/storage-service/DatabaseService.js +42 -3
  102. package/services/storage-service/databases/index.d.ts +2 -0
  103. package/services/storage-service/databases/index.js +3 -0
  104. package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
  105. package/services/storage-service/db-stores/InappNotification.js +73 -0
  106. package/services/transaction-service/index.js +13 -0
  107. package/types/avail-bridge/index.d.ts +6 -0
  108. package/types/avail-bridge/index.js +1 -0
  109. package/types/notification/index.d.ts +9 -0
  110. package/types/notification/index.js +1 -0
  111. package/utils/account/transform.js +9 -5
  112. package/utils/staticData/index.d.ts +5 -1
  113. package/utils/staticData/index.js +5 -2
  114. package/utils/staticData/remindNotificationTime.json +1 -0
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DEFAULT_UNLOCK_TYPE = exports.DEFAULT_THEME = exports.DEFAULT_SHOW_ZERO_BALANCE = exports.DEFAULT_SHOW_BALANCE = exports.DEFAULT_SETTING = exports.DEFAULT_NOTIFICATION_TYPE = exports.DEFAULT_LANGUAGE = exports.DEFAULT_CURRENCY = exports.DEFAULT_CHAIN_PATROL_ENABLE = exports.DEFAULT_CAMERA_ENABLE = exports.DEFAULT_AUTO_LOCK_TIME = exports.DEFAULT_ALL_LOGO = void 0;
6
+ exports.DEFAULT_UNLOCK_TYPE = exports.DEFAULT_THEME = exports.DEFAULT_SHOW_ZERO_BALANCE = exports.DEFAULT_SHOW_BALANCE = exports.DEFAULT_SETTING = exports.DEFAULT_NOTIFICATION_TYPE = exports.DEFAULT_NOTIFICATION_SETUP = exports.DEFAULT_LANGUAGE = exports.DEFAULT_CURRENCY = exports.DEFAULT_CHAIN_PATROL_ENABLE = exports.DEFAULT_CAMERA_ENABLE = exports.DEFAULT_AUTO_LOCK_TIME = exports.DEFAULT_ALL_LOGO = void 0;
7
7
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
8
8
  var _utils = require("@subwallet/extension-base/utils");
9
9
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
@@ -31,6 +31,20 @@ const DEFAULT_ALL_LOGO = '';
31
31
  exports.DEFAULT_ALL_LOGO = DEFAULT_ALL_LOGO;
32
32
  const DEFAULT_CAMERA_ENABLE = false;
33
33
  exports.DEFAULT_CAMERA_ENABLE = DEFAULT_CAMERA_ENABLE;
34
+ const DEFAULT_NOTIFICATION_SETUP = {
35
+ isEnabled: true,
36
+ showNotice: {
37
+ // send: true,
38
+ // receive: true,
39
+ earningClaim: true,
40
+ earningWithdraw: true,
41
+ availBridgeClaim: true
42
+ // isHideWithdraw: false, // todo: just for test, remove later
43
+ // isHideMarketing: false,
44
+ // isHideAnnouncement: false
45
+ }
46
+ };
47
+ exports.DEFAULT_NOTIFICATION_SETUP = DEFAULT_NOTIFICATION_SETUP;
34
48
  const DEFAULT_SETTING = {
35
49
  language: DEFAULT_LANGUAGE,
36
50
  currency: DEFAULT_CURRENCY,
@@ -43,6 +57,7 @@ const DEFAULT_SETTING = {
43
57
  camera: DEFAULT_CAMERA_ENABLE,
44
58
  timeAutoLock: DEFAULT_AUTO_LOCK_TIME,
45
59
  enableChainPatrol: DEFAULT_CHAIN_PATROL_ENABLE,
60
+ notificationSetup: DEFAULT_NOTIFICATION_SETUP,
46
61
  walletReference: ''
47
62
  };
48
63
  exports.DEFAULT_SETTING = DEFAULT_SETTING;
@@ -10,6 +10,7 @@ var _databases = _interopRequireDefault(require("@subwallet/extension-base/servi
10
10
  var _dbStores = require("@subwallet/extension-base/services/storage-service/db-stores");
11
11
  var _Campaign = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/Campaign"));
12
12
  var _ChainStakingMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata"));
13
+ var _InappNotification = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/InappNotification"));
13
14
  var _MantaPay = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/MantaPay"));
14
15
  var _NominatorMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata"));
15
16
  var _YieldPoolStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/YieldPoolStore"));
@@ -53,11 +54,13 @@ class DatabaseService {
53
54
  chainStakingMetadata: new _ChainStakingMetadata.default(this._db.chainStakingMetadata),
54
55
  nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata),
55
56
  mantaPay: new _MantaPay.default(this._db.mantaPay),
56
- campaign: new _Campaign.default(this._db.campaign)
57
+ campaign: new _Campaign.default(this._db.campaign),
57
58
  // assetRef: new AssetRefStore(this._db.assetRef)
59
+
60
+ // inapp notification
61
+ inappNotification: new _InappNotification.default(this._db.inappNotification)
58
62
  };
59
63
  }
60
-
61
64
  async updatePriceStore(priceData) {
62
65
  await this.stores.price.table.put(priceData);
63
66
  }
@@ -370,7 +373,7 @@ class DatabaseService {
370
373
  }
371
374
  async resetWallet(resetAll) {
372
375
  return new Promise((resolve, reject) => {
373
- const stores = [this.stores.balance, this.stores.nft, this.stores.nftCollection, this.stores.crowdloan, this.stores.staking, this.stores.transaction, this.stores.nominatorMetadata];
376
+ const stores = [this.stores.balance, this.stores.nft, this.stores.nftCollection, this.stores.crowdloan, this.stores.staking, this.stores.transaction, this.stores.nominatorMetadata, this.stores.inappNotification];
374
377
  if (resetAll) {
375
378
  stores.push(this.stores.chain, this.stores.asset);
376
379
  }
@@ -457,6 +460,9 @@ class DatabaseService {
457
460
  async updateYieldPositions(data) {
458
461
  await this.stores.yieldPosition.bulkUpsert(data);
459
462
  }
463
+ async getYieldPositions() {
464
+ return this.stores.yieldPosition.getAll();
465
+ }
460
466
  async getYieldPositionByAddress(addresses) {
461
467
  return this.stores.yieldPosition.getByAddress(addresses);
462
468
  }
@@ -486,6 +492,39 @@ class DatabaseService {
486
492
  upsertCampaign(campaign) {
487
493
  return this.stores.campaign.upsertCampaign(campaign);
488
494
  }
495
+
496
+ /* Inapp Notification */
497
+
498
+ getNotification(id) {
499
+ return this.stores.inappNotification.getNotificationInfo(id);
500
+ }
501
+ updateNotification(notification) {
502
+ return this.stores.inappNotification.upsert(notification);
503
+ }
504
+ async getNotificationsByParams(params) {
505
+ return this.stores.inappNotification.getNotificationsByParams(params);
506
+ }
507
+ cleanUpOldNotifications(overdueTime) {
508
+ return this.stores.inappNotification.cleanUpOldNotifications(overdueTime);
509
+ }
510
+ subscribeUnreadNotificationsCountMap() {
511
+ return this.stores.inappNotification.subscribeUnreadNotificationsCount();
512
+ }
513
+ getUnreadNotificationsCountMap() {
514
+ return this.stores.inappNotification.getUnreadNotificationsCountMap();
515
+ }
516
+ upsertNotifications(notifications) {
517
+ return this.stores.inappNotification.bulkUpsert(notifications);
518
+ }
519
+ markAllRead(proxyId) {
520
+ return this.stores.inappNotification.markAllRead(proxyId);
521
+ }
522
+ switchReadStatus(params) {
523
+ return this.stores.inappNotification.switchReadStatus(params);
524
+ }
525
+ removeAccountNotifications(proxyId) {
526
+ return this.stores.inappNotification.removeAccountNotifications(proxyId);
527
+ }
489
528
  async exportDB() {
490
529
  const blob = await (0, _dexieExportImport.exportDB)(this._db, {
491
530
  filter: (table, value, key) => {
@@ -50,6 +50,9 @@ class KoniDatabase extends _dexie.default {
50
50
  this.conditionalVersion(6, {
51
51
  keyValue: 'key'
52
52
  });
53
+ this.conditionalVersion(7, {
54
+ inappNotification: 'id, address, proxyId, [proxyId+actionType], actionType'
55
+ });
53
56
  }
54
57
  conditionalVersion(version, schema, upgrade) {
55
58
  if (this.schemaVersion != null && this.schemaVersion < version) {
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _constants = require("@subwallet/extension-base/constants");
9
+ var _interfaces = require("@subwallet/extension-base/services/inapp-notification-service/interfaces");
10
+ var _utils = require("@subwallet/extension-base/services/inapp-notification-service/utils");
11
+ var _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
12
+ var _dexie = require("dexie");
13
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
14
+ // SPDX-License-Identifier: Apache-2.0
15
+
16
+ class InappNotificationStore extends _BaseStore.default {
17
+ async getNotificationInfo(id) {
18
+ return this.table.get(id);
19
+ }
20
+ async getAll() {
21
+ return this.table.toArray();
22
+ }
23
+ async getNotificationsByParams(params) {
24
+ const {
25
+ notificationTab,
26
+ proxyId
27
+ } = params;
28
+ const isAllAccount = proxyId === _constants.ALL_ACCOUNT_KEY;
29
+ const isTabAll = notificationTab === _interfaces.NotificationTab.ALL;
30
+ if (isTabAll && isAllAccount) {
31
+ return this.getAll();
32
+ }
33
+ const filteredTable = this.table.filter(item => {
34
+ const matchesProxyId = item.proxyId === proxyId;
35
+ const matchesReadStatus = item.isRead === (0, _utils.getIsTabRead)(notificationTab);
36
+ if (isTabAll) {
37
+ return matchesProxyId;
38
+ }
39
+ if (isAllAccount) {
40
+ return matchesReadStatus;
41
+ }
42
+ return matchesProxyId && matchesReadStatus;
43
+ });
44
+ return filteredTable.toArray();
45
+ }
46
+ async cleanUpOldNotifications(overdueTime) {
47
+ const currentTimestamp = Date.now();
48
+ return this.table.filter(item => item.time <= currentTimestamp - overdueTime).delete();
49
+ }
50
+ subscribeUnreadNotificationsCount() {
51
+ return (0, _dexie.liveQuery)(async () => {
52
+ return await this.getUnreadNotificationsCountMap();
53
+ });
54
+ }
55
+ async getUnreadNotificationsCountMap() {
56
+ const unreadNotifications = await this.table.filter(item => !item.isRead).toArray();
57
+ return unreadNotifications.reduce((countMap, item) => {
58
+ countMap[item.proxyId] = (countMap[item.proxyId] || 0) + 1;
59
+ return countMap;
60
+ }, {});
61
+ }
62
+ markAllRead(proxyId) {
63
+ if (proxyId === _constants.ALL_ACCOUNT_KEY) {
64
+ return this.table.toCollection().modify({
65
+ isRead: true
66
+ });
67
+ }
68
+ return this.table.where('proxyId').equalsIgnoreCase(proxyId).modify({
69
+ isRead: true
70
+ });
71
+ }
72
+ switchReadStatus(params) {
73
+ return this.table.where('id').equals(params.id).modify({
74
+ isRead: !params.isRead
75
+ });
76
+ }
77
+ removeAccountNotifications(proxyId) {
78
+ return this.table.where('proxyId').equalsIgnoreCase(proxyId).delete();
79
+ }
80
+ }
81
+ exports.default = InappNotificationStore;
@@ -585,6 +585,19 @@ class TransactionService {
585
585
  historyItem.additionalInfo = data;
586
586
  break;
587
587
  }
588
+ case _KoniTypes.ExtrinsicType.CLAIM_AVAIL_BRIDGE:
589
+ {
590
+ const data = (0, _utils3.parseTransactionData)(transaction.data); // TODO: switch by provider
591
+ const metadata = data.notification.metadata;
592
+ const claimAsset = this.state.chainService.getAssetBySlug(metadata.tokenSlug);
593
+ historyItem.amount = {
594
+ value: metadata.amount,
595
+ symbol: (0, _utils2._getAssetSymbol)(claimAsset),
596
+ decimals: (0, _utils2._getAssetDecimals)(claimAsset)
597
+ };
598
+ historyItem.additionalInfo = data;
599
+ break;
600
+ }
588
601
  case _KoniTypes.ExtrinsicType.UNKNOWN:
589
602
  break;
590
603
  }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ "use strict";
@@ -145,23 +145,24 @@ const EARN_QDOT_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.Extrin
145
145
  const EARN_STDOT_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.REDEEM_STDOT, _KoniTypes.ExtrinsicType.UNSTAKE_STDOT];
146
146
  const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.ExtrinsicType.REDEEM_VMANTA, _KoniTypes.ExtrinsicType.UNSTAKE_VMANTA];
147
147
  const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
148
+ const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_AVAIL_BRIDGE];
148
149
  const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
149
150
  const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
150
151
  if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
151
152
  switch (networkType) {
152
153
  case _types2.AccountChainType.SUBSTRATE:
153
- return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...OTHER_ACTIONS];
154
+ return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS];
154
155
  case _types2.AccountChainType.ETHEREUM:
155
- return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...EVM_ACTIONS];
156
+ return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
156
157
  case _types2.AccountChainType.TON:
157
158
  return [...BASE_TRANSFER_ACTIONS];
158
159
  }
159
160
  } else if (signMode === _types2.AccountSignMode.QR) {
160
161
  switch (networkType) {
161
162
  case _types2.AccountChainType.SUBSTRATE:
162
- return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...OTHER_ACTIONS];
163
+ return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS];
163
164
  case _types2.AccountChainType.ETHEREUM:
164
- return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
165
+ return [...(_constants.isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
165
166
  case _types2.AccountChainType.TON:
166
167
  return [];
167
168
  }
@@ -174,7 +175,7 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
174
175
  // ...EARN_QDOT_ACTIONS,
175
176
  ...OTHER_ACTIONS];
176
177
  case _types2.AccountChainType.ETHEREUM:
177
- return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
178
+ return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
178
179
  // For liquid staking
179
180
  _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP];
180
181
  case _types2.AccountChainType.TON:
@@ -212,6 +213,9 @@ const getAccountTransactionActions = (signMode, networkType, type, _meta, _speci
212
213
  if (['polkadot', 'kusama', 'statemint', 'statemine'].includes(specialNetwork)) {
213
214
  result.push(_KoniTypes.ExtrinsicType.TRANSFER_XCM);
214
215
  }
216
+ if (['availTuringTest', 'avail_mainnet'].includes(specialNetwork)) {
217
+ result.push(...CLAIM_AVAIL_BRIDGE);
218
+ }
215
219
  return result;
216
220
  }
217
221
  return [];
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.StaticKey = void 0;
6
+ exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.StaticKey = void 0;
7
7
  var _chainList = require("@subwallet/chain-list");
8
8
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
9
  // SPDX-License-Identifier: Apache-2.0
@@ -30,7 +30,10 @@ const currencySymbol = require('./currencySymbol.json');
30
30
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
31
31
  exports.currencySymbol = currencySymbol;
32
32
  const blockedActionsFeatures = require('./blockedActionsFeatures.json');
33
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
33
34
  exports.blockedActionsFeatures = blockedActionsFeatures;
35
+ const remindNotificationTime = require('./remindNotificationTime.json');
36
+ exports.remindNotificationTime = remindNotificationTime;
34
37
  let StaticKey;
35
38
  exports.StaticKey = StaticKey;
36
39
  (function (StaticKey) {
@@ -42,6 +45,7 @@ exports.StaticKey = StaticKey;
42
45
  StaticKey["TERM_AND_CONDITION"] = "term-and-condition";
43
46
  StaticKey["BUY_TOKEN_CONFIGS"] = "buy-token-configs";
44
47
  StaticKey["BLOCKED_ACTIONS_FEATURES"] = "blocked-actions-features";
48
+ StaticKey["REMIND_NOTIFICATION_TIME"] = "remind-notification-time";
45
49
  })(StaticKey || (exports.StaticKey = StaticKey = {}));
46
50
  const staticData = {
47
51
  [StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
@@ -51,6 +55,7 @@ const staticData = {
51
55
  [StaticKey.MARKETING_CAMPAINGS]: marketingCampaigns,
52
56
  [StaticKey.TERM_AND_CONDITION]: termAndCondition.default,
53
57
  [StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs,
54
- [StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures
58
+ [StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures,
59
+ [StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime
55
60
  };
56
61
  exports.staticData = staticData;
@@ -2,7 +2,6 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { fetchStaticData } from '@subwallet/extension-base/utils';
5
- const BLOCKED_ACTIONS_AND_FEATURES_PROMISE = fetchStaticData('blocked-actions-features');
6
5
  export const fetchLastestBlockedActionsAndFeatures = async () => {
7
- return await BLOCKED_ACTIONS_AND_FEATURES_PROMISE;
6
+ return await fetchStaticData('blocked-actions-features');
8
7
  };
@@ -21,6 +21,7 @@ export declare const MANTA_PAY_BALANCE_INTERVAL = 30000;
21
21
  export declare const BITTENSOR_REFRESH_STAKE_INFO = 30000;
22
22
  export declare const BITTENSOR_REFRESH_STAKE_APY = 300000;
23
23
  export declare const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL: number;
24
+ export declare const CRON_LISTEN_AVAIL_BRIDGE_CLAIM = 1800000;
24
25
  export declare const ALL_ACCOUNT_KEY = "ALL";
25
26
  export declare const ALL_NETWORK_KEY = "all";
26
27
  export declare const ALL_GENESIS_HASH: null;
@@ -39,3 +40,4 @@ export * from './environment';
39
40
  export * from './signing';
40
41
  export * from './staking';
41
42
  export * from './storage';
43
+ export * from './remind-notification-time';
@@ -23,6 +23,7 @@ export const MANTA_PAY_BALANCE_INTERVAL = 30000;
23
23
  export const BITTENSOR_REFRESH_STAKE_INFO = 30000;
24
24
  export const BITTENSOR_REFRESH_STAKE_APY = 300000;
25
25
  export const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
26
+ export const CRON_LISTEN_AVAIL_BRIDGE_CLAIM = 1800000;
26
27
  export const ALL_ACCOUNT_KEY = 'ALL';
27
28
  export const ALL_NETWORK_KEY = 'all';
28
29
  export const ALL_GENESIS_HASH = null;
@@ -40,4 +41,5 @@ export * from "./blocked-actions-list.js";
40
41
  export * from "./environment.js";
41
42
  export * from "./signing.js";
42
43
  export * from "./staking.js";
43
- export * from "./storage.js";
44
+ export * from "./storage.js";
45
+ export * from "./remind-notification-time.js";
@@ -0,0 +1,2 @@
1
+ import { NotificationActionType } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
2
+ export declare const fetchLastestRemindNotificationTime: () => Promise<Record<NotificationActionType, number>>;
@@ -0,0 +1,7 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { fetchStaticData } from '@subwallet/extension-base/utils';
5
+ export const fetchLastestRemindNotificationTime = async () => {
6
+ return await fetchStaticData('config/remind-notification-time');
7
+ };
@@ -342,14 +342,20 @@ export async function estimateFeeForTransaction(validationResponse, transaction,
342
342
  } else if (isTonTransaction(transaction)) {
343
343
  estimateFee.value = transaction.estimateFee; // todo: might need to update logic estimate fee inside for future actions excluding normal transfer Ton and Jetton
344
344
  } else {
345
- const gasLimit = await evmApi.api.eth.estimateGas(transaction);
345
+ const gasLimit = transaction.gas || (await evmApi.api.eth.estimateGas(transaction));
346
346
  const priority = await calculateGasFeeParams(evmApi, chainInfo.slug);
347
- if (priority.baseGasFee) {
348
- const maxFee = priority.maxFeePerGas; // TODO: Need review
349
-
350
- estimateFee.value = maxFee.multipliedBy(gasLimit).toFixed(0);
347
+ if (transaction.maxFeePerGas) {
348
+ estimateFee.value = new BigN(transaction.maxFeePerGas.toString()).multipliedBy(gasLimit).toFixed(0);
349
+ } else if (transaction.gasPrice) {
350
+ estimateFee.value = new BigN((transaction.gasPrice || 0).toString()).multipliedBy(gasLimit).toFixed(0);
351
351
  } else {
352
- estimateFee.value = new BigN(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
352
+ if (priority.baseGasFee) {
353
+ const maxFee = priority.maxFeePerGas; // TODO: Need review
354
+
355
+ estimateFee.value = maxFee.multipliedBy(gasLimit).toFixed(0);
356
+ } else {
357
+ estimateFee.value = new BigN(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
358
+ }
353
359
  }
354
360
  estimateFee.tooHigh = priority.busyNetwork;
355
361
  }
@@ -51,5 +51,6 @@ export declare function _isXcmTransferUnstable(originChainInfo: _ChainInfo, dest
51
51
  export declare function _getXcmUnstableWarning(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): string;
52
52
  export declare function _isXcmWithinSameConsensus(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
53
53
  export declare function _isSnowBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
54
+ export declare function _isAvailBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
54
55
  export declare function _isMythosFromHydrationToMythos(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo, assetSlug: string): boolean;
55
56
  export declare function _adaptX1Interior(assetIdentifier: Record<string, any>, version: number): Record<string, any>;
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
5
+ import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
5
6
  import { _getChainSubstrateAddressPrefix, _getEvmChainId, _getSubstrateParaId, _getSubstrateRelayParent, _getXcmAssetMultilocation, _isChainEvmCompatible, _isPureEvmChain, _isSubstrateParaChain } from '@subwallet/extension-base/services/chain-service/utils';
6
7
  import { decodeAddress, evmToAddress } from '@polkadot/util-crypto';
7
8
  const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
@@ -72,8 +73,13 @@ function getSnowBridgeUnstableWarning(originChainInfo) {
72
73
  function getMythosFromHydrationToMythosWarning() {
73
74
  return 'Cross-chain transfer of this token requires a high transaction fee. Do you want to continue?';
74
75
  }
76
+ function getAvailBridgeWarning() {
77
+ 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?';
78
+ }
75
79
  export function _getXcmUnstableWarning(originChainInfo, destChainInfo, assetSlug) {
76
- if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
80
+ if (_isAvailBridgeXcm(originChainInfo, destChainInfo)) {
81
+ return getAvailBridgeWarning();
82
+ } else if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
77
83
  return getSnowBridgeUnstableWarning(originChainInfo);
78
84
  } else if (_isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug)) {
79
85
  return getMythosFromHydrationToMythosWarning();
@@ -87,6 +93,11 @@ export function _isXcmWithinSameConsensus(originChainInfo, destChainInfo) {
87
93
  export function _isSnowBridgeXcm(originChainInfo, destChainInfo) {
88
94
  return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) && (_isPureEvmChain(originChainInfo) || _isPureEvmChain(destChainInfo));
89
95
  }
96
+ export function _isAvailBridgeXcm(originChainInfo, destChainInfo) {
97
+ const isAvailBridgeFromEvm = _isPureEvmChain(originChainInfo) && isAvailChainBridge(destChainInfo.slug);
98
+ const isAvailBridgeFromAvail = isAvailChainBridge(originChainInfo.slug) && _isPureEvmChain(destChainInfo);
99
+ return isAvailBridgeFromEvm || isAvailBridgeFromAvail;
100
+ }
90
101
  export function _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) {
91
102
  return originChainInfo.slug === 'hydradx_main' && destChainInfo.slug === 'mythos' && assetSlug === 'hydradx_main-LOCAL-MYTH';
92
103
  }