@subwallet/extension-base 1.1.17-0 → 1.1.18-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 +67 -1
- package/background/KoniTypes.js +5 -0
- package/cjs/background/KoniTypes.js +7 -1
- package/cjs/constants/index.js +6 -3
- package/cjs/koni/api/dotsama/crowdloan.js +106 -60
- package/cjs/koni/background/handlers/Extension.js +48 -0
- package/cjs/koni/background/handlers/State.js +25 -33
- package/cjs/koni/background/subscription.js +6 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/helpers.js +61 -0
- package/cjs/services/campaign-service/index.js +142 -0
- package/cjs/services/campaign-service/types.js +1 -0
- package/cjs/services/event-service/index.js +2 -0
- package/cjs/services/migration-service/index.js +4 -1
- package/cjs/services/notification-service/NotificationService.js +20 -6
- package/cjs/services/storage-service/DatabaseService.js +18 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/Campaign.js +35 -0
- package/constants/index.d.ts +1 -0
- package/constants/index.js +1 -0
- package/koni/api/dotsama/crowdloan.d.ts +7 -6
- package/koni/api/dotsama/crowdloan.js +103 -51
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +48 -1
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +4 -11
- package/koni/background/subscription.js +6 -2
- package/package.json +26 -6
- package/packageInfo.js +1 -1
- package/services/campaign-service/helpers.d.ts +3 -0
- package/services/campaign-service/helpers.js +54 -0
- package/services/campaign-service/index.d.ts +11 -0
- package/services/campaign-service/index.js +134 -0
- package/services/campaign-service/types.d.ts +34 -0
- package/services/campaign-service/types.js +1 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +2 -0
- package/services/event-service/types.d.ts +2 -0
- package/services/migration-service/index.d.ts +3 -1
- package/services/migration-service/index.js +4 -1
- package/services/notification-service/NotificationService.d.ts +2 -2
- package/services/notification-service/NotificationService.js +20 -6
- package/services/storage-service/DatabaseService.d.ts +7 -1
- package/services/storage-service/DatabaseService.js +18 -1
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/Campaign.d.ts +9 -0
- package/services/storage-service/db-stores/Campaign.js +27 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
-
import { BalanceItem, ChainStakingMetadata, CrowdloanItem, MetadataItem, NftCollection, NftItem, NominatorMetadata, PriceJson, StakingItem, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import { BalanceItem, CampaignData, ChainStakingMetadata, CrowdloanItem, MetadataItem, NftCollection, NftItem, NominatorMetadata, PriceJson, StakingItem, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import Dexie, { Table } from 'dexie';
|
|
4
4
|
export interface DefaultChainDoc {
|
|
5
5
|
chain: string;
|
|
@@ -29,6 +29,7 @@ export interface IMigration {
|
|
|
29
29
|
export interface IMetadataItem extends MetadataItem, DefaultChainDoc {
|
|
30
30
|
}
|
|
31
31
|
export declare type IMantaPayLedger = any;
|
|
32
|
+
export declare type ICampaign = CampaignData;
|
|
32
33
|
export default class KoniDatabase extends Dexie {
|
|
33
34
|
price: Table<PriceJson, object>;
|
|
34
35
|
balances: Table<IBalance, object>;
|
|
@@ -44,6 +45,7 @@ export default class KoniDatabase extends Dexie {
|
|
|
44
45
|
chainStakingMetadata: Table<ChainStakingMetadata, object>;
|
|
45
46
|
nominatorMetadata: Table<NominatorMetadata, object>;
|
|
46
47
|
mantaPay: Table<IMantaPayLedger, object>;
|
|
48
|
+
campaign: Table<ICampaign, object>;
|
|
47
49
|
private schemaVersion;
|
|
48
50
|
constructor(name?: string, schemaVersion?: number);
|
|
49
51
|
private conditionalVersion;
|
|
@@ -30,6 +30,9 @@ export default class KoniDatabase extends Dexie {
|
|
|
30
30
|
this.conditionalVersion(3, {
|
|
31
31
|
mantaPay: 'key, chain'
|
|
32
32
|
});
|
|
33
|
+
this.conditionalVersion(4, {
|
|
34
|
+
campaign: 'slug'
|
|
35
|
+
});
|
|
33
36
|
}
|
|
34
37
|
conditionalVersion(version, schema, upgrade) {
|
|
35
38
|
if (this.schemaVersion != null && this.schemaVersion < version) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICampaign } from '@subwallet/extension-base/services/storage-service/databases';
|
|
2
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
3
|
+
export default class CampaignStore extends BaseStore<ICampaign> {
|
|
4
|
+
getAll(): Promise<import("../../../background/KoniTypes").CampaignData[]>;
|
|
5
|
+
getCampaign(slug: string): Promise<import("../../../background/KoniTypes").CampaignData | undefined>;
|
|
6
|
+
getProcessingCampaign(): Promise<import("../../../background/KoniTypes").CampaignData[]>;
|
|
7
|
+
subscribeProcessingCampaign(): import("dexie").Observable<import("../../../background/KoniTypes").CampaignData[]>;
|
|
8
|
+
upsertCampaign(campaign: ICampaign): import("dexie").PromiseExtended<unknown>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
5
|
+
import { liveQuery } from 'dexie';
|
|
6
|
+
const filterProcessing = campaign => {
|
|
7
|
+
const now = new Date().getTime();
|
|
8
|
+
const isExpired = now <= campaign.startTime || now >= campaign.endTime;
|
|
9
|
+
return !(campaign.isDone || isExpired);
|
|
10
|
+
};
|
|
11
|
+
export default class CampaignStore extends BaseStore {
|
|
12
|
+
async getAll() {
|
|
13
|
+
return this.table.toArray();
|
|
14
|
+
}
|
|
15
|
+
async getCampaign(slug) {
|
|
16
|
+
return this.table.get(slug);
|
|
17
|
+
}
|
|
18
|
+
async getProcessingCampaign() {
|
|
19
|
+
return (await this.table.toArray()).filter(filterProcessing);
|
|
20
|
+
}
|
|
21
|
+
subscribeProcessingCampaign() {
|
|
22
|
+
return liveQuery(() => this.table.filter(filterProcessing).toArray());
|
|
23
|
+
}
|
|
24
|
+
upsertCampaign(campaign) {
|
|
25
|
+
return this.table.put(campaign);
|
|
26
|
+
}
|
|
27
|
+
}
|