@subwallet/extension-base 1.1.16-1 → 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/api/nft/config.js +5 -1
- package/cjs/koni/api/nft/index.js +3 -0
- package/cjs/koni/api/nft/vara_nft/index.js +107 -0
- 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/chain-service/constants.js +3 -2
- package/cjs/services/chain-service/index.js +2 -0
- package/cjs/services/event-service/index.js +2 -0
- package/cjs/services/migration-service/index.js +4 -1
- package/cjs/services/migration-service/scripts/EnableChain.js +18 -0
- package/cjs/services/migration-service/scripts/EnableVaraChain.js +15 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +5 -20
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/index.js +5 -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/cjs/services/transaction-service/index.js +6 -1
- 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/api/nft/config.d.ts +1 -0
- package/koni/api/nft/config.js +4 -0
- package/koni/api/nft/index.js +3 -0
- package/koni/api/nft/vara_nft/index.d.ts +9 -0
- package/koni/api/nft/vara_nft/index.js +99 -0
- 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 +51 -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/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +3 -2
- package/services/chain-service/index.js +2 -0
- package/services/chain-service/types.d.ts +3 -1
- 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/migration-service/scripts/EnableChain.d.ts +5 -0
- package/services/migration-service/scripts/EnableChain.js +10 -0
- package/services/migration-service/scripts/EnableVaraChain.d.ts +4 -0
- package/services/migration-service/scripts/EnableVaraChain.js +7 -0
- package/services/migration-service/scripts/MigrateEthProvider.d.ts +5 -3
- package/services/migration-service/scripts/MigrateEthProvider.js +5 -20
- package/services/migration-service/scripts/MigratePioneerProvider.d.ts +6 -0
- package/services/migration-service/scripts/MigratePioneerProvider.js +9 -0
- package/services/migration-service/scripts/MigrateProvider.d.ts +7 -0
- package/services/migration-service/scripts/MigrateProvider.js +21 -0
- package/services/migration-service/scripts/index.js +5 -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
- package/services/transaction-service/index.js +6 -1
|
@@ -19,26 +19,40 @@ export default class NotificationService {
|
|
|
19
19
|
});
|
|
20
20
|
this.notificationSubject.next(notifications);
|
|
21
21
|
if (notification.notifyViaBrowser) {
|
|
22
|
-
|
|
23
|
-
NotificationService.createBrowserNotification(notification.title, notification.message, notification === null || notification === void 0 ? void 0 : (_notification$action = notification.action) === null || _notification$action === void 0 ? void 0 : _notification$action.url);
|
|
22
|
+
NotificationService.createBrowserNotification(notification.title, notification.message, notification.action, notification.buttons);
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
// Create a new chrome notification with link
|
|
28
|
-
static createBrowserNotification(title, message,
|
|
27
|
+
static createBrowserNotification(title, message, action, buttons) {
|
|
29
28
|
var _chrome, _chrome$notifications;
|
|
29
|
+
const link = action === null || action === void 0 ? void 0 : action.url;
|
|
30
|
+
const onClick = action === null || action === void 0 ? void 0 : action.click;
|
|
31
|
+
const onButtonClick = action === null || action === void 0 ? void 0 : action.buttonClick;
|
|
30
32
|
(_chrome = chrome) === null || _chrome === void 0 ? void 0 : (_chrome$notifications = _chrome.notifications) === null || _chrome$notifications === void 0 ? void 0 : _chrome$notifications.create({
|
|
31
33
|
type: 'basic',
|
|
32
34
|
title,
|
|
33
35
|
message,
|
|
34
36
|
iconUrl: './images/icon-128.png',
|
|
35
37
|
priority: 2,
|
|
36
|
-
isClickable: !!link
|
|
38
|
+
isClickable: !!link || !!onClick,
|
|
39
|
+
buttons
|
|
37
40
|
}, notificationId => {
|
|
38
|
-
if (link) {
|
|
41
|
+
if (link || onClick) {
|
|
39
42
|
chrome.notifications.onClicked.addListener(nId => {
|
|
40
43
|
if (nId === notificationId) {
|
|
41
|
-
|
|
44
|
+
if (onClick) {
|
|
45
|
+
onClick();
|
|
46
|
+
} else {
|
|
47
|
+
window.open(link);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (onButtonClick) {
|
|
53
|
+
chrome.notifications.onButtonClicked.addListener((nId, btnIndex) => {
|
|
54
|
+
if (nId === notificationId) {
|
|
55
|
+
onButtonClick(btnIndex);
|
|
42
56
|
}
|
|
43
57
|
});
|
|
44
58
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
2
|
import { BalanceItem, 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 { IBalance, IChain, INft } from '@subwallet/extension-base/services/storage-service/databases';
|
|
4
|
+
import { IBalance, ICampaign, IChain, INft } from '@subwallet/extension-base/services/storage-service/databases';
|
|
5
5
|
import { AssetStore, BalanceStore, ChainStore, CrowdloanStore, MetadataStore, MigrationStore, NftCollectionStore, NftStore, PriceStore, StakingStore, TransactionStore } from '@subwallet/extension-base/services/storage-service/db-stores';
|
|
6
|
+
import CampaignStore from '@subwallet/extension-base/services/storage-service/db-stores/Campaign';
|
|
6
7
|
import ChainStakingMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata';
|
|
7
8
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
8
9
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
@@ -26,6 +27,7 @@ export default class DatabaseService {
|
|
|
26
27
|
chainStakingMetadata: ChainStakingMetadataStore;
|
|
27
28
|
nominatorMetadata: NominatorMetadataStore;
|
|
28
29
|
mantaPay: MantaPayStore;
|
|
30
|
+
campaign: CampaignStore;
|
|
29
31
|
};
|
|
30
32
|
private logger;
|
|
31
33
|
private nftSubscription;
|
|
@@ -77,4 +79,8 @@ export default class DatabaseService {
|
|
|
77
79
|
subscribeMantaPayConfig(chain: string, callback: (data: MantaPayConfig[]) => void): void;
|
|
78
80
|
getMantaPayConfig(chain: string): Promise<any[]>;
|
|
79
81
|
getMantaPayFirstConfig(chain: string): Promise<any>;
|
|
82
|
+
subscribeProcessingCampaign(): import("dexie").Observable<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
83
|
+
getProcessingCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
84
|
+
getCampaign(slug: string): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData | undefined>;
|
|
85
|
+
upsertCampaign(campaign: ICampaign): import("dexie").PromiseExtended<unknown>;
|
|
80
86
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import KoniDatabase from '@subwallet/extension-base/services/storage-service/databases';
|
|
6
6
|
import { AssetStore, BalanceStore, ChainStore, CrowdloanStore, MetadataStore, MigrationStore, NftCollectionStore, NftStore, PriceStore, StakingStore, TransactionStore } from '@subwallet/extension-base/services/storage-service/db-stores';
|
|
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';
|
|
8
9
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
9
10
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
@@ -34,7 +35,8 @@ export default class DatabaseService {
|
|
|
34
35
|
// staking
|
|
35
36
|
chainStakingMetadata: new ChainStakingMetadataStore(this._db.chainStakingMetadata),
|
|
36
37
|
nominatorMetadata: new NominatorMetadataStore(this._db.nominatorMetadata),
|
|
37
|
-
mantaPay: new MantaPayStore(this._db.mantaPay)
|
|
38
|
+
mantaPay: new MantaPayStore(this._db.mantaPay),
|
|
39
|
+
campaign: new CampaignStore(this._db.campaign)
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
async updatePriceStore(priceData) {
|
|
@@ -262,4 +264,19 @@ export default class DatabaseService {
|
|
|
262
264
|
async getMantaPayFirstConfig(chain) {
|
|
263
265
|
return this.stores.mantaPay.getFirstConfig(chain);
|
|
264
266
|
}
|
|
267
|
+
|
|
268
|
+
/* Campaign */
|
|
269
|
+
|
|
270
|
+
subscribeProcessingCampaign() {
|
|
271
|
+
return this.stores.campaign.subscribeProcessingCampaign();
|
|
272
|
+
}
|
|
273
|
+
getProcessingCampaign() {
|
|
274
|
+
return this.stores.campaign.getProcessingCampaign();
|
|
275
|
+
}
|
|
276
|
+
getCampaign(slug) {
|
|
277
|
+
return this.stores.campaign.getCampaign(slug);
|
|
278
|
+
}
|
|
279
|
+
upsertCampaign(campaign) {
|
|
280
|
+
return this.stores.campaign.upsertCampaign(campaign);
|
|
281
|
+
}
|
|
265
282
|
}
|
|
@@ -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
|
+
}
|
|
@@ -68,6 +68,7 @@ export default class TransactionService {
|
|
|
68
68
|
address,
|
|
69
69
|
chain,
|
|
70
70
|
edAsWarning,
|
|
71
|
+
extrinsicType,
|
|
71
72
|
isTransferAll,
|
|
72
73
|
transaction
|
|
73
74
|
} = validation;
|
|
@@ -77,7 +78,11 @@ export default class TransactionService {
|
|
|
77
78
|
|
|
78
79
|
// Return unsupported error if not found transaction
|
|
79
80
|
if (!transaction) {
|
|
80
|
-
|
|
81
|
+
if (extrinsicType === ExtrinsicType.SEND_NFT) {
|
|
82
|
+
validation.errors.push(new TransactionError(BasicTxErrorType.UNSUPPORTED, t('This feature is not yet available for this NFT')));
|
|
83
|
+
} else {
|
|
84
|
+
validation.errors.push(new TransactionError(BasicTxErrorType.UNSUPPORTED));
|
|
85
|
+
}
|
|
81
86
|
}
|
|
82
87
|
const validationResponse = {
|
|
83
88
|
status: undefined,
|