@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
|
@@ -165,11 +165,15 @@ export class KoniSubscription {
|
|
|
165
165
|
this.state.setCrowdloanItem(networkKey, rs);
|
|
166
166
|
}, this.state.getChainInfoMap());
|
|
167
167
|
if (onlyRunOnFirstTime) {
|
|
168
|
-
subscriptionPromise.then(unsub =>
|
|
168
|
+
subscriptionPromise.then(unsub => {
|
|
169
|
+
unsub && unsub();
|
|
170
|
+
}).catch(this.logger.warn);
|
|
169
171
|
return;
|
|
170
172
|
}
|
|
171
173
|
return () => {
|
|
172
|
-
subscriptionPromise.then(unsub =>
|
|
174
|
+
subscriptionPromise.then(unsub => {
|
|
175
|
+
unsub && unsub();
|
|
176
|
+
}).catch(this.logger.warn);
|
|
173
177
|
};
|
|
174
178
|
}
|
|
175
179
|
subscribeNft(address, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.18-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -279,6 +279,11 @@
|
|
|
279
279
|
"require": "./cjs/koni/api/nft/unique_nft/uniqueNftV2.js",
|
|
280
280
|
"default": "./koni/api/nft/unique_nft/uniqueNftV2.js"
|
|
281
281
|
},
|
|
282
|
+
"./koni/api/nft/vara_nft": {
|
|
283
|
+
"types": "./koni/api/nft/vara_nft/index.d.ts",
|
|
284
|
+
"require": "./cjs/koni/api/nft/vara_nft/index.js",
|
|
285
|
+
"default": "./koni/api/nft/vara_nft/index.js"
|
|
286
|
+
},
|
|
282
287
|
"./koni/api/nft/wasm_nft": {
|
|
283
288
|
"types": "./koni/api/nft/wasm_nft/index.d.ts",
|
|
284
289
|
"require": "./cjs/koni/api/nft/wasm_nft/index.js",
|
|
@@ -515,6 +520,21 @@
|
|
|
515
520
|
"require": "./cjs/services/base/types.js",
|
|
516
521
|
"default": "./services/base/types.js"
|
|
517
522
|
},
|
|
523
|
+
"./services/campaign-service": {
|
|
524
|
+
"types": "./services/campaign-service/index.d.ts",
|
|
525
|
+
"require": "./cjs/services/campaign-service/index.js",
|
|
526
|
+
"default": "./services/campaign-service/index.js"
|
|
527
|
+
},
|
|
528
|
+
"./services/campaign-service/helpers": {
|
|
529
|
+
"types": "./services/campaign-service/helpers.d.ts",
|
|
530
|
+
"require": "./cjs/services/campaign-service/helpers.js",
|
|
531
|
+
"default": "./services/campaign-service/helpers.js"
|
|
532
|
+
},
|
|
533
|
+
"./services/campaign-service/types": {
|
|
534
|
+
"types": "./services/campaign-service/types.d.ts",
|
|
535
|
+
"require": "./cjs/services/campaign-service/types.js",
|
|
536
|
+
"default": "./services/campaign-service/types.js"
|
|
537
|
+
},
|
|
518
538
|
"./services/chain-service": {
|
|
519
539
|
"types": "./services/chain-service/index.d.ts",
|
|
520
540
|
"require": "./cjs/services/chain-service/index.js",
|
|
@@ -673,6 +693,16 @@
|
|
|
673
693
|
"require": "./cjs/services/migration-service/scripts/DeleteChain.js",
|
|
674
694
|
"default": "./services/migration-service/scripts/DeleteChain.js"
|
|
675
695
|
},
|
|
696
|
+
"./services/migration-service/scripts/EnableChain": {
|
|
697
|
+
"types": "./services/migration-service/scripts/EnableChain.d.ts",
|
|
698
|
+
"require": "./cjs/services/migration-service/scripts/EnableChain.js",
|
|
699
|
+
"default": "./services/migration-service/scripts/EnableChain.js"
|
|
700
|
+
},
|
|
701
|
+
"./services/migration-service/scripts/EnableVaraChain": {
|
|
702
|
+
"types": "./services/migration-service/scripts/EnableVaraChain.d.ts",
|
|
703
|
+
"require": "./cjs/services/migration-service/scripts/EnableVaraChain.js",
|
|
704
|
+
"default": "./services/migration-service/scripts/EnableVaraChain.js"
|
|
705
|
+
},
|
|
676
706
|
"./services/migration-service/scripts/MigrateAuthUrls": {
|
|
677
707
|
"types": "./services/migration-service/scripts/MigrateAuthUrls.d.ts",
|
|
678
708
|
"require": "./cjs/services/migration-service/scripts/MigrateAuthUrls.js",
|
|
@@ -708,6 +738,16 @@
|
|
|
708
738
|
"require": "./cjs/services/migration-service/scripts/MigrateNetworkSettings.js",
|
|
709
739
|
"default": "./services/migration-service/scripts/MigrateNetworkSettings.js"
|
|
710
740
|
},
|
|
741
|
+
"./services/migration-service/scripts/MigratePioneerProvider": {
|
|
742
|
+
"types": "./services/migration-service/scripts/MigratePioneerProvider.d.ts",
|
|
743
|
+
"require": "./cjs/services/migration-service/scripts/MigratePioneerProvider.js",
|
|
744
|
+
"default": "./services/migration-service/scripts/MigratePioneerProvider.js"
|
|
745
|
+
},
|
|
746
|
+
"./services/migration-service/scripts/MigrateProvider": {
|
|
747
|
+
"types": "./services/migration-service/scripts/MigrateProvider.d.ts",
|
|
748
|
+
"require": "./cjs/services/migration-service/scripts/MigrateProvider.js",
|
|
749
|
+
"default": "./services/migration-service/scripts/MigrateProvider.js"
|
|
750
|
+
},
|
|
711
751
|
"./services/migration-service/scripts/MigrateSettings": {
|
|
712
752
|
"types": "./services/migration-service/scripts/MigrateSettings.d.ts",
|
|
713
753
|
"require": "./cjs/services/migration-service/scripts/MigrateSettings.js",
|
|
@@ -878,6 +918,11 @@
|
|
|
878
918
|
"require": "./cjs/services/storage-service/db-stores/BaseStoreWithChain.js",
|
|
879
919
|
"default": "./services/storage-service/db-stores/BaseStoreWithChain.js"
|
|
880
920
|
},
|
|
921
|
+
"./services/storage-service/db-stores/Campaign": {
|
|
922
|
+
"types": "./services/storage-service/db-stores/Campaign.d.ts",
|
|
923
|
+
"require": "./cjs/services/storage-service/db-stores/Campaign.js",
|
|
924
|
+
"default": "./services/storage-service/db-stores/Campaign.js"
|
|
925
|
+
},
|
|
881
926
|
"./services/storage-service/db-stores/Chain": {
|
|
882
927
|
"types": "./services/storage-service/db-stores/Chain.d.ts",
|
|
883
928
|
"require": "./cjs/services/storage-service/db-stores/Chain.js",
|
|
@@ -1232,11 +1277,11 @@
|
|
|
1232
1277
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1233
1278
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1234
1279
|
"@substrate/connect": "^0.7.26",
|
|
1235
|
-
"@subwallet/chain-list": "0.2.
|
|
1236
|
-
"@subwallet/extension-base": "^1.1.
|
|
1237
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1238
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1239
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1280
|
+
"@subwallet/chain-list": "0.2.18-beta.2",
|
|
1281
|
+
"@subwallet/extension-base": "^1.1.18-0",
|
|
1282
|
+
"@subwallet/extension-chains": "^1.1.18-0",
|
|
1283
|
+
"@subwallet/extension-dapp": "^1.1.18-0",
|
|
1284
|
+
"@subwallet/extension-inject": "^1.1.18-0",
|
|
1240
1285
|
"@subwallet/keyring": "^0.1.1",
|
|
1241
1286
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1242
1287
|
"@walletconnect/sign-client": "^2.8.4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.18-0'
|
|
11
11
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CampaignNotification } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
3
|
+
export declare const runCampaign: (notificationService: NotificationService, campaign: CampaignNotification) => void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { NotificationType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { t } from 'i18next';
|
|
6
|
+
export const runCampaign = (notificationService, campaign) => {
|
|
7
|
+
const {
|
|
8
|
+
action,
|
|
9
|
+
message,
|
|
10
|
+
metadata,
|
|
11
|
+
title
|
|
12
|
+
} = campaign.data;
|
|
13
|
+
const {
|
|
14
|
+
buttons
|
|
15
|
+
} = campaign;
|
|
16
|
+
const onClick = (action, metadata) => {
|
|
17
|
+
return () => {
|
|
18
|
+
switch (action) {
|
|
19
|
+
case 'open_url':
|
|
20
|
+
{
|
|
21
|
+
if (metadata) {
|
|
22
|
+
const url = metadata.url;
|
|
23
|
+
if (url) {
|
|
24
|
+
window.open(url);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
default:
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const onButtonClick = btnIndex => {
|
|
35
|
+
const {
|
|
36
|
+
metadata,
|
|
37
|
+
type
|
|
38
|
+
} = buttons[btnIndex];
|
|
39
|
+
onClick(type, metadata)();
|
|
40
|
+
};
|
|
41
|
+
notificationService.notify({
|
|
42
|
+
type: NotificationType.SUCCESS,
|
|
43
|
+
title: t(title),
|
|
44
|
+
message: t(message),
|
|
45
|
+
action: {
|
|
46
|
+
buttonClick: onButtonClick,
|
|
47
|
+
click: onClick(action, metadata)
|
|
48
|
+
},
|
|
49
|
+
notifyViaBrowser: true,
|
|
50
|
+
buttons: buttons.map(button => ({
|
|
51
|
+
title: button.name
|
|
52
|
+
}))
|
|
53
|
+
});
|
|
54
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CampaignData } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
+
export default class CampaignService {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(state: KoniState);
|
|
6
|
+
private fetchCampaign;
|
|
7
|
+
private runCampaign;
|
|
8
|
+
getProcessingCampaign(): Promise<CampaignData[]>;
|
|
9
|
+
subscribeProcessingCampaign(): import("dexie").Observable<CampaignData[]>;
|
|
10
|
+
private completeCampaignNotification;
|
|
11
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { CampaignDataType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { MARKETING_CAMPAIGN_URL } from '@subwallet/extension-base/constants';
|
|
6
|
+
import { TARGET_ENV } from '@subwallet/extension-base/utils';
|
|
7
|
+
import axios from 'axios';
|
|
8
|
+
import { runCampaign } from "./helpers.js";
|
|
9
|
+
export default class CampaignService {
|
|
10
|
+
#state;
|
|
11
|
+
constructor(state) {
|
|
12
|
+
this.#state = state;
|
|
13
|
+
this.fetchCampaign().catch(e => {
|
|
14
|
+
console.error('Error on fetch campaigns', e);
|
|
15
|
+
});
|
|
16
|
+
this.runCampaign().catch(e => {
|
|
17
|
+
console.error('Error on run campaigns', e);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async fetchCampaign() {
|
|
21
|
+
const response = await axios.request({
|
|
22
|
+
method: 'GET',
|
|
23
|
+
url: MARKETING_CAMPAIGN_URL
|
|
24
|
+
});
|
|
25
|
+
const respData = response.data;
|
|
26
|
+
const campaigns = [];
|
|
27
|
+
for (const data of respData) {
|
|
28
|
+
// eslint-disable-next-line camelcase
|
|
29
|
+
const {
|
|
30
|
+
condition,
|
|
31
|
+
end_time,
|
|
32
|
+
id: campaignId,
|
|
33
|
+
start_time
|
|
34
|
+
} = data;
|
|
35
|
+
const endTime = new Date(end_time).getTime();
|
|
36
|
+
const startTime = new Date(start_time).getTime();
|
|
37
|
+
for (const banner of data.banners) {
|
|
38
|
+
const {
|
|
39
|
+
buttons,
|
|
40
|
+
id,
|
|
41
|
+
...baseData
|
|
42
|
+
} = banner;
|
|
43
|
+
const slug = `${campaignId}-banner-${id}`;
|
|
44
|
+
if (banner.environments.includes(TARGET_ENV)) {
|
|
45
|
+
campaigns.push({
|
|
46
|
+
slug,
|
|
47
|
+
endTime,
|
|
48
|
+
startTime,
|
|
49
|
+
isDone: false,
|
|
50
|
+
campaignId,
|
|
51
|
+
type: CampaignDataType.BANNER,
|
|
52
|
+
buttons,
|
|
53
|
+
data: baseData,
|
|
54
|
+
condition
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const notification of data.notifications) {
|
|
59
|
+
const {
|
|
60
|
+
buttons,
|
|
61
|
+
id,
|
|
62
|
+
...baseData
|
|
63
|
+
} = notification;
|
|
64
|
+
const slug = `${campaignId}-notification-${id}`;
|
|
65
|
+
campaigns.push({
|
|
66
|
+
slug,
|
|
67
|
+
endTime,
|
|
68
|
+
startTime,
|
|
69
|
+
isDone: false,
|
|
70
|
+
campaignId,
|
|
71
|
+
type: CampaignDataType.NOTIFICATION,
|
|
72
|
+
buttons,
|
|
73
|
+
data: baseData,
|
|
74
|
+
condition
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const campaign of campaigns) {
|
|
79
|
+
const exists = await this.#state.dbService.getCampaign(campaign.slug);
|
|
80
|
+
if (!exists) {
|
|
81
|
+
await this.#state.dbService.upsertCampaign(campaign);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.#state.eventService.emit('campaign.ready', true);
|
|
85
|
+
}
|
|
86
|
+
async runCampaign() {
|
|
87
|
+
await this.#state.eventService.waitCampaignReady;
|
|
88
|
+
const campaigns = (await this.getProcessingCampaign()).filter(data => data.type === CampaignDataType.NOTIFICATION);
|
|
89
|
+
campaigns.forEach(campaign => {
|
|
90
|
+
const {
|
|
91
|
+
isDone,
|
|
92
|
+
slug,
|
|
93
|
+
type
|
|
94
|
+
} = campaign;
|
|
95
|
+
if (isDone) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const onComplete = () => {
|
|
99
|
+
this.completeCampaignNotification(slug).catch(e => {
|
|
100
|
+
console.error('Error when complete campaign', slug, e);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
try {
|
|
104
|
+
switch (type) {
|
|
105
|
+
case CampaignDataType.NOTIFICATION:
|
|
106
|
+
{
|
|
107
|
+
runCampaign(this.#state.notificationService, campaign);
|
|
108
|
+
onComplete();
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
default:
|
|
112
|
+
throw new Error('Missing handle campaign');
|
|
113
|
+
}
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.error('Error on running campaigns', slug, e);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
getProcessingCampaign() {
|
|
120
|
+
return this.#state.dbService.getProcessingCampaign();
|
|
121
|
+
}
|
|
122
|
+
subscribeProcessingCampaign() {
|
|
123
|
+
return this.#state.dbService.subscribeProcessingCampaign();
|
|
124
|
+
}
|
|
125
|
+
async completeCampaignNotification(slug) {
|
|
126
|
+
const campaign = await this.#state.dbService.getCampaign(slug);
|
|
127
|
+
if (campaign) {
|
|
128
|
+
await this.#state.dbService.upsertCampaign({
|
|
129
|
+
...campaign,
|
|
130
|
+
isDone: true
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CampaignAction, CampaignButton } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
declare type Metadata = Record<string, any> | null;
|
|
3
|
+
interface _BannerData {
|
|
4
|
+
id: number;
|
|
5
|
+
alt: string;
|
|
6
|
+
action: CampaignAction;
|
|
7
|
+
metadata: Metadata;
|
|
8
|
+
environments: string[];
|
|
9
|
+
position: string[];
|
|
10
|
+
buttons: CampaignButton[];
|
|
11
|
+
media: string;
|
|
12
|
+
}
|
|
13
|
+
interface _NotificationData {
|
|
14
|
+
id: number;
|
|
15
|
+
title: string;
|
|
16
|
+
message: string;
|
|
17
|
+
repeat: number;
|
|
18
|
+
repeatAfter: number;
|
|
19
|
+
action: CampaignAction;
|
|
20
|
+
metadata: Metadata;
|
|
21
|
+
buttons: CampaignButton[];
|
|
22
|
+
}
|
|
23
|
+
interface _CampaignData {
|
|
24
|
+
id: number;
|
|
25
|
+
name: string;
|
|
26
|
+
description: null;
|
|
27
|
+
start_time: string;
|
|
28
|
+
end_time: string;
|
|
29
|
+
condition: Metadata;
|
|
30
|
+
banners: _BannerData[];
|
|
31
|
+
notifications: _NotificationData[];
|
|
32
|
+
}
|
|
33
|
+
export declare type ListCampaignResponse = _CampaignData[];
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -44,7 +44,8 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
44
44
|
statemine: ['statemine'],
|
|
45
45
|
statemint: ['statemint'],
|
|
46
46
|
unique_network: ['unique_network'],
|
|
47
|
-
bitcountry: ['bitcountry', 'pioneer']
|
|
47
|
+
bitcountry: ['bitcountry', 'pioneer'],
|
|
48
|
+
vara: ['vara_network']
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
@@ -217,7 +218,7 @@ export const _XCM_TYPE = {
|
|
|
217
218
|
PR: `${_SubstrateChainType.PARACHAIN}-${_SubstrateChainType.RELAYCHAIN}` // UMP
|
|
218
219
|
};
|
|
219
220
|
|
|
220
|
-
export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS];
|
|
221
|
+
export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS, 'vara_network'];
|
|
221
222
|
export const EVM_PASS_CONNECT_STATUS = {
|
|
222
223
|
acala: ['acala_evm', 'karura_evm']
|
|
223
224
|
};
|
|
@@ -834,6 +834,8 @@ export class ChainService {
|
|
|
834
834
|
let evmInfo = null;
|
|
835
835
|
if (params.chainSpec.genesisHash !== '') {
|
|
836
836
|
substrateInfo = {
|
|
837
|
+
crowdloanFunds: params.chainSpec.crowdloanFunds || null,
|
|
838
|
+
crowdloanParaId: params.chainSpec.crowdloanParaId || null,
|
|
837
839
|
addressPrefix: params.chainSpec.addressPrefix,
|
|
838
840
|
blockExplorer: params.chainEditInfo.blockExplorer || null,
|
|
839
841
|
chainType: params.chainSpec.paraId !== null ? _SubstrateChainType.PARACHAIN : _SubstrateChainType.RELAYCHAIN,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
1
|
+
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _CrowdloanFund } from '@subwallet/chain-list/types';
|
|
2
2
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
3
3
|
import { BehaviorSubject } from 'rxjs';
|
|
4
4
|
import Web3 from 'web3';
|
|
@@ -89,6 +89,8 @@ export declare type _NetworkUpsertParams = {
|
|
|
89
89
|
genesisHash: string;
|
|
90
90
|
paraId: number | null;
|
|
91
91
|
addressPrefix: number;
|
|
92
|
+
crowdloanFunds?: _CrowdloanFund[] | null;
|
|
93
|
+
crowdloanParaId?: number | null;
|
|
92
94
|
evmChainId: number | null;
|
|
93
95
|
existentialDeposit: string;
|
|
94
96
|
decimals: number;
|
|
@@ -11,6 +11,8 @@ export declare class EventService extends EventEmitter<EventRegistry> {
|
|
|
11
11
|
readonly waitAccountReady: Promise<boolean>;
|
|
12
12
|
readonly waitChainReady: Promise<boolean>;
|
|
13
13
|
readonly waitAssetReady: Promise<boolean>;
|
|
14
|
+
readonly waitMigrateReady: Promise<boolean>;
|
|
15
|
+
readonly waitCampaignReady: Promise<boolean>;
|
|
14
16
|
constructor(options?: {
|
|
15
17
|
lazyTime: number;
|
|
16
18
|
});
|
|
@@ -19,6 +19,8 @@ export class EventService extends EventEmitter {
|
|
|
19
19
|
this.waitAccountReady = this.generateWaitPromise('account.ready');
|
|
20
20
|
this.waitChainReady = this.generateWaitPromise('chain.ready');
|
|
21
21
|
this.waitAssetReady = this.generateWaitPromise('asset.ready');
|
|
22
|
+
this.waitMigrateReady = this.generateWaitPromise('migration.done');
|
|
23
|
+
this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
|
|
22
24
|
}
|
|
23
25
|
generateWaitPromise(eventType) {
|
|
24
26
|
return new Promise(resolve => {
|
|
@@ -23,6 +23,8 @@ export interface EventRegistry {
|
|
|
23
23
|
'mantaPay.initSync': [string | undefined];
|
|
24
24
|
'mantaPay.submitTransaction': [SWTransaction | undefined];
|
|
25
25
|
'mantaPay.enable': [string];
|
|
26
|
+
'migration.done': [boolean];
|
|
27
|
+
'campaign.ready': [boolean];
|
|
26
28
|
}
|
|
27
29
|
export declare type EventType = keyof EventRegistry;
|
|
28
30
|
export declare const COMMON_RELOAD_EVENTS: EventType[];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import State from '@subwallet/extension-base/koni/background/handlers/State';
|
|
2
|
+
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
2
3
|
export default class MigrationService {
|
|
4
|
+
#private;
|
|
3
5
|
readonly state: State;
|
|
4
6
|
private logger;
|
|
5
|
-
constructor(state: State);
|
|
7
|
+
constructor(state: State, eventService: EventService);
|
|
6
8
|
run(): Promise<void>;
|
|
7
9
|
}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
import { logger as createLogger } from '@polkadot/util';
|
|
5
5
|
import MigrationScripts, { EVERYTIME } from "./scripts/index.js";
|
|
6
6
|
export default class MigrationService {
|
|
7
|
-
|
|
7
|
+
#eventService;
|
|
8
|
+
constructor(state, eventService) {
|
|
8
9
|
this.state = state;
|
|
10
|
+
this.#eventService = eventService;
|
|
9
11
|
this.logger = createLogger('Migration');
|
|
10
12
|
}
|
|
11
13
|
async run() {
|
|
@@ -32,5 +34,6 @@ export default class MigrationService {
|
|
|
32
34
|
this.logger.error('Migration error: ', MigrationScripts[keys[i]].name, error);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
37
|
+
this.#eventService.emit('migration.done', true);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class EnableChain extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
const state = this.state;
|
|
8
|
+
await state.enableChain(this.slug, true);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class MigrateEthProvider extends
|
|
3
|
-
|
|
1
|
+
import MigrateProvider from './MigrateProvider';
|
|
2
|
+
export default class MigrateEthProvider extends MigrateProvider {
|
|
3
|
+
newProvider: string;
|
|
4
|
+
oldProvider: string;
|
|
5
|
+
slug: string;
|
|
4
6
|
}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
export default class MigrateEthProvider extends
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const oldProvider = 'Cloudflare';
|
|
10
|
-
const newProvider = 'Llamarpc';
|
|
11
|
-
const chainState = state.getChainStateByKey(slug);
|
|
12
|
-
const chainInfo = state.getChainInfo(slug);
|
|
13
|
-
if (chainState.active && chainState.currentProvider === oldProvider) {
|
|
14
|
-
await state.upsertChainInfo({
|
|
15
|
-
mode: 'update',
|
|
16
|
-
chainEditInfo: {
|
|
17
|
-
currentProvider: newProvider,
|
|
18
|
-
slug: slug,
|
|
19
|
-
providers: chainInfo.providers
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
4
|
+
import MigrateProvider from "./MigrateProvider.js";
|
|
5
|
+
export default class MigrateEthProvider extends MigrateProvider {
|
|
6
|
+
newProvider = 'ethereum';
|
|
7
|
+
oldProvider = 'Cloudflare';
|
|
8
|
+
slug = 'Llamarpc';
|
|
24
9
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import MigrateProvider from "./MigrateProvider.js";
|
|
5
|
+
export default class MigratePioneerProvider extends MigrateProvider {
|
|
6
|
+
slug = 'pioneer';
|
|
7
|
+
oldProvider = 'OnFinality';
|
|
8
|
+
newProvider = 'Pioneer';
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
2
|
+
export default abstract class MigrateProvider extends BaseMigrationJob {
|
|
3
|
+
abstract slug: string;
|
|
4
|
+
abstract oldProvider: string;
|
|
5
|
+
abstract newProvider: string;
|
|
6
|
+
run(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateProvider extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
const state = this.state;
|
|
8
|
+
const chainState = state.getChainStateByKey(this.slug);
|
|
9
|
+
const chainInfo = state.getChainInfo(this.slug);
|
|
10
|
+
if (chainState.active && chainState.currentProvider === this.oldProvider) {
|
|
11
|
+
await state.upsertChainInfo({
|
|
12
|
+
mode: 'update',
|
|
13
|
+
chainEditInfo: {
|
|
14
|
+
currentProvider: this.newProvider,
|
|
15
|
+
slug: this.slug,
|
|
16
|
+
providers: chainInfo.providers
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import DeleteChain from '@subwallet/extension-base/services/migration-service/scripts/DeleteChain';
|
|
5
5
|
import AutoEnableChainsTokens from "./AutoEnableChainsTokens.js";
|
|
6
|
+
import EnableVaraChain from "./EnableVaraChain.js";
|
|
6
7
|
import MigrateAuthUrls from "./MigrateAuthUrls.js";
|
|
7
8
|
import MigrateAutoLock from "./MigrateAutoLock.js";
|
|
8
9
|
import MigrateChainPatrol from "./MigrateChainPatrol.js";
|
|
@@ -10,6 +11,7 @@ import MigrateEthProvider from "./MigrateEthProvider.js";
|
|
|
10
11
|
import MigrateImportedToken from "./MigrateImportedToken.js";
|
|
11
12
|
import MigrateLedgerAccount from "./MigrateLedgerAccount.js";
|
|
12
13
|
import MigrateNetworkSettings from "./MigrateNetworkSettings.js";
|
|
14
|
+
import MigratePioneerProvider from "./MigratePioneerProvider.js";
|
|
13
15
|
import MigrateSettings from "./MigrateSettings.js";
|
|
14
16
|
import MigrateTokenDecimals from "./MigrateTokenDecimals.js";
|
|
15
17
|
import MigrateTransactionHistory from "./MigrateTransactionHistory.js";
|
|
@@ -28,6 +30,8 @@ export default {
|
|
|
28
30
|
'1.0.12-02': MigrateEthProvider,
|
|
29
31
|
'1.1.6-01': MigrateWalletReference,
|
|
30
32
|
'1.1.7': DeleteChain,
|
|
31
|
-
'1.1.13-01': MigrateTokenDecimals
|
|
33
|
+
'1.1.13-01': MigrateTokenDecimals,
|
|
34
|
+
'1.1.17-01': MigratePioneerProvider,
|
|
35
|
+
'1.1.17-03': EnableVaraChain
|
|
32
36
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
33
37
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Notification, NotificationParams } from '@subwallet/extension-base/background/KoniTypes';
|
|
1
|
+
import { Notification, NotificationButton, NotificationParams } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import { BehaviorSubject } from 'rxjs';
|
|
3
3
|
export default class NotificationService {
|
|
4
4
|
private notificationSubject;
|
|
5
5
|
getNotificationSubject(): BehaviorSubject<Notification[]>;
|
|
6
6
|
notify(notification: NotificationParams): void;
|
|
7
|
-
static createBrowserNotification(title: string, message: string,
|
|
7
|
+
static createBrowserNotification(title: string, message: string, action?: NotificationParams['action'], buttons?: NotificationButton[]): void;
|
|
8
8
|
}
|