@subwallet/extension-base 1.3.3-0 → 1.3.5-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.
- package/background/KoniTypes.d.ts +14 -1
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/constants/blocked-actions-list.js +1 -2
- package/cjs/constants/index.js +16 -1
- package/cjs/constants/remind-notification-time.js +14 -0
- package/cjs/core/logic-validation/transfer.js +12 -6
- package/cjs/core/substrate/xcm-parser.js +13 -1
- package/cjs/koni/api/contract-handler/utils/index.js +20 -1
- package/cjs/koni/api/nft/config.js +1 -1
- package/cjs/koni/api/nft/index.js +9 -0
- package/cjs/koni/api/nft/rari/index.js +87 -0
- package/cjs/koni/api/yield/helper/utils.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +110 -23
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +2 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +5 -0
- package/cjs/services/balance-service/index.js +1 -1
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
- package/cjs/services/chain-service/constants.js +2 -1
- package/cjs/services/chain-service/handler/EvmApi.js +12 -21
- package/cjs/services/chain-service/handler/EvmChainHandler.js +0 -2
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +73 -40
- package/cjs/services/chain-service/index.js +44 -13
- package/cjs/services/chain-service/utils/index.js +20 -0
- package/cjs/services/earning-service/handlers/base.js +12 -3
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +11 -3
- package/cjs/services/earning-service/handlers/native-staking/astar.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/cjs/services/earning-service/handlers/native-staking/tao.js +11 -3
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +14 -12
- package/cjs/services/earning-service/service.js +5 -0
- package/cjs/services/inapp-notification-service/consts.js +31 -0
- package/cjs/services/inapp-notification-service/index.js +260 -0
- package/cjs/services/inapp-notification-service/interfaces.js +32 -0
- package/cjs/services/inapp-notification-service/utils.js +197 -0
- package/cjs/services/keyring-service/context/account-context.js +9 -0
- package/cjs/services/keyring-service/context/state.js +4 -0
- package/cjs/services/setting-service/SettingService.js +9 -1
- package/cjs/services/setting-service/constants.js +16 -1
- package/cjs/services/storage-service/DatabaseService.js +42 -3
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
- package/cjs/services/transaction-service/index.js +18 -4
- package/cjs/types/avail-bridge/index.js +1 -0
- package/cjs/types/notification/index.js +1 -0
- package/cjs/utils/account/transform.js +9 -5
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/blocked-actions-list.js +1 -2
- package/constants/index.d.ts +2 -0
- package/constants/index.js +3 -1
- package/constants/remind-notification-time.d.ts +2 -0
- package/constants/remind-notification-time.js +7 -0
- package/core/logic-validation/transfer.js +12 -6
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +12 -1
- package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
- package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
- package/koni/api/contract-handler/utils/index.d.ts +7 -2
- package/koni/api/contract-handler/utils/index.js +15 -0
- package/koni/api/nft/config.js +1 -1
- package/koni/api/nft/index.js +9 -0
- package/koni/api/nft/rari/index.d.ts +7 -0
- package/koni/api/nft/rari/index.js +80 -0
- package/koni/api/yield/helper/utils.js +1 -1
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +112 -25
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +59 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.js +2 -1
- package/services/balance-service/helpers/subscribe/index.js +5 -0
- package/services/balance-service/index.js +2 -2
- package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
- package/services/balance-service/transfer/xcm/availBridge.js +186 -0
- package/services/balance-service/transfer/xcm/index.d.ts +8 -8
- package/services/balance-service/transfer/xcm/index.js +46 -5
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +2 -1
- package/services/chain-service/handler/EvmApi.js +12 -21
- package/services/chain-service/handler/EvmChainHandler.js +0 -2
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +3 -2
- package/services/chain-service/handler/SubstrateChainHandler.js +73 -40
- package/services/chain-service/index.d.ts +2 -0
- package/services/chain-service/index.js +45 -14
- package/services/chain-service/types.d.ts +2 -1
- package/services/chain-service/utils/index.d.ts +3 -0
- package/services/chain-service/utils/index.js +14 -0
- package/services/earning-service/handlers/base.d.ts +2 -0
- package/services/earning-service/handlers/base.js +9 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +11 -3
- package/services/earning-service/handlers/native-staking/astar.js +1 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/services/earning-service/handlers/native-staking/tao.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/tao.js +6 -2
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +14 -12
- package/services/earning-service/service.d.ts +2 -0
- package/services/earning-service/service.js +5 -0
- package/services/inapp-notification-service/consts.d.ts +18 -0
- package/services/inapp-notification-service/consts.js +22 -0
- package/services/inapp-notification-service/index.d.ts +37 -0
- package/services/inapp-notification-service/index.js +252 -0
- package/services/inapp-notification-service/interfaces.d.ts +77 -0
- package/services/inapp-notification-service/interfaces.js +24 -0
- package/services/inapp-notification-service/utils.d.ts +55 -0
- package/services/inapp-notification-service/utils.js +173 -0
- package/services/keyring-service/context/account-context.d.ts +3 -0
- package/services/keyring-service/context/account-context.js +9 -0
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +4 -0
- package/services/setting-service/SettingService.js +9 -1
- package/services/setting-service/constants.d.ts +2 -0
- package/services/setting-service/constants.js +15 -0
- package/services/storage-service/DatabaseService.d.ts +15 -0
- package/services/storage-service/DatabaseService.js +42 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
- package/services/storage-service/db-stores/InappNotification.js +73 -0
- package/services/transaction-service/index.js +18 -4
- package/types/avail-bridge/index.d.ts +6 -0
- package/types/avail-bridge/index.js +1 -0
- package/types/notification/index.d.ts +9 -0
- package/types/notification/index.js +1 -0
- package/utils/account/transform.js +9 -5
- package/utils/staticData/index.d.ts +5 -1
- package/utils/staticData/index.js +5 -2
- package/utils/staticData/remindNotificationTime.json +1 -0
|
@@ -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;
|
|
@@ -371,14 +371,15 @@ class TransactionService {
|
|
|
371
371
|
};
|
|
372
372
|
}
|
|
373
373
|
break;
|
|
374
|
-
case _KoniTypes.ExtrinsicType.
|
|
374
|
+
case _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL:
|
|
375
375
|
{
|
|
376
376
|
const data = (0, _utils3.parseTransactionData)(transaction.data);
|
|
377
|
+
const poolData = data.data;
|
|
377
378
|
historyItem.amount = {
|
|
378
379
|
...baseNativeAmount,
|
|
379
|
-
value:
|
|
380
|
+
value: poolData.amount || '0'
|
|
380
381
|
};
|
|
381
|
-
historyItem.to =
|
|
382
|
+
historyItem.to = poolData.selectedPool.name || poolData.selectedPool.id.toString();
|
|
382
383
|
}
|
|
383
384
|
break;
|
|
384
385
|
case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
|
|
@@ -585,6 +586,19 @@ class TransactionService {
|
|
|
585
586
|
historyItem.additionalInfo = data;
|
|
586
587
|
break;
|
|
587
588
|
}
|
|
589
|
+
case _KoniTypes.ExtrinsicType.CLAIM_AVAIL_BRIDGE:
|
|
590
|
+
{
|
|
591
|
+
const data = (0, _utils3.parseTransactionData)(transaction.data); // TODO: switch by provider
|
|
592
|
+
const metadata = data.notification.metadata;
|
|
593
|
+
const claimAsset = this.state.chainService.getAssetBySlug(metadata.tokenSlug);
|
|
594
|
+
historyItem.amount = {
|
|
595
|
+
value: metadata.amount,
|
|
596
|
+
symbol: (0, _utils2._getAssetSymbol)(claimAsset),
|
|
597
|
+
decimals: (0, _utils2._getAssetDecimals)(claimAsset)
|
|
598
|
+
};
|
|
599
|
+
historyItem.additionalInfo = data;
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
588
602
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
589
603
|
break;
|
|
590
604
|
}
|
|
@@ -679,7 +693,7 @@ class TransactionService {
|
|
|
679
693
|
} catch (e) {
|
|
680
694
|
console.error(e);
|
|
681
695
|
}
|
|
682
|
-
} else if ([_KoniTypes.ExtrinsicType.STAKING_BOND, _KoniTypes.ExtrinsicType.STAKING_UNBOND, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.
|
|
696
|
+
} else if ([_KoniTypes.ExtrinsicType.STAKING_BOND, _KoniTypes.ExtrinsicType.STAKING_UNBOND, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
683
697
|
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
684
698
|
} else if (transaction.extrinsicType === _KoniTypes.ExtrinsicType.SWAP) {
|
|
685
699
|
const inputData = (0, _utils3.parseTransactionData)(transaction.data);
|
|
@@ -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
|
|
6
|
+
return await fetchStaticData('blocked-actions-features');
|
|
8
7
|
};
|
package/constants/index.d.ts
CHANGED
|
@@ -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';
|
package/constants/index.js
CHANGED
|
@@ -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,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 (
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
estimateFee.value =
|
|
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
|
-
|
|
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 (
|
|
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
|
}
|