@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
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _chainList = require("@subwallet/chain-list");
|
|
9
8
|
var _EvmProviderError = require("@subwallet/extension-base/background/errors/EvmProviderError");
|
|
10
9
|
var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
|
|
11
10
|
var _subscriptions = require("@subwallet/extension-base/background/handlers/subscriptions");
|
|
@@ -13,6 +12,7 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
|
13
12
|
var _constants = require("@subwallet/extension-base/constants");
|
|
14
13
|
var _balanceService = require("@subwallet/extension-base/services/balance-service");
|
|
15
14
|
var _types = require("@subwallet/extension-base/services/base/types");
|
|
15
|
+
var _campaignService = _interopRequireDefault(require("@subwallet/extension-base/services/campaign-service"));
|
|
16
16
|
var _chainService = require("@subwallet/extension-base/services/chain-service");
|
|
17
17
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
18
18
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
@@ -57,15 +57,6 @@ const getSuri = (seed, type) => {
|
|
|
57
57
|
};
|
|
58
58
|
const generateDefaultCrowdloanMap = () => {
|
|
59
59
|
const crowdloanMap = {};
|
|
60
|
-
Object.entries(_chainList.ChainInfoMap).forEach(_ref => {
|
|
61
|
-
let [networkKey, chainInfo] = _ref;
|
|
62
|
-
if ((0, _utils._isSubstrateParaChain)(chainInfo)) {
|
|
63
|
-
crowdloanMap[networkKey] = {
|
|
64
|
-
state: _KoniTypes.APIItemState.PENDING,
|
|
65
|
-
contribute: '0'
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
60
|
return crowdloanMap;
|
|
70
61
|
};
|
|
71
62
|
class KoniState {
|
|
@@ -109,7 +100,8 @@ class KoniState {
|
|
|
109
100
|
this.historyService = new _historyService.HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService);
|
|
110
101
|
this.transactionService = new _transactionService.default(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
111
102
|
this.walletConnectService = new _walletConnectService.default(this, this.requestService);
|
|
112
|
-
this.migrationService = new _migrationService.default(this);
|
|
103
|
+
this.migrationService = new _migrationService.default(this, this.eventService);
|
|
104
|
+
this.campaignService = new _campaignService.default(this);
|
|
113
105
|
this.subscription = new _subscription.KoniSubscription(this, this.dbService);
|
|
114
106
|
this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
|
|
115
107
|
this.logger = (0, _util.logger)('State');
|
|
@@ -165,12 +157,12 @@ class KoniState {
|
|
|
165
157
|
});
|
|
166
158
|
return Promise.resolve(this.providers[key].meta);
|
|
167
159
|
}
|
|
168
|
-
rpcSubscribe(
|
|
160
|
+
rpcSubscribe(_ref, cb, port) {
|
|
169
161
|
let {
|
|
170
162
|
method,
|
|
171
163
|
params,
|
|
172
164
|
type
|
|
173
|
-
} =
|
|
165
|
+
} = _ref;
|
|
174
166
|
const provider = this.injectedProviders.get(port);
|
|
175
167
|
(0, _util.assert)(provider, 'Cannot call pub(rpc.subscribe) before provider is set');
|
|
176
168
|
return provider.subscribe(type, method, params, cb);
|
|
@@ -548,10 +540,10 @@ class KoniState {
|
|
|
548
540
|
address: changeAddress
|
|
549
541
|
}, {
|
|
550
542
|
address: changeAddress
|
|
551
|
-
}).then(
|
|
543
|
+
}).then(_ref2 => {
|
|
552
544
|
let {
|
|
553
545
|
isApproved
|
|
554
|
-
} =
|
|
546
|
+
} = _ref2;
|
|
555
547
|
if (isApproved) {
|
|
556
548
|
const useAddress = changeAddress || address;
|
|
557
549
|
if (chainInfo && !(0, _utils._isChainEnabled)(chainState)) {
|
|
@@ -576,10 +568,10 @@ class KoniState {
|
|
|
576
568
|
});
|
|
577
569
|
}
|
|
578
570
|
async addNetworkConfirm(id, url, networkData) {
|
|
579
|
-
return this.requestService.addConfirmation(id, url, 'addNetworkRequest', networkData).then(async
|
|
571
|
+
return this.requestService.addConfirmation(id, url, 'addNetworkRequest', networkData).then(async _ref3 => {
|
|
580
572
|
let {
|
|
581
573
|
isApproved
|
|
582
|
-
} =
|
|
574
|
+
} = _ref3;
|
|
583
575
|
if (isApproved) {
|
|
584
576
|
if (networkData.mode === 'insert') {
|
|
585
577
|
await this.upsertChainInfo(networkData);
|
|
@@ -593,10 +585,10 @@ class KoniState {
|
|
|
593
585
|
});
|
|
594
586
|
}
|
|
595
587
|
async addTokenConfirm(id, url, tokenInfo) {
|
|
596
|
-
return this.requestService.addConfirmation(id, url, 'addTokenRequest', tokenInfo).then(async
|
|
588
|
+
return this.requestService.addConfirmation(id, url, 'addTokenRequest', tokenInfo).then(async _ref4 => {
|
|
597
589
|
let {
|
|
598
590
|
isApproved
|
|
599
|
-
} =
|
|
591
|
+
} = _ref4;
|
|
600
592
|
if (isApproved) {
|
|
601
593
|
await this.upsertCustomToken({
|
|
602
594
|
originChain: tokenInfo.originChain,
|
|
@@ -676,8 +668,8 @@ class KoniState {
|
|
|
676
668
|
}
|
|
677
669
|
removeInactiveChainBalances(balanceMap) {
|
|
678
670
|
const activeBalanceMap = {};
|
|
679
|
-
Object.entries(balanceMap).forEach(
|
|
680
|
-
let [tokenSlug, balanceItem] =
|
|
671
|
+
Object.entries(balanceMap).forEach(_ref5 => {
|
|
672
|
+
let [tokenSlug, balanceItem] = _ref5;
|
|
681
673
|
const tokenInfo = this.chainService.getAssetBySlug(tokenSlug);
|
|
682
674
|
if (tokenInfo) {
|
|
683
675
|
const chainInfo = this.chainService.getChainInfoByKey(tokenInfo.originChain);
|
|
@@ -1026,8 +1018,8 @@ class KoniState {
|
|
|
1026
1018
|
if (!genesisHash) {
|
|
1027
1019
|
return [undefined, undefined];
|
|
1028
1020
|
}
|
|
1029
|
-
const rs = Object.entries(this.chainService.getChainInfoMap()).find(
|
|
1030
|
-
let [networkKey, chainInfo] =
|
|
1021
|
+
const rs = Object.entries(this.chainService.getChainInfoMap()).find(_ref6 => {
|
|
1022
|
+
let [networkKey, chainInfo] = _ref6;
|
|
1031
1023
|
return (0, _utils._getSubstrateGenesisHash)(chainInfo) === genesisHash;
|
|
1032
1024
|
});
|
|
1033
1025
|
if (rs) {
|
|
@@ -1044,9 +1036,9 @@ class KoniState {
|
|
|
1044
1036
|
if (!chainId) {
|
|
1045
1037
|
return [undefined, undefined];
|
|
1046
1038
|
}
|
|
1047
|
-
const rs = Object.entries(this.chainService.getChainInfoMap()).find(
|
|
1039
|
+
const rs = Object.entries(this.chainService.getChainInfoMap()).find(_ref7 => {
|
|
1048
1040
|
var _chainInfo$evmInfo;
|
|
1049
|
-
let [networkKey, chainInfo] =
|
|
1041
|
+
let [networkKey, chainInfo] = _ref7;
|
|
1050
1042
|
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.evmChainId) === chainId;
|
|
1051
1043
|
});
|
|
1052
1044
|
if (rs) {
|
|
@@ -1062,11 +1054,11 @@ class KoniState {
|
|
|
1062
1054
|
}
|
|
1063
1055
|
return Object.values(_constants2._PREDEFINED_SINGLE_MODES).find(item => item.networkKeys.includes(networkKey));
|
|
1064
1056
|
}
|
|
1065
|
-
accountExportPrivateKey(
|
|
1057
|
+
accountExportPrivateKey(_ref8) {
|
|
1066
1058
|
let {
|
|
1067
1059
|
address,
|
|
1068
1060
|
password
|
|
1069
|
-
} =
|
|
1061
|
+
} = _ref8;
|
|
1070
1062
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1071
1063
|
const exportedJson = _uiKeyring.keyring.backupAccount(_uiKeyring.keyring.getPair(address), password);
|
|
1072
1064
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -1076,11 +1068,11 @@ class KoniState {
|
|
|
1076
1068
|
publicKey: (0, _util.u8aToHex)(decoded.publicKey)
|
|
1077
1069
|
};
|
|
1078
1070
|
}
|
|
1079
|
-
checkPublicAndSecretKey(
|
|
1071
|
+
checkPublicAndSecretKey(_ref9) {
|
|
1080
1072
|
let {
|
|
1081
1073
|
publicKey,
|
|
1082
1074
|
secretKey
|
|
1083
|
-
} =
|
|
1075
|
+
} = _ref9;
|
|
1084
1076
|
try {
|
|
1085
1077
|
const _secret = (0, _util.hexStripPrefix)(secretKey);
|
|
1086
1078
|
if (_secret.length === 64) {
|
|
@@ -1198,11 +1190,11 @@ class KoniState {
|
|
|
1198
1190
|
return this.requestService.addConfirmation(id, url, 'evmSignatureRequest', signPayload, {
|
|
1199
1191
|
requiredPassword: false,
|
|
1200
1192
|
address
|
|
1201
|
-
}).then(
|
|
1193
|
+
}).then(_ref10 => {
|
|
1202
1194
|
let {
|
|
1203
1195
|
isApproved,
|
|
1204
1196
|
payload
|
|
1205
|
-
} =
|
|
1197
|
+
} = _ref10;
|
|
1206
1198
|
if (isApproved) {
|
|
1207
1199
|
if (payload) {
|
|
1208
1200
|
return payload;
|
|
@@ -1486,7 +1478,7 @@ class KoniState {
|
|
|
1486
1478
|
const chainMap = this.chainService.getChainInfoMap();
|
|
1487
1479
|
const balanceDataList = await Promise.all(promiseList);
|
|
1488
1480
|
balanceDataList.forEach(balanceData => {
|
|
1489
|
-
balanceData && balanceData.forEach(
|
|
1481
|
+
balanceData && balanceData.forEach(_ref11 => {
|
|
1490
1482
|
var _currentAssetSettings;
|
|
1491
1483
|
let {
|
|
1492
1484
|
balance,
|
|
@@ -1495,7 +1487,7 @@ class KoniState {
|
|
|
1495
1487
|
locked,
|
|
1496
1488
|
network,
|
|
1497
1489
|
symbol
|
|
1498
|
-
} =
|
|
1490
|
+
} = _ref11;
|
|
1499
1491
|
const chain = _subscanChainMap.SUBSCAN_CHAIN_MAP_REVERSE[network];
|
|
1500
1492
|
const chainInfo = chain ? chainMap[chain] : null;
|
|
1501
1493
|
const balanceIsEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
|
|
@@ -171,11 +171,15 @@ class KoniSubscription {
|
|
|
171
171
|
this.state.setCrowdloanItem(networkKey, rs);
|
|
172
172
|
}, this.state.getChainInfoMap());
|
|
173
173
|
if (onlyRunOnFirstTime) {
|
|
174
|
-
subscriptionPromise.then(unsub =>
|
|
174
|
+
subscriptionPromise.then(unsub => {
|
|
175
|
+
unsub && unsub();
|
|
176
|
+
}).catch(this.logger.warn);
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
179
|
return () => {
|
|
178
|
-
subscriptionPromise.then(unsub =>
|
|
180
|
+
subscriptionPromise.then(unsub => {
|
|
181
|
+
unsub && unsub();
|
|
182
|
+
}).catch(this.logger.warn);
|
|
179
183
|
};
|
|
180
184
|
}
|
|
181
185
|
subscribeNft(address, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runCampaign = void 0;
|
|
7
|
+
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
+
var _i18next = require("i18next");
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
const runCampaign = (notificationService, campaign) => {
|
|
13
|
+
const {
|
|
14
|
+
action,
|
|
15
|
+
message,
|
|
16
|
+
metadata,
|
|
17
|
+
title
|
|
18
|
+
} = campaign.data;
|
|
19
|
+
const {
|
|
20
|
+
buttons
|
|
21
|
+
} = campaign;
|
|
22
|
+
const onClick = (action, metadata) => {
|
|
23
|
+
return () => {
|
|
24
|
+
switch (action) {
|
|
25
|
+
case 'open_url':
|
|
26
|
+
{
|
|
27
|
+
if (metadata) {
|
|
28
|
+
const url = metadata.url;
|
|
29
|
+
if (url) {
|
|
30
|
+
window.open(url);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const onButtonClick = btnIndex => {
|
|
41
|
+
const {
|
|
42
|
+
metadata,
|
|
43
|
+
type
|
|
44
|
+
} = buttons[btnIndex];
|
|
45
|
+
onClick(type, metadata)();
|
|
46
|
+
};
|
|
47
|
+
notificationService.notify({
|
|
48
|
+
type: _KoniTypes.NotificationType.SUCCESS,
|
|
49
|
+
title: (0, _i18next.t)(title),
|
|
50
|
+
message: (0, _i18next.t)(message),
|
|
51
|
+
action: {
|
|
52
|
+
buttonClick: onButtonClick,
|
|
53
|
+
click: onClick(action, metadata)
|
|
54
|
+
},
|
|
55
|
+
notifyViaBrowser: true,
|
|
56
|
+
buttons: buttons.map(button => ({
|
|
57
|
+
title: button.name
|
|
58
|
+
}))
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
exports.runCampaign = runCampaign;
|
|
@@ -0,0 +1,142 @@
|
|
|
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 _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
9
|
+
var _constants = require("@subwallet/extension-base/constants");
|
|
10
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
11
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
12
|
+
var _helpers = require("./helpers");
|
|
13
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
14
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
15
|
+
|
|
16
|
+
class CampaignService {
|
|
17
|
+
#state;
|
|
18
|
+
constructor(state) {
|
|
19
|
+
this.#state = state;
|
|
20
|
+
this.fetchCampaign().catch(e => {
|
|
21
|
+
console.error('Error on fetch campaigns', e);
|
|
22
|
+
});
|
|
23
|
+
this.runCampaign().catch(e => {
|
|
24
|
+
console.error('Error on run campaigns', e);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async fetchCampaign() {
|
|
28
|
+
const response = await _axios.default.request({
|
|
29
|
+
method: 'GET',
|
|
30
|
+
url: _constants.MARKETING_CAMPAIGN_URL
|
|
31
|
+
});
|
|
32
|
+
const respData = response.data;
|
|
33
|
+
const campaigns = [];
|
|
34
|
+
for (const data of respData) {
|
|
35
|
+
// eslint-disable-next-line camelcase
|
|
36
|
+
const {
|
|
37
|
+
condition,
|
|
38
|
+
end_time,
|
|
39
|
+
id: campaignId,
|
|
40
|
+
start_time
|
|
41
|
+
} = data;
|
|
42
|
+
const endTime = new Date(end_time).getTime();
|
|
43
|
+
const startTime = new Date(start_time).getTime();
|
|
44
|
+
for (const banner of data.banners) {
|
|
45
|
+
const {
|
|
46
|
+
buttons,
|
|
47
|
+
id,
|
|
48
|
+
...baseData
|
|
49
|
+
} = banner;
|
|
50
|
+
const slug = `${campaignId}-banner-${id}`;
|
|
51
|
+
if (banner.environments.includes(_utils.TARGET_ENV)) {
|
|
52
|
+
campaigns.push({
|
|
53
|
+
slug,
|
|
54
|
+
endTime,
|
|
55
|
+
startTime,
|
|
56
|
+
isDone: false,
|
|
57
|
+
campaignId,
|
|
58
|
+
type: _KoniTypes.CampaignDataType.BANNER,
|
|
59
|
+
buttons,
|
|
60
|
+
data: baseData,
|
|
61
|
+
condition
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (const notification of data.notifications) {
|
|
66
|
+
const {
|
|
67
|
+
buttons,
|
|
68
|
+
id,
|
|
69
|
+
...baseData
|
|
70
|
+
} = notification;
|
|
71
|
+
const slug = `${campaignId}-notification-${id}`;
|
|
72
|
+
campaigns.push({
|
|
73
|
+
slug,
|
|
74
|
+
endTime,
|
|
75
|
+
startTime,
|
|
76
|
+
isDone: false,
|
|
77
|
+
campaignId,
|
|
78
|
+
type: _KoniTypes.CampaignDataType.NOTIFICATION,
|
|
79
|
+
buttons,
|
|
80
|
+
data: baseData,
|
|
81
|
+
condition
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const campaign of campaigns) {
|
|
86
|
+
const exists = await this.#state.dbService.getCampaign(campaign.slug);
|
|
87
|
+
if (!exists) {
|
|
88
|
+
await this.#state.dbService.upsertCampaign(campaign);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
this.#state.eventService.emit('campaign.ready', true);
|
|
92
|
+
}
|
|
93
|
+
async runCampaign() {
|
|
94
|
+
await this.#state.eventService.waitCampaignReady;
|
|
95
|
+
const campaigns = (await this.getProcessingCampaign()).filter(data => data.type === _KoniTypes.CampaignDataType.NOTIFICATION);
|
|
96
|
+
campaigns.forEach(campaign => {
|
|
97
|
+
const {
|
|
98
|
+
isDone,
|
|
99
|
+
slug,
|
|
100
|
+
type
|
|
101
|
+
} = campaign;
|
|
102
|
+
if (isDone) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const onComplete = () => {
|
|
106
|
+
this.completeCampaignNotification(slug).catch(e => {
|
|
107
|
+
console.error('Error when complete campaign', slug, e);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
try {
|
|
111
|
+
switch (type) {
|
|
112
|
+
case _KoniTypes.CampaignDataType.NOTIFICATION:
|
|
113
|
+
{
|
|
114
|
+
(0, _helpers.runCampaign)(this.#state.notificationService, campaign);
|
|
115
|
+
onComplete();
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
default:
|
|
119
|
+
throw new Error('Missing handle campaign');
|
|
120
|
+
}
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.error('Error on running campaigns', slug, e);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
getProcessingCampaign() {
|
|
127
|
+
return this.#state.dbService.getProcessingCampaign();
|
|
128
|
+
}
|
|
129
|
+
subscribeProcessingCampaign() {
|
|
130
|
+
return this.#state.dbService.subscribeProcessingCampaign();
|
|
131
|
+
}
|
|
132
|
+
async completeCampaignNotification(slug) {
|
|
133
|
+
const campaign = await this.#state.dbService.getCampaign(slug);
|
|
134
|
+
if (campaign) {
|
|
135
|
+
await this.#state.dbService.upsertCampaign({
|
|
136
|
+
...campaign,
|
|
137
|
+
isDone: true
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.default = CampaignService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -56,7 +56,8 @@ const _NFT_CHAIN_GROUP = {
|
|
|
56
56
|
statemine: ['statemine'],
|
|
57
57
|
statemint: ['statemint'],
|
|
58
58
|
unique_network: ['unique_network'],
|
|
59
|
-
bitcountry: ['bitcountry', 'pioneer']
|
|
59
|
+
bitcountry: ['bitcountry', 'pioneer'],
|
|
60
|
+
vara: ['vara_network']
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
@@ -238,7 +239,7 @@ const _XCM_TYPE = {
|
|
|
238
239
|
PR: `${_types._SubstrateChainType.PARACHAIN}-${_types._SubstrateChainType.RELAYCHAIN}` // UMP
|
|
239
240
|
};
|
|
240
241
|
exports._XCM_TYPE = _XCM_TYPE;
|
|
241
|
-
const _DEFAULT_ACTIVE_CHAINS = [..._chainList._DEFAULT_CHAINS];
|
|
242
|
+
const _DEFAULT_ACTIVE_CHAINS = [..._chainList._DEFAULT_CHAINS, 'vara_network'];
|
|
242
243
|
exports._DEFAULT_ACTIVE_CHAINS = _DEFAULT_ACTIVE_CHAINS;
|
|
243
244
|
const EVM_PASS_CONNECT_STATUS = {
|
|
244
245
|
acala: ['acala_evm', 'karura_evm']
|
|
@@ -851,6 +851,8 @@ class ChainService {
|
|
|
851
851
|
let evmInfo = null;
|
|
852
852
|
if (params.chainSpec.genesisHash !== '') {
|
|
853
853
|
substrateInfo = {
|
|
854
|
+
crowdloanFunds: params.chainSpec.crowdloanFunds || null,
|
|
855
|
+
crowdloanParaId: params.chainSpec.crowdloanParaId || null,
|
|
854
856
|
addressPrefix: params.chainSpec.addressPrefix,
|
|
855
857
|
blockExplorer: params.chainEditInfo.blockExplorer || null,
|
|
856
858
|
chainType: params.chainSpec.paraId !== null ? _types._SubstrateChainType.PARACHAIN : _types._SubstrateChainType.RELAYCHAIN,
|
|
@@ -27,6 +27,8 @@ class EventService extends _eventemitter.default {
|
|
|
27
27
|
this.waitAccountReady = this.generateWaitPromise('account.ready');
|
|
28
28
|
this.waitChainReady = this.generateWaitPromise('chain.ready');
|
|
29
29
|
this.waitAssetReady = this.generateWaitPromise('asset.ready');
|
|
30
|
+
this.waitMigrateReady = this.generateWaitPromise('migration.done');
|
|
31
|
+
this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
|
|
30
32
|
}
|
|
31
33
|
generateWaitPromise(eventType) {
|
|
32
34
|
return new Promise(resolve => {
|
|
@@ -12,8 +12,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
12
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
13
|
|
|
14
14
|
class MigrationService {
|
|
15
|
-
|
|
15
|
+
#eventService;
|
|
16
|
+
constructor(state, eventService) {
|
|
16
17
|
this.state = state;
|
|
18
|
+
this.#eventService = eventService;
|
|
17
19
|
this.logger = (0, _util.logger)('Migration');
|
|
18
20
|
}
|
|
19
21
|
async run() {
|
|
@@ -40,6 +42,7 @@ class MigrationService {
|
|
|
40
42
|
this.logger.error('Migration error: ', _scripts.default[keys[i]].name, error);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
45
|
+
this.#eventService.emit('migration.done', true);
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
exports.default = MigrationService;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class EnableChain extends _Base.default {
|
|
13
|
+
async run() {
|
|
14
|
+
const state = this.state;
|
|
15
|
+
await state.enableChain(this.slug, true);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = EnableChain;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 _EnableChain = _interopRequireDefault(require("./EnableChain"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class EnableVaraChain extends _EnableChain.default {
|
|
13
|
+
slug = 'vara_network';
|
|
14
|
+
}
|
|
15
|
+
exports.default = EnableVaraChain;
|
|
@@ -5,28 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _MigrateProvider = _interopRequireDefault(require("./MigrateProvider"));
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
|
|
12
|
-
class MigrateEthProvider extends
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const oldProvider = 'Cloudflare';
|
|
17
|
-
const newProvider = 'Llamarpc';
|
|
18
|
-
const chainState = state.getChainStateByKey(slug);
|
|
19
|
-
const chainInfo = state.getChainInfo(slug);
|
|
20
|
-
if (chainState.active && chainState.currentProvider === oldProvider) {
|
|
21
|
-
await state.upsertChainInfo({
|
|
22
|
-
mode: 'update',
|
|
23
|
-
chainEditInfo: {
|
|
24
|
-
currentProvider: newProvider,
|
|
25
|
-
slug: slug,
|
|
26
|
-
providers: chainInfo.providers
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
12
|
+
class MigrateEthProvider extends _MigrateProvider.default {
|
|
13
|
+
newProvider = 'ethereum';
|
|
14
|
+
oldProvider = 'Cloudflare';
|
|
15
|
+
slug = 'Llamarpc';
|
|
31
16
|
}
|
|
32
17
|
exports.default = MigrateEthProvider;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 _MigrateProvider = _interopRequireDefault(require("./MigrateProvider"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class MigratePioneerProvider extends _MigrateProvider.default {
|
|
13
|
+
slug = 'pioneer';
|
|
14
|
+
oldProvider = 'OnFinality';
|
|
15
|
+
newProvider = 'Pioneer';
|
|
16
|
+
}
|
|
17
|
+
exports.default = MigratePioneerProvider;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
+
|
|
12
|
+
class MigrateProvider extends _Base.default {
|
|
13
|
+
async run() {
|
|
14
|
+
const state = this.state;
|
|
15
|
+
const chainState = state.getChainStateByKey(this.slug);
|
|
16
|
+
const chainInfo = state.getChainInfo(this.slug);
|
|
17
|
+
if (chainState.active && chainState.currentProvider === this.oldProvider) {
|
|
18
|
+
await state.upsertChainInfo({
|
|
19
|
+
mode: 'update',
|
|
20
|
+
chainEditInfo: {
|
|
21
|
+
currentProvider: this.newProvider,
|
|
22
|
+
slug: this.slug,
|
|
23
|
+
providers: chainInfo.providers
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = MigrateProvider;
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.EVERYTIME = void 0;
|
|
8
8
|
var _DeleteChain = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/DeleteChain"));
|
|
9
9
|
var _AutoEnableChainsTokens = _interopRequireDefault(require("./AutoEnableChainsTokens"));
|
|
10
|
+
var _EnableVaraChain = _interopRequireDefault(require("./EnableVaraChain"));
|
|
10
11
|
var _MigrateAuthUrls = _interopRequireDefault(require("./MigrateAuthUrls"));
|
|
11
12
|
var _MigrateAutoLock = _interopRequireDefault(require("./MigrateAutoLock"));
|
|
12
13
|
var _MigrateChainPatrol = _interopRequireDefault(require("./MigrateChainPatrol"));
|
|
@@ -14,6 +15,7 @@ var _MigrateEthProvider = _interopRequireDefault(require("./MigrateEthProvider")
|
|
|
14
15
|
var _MigrateImportedToken = _interopRequireDefault(require("./MigrateImportedToken"));
|
|
15
16
|
var _MigrateLedgerAccount = _interopRequireDefault(require("./MigrateLedgerAccount"));
|
|
16
17
|
var _MigrateNetworkSettings = _interopRequireDefault(require("./MigrateNetworkSettings"));
|
|
18
|
+
var _MigratePioneerProvider = _interopRequireDefault(require("./MigratePioneerProvider"));
|
|
17
19
|
var _MigrateSettings = _interopRequireDefault(require("./MigrateSettings"));
|
|
18
20
|
var _MigrateTokenDecimals = _interopRequireDefault(require("./MigrateTokenDecimals"));
|
|
19
21
|
var _MigrateTransactionHistory = _interopRequireDefault(require("./MigrateTransactionHistory"));
|
|
@@ -36,7 +38,9 @@ var _default = {
|
|
|
36
38
|
'1.0.12-02': _MigrateEthProvider.default,
|
|
37
39
|
'1.1.6-01': _MigrateWalletReference.default,
|
|
38
40
|
'1.1.7': _DeleteChain.default,
|
|
39
|
-
'1.1.13-01': _MigrateTokenDecimals.default
|
|
41
|
+
'1.1.13-01': _MigrateTokenDecimals.default,
|
|
42
|
+
'1.1.17-01': _MigratePioneerProvider.default,
|
|
43
|
+
'1.1.17-03': _EnableVaraChain.default
|
|
40
44
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
41
45
|
};
|
|
42
46
|
exports.default = _default;
|
|
@@ -25,26 +25,40 @@ class NotificationService {
|
|
|
25
25
|
});
|
|
26
26
|
this.notificationSubject.next(notifications);
|
|
27
27
|
if (notification.notifyViaBrowser) {
|
|
28
|
-
|
|
29
|
-
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);
|
|
28
|
+
NotificationService.createBrowserNotification(notification.title, notification.message, notification.action, notification.buttons);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
// Create a new chrome notification with link
|
|
34
|
-
static createBrowserNotification(title, message,
|
|
33
|
+
static createBrowserNotification(title, message, action, buttons) {
|
|
35
34
|
var _chrome, _chrome$notifications;
|
|
35
|
+
const link = action === null || action === void 0 ? void 0 : action.url;
|
|
36
|
+
const onClick = action === null || action === void 0 ? void 0 : action.click;
|
|
37
|
+
const onButtonClick = action === null || action === void 0 ? void 0 : action.buttonClick;
|
|
36
38
|
(_chrome = chrome) === null || _chrome === void 0 ? void 0 : (_chrome$notifications = _chrome.notifications) === null || _chrome$notifications === void 0 ? void 0 : _chrome$notifications.create({
|
|
37
39
|
type: 'basic',
|
|
38
40
|
title,
|
|
39
41
|
message,
|
|
40
42
|
iconUrl: './images/icon-128.png',
|
|
41
43
|
priority: 2,
|
|
42
|
-
isClickable: !!link
|
|
44
|
+
isClickable: !!link || !!onClick,
|
|
45
|
+
buttons
|
|
43
46
|
}, notificationId => {
|
|
44
|
-
if (link) {
|
|
47
|
+
if (link || onClick) {
|
|
45
48
|
chrome.notifications.onClicked.addListener(nId => {
|
|
46
49
|
if (nId === notificationId) {
|
|
47
|
-
|
|
50
|
+
if (onClick) {
|
|
51
|
+
onClick();
|
|
52
|
+
} else {
|
|
53
|
+
window.open(link);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (onButtonClick) {
|
|
59
|
+
chrome.notifications.onButtonClicked.addListener((nId, btnIndex) => {
|
|
60
|
+
if (nId === notificationId) {
|
|
61
|
+
onButtonClick(btnIndex);
|
|
48
62
|
}
|
|
49
63
|
});
|
|
50
64
|
}
|