@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
|
@@ -14,6 +14,20 @@ export const DEFAULT_SHOW_ZERO_BALANCE = true;
|
|
|
14
14
|
export const DEFAULT_SHOW_BALANCE = false;
|
|
15
15
|
export const DEFAULT_ALL_LOGO = '';
|
|
16
16
|
export const DEFAULT_CAMERA_ENABLE = false;
|
|
17
|
+
export const DEFAULT_NOTIFICATION_SETUP = {
|
|
18
|
+
isEnabled: true,
|
|
19
|
+
showNotice: {
|
|
20
|
+
// send: true,
|
|
21
|
+
// receive: true,
|
|
22
|
+
earningClaim: true,
|
|
23
|
+
earningWithdraw: true,
|
|
24
|
+
availBridgeClaim: true
|
|
25
|
+
// isHideWithdraw: false, // todo: just for test, remove later
|
|
26
|
+
// isHideMarketing: false,
|
|
27
|
+
// isHideAnnouncement: false
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
17
31
|
export const DEFAULT_SETTING = {
|
|
18
32
|
language: DEFAULT_LANGUAGE,
|
|
19
33
|
currency: DEFAULT_CURRENCY,
|
|
@@ -26,5 +40,6 @@ export const DEFAULT_SETTING = {
|
|
|
26
40
|
camera: DEFAULT_CAMERA_ENABLE,
|
|
27
41
|
timeAutoLock: DEFAULT_AUTO_LOCK_TIME,
|
|
28
42
|
enableChainPatrol: DEFAULT_CHAIN_PATROL_ENABLE,
|
|
43
|
+
notificationSetup: DEFAULT_NOTIFICATION_SETUP,
|
|
29
44
|
walletReference: ''
|
|
30
45
|
};
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
2
|
import { ChainStakingMetadata, CrowdloanItem, MantaPayConfig, NftCollection, NftItem, NominatorMetadata, PriceJson, StakingItem, StakingType, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
4
|
+
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
4
5
|
import { IBalance, ICampaign, IChain, INft } from '@subwallet/extension-base/services/storage-service/databases';
|
|
5
6
|
import { AssetStore, BalanceStore, ChainStore, CrowdloanStore, MetadataStore, MigrationStore, NftCollectionStore, NftStore, PriceStore, StakingStore, TransactionStore } from '@subwallet/extension-base/services/storage-service/db-stores';
|
|
6
7
|
import CampaignStore from '@subwallet/extension-base/services/storage-service/db-stores/Campaign';
|
|
7
8
|
import ChainStakingMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata';
|
|
9
|
+
import InappNotificationStore from '@subwallet/extension-base/services/storage-service/db-stores/InappNotification';
|
|
8
10
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
9
11
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
10
12
|
import { HistoryQuery } from '@subwallet/extension-base/services/storage-service/db-stores/Transaction';
|
|
11
13
|
import YieldPoolStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPoolStore';
|
|
12
14
|
import YieldPositionStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPositionStore';
|
|
13
15
|
import { BalanceItem, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
16
|
+
import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
14
17
|
import { Subscription } from 'dexie';
|
|
15
18
|
import { DexieExportJsonStructure } from 'dexie-export-import';
|
|
16
19
|
export declare const DEXIE_BACKUP_TABLES: string[];
|
|
@@ -35,6 +38,7 @@ export default class DatabaseService {
|
|
|
35
38
|
nominatorMetadata: NominatorMetadataStore;
|
|
36
39
|
mantaPay: MantaPayStore;
|
|
37
40
|
campaign: CampaignStore;
|
|
41
|
+
inappNotification: InappNotificationStore;
|
|
38
42
|
};
|
|
39
43
|
private logger;
|
|
40
44
|
private nftSubscription;
|
|
@@ -106,6 +110,7 @@ export default class DatabaseService {
|
|
|
106
110
|
removeYieldPositionByChains(chains: string[]): import("dexie").PromiseExtended<number>;
|
|
107
111
|
updateYieldPosition(data: YieldPositionInfo): Promise<void>;
|
|
108
112
|
updateYieldPositions(data: YieldPositionInfo[]): Promise<void>;
|
|
113
|
+
getYieldPositions(): Promise<YieldPositionInfo[]>;
|
|
109
114
|
getYieldPositionByAddress(addresses: string[]): Promise<YieldPositionInfo[]>;
|
|
110
115
|
subscribeYieldPosition(addresses: string[], callback: (data: YieldPositionInfo[]) => void): Subscription;
|
|
111
116
|
getYieldNominationPoolPosition(addresses: string[], chains: string[]): Promise<YieldPositionInfo[]>;
|
|
@@ -114,6 +119,16 @@ export default class DatabaseService {
|
|
|
114
119
|
getProcessingCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
115
120
|
getCampaign(slug: string): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData | undefined>;
|
|
116
121
|
upsertCampaign(campaign: ICampaign): import("dexie").PromiseExtended<unknown>;
|
|
122
|
+
getNotification(id: string): Promise<_NotificationInfo | undefined>;
|
|
123
|
+
updateNotification(notification: _NotificationInfo): Promise<unknown>;
|
|
124
|
+
getNotificationsByParams(params: GetNotificationParams): Promise<_NotificationInfo[]>;
|
|
125
|
+
cleanUpOldNotifications(overdueTime: number): Promise<number>;
|
|
126
|
+
subscribeUnreadNotificationsCountMap(): import("dexie").Observable<Record<string, number>>;
|
|
127
|
+
getUnreadNotificationsCountMap(): Promise<Record<string, number>>;
|
|
128
|
+
upsertNotifications(notifications: _NotificationInfo[]): Promise<unknown>;
|
|
129
|
+
markAllRead(proxyId: string): import("dexie").PromiseExtended<number>;
|
|
130
|
+
switchReadStatus(params: RequestSwitchStatusParams): import("dexie").PromiseExtended<number>;
|
|
131
|
+
removeAccountNotifications(proxyId: string): import("dexie").PromiseExtended<number>;
|
|
117
132
|
exportDB(): Promise<string>;
|
|
118
133
|
importDB(data: string): Promise<boolean>;
|
|
119
134
|
getExportJson(): Promise<DexieExportJsonStructure>;
|
|
@@ -6,6 +6,7 @@ import KoniDatabase from '@subwallet/extension-base/services/storage-service/dat
|
|
|
6
6
|
import { AssetStore, BalanceStore, ChainStore, CrowdloanStore, MetadataStore, MigrationStore, NftCollectionStore, NftStore, PriceStore, StakingStore, TransactionStore } from '@subwallet/extension-base/services/storage-service/db-stores';
|
|
7
7
|
import CampaignStore from '@subwallet/extension-base/services/storage-service/db-stores/Campaign';
|
|
8
8
|
import ChainStakingMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata';
|
|
9
|
+
import InappNotificationStore from '@subwallet/extension-base/services/storage-service/db-stores/InappNotification';
|
|
9
10
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
10
11
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
11
12
|
import YieldPoolStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPoolStore';
|
|
@@ -45,11 +46,13 @@ export default class DatabaseService {
|
|
|
45
46
|
chainStakingMetadata: new ChainStakingMetadataStore(this._db.chainStakingMetadata),
|
|
46
47
|
nominatorMetadata: new NominatorMetadataStore(this._db.nominatorMetadata),
|
|
47
48
|
mantaPay: new MantaPayStore(this._db.mantaPay),
|
|
48
|
-
campaign: new CampaignStore(this._db.campaign)
|
|
49
|
+
campaign: new CampaignStore(this._db.campaign),
|
|
49
50
|
// assetRef: new AssetRefStore(this._db.assetRef)
|
|
51
|
+
|
|
52
|
+
// inapp notification
|
|
53
|
+
inappNotification: new InappNotificationStore(this._db.inappNotification)
|
|
50
54
|
};
|
|
51
55
|
}
|
|
52
|
-
|
|
53
56
|
async updatePriceStore(priceData) {
|
|
54
57
|
await this.stores.price.table.put(priceData);
|
|
55
58
|
}
|
|
@@ -358,7 +361,7 @@ export default class DatabaseService {
|
|
|
358
361
|
}
|
|
359
362
|
async resetWallet(resetAll) {
|
|
360
363
|
return new Promise((resolve, reject) => {
|
|
361
|
-
const stores = [this.stores.balance, this.stores.nft, this.stores.nftCollection, this.stores.crowdloan, this.stores.staking, this.stores.transaction, this.stores.nominatorMetadata];
|
|
364
|
+
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];
|
|
362
365
|
if (resetAll) {
|
|
363
366
|
stores.push(this.stores.chain, this.stores.asset);
|
|
364
367
|
}
|
|
@@ -445,6 +448,9 @@ export default class DatabaseService {
|
|
|
445
448
|
async updateYieldPositions(data) {
|
|
446
449
|
await this.stores.yieldPosition.bulkUpsert(data);
|
|
447
450
|
}
|
|
451
|
+
async getYieldPositions() {
|
|
452
|
+
return this.stores.yieldPosition.getAll();
|
|
453
|
+
}
|
|
448
454
|
async getYieldPositionByAddress(addresses) {
|
|
449
455
|
return this.stores.yieldPosition.getByAddress(addresses);
|
|
450
456
|
}
|
|
@@ -474,6 +480,39 @@ export default class DatabaseService {
|
|
|
474
480
|
upsertCampaign(campaign) {
|
|
475
481
|
return this.stores.campaign.upsertCampaign(campaign);
|
|
476
482
|
}
|
|
483
|
+
|
|
484
|
+
/* Inapp Notification */
|
|
485
|
+
|
|
486
|
+
getNotification(id) {
|
|
487
|
+
return this.stores.inappNotification.getNotificationInfo(id);
|
|
488
|
+
}
|
|
489
|
+
updateNotification(notification) {
|
|
490
|
+
return this.stores.inappNotification.upsert(notification);
|
|
491
|
+
}
|
|
492
|
+
async getNotificationsByParams(params) {
|
|
493
|
+
return this.stores.inappNotification.getNotificationsByParams(params);
|
|
494
|
+
}
|
|
495
|
+
cleanUpOldNotifications(overdueTime) {
|
|
496
|
+
return this.stores.inappNotification.cleanUpOldNotifications(overdueTime);
|
|
497
|
+
}
|
|
498
|
+
subscribeUnreadNotificationsCountMap() {
|
|
499
|
+
return this.stores.inappNotification.subscribeUnreadNotificationsCount();
|
|
500
|
+
}
|
|
501
|
+
getUnreadNotificationsCountMap() {
|
|
502
|
+
return this.stores.inappNotification.getUnreadNotificationsCountMap();
|
|
503
|
+
}
|
|
504
|
+
upsertNotifications(notifications) {
|
|
505
|
+
return this.stores.inappNotification.bulkUpsert(notifications);
|
|
506
|
+
}
|
|
507
|
+
markAllRead(proxyId) {
|
|
508
|
+
return this.stores.inappNotification.markAllRead(proxyId);
|
|
509
|
+
}
|
|
510
|
+
switchReadStatus(params) {
|
|
511
|
+
return this.stores.inappNotification.switchReadStatus(params);
|
|
512
|
+
}
|
|
513
|
+
removeAccountNotifications(proxyId) {
|
|
514
|
+
return this.stores.inappNotification.removeAccountNotifications(proxyId);
|
|
515
|
+
}
|
|
477
516
|
async exportDB() {
|
|
478
517
|
const blob = await exportDB(this._db, {
|
|
479
518
|
filter: (table, value, key) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _AssetRef, _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { CampaignData, ChainStakingMetadata, CrowdloanItem, MetadataItem, NftCollection, NftItem, NominatorMetadata, PriceJson, StakingItem, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
3
4
|
import { BalanceItem, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
4
5
|
import Dexie, { Table } from 'dexie';
|
|
5
6
|
export declare const DEFAULT_DATABASE = "SubWalletDB_v2";
|
|
@@ -59,6 +60,7 @@ export default class KoniDatabase extends Dexie {
|
|
|
59
60
|
mantaPay: Table<IMantaPayLedger, object>;
|
|
60
61
|
campaign: Table<ICampaign, object>;
|
|
61
62
|
keyValue: Table<IKeyValue, object>;
|
|
63
|
+
inappNotification: Table<_NotificationInfo, object>;
|
|
62
64
|
private schemaVersion;
|
|
63
65
|
constructor(name?: string, schemaVersion?: number);
|
|
64
66
|
private conditionalVersion;
|
|
@@ -40,6 +40,9 @@ export default class KoniDatabase extends Dexie {
|
|
|
40
40
|
this.conditionalVersion(6, {
|
|
41
41
|
keyValue: 'key'
|
|
42
42
|
});
|
|
43
|
+
this.conditionalVersion(7, {
|
|
44
|
+
inappNotification: 'id, address, proxyId, [proxyId+actionType], actionType'
|
|
45
|
+
});
|
|
43
46
|
}
|
|
44
47
|
conditionalVersion(version, schema, upgrade) {
|
|
45
48
|
if (this.schemaVersion != null && this.schemaVersion < version) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { _NotificationInfo } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
2
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
3
|
+
import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
4
|
+
export default class InappNotificationStore extends BaseStore<_NotificationInfo> {
|
|
5
|
+
getNotificationInfo(id: string): Promise<_NotificationInfo | undefined>;
|
|
6
|
+
getAll(): Promise<_NotificationInfo[]>;
|
|
7
|
+
getNotificationsByParams(params: GetNotificationParams): Promise<_NotificationInfo[]>;
|
|
8
|
+
cleanUpOldNotifications(overdueTime: number): Promise<number>;
|
|
9
|
+
subscribeUnreadNotificationsCount(): import("dexie").Observable<Record<string, number>>;
|
|
10
|
+
getUnreadNotificationsCountMap(): Promise<Record<string, number>>;
|
|
11
|
+
markAllRead(proxyId: string): import("dexie").PromiseExtended<number>;
|
|
12
|
+
switchReadStatus(params: RequestSwitchStatusParams): import("dexie").PromiseExtended<number>;
|
|
13
|
+
removeAccountNotifications(proxyId: string): import("dexie").PromiseExtended<number>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
5
|
+
import { NotificationTab } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
6
|
+
import { getIsTabRead } from '@subwallet/extension-base/services/inapp-notification-service/utils';
|
|
7
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
8
|
+
import { liveQuery } from 'dexie';
|
|
9
|
+
export default class InappNotificationStore extends BaseStore {
|
|
10
|
+
async getNotificationInfo(id) {
|
|
11
|
+
return this.table.get(id);
|
|
12
|
+
}
|
|
13
|
+
async getAll() {
|
|
14
|
+
return this.table.toArray();
|
|
15
|
+
}
|
|
16
|
+
async getNotificationsByParams(params) {
|
|
17
|
+
const {
|
|
18
|
+
notificationTab,
|
|
19
|
+
proxyId
|
|
20
|
+
} = params;
|
|
21
|
+
const isAllAccount = proxyId === ALL_ACCOUNT_KEY;
|
|
22
|
+
const isTabAll = notificationTab === NotificationTab.ALL;
|
|
23
|
+
if (isTabAll && isAllAccount) {
|
|
24
|
+
return this.getAll();
|
|
25
|
+
}
|
|
26
|
+
const filteredTable = this.table.filter(item => {
|
|
27
|
+
const matchesProxyId = item.proxyId === proxyId;
|
|
28
|
+
const matchesReadStatus = item.isRead === getIsTabRead(notificationTab);
|
|
29
|
+
if (isTabAll) {
|
|
30
|
+
return matchesProxyId;
|
|
31
|
+
}
|
|
32
|
+
if (isAllAccount) {
|
|
33
|
+
return matchesReadStatus;
|
|
34
|
+
}
|
|
35
|
+
return matchesProxyId && matchesReadStatus;
|
|
36
|
+
});
|
|
37
|
+
return filteredTable.toArray();
|
|
38
|
+
}
|
|
39
|
+
async cleanUpOldNotifications(overdueTime) {
|
|
40
|
+
const currentTimestamp = Date.now();
|
|
41
|
+
return this.table.filter(item => item.time <= currentTimestamp - overdueTime).delete();
|
|
42
|
+
}
|
|
43
|
+
subscribeUnreadNotificationsCount() {
|
|
44
|
+
return liveQuery(async () => {
|
|
45
|
+
return await this.getUnreadNotificationsCountMap();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async getUnreadNotificationsCountMap() {
|
|
49
|
+
const unreadNotifications = await this.table.filter(item => !item.isRead).toArray();
|
|
50
|
+
return unreadNotifications.reduce((countMap, item) => {
|
|
51
|
+
countMap[item.proxyId] = (countMap[item.proxyId] || 0) + 1;
|
|
52
|
+
return countMap;
|
|
53
|
+
}, {});
|
|
54
|
+
}
|
|
55
|
+
markAllRead(proxyId) {
|
|
56
|
+
if (proxyId === ALL_ACCOUNT_KEY) {
|
|
57
|
+
return this.table.toCollection().modify({
|
|
58
|
+
isRead: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return this.table.where('proxyId').equalsIgnoreCase(proxyId).modify({
|
|
62
|
+
isRead: true
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
switchReadStatus(params) {
|
|
66
|
+
return this.table.where('id').equals(params.id).modify({
|
|
67
|
+
isRead: !params.isRead
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
removeAccountNotifications(proxyId) {
|
|
71
|
+
return this.table.where('proxyId').equalsIgnoreCase(proxyId).delete();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -364,14 +364,15 @@ export default class TransactionService {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
break;
|
|
367
|
-
case ExtrinsicType.
|
|
367
|
+
case ExtrinsicType.JOIN_YIELD_POOL:
|
|
368
368
|
{
|
|
369
369
|
const data = parseTransactionData(transaction.data);
|
|
370
|
+
const poolData = data.data;
|
|
370
371
|
historyItem.amount = {
|
|
371
372
|
...baseNativeAmount,
|
|
372
|
-
value:
|
|
373
|
+
value: poolData.amount || '0'
|
|
373
374
|
};
|
|
374
|
-
historyItem.to =
|
|
375
|
+
historyItem.to = poolData.selectedPool.name || poolData.selectedPool.id.toString();
|
|
375
376
|
}
|
|
376
377
|
break;
|
|
377
378
|
case ExtrinsicType.STAKING_UNBOND:
|
|
@@ -578,6 +579,19 @@ export default class TransactionService {
|
|
|
578
579
|
historyItem.additionalInfo = data;
|
|
579
580
|
break;
|
|
580
581
|
}
|
|
582
|
+
case ExtrinsicType.CLAIM_AVAIL_BRIDGE:
|
|
583
|
+
{
|
|
584
|
+
const data = parseTransactionData(transaction.data); // TODO: switch by provider
|
|
585
|
+
const metadata = data.notification.metadata;
|
|
586
|
+
const claimAsset = this.state.chainService.getAssetBySlug(metadata.tokenSlug);
|
|
587
|
+
historyItem.amount = {
|
|
588
|
+
value: metadata.amount,
|
|
589
|
+
symbol: _getAssetSymbol(claimAsset),
|
|
590
|
+
decimals: _getAssetDecimals(claimAsset)
|
|
591
|
+
};
|
|
592
|
+
historyItem.additionalInfo = data;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
581
595
|
case ExtrinsicType.UNKNOWN:
|
|
582
596
|
break;
|
|
583
597
|
}
|
|
@@ -669,7 +683,7 @@ export default class TransactionService {
|
|
|
669
683
|
} catch (e) {
|
|
670
684
|
console.error(e);
|
|
671
685
|
}
|
|
672
|
-
} else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.
|
|
686
|
+
} else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
673
687
|
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
674
688
|
} else if (transaction.extrinsicType === ExtrinsicType.SWAP) {
|
|
675
689
|
const inputData = parseTransactionData(transaction.data);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NotificationTab } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
2
|
+
export interface GetNotificationParams {
|
|
3
|
+
proxyId: string;
|
|
4
|
+
notificationTab: NotificationTab;
|
|
5
|
+
}
|
|
6
|
+
export interface RequestSwitchStatusParams {
|
|
7
|
+
id: string;
|
|
8
|
+
isRead: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -135,23 +135,24 @@ const EARN_QDOT_ACTIONS = [ExtrinsicType.MINT_QDOT, ExtrinsicType.REDEEM_QDOT, E
|
|
|
135
135
|
const EARN_STDOT_ACTIONS = [ExtrinsicType.MINT_STDOT, ExtrinsicType.REDEEM_STDOT, ExtrinsicType.UNSTAKE_STDOT];
|
|
136
136
|
const EARN_VMANTA_ACTIONS = [ExtrinsicType.MINT_VMANTA, ExtrinsicType.REDEEM_VMANTA, ExtrinsicType.UNSTAKE_VMANTA];
|
|
137
137
|
const EVM_ACTIONS = [ExtrinsicType.TOKEN_SPENDING_APPROVAL, ExtrinsicType.EVM_EXECUTE];
|
|
138
|
+
const CLAIM_AVAIL_BRIDGE = [ExtrinsicType.CLAIM_AVAIL_BRIDGE];
|
|
138
139
|
const OTHER_ACTIONS = [ExtrinsicType.TRANSFER_XCM, ExtrinsicType.SEND_NFT, ExtrinsicType.SWAP, ExtrinsicType.CROWDLOAN];
|
|
139
140
|
export const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
|
|
140
141
|
if ([AccountSignMode.PASSWORD, AccountSignMode.INJECTED].includes(signMode)) {
|
|
141
142
|
switch (networkType) {
|
|
142
143
|
case AccountChainType.SUBSTRATE:
|
|
143
|
-
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];
|
|
144
|
+
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];
|
|
144
145
|
case AccountChainType.ETHEREUM:
|
|
145
|
-
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...EVM_ACTIONS];
|
|
146
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
|
|
146
147
|
case AccountChainType.TON:
|
|
147
148
|
return [...BASE_TRANSFER_ACTIONS];
|
|
148
149
|
}
|
|
149
150
|
} else if (signMode === AccountSignMode.QR) {
|
|
150
151
|
switch (networkType) {
|
|
151
152
|
case AccountChainType.SUBSTRATE:
|
|
152
|
-
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];
|
|
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, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS];
|
|
153
154
|
case AccountChainType.ETHEREUM:
|
|
154
|
-
return [...(isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
|
|
155
|
+
return [...(isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
|
|
155
156
|
case AccountChainType.TON:
|
|
156
157
|
return [];
|
|
157
158
|
}
|
|
@@ -164,7 +165,7 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
164
165
|
// ...EARN_QDOT_ACTIONS,
|
|
165
166
|
...OTHER_ACTIONS];
|
|
166
167
|
case AccountChainType.ETHEREUM:
|
|
167
|
-
return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ExtrinsicType.STAKING_WITHDRAW,
|
|
168
|
+
return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ExtrinsicType.STAKING_WITHDRAW,
|
|
168
169
|
// For liquid staking
|
|
169
170
|
ExtrinsicType.SEND_NFT, ExtrinsicType.SWAP];
|
|
170
171
|
case AccountChainType.TON:
|
|
@@ -202,6 +203,9 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
202
203
|
if (['polkadot', 'kusama', 'statemint', 'statemine'].includes(specialNetwork)) {
|
|
203
204
|
result.push(ExtrinsicType.TRANSFER_XCM);
|
|
204
205
|
}
|
|
206
|
+
if (['availTuringTest', 'avail_mainnet'].includes(specialNetwork)) {
|
|
207
|
+
result.push(...CLAIM_AVAIL_BRIDGE);
|
|
208
|
+
}
|
|
205
209
|
return result;
|
|
206
210
|
}
|
|
207
211
|
return [];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NotificationActionType } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
1
2
|
export declare const buyServiceInfos: Record<string, unknown>[];
|
|
2
3
|
export declare const buyTokenConfigs: Record<string, unknown>[];
|
|
3
4
|
export declare const crowdloanFunds: Record<string, unknown>[];
|
|
@@ -5,6 +6,7 @@ export declare const marketingCampaigns: Record<string, unknown>;
|
|
|
5
6
|
export declare const termAndCondition: Record<string, unknown>;
|
|
6
7
|
export declare const currencySymbol: Record<string, unknown>;
|
|
7
8
|
export declare const blockedActionsFeatures: Record<string, unknown>;
|
|
9
|
+
export declare const remindNotificationTime: Record<NotificationActionType, number>;
|
|
8
10
|
export declare enum StaticKey {
|
|
9
11
|
BUY_SERVICE_INFOS = "buy-service-infos",
|
|
10
12
|
CHAINS = "chains",
|
|
@@ -13,7 +15,8 @@ export declare enum StaticKey {
|
|
|
13
15
|
CROWDLOAN_FUNDS = "crowdloan-funds",
|
|
14
16
|
TERM_AND_CONDITION = "term-and-condition",
|
|
15
17
|
BUY_TOKEN_CONFIGS = "buy-token-configs",
|
|
16
|
-
BLOCKED_ACTIONS_FEATURES = "blocked-actions-features"
|
|
18
|
+
BLOCKED_ACTIONS_FEATURES = "blocked-actions-features",
|
|
19
|
+
REMIND_NOTIFICATION_TIME = "remind-notification-time"
|
|
17
20
|
}
|
|
18
21
|
export declare const staticData: {
|
|
19
22
|
chains: import("@subwallet/chain-list/types")._ChainInfo[];
|
|
@@ -24,4 +27,5 @@ export declare const staticData: {
|
|
|
24
27
|
"term-and-condition": unknown;
|
|
25
28
|
"buy-token-configs": Record<string, unknown>[];
|
|
26
29
|
"blocked-actions-features": Record<string, unknown>;
|
|
30
|
+
"remind-notification-time": Record<NotificationActionType, number>;
|
|
27
31
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
5
5
|
import { ChainInfoMap } from '@subwallet/chain-list';
|
|
6
|
-
|
|
7
6
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-var-requires
|
|
8
7
|
export const buyServiceInfos = require("./buyServiceInfos.json");
|
|
9
8
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
@@ -18,6 +17,8 @@ export const termAndCondition = require("./termAndCondition.json");
|
|
|
18
17
|
export const currencySymbol = require("./currencySymbol.json");
|
|
19
18
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
20
19
|
export const blockedActionsFeatures = require("./blockedActionsFeatures.json");
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
21
|
+
export const remindNotificationTime = require("./remindNotificationTime.json");
|
|
21
22
|
export let StaticKey;
|
|
22
23
|
(function (StaticKey) {
|
|
23
24
|
StaticKey["BUY_SERVICE_INFOS"] = "buy-service-infos";
|
|
@@ -28,6 +29,7 @@ export let StaticKey;
|
|
|
28
29
|
StaticKey["TERM_AND_CONDITION"] = "term-and-condition";
|
|
29
30
|
StaticKey["BUY_TOKEN_CONFIGS"] = "buy-token-configs";
|
|
30
31
|
StaticKey["BLOCKED_ACTIONS_FEATURES"] = "blocked-actions-features";
|
|
32
|
+
StaticKey["REMIND_NOTIFICATION_TIME"] = "remind-notification-time";
|
|
31
33
|
})(StaticKey || (StaticKey = {}));
|
|
32
34
|
export const staticData = {
|
|
33
35
|
[StaticKey.CHAINS]: Object.values(ChainInfoMap),
|
|
@@ -37,5 +39,6 @@ export const staticData = {
|
|
|
37
39
|
[StaticKey.MARKETING_CAMPAINGS]: marketingCampaigns,
|
|
38
40
|
[StaticKey.TERM_AND_CONDITION]: termAndCondition.default,
|
|
39
41
|
[StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs,
|
|
40
|
-
[StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures
|
|
42
|
+
[StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures,
|
|
43
|
+
[StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime
|
|
41
44
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|