@subwallet/extension-base 1.2.23-0 → 1.2.24-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.
Files changed (42) hide show
  1. package/background/KoniTypes.d.ts +14 -0
  2. package/cjs/constants/index.js +4 -1
  3. package/cjs/koni/background/cron.js +10 -0
  4. package/cjs/koni/background/handlers/Extension.js +60 -4
  5. package/cjs/koni/background/handlers/State.js +3 -0
  6. package/cjs/packageInfo.js +1 -1
  7. package/cjs/services/migration-service/scripts/MigrateLedgerAccountV2.js +3 -3
  8. package/cjs/services/mkt-campaign-service/index.js +284 -0
  9. package/cjs/services/mkt-campaign-service/types.js +17 -0
  10. package/cjs/services/storage-service/DatabaseService.js +115 -0
  11. package/cjs/services/storage-service/db-stores/Balance.js +6 -0
  12. package/cjs/services/storage-service/db-stores/Crowdloan.js +8 -0
  13. package/cjs/services/storage-service/db-stores/Nft.js +12 -0
  14. package/cjs/services/storage-service/db-stores/NftCollection.js +11 -0
  15. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +6 -0
  16. package/constants/index.d.ts +1 -0
  17. package/constants/index.js +1 -0
  18. package/koni/background/cron.d.ts +1 -0
  19. package/koni/background/cron.js +11 -1
  20. package/koni/background/handlers/Extension.d.ts +3 -0
  21. package/koni/background/handlers/Extension.js +60 -4
  22. package/koni/background/handlers/State.d.ts +2 -0
  23. package/koni/background/handlers/State.js +3 -0
  24. package/package.json +15 -5
  25. package/packageInfo.js +1 -1
  26. package/services/migration-service/scripts/MigrateLedgerAccountV2.js +3 -3
  27. package/services/mkt-campaign-service/index.d.ts +30 -0
  28. package/services/mkt-campaign-service/index.js +275 -0
  29. package/services/mkt-campaign-service/types.d.ts +107 -0
  30. package/services/mkt-campaign-service/types.js +11 -0
  31. package/services/storage-service/DatabaseService.d.ts +5 -0
  32. package/services/storage-service/DatabaseService.js +116 -1
  33. package/services/storage-service/db-stores/Balance.d.ts +2 -0
  34. package/services/storage-service/db-stores/Balance.js +6 -0
  35. package/services/storage-service/db-stores/Crowdloan.d.ts +2 -0
  36. package/services/storage-service/db-stores/Crowdloan.js +8 -0
  37. package/services/storage-service/db-stores/Nft.d.ts +2 -0
  38. package/services/storage-service/db-stores/Nft.js +12 -0
  39. package/services/storage-service/db-stores/NftCollection.d.ts +1 -0
  40. package/services/storage-service/db-stores/NftCollection.js +11 -0
  41. package/services/storage-service/db-stores/YieldPositionStore.d.ts +2 -0
  42. package/services/storage-service/db-stores/YieldPositionStore.js +6 -0
@@ -16,6 +16,7 @@ var _YieldPoolStore = _interopRequireDefault(require("@subwallet/extension-base/
16
16
  var _YieldPositionStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/YieldPositionStore"));
17
17
  var _utils = require("@subwallet/extension-base/utils");
18
18
  var _uiKeyring = _interopRequireDefault(require("@subwallet/ui-keyring"));
19
+ var _bignumber = _interopRequireDefault(require("bignumber.js"));
19
20
  var _dexieExportImport = require("dexie-export-import");
20
21
  var _util = require("@polkadot/util");
21
22
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
@@ -81,6 +82,120 @@ class DatabaseService {
81
82
  // Filter not exist address
82
83
  return this.stores.balance.table.filter(obj => addresses.includes(obj.address)).toArray();
83
84
  }
85
+ async checkBalanceByTokens(tokens, comparison, addresses, amount) {
86
+ const filterFunc = item => {
87
+ const freeBalance = item === null || item === void 0 ? void 0 : item.free;
88
+ const lockedBalance = item === null || item === void 0 ? void 0 : item.locked;
89
+ const value = new _bignumber.default(freeBalance).plus(lockedBalance);
90
+ if (!addresses.includes(item.address)) {
91
+ return false;
92
+ }
93
+ switch (comparison) {
94
+ case 'eq':
95
+ return value.eq(amount || 0);
96
+ case 'gt':
97
+ return value.gt(amount || 0);
98
+ case 'gte':
99
+ return value.gte(amount || 0);
100
+ case 'lt':
101
+ return value.lt(amount || 0);
102
+ case 'lte':
103
+ return value.lte(amount || 0);
104
+ }
105
+ };
106
+ return this.stores.balance.checkBalanceByTokens(tokens, filterFunc);
107
+ }
108
+ async checkEarningByTokens(slug, comparison, addresses, amount) {
109
+ const filterFunc = item => {
110
+ if (!addresses.includes(item.address)) {
111
+ return false;
112
+ }
113
+ const value = new _bignumber.default(item.activeStake);
114
+ switch (comparison) {
115
+ case 'eq':
116
+ return value.eq(amount || 0);
117
+ case 'gt':
118
+ return value.gt(amount || 0);
119
+ case 'gte':
120
+ return value.gte(amount || 0);
121
+ case 'lt':
122
+ return value.lt(amount || 0);
123
+ case 'lte':
124
+ return value.lte(amount || 0);
125
+ }
126
+ };
127
+ return this.stores.yieldPosition.checkPositionByPoolSlug(slug, filterFunc);
128
+ }
129
+ async checkNftByTokens(chain, addresses, collectionId) {
130
+ const filterFunc = item => {
131
+ if (!addresses.includes(item.address)) {
132
+ return false;
133
+ } else {
134
+ return true;
135
+ }
136
+ };
137
+ return this.stores.nft.checkNftsByChainAndCollection(chain, filterFunc, collectionId);
138
+ }
139
+ async checkCrowdloanByChain(chain, addresses) {
140
+ const filterFunc = item => {
141
+ if (!addresses.includes(item.address)) {
142
+ return false;
143
+ } else {
144
+ return true;
145
+ }
146
+ };
147
+ return this.stores.crowdloan.checkCrowdloanExist(filterFunc);
148
+ }
149
+ async checkHasMoneyByTokens(types, addresses) {
150
+ const allHasMoneysConditionValid = [];
151
+ if (types.includes('balance')) {
152
+ const filterFunc = item => {
153
+ if (!addresses.includes(item.address)) {
154
+ return false;
155
+ }
156
+ const freeBalance = item === null || item === void 0 ? void 0 : item.free;
157
+ const lockedBalance = item === null || item === void 0 ? void 0 : item.locked;
158
+ const value = new _bignumber.default(freeBalance).plus(lockedBalance);
159
+ return value.gt(_utils.BN_ZERO);
160
+ };
161
+ const balanceResult = await this.stores.balance.checkBalanceExist(filterFunc);
162
+ balanceResult > 0 && allHasMoneysConditionValid.push('balance');
163
+ }
164
+ if (types.includes('earning')) {
165
+ const filterFunc = item => {
166
+ if (!addresses.includes(item.address)) {
167
+ return false;
168
+ }
169
+ const value = new _bignumber.default(item.activeStake);
170
+ return value.gt(_utils.BN_ZERO);
171
+ };
172
+ const earningResult = await this.stores.yieldPosition.checkPositionExist(filterFunc);
173
+ earningResult > 0 && allHasMoneysConditionValid.push('earning');
174
+ }
175
+ if (types.includes('nft')) {
176
+ const filterFunc = item => {
177
+ if (!addresses.includes(item.address)) {
178
+ return false;
179
+ } else {
180
+ return true;
181
+ }
182
+ };
183
+ const nftResult = await this.stores.nft.checkNftExist(filterFunc);
184
+ nftResult > 0 && allHasMoneysConditionValid.push('nft');
185
+ }
186
+ if (types.includes('crowdloan')) {
187
+ const filterFunc = item => {
188
+ if (!addresses.includes(item.address)) {
189
+ return false;
190
+ } else {
191
+ return true;
192
+ }
193
+ };
194
+ const crowdloanResult = await this.stores.crowdloan.checkCrowdloanExist(filterFunc);
195
+ crowdloanResult > 0 && allHasMoneysConditionValid.push('crowdloan');
196
+ }
197
+ return allHasMoneysConditionValid.length;
198
+ }
84
199
  async updateBalanceStore(item) {
85
200
  if (item.state === _KoniTypes.APIItemState.READY) {
86
201
  return this.stores.balance.upsert({
@@ -19,5 +19,11 @@ class BalanceStore extends _BaseStoreWithAddress.default {
19
19
  async removeByAddresses(addresses) {
20
20
  return this.table.where('address').anyOfIgnoreCase(addresses).delete();
21
21
  }
22
+ async checkBalanceByTokens(tokens, filterFunc) {
23
+ return this.table.where('tokenSlug').anyOfIgnoreCase(tokens).filter(filterFunc).count();
24
+ }
25
+ async checkBalanceExist(filterFunc) {
26
+ return this.table.filter(item => filterFunc(item)).count();
27
+ }
22
28
  }
23
29
  exports.default = BalanceStore;
@@ -33,5 +33,13 @@ class CrowdloanStore extends _BaseStoreWithAddressAndChain.default {
33
33
  address
34
34
  }).delete();
35
35
  }
36
+ checkCrowdloanByChain(chain, filterFunc) {
37
+ return this.table.where({
38
+ chain
39
+ }).filter(filterFunc).count();
40
+ }
41
+ checkCrowdloanExist(filterFunc) {
42
+ return this.table.filter(filterFunc).count();
43
+ }
36
44
  }
37
45
  exports.default = CrowdloanStore;
@@ -58,6 +58,18 @@ class NftStore extends _BaseStoreWithAddressAndChain.default {
58
58
  removeNftsByAddress(addresses) {
59
59
  return this.table.where('address').anyOfIgnoreCase(addresses).delete();
60
60
  }
61
+ checkNftsByChainAndCollection(chain, filterFunc, collectionId) {
62
+ const data = collectionId ? this.table.where({
63
+ chain,
64
+ collectionId
65
+ }) : this.table.where({
66
+ chain
67
+ });
68
+ return data.filter(item => filterFunc(item)).count();
69
+ }
70
+ checkNftExist(filterFunc) {
71
+ return this.table.filter(filterFunc).count();
72
+ }
61
73
 
62
74
  // reformatCollectionIds (items: INft[]) {
63
75
  // return items.map((item) => {
@@ -26,5 +26,16 @@ class NftCollectionStore extends _BaseStoreWithChain.default {
26
26
  collectionId
27
27
  }).delete();
28
28
  }
29
+ async checkNftByChainOrCollectionId(chain, collectionId) {
30
+ if (collectionId) {
31
+ return this.table.where({
32
+ chain,
33
+ collectionId
34
+ }).count();
35
+ }
36
+ return this.table.where({
37
+ chain
38
+ }).count();
39
+ }
29
40
  }
30
41
  exports.default = NftCollectionStore;
@@ -67,5 +67,11 @@ class YieldPositionStore extends _BaseStore.default {
67
67
  subscribeYieldPositions(addresses) {
68
68
  return (0, _dexie.liveQuery)(() => this.getByAddress(addresses));
69
69
  }
70
+ async checkPositionByPoolSlug(slug, filterFunc) {
71
+ return this.table.where('slug').anyOfIgnoreCase(slug).filter(filterFunc).limit(1).count();
72
+ }
73
+ async checkPositionExist(filterFunc) {
74
+ return this.table.filter(filterFunc).limit(1).count();
75
+ }
70
76
  }
71
77
  exports.default = YieldPositionStore;
@@ -7,6 +7,7 @@ export declare const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
7
7
  export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
8
8
  export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
9
9
  export declare const CRON_REFRESH_NFT_INTERVAL = 7200000;
10
+ export declare const CRON_REFRESH_MKT_CAMPAIGN_INTERVAL: number;
10
11
  export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
11
12
  export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
12
13
  export declare const CRON_REFRESH_HISTORY_INTERVAL = 900000;
@@ -10,6 +10,7 @@ export const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
10
10
  export const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
11
11
  export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
12
12
  export const CRON_REFRESH_NFT_INTERVAL = 7200000;
13
+ export const CRON_REFRESH_MKT_CAMPAIGN_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
13
14
  export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
14
15
  export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
15
16
  export const CRON_REFRESH_HISTORY_INTERVAL = 900000;
@@ -24,6 +24,7 @@ export declare class KoniCron {
24
24
  stop: () => Promise<void>;
25
25
  syncMantaPay: () => void;
26
26
  fetchPoolInfo: () => void;
27
+ fetchMktCampaignData: () => void;
27
28
  stopPoolInfo: () => void;
28
29
  refreshNft: (address: string, apiMap: ApiMap, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>) => () => void;
29
30
  resetNft: (newAddress: string) => void;
@@ -1,7 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { CRON_REFRESH_CHAIN_STAKING_METADATA, CRON_REFRESH_NFT_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
4
+ import { CRON_REFRESH_CHAIN_STAKING_METADATA, CRON_REFRESH_MKT_CAMPAIGN_INTERVAL, CRON_REFRESH_NFT_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
5
5
  import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
6
6
  import { waitTimeout } from '@subwallet/extension-base/utils';
7
7
  import { Subject } from 'rxjs';
@@ -54,10 +54,12 @@ export class KoniCron {
54
54
  await Promise.all([this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
55
55
  const currentAccountInfo = this.state.keyringService.currentAccount;
56
56
  const commonReloadEvents = ['account.add', 'account.remove', 'account.updateCurrent', 'chain.add', 'asset.updateState'];
57
+ const mktCampaignReloadEvents = ['account.add', 'account.remove'];
57
58
  this.eventHandler = (events, eventTypes) => {
58
59
  var _serviceInfo$currentA;
59
60
  const serviceInfo = this.state.getServiceInfo();
60
61
  const commonReload = eventTypes.some(eventType => commonReloadEvents.includes(eventType));
62
+ const mktCampaignNeedReload = eventTypes.some(eventType => mktCampaignReloadEvents.includes(eventType));
61
63
  const chainUpdated = eventTypes.includes('chain.updateState');
62
64
  const reloadMantaPay = eventTypes.includes('mantaPay.submitTransaction') || eventTypes.includes('mantaPay.enable');
63
65
  const updatedChains = [];
@@ -87,6 +89,10 @@ export class KoniCron {
87
89
  (commonReload || needUpdateNft) && this.resetNft(address);
88
90
  (commonReload || needUpdateNft) && this.removeCron('refreshNft');
89
91
  commonReload && this.removeCron('refreshPoolingStakingReward');
92
+ if (mktCampaignNeedReload) {
93
+ this.removeCron('fetchMktCampaignData');
94
+ this.addCron('fetchMktCampaignData', this.fetchMktCampaignData, CRON_REFRESH_MKT_CAMPAIGN_INTERVAL);
95
+ }
90
96
  if (chainUpdated) {
91
97
  this.stopPoolInfo();
92
98
  this.removeCron('fetchPoolInfo');
@@ -102,6 +108,7 @@ export class KoniCron {
102
108
  };
103
109
  this.state.eventService.onLazy(this.eventHandler);
104
110
  this.addCron('fetchPoolInfo', this.fetchPoolInfo, CRON_REFRESH_CHAIN_STAKING_METADATA);
111
+ this.addCron('fetchMktCampaignData', this.fetchMktCampaignData, CRON_REFRESH_MKT_CAMPAIGN_INTERVAL);
105
112
  if (!(currentAccountInfo !== null && currentAccountInfo !== void 0 && currentAccountInfo.address)) {
106
113
  return;
107
114
  }
@@ -140,6 +147,9 @@ export class KoniCron {
140
147
  fetchPoolInfo = () => {
141
148
  this.state.earningService.runSubscribePoolsInfo().catch(console.error);
142
149
  };
150
+ fetchMktCampaignData = () => {
151
+ this.state.mktCampaignService.fetchMktCampaignData();
152
+ };
143
153
  stopPoolInfo = () => {
144
154
  this.state.earningService.runUnsubscribePoolsInfo();
145
155
  };
@@ -245,6 +245,9 @@ export default class KoniExtension {
245
245
  private completeCampaignBanner;
246
246
  private subscribeCampaignPopupVisibility;
247
247
  private toggleCampaignPopup;
248
+ private subscribeAppPopupData;
249
+ private subscribeAppBannerData;
250
+ private subscribeAppConfirmationData;
248
251
  private subscribeBuyTokens;
249
252
  private subscribeBuyServices;
250
253
  private subscribeSwapPairs;
@@ -2123,14 +2123,15 @@ export default class KoniExtension {
2123
2123
  genesisHash,
2124
2124
  hardwareType,
2125
2125
  isAllowed,
2126
- name
2126
+ name,
2127
+ originGenesisHash
2127
2128
  }) {
2128
2129
  const key = keyring.addHardware(address, hardwareType, {
2129
2130
  accountIndex,
2130
2131
  addressOffset,
2131
2132
  genesisHash,
2132
2133
  name,
2133
- originGenesisHash: genesisHash
2134
+ originGenesisHash
2134
2135
  });
2135
2136
  const result = key.pair;
2136
2137
  const _address = result.address;
@@ -2164,7 +2165,8 @@ export default class KoniExtension {
2164
2165
  hardwareType,
2165
2166
  isEthereum,
2166
2167
  isGeneric,
2167
- name
2168
+ name,
2169
+ originGenesisHash
2168
2170
  } = account;
2169
2171
  let result;
2170
2172
  const baseMeta = {
@@ -2173,7 +2175,7 @@ export default class KoniExtension {
2173
2175
  accountIndex,
2174
2176
  addressOffset,
2175
2177
  genesisHash,
2176
- originGenesisHash: genesisHash,
2178
+ originGenesisHash,
2177
2179
  isGeneric
2178
2180
  };
2179
2181
  if (isEthereum) {
@@ -3975,6 +3977,54 @@ export default class KoniExtension {
3975
3977
  this.#koniState.campaignService.toggleCampaignPopup(value);
3976
3978
  return null;
3977
3979
  }
3980
+ subscribeAppPopupData(id, port) {
3981
+ const cb = createSubscription(id, port);
3982
+ let ready = false;
3983
+ const callback = rs => {
3984
+ if (ready) {
3985
+ cb(rs);
3986
+ }
3987
+ };
3988
+ const subscription = this.#koniState.mktCampaignService.subscribePopupsData(callback);
3989
+ this.createUnsubscriptionHandle(id, subscription.unsubscribe);
3990
+ port.onDisconnect.addListener(() => {
3991
+ this.cancelSubscription(id);
3992
+ });
3993
+ ready = true;
3994
+ return this.#koniState.mktCampaignService.getAppPopupsData();
3995
+ }
3996
+ subscribeAppBannerData(id, port) {
3997
+ const cb = createSubscription(id, port);
3998
+ let ready = false;
3999
+ const callback = rs => {
4000
+ if (ready) {
4001
+ cb(rs);
4002
+ }
4003
+ };
4004
+ const subscription = this.#koniState.mktCampaignService.subscribeBannersData(callback);
4005
+ this.createUnsubscriptionHandle(id, subscription.unsubscribe);
4006
+ port.onDisconnect.addListener(() => {
4007
+ this.cancelSubscription(id);
4008
+ });
4009
+ ready = true;
4010
+ return this.#koniState.mktCampaignService.getAppBannersData();
4011
+ }
4012
+ subscribeAppConfirmationData(id, port) {
4013
+ const cb = createSubscription(id, port);
4014
+ let ready = false;
4015
+ const callback = rs => {
4016
+ if (ready) {
4017
+ cb(rs);
4018
+ }
4019
+ };
4020
+ const subscription = this.#koniState.mktCampaignService.subscribeConfirmationsData(callback);
4021
+ this.createUnsubscriptionHandle(id, subscription.unsubscribe);
4022
+ port.onDisconnect.addListener(() => {
4023
+ this.cancelSubscription(id);
4024
+ });
4025
+ ready = true;
4026
+ return this.#koniState.mktCampaignService.getAppConfirmationsData();
4027
+ }
3978
4028
 
3979
4029
  /* Campaign */
3980
4030
 
@@ -4601,6 +4651,12 @@ export default class KoniExtension {
4601
4651
  return this.subscribeCampaignPopupVisibility(id, port);
4602
4652
  case 'pri(campaign.popup.toggle)':
4603
4653
  return this.toggleCampaignPopup(request);
4654
+ case 'pri(campaign.popups.subscribe)':
4655
+ return this.subscribeAppPopupData(id, port);
4656
+ case 'pri(campaign.banners.subscribe)':
4657
+ return this.subscribeAppBannerData(id, port);
4658
+ case 'pri(campaign.confirmations.subscribe)':
4659
+ return this.subscribeAppConfirmationData(id, port);
4604
4660
 
4605
4661
  /* Campaign */
4606
4662
 
@@ -14,6 +14,7 @@ import { HistoryService } from '@subwallet/extension-base/services/history-servi
14
14
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
15
15
  import MigrationService from '@subwallet/extension-base/services/migration-service';
16
16
  import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
17
+ import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
17
18
  import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
18
19
  import { PriceService } from '@subwallet/extension-base/services/price-service';
19
20
  import RequestService from '@subwallet/extension-base/services/request-service';
@@ -69,6 +70,7 @@ export default class KoniState {
69
70
  readonly walletConnectService: WalletConnectService;
70
71
  readonly mintCampaignService: MintCampaignService;
71
72
  readonly campaignService: CampaignService;
73
+ readonly mktCampaignService: MktCampaignService;
72
74
  readonly buyService: BuyService;
73
75
  readonly earningService: EarningService;
74
76
  readonly feeService: FeeService;
@@ -21,6 +21,7 @@ import { HistoryService } from '@subwallet/extension-base/services/history-servi
21
21
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
22
22
  import MigrationService from '@subwallet/extension-base/services/migration-service';
23
23
  import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
24
+ import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
24
25
  import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
25
26
  import { PriceService } from '@subwallet/extension-base/services/price-service';
26
27
  import RequestService from '@subwallet/extension-base/services/request-service';
@@ -103,6 +104,7 @@ export default class KoniState {
103
104
  this.walletConnectService = new WalletConnectService(this, this.requestService);
104
105
  this.migrationService = new MigrationService(this, this.eventService);
105
106
  this.campaignService = new CampaignService(this);
107
+ this.mktCampaignService = new MktCampaignService(this);
106
108
  this.buyService = new BuyService(this);
107
109
  this.transactionService = new TransactionService(this);
108
110
  this.earningService = new EarningService(this);
@@ -227,6 +229,7 @@ export default class KoniState {
227
229
  this.afterChainServiceInit();
228
230
  await this.migrationService.run();
229
231
  this.campaignService.init();
232
+ this.mktCampaignService.init();
230
233
  this.eventService.emit('chain.ready', true);
231
234
  await this.balanceService.init();
232
235
  await this.earningService.init();
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.2.23-0",
20
+ "version": "1.2.24-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1186,6 +1186,16 @@
1186
1186
  "require": "./cjs/services/mint-campaign-service/constants.js",
1187
1187
  "default": "./services/mint-campaign-service/constants.js"
1188
1188
  },
1189
+ "./services/mkt-campaign-service": {
1190
+ "types": "./services/mkt-campaign-service/index.d.ts",
1191
+ "require": "./cjs/services/mkt-campaign-service/index.js",
1192
+ "default": "./services/mkt-campaign-service/index.js"
1193
+ },
1194
+ "./services/mkt-campaign-service/types": {
1195
+ "types": "./services/mkt-campaign-service/types.d.ts",
1196
+ "require": "./cjs/services/mkt-campaign-service/types.js",
1197
+ "default": "./services/mkt-campaign-service/types.js"
1198
+ },
1189
1199
  "./services/notification-service/NotificationService": {
1190
1200
  "types": "./services/notification-service/NotificationService.d.ts",
1191
1201
  "require": "./cjs/services/notification-service/NotificationService.js",
@@ -2025,10 +2035,10 @@
2025
2035
  "@sora-substrate/type-definitions": "^1.17.7",
2026
2036
  "@substrate/connect": "^0.8.9",
2027
2037
  "@subwallet/chain-list": "0.2.80",
2028
- "@subwallet/extension-base": "^1.2.23-0",
2029
- "@subwallet/extension-chains": "^1.2.23-0",
2030
- "@subwallet/extension-dapp": "^1.2.23-0",
2031
- "@subwallet/extension-inject": "^1.2.23-0",
2038
+ "@subwallet/extension-base": "^1.2.24-0",
2039
+ "@subwallet/extension-chains": "^1.2.24-0",
2040
+ "@subwallet/extension-dapp": "^1.2.24-0",
2041
+ "@subwallet/extension-inject": "^1.2.24-0",
2032
2042
  "@subwallet/keyring": "^0.1.5",
2033
2043
  "@subwallet/ui-keyring": "^0.1.5",
2034
2044
  "@walletconnect/keyvaluestorage": "^1.1.1",
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.2.23-0'
10
+ version: '1.2.24-0'
11
11
  };
@@ -12,7 +12,7 @@ export default class MigrateLedgerAccountV2 extends BaseMigrationJob {
12
12
  const store = new AccountsStore();
13
13
  const update = (key, value) => {
14
14
  var _value$meta;
15
- if (key.startsWith('account:') && value.meta && isString((_value$meta = value.meta) === null || _value$meta === void 0 ? void 0 : _value$meta.originGenesisHash)) {
15
+ if (key.startsWith('account:') && value.meta && isString((_value$meta = value.meta) === null || _value$meta === void 0 ? void 0 : _value$meta.genesisHash)) {
16
16
  const newValue = {
17
17
  ...value
18
18
  };
@@ -21,10 +21,10 @@ export default class MigrateLedgerAccountV2 extends BaseMigrationJob {
21
21
  if (isEther) {
22
22
  newValue.meta.isGeneric = true;
23
23
  } else {
24
- newValue.meta.isGeneric = !newValue.meta.originGenesisHash;
24
+ newValue.meta.isGeneric = !newValue.meta.genesisHash;
25
25
  }
26
26
  }
27
- newValue.meta.availableGenesisHashes = [value.meta.originGenesisHash];
27
+ newValue.meta.availableGenesisHashes = [value.meta.genesisHash];
28
28
  store.set(key, newValue);
29
29
  }
30
30
  };
@@ -0,0 +1,30 @@
1
+ import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
2
+ import { AppBannerData, AppCommonData, AppConfirmationData, AppPopupData } from '@subwallet/extension-base/services/mkt-campaign-service/types';
3
+ export default class MktCampaignService {
4
+ #private;
5
+ private appPopupSubject;
6
+ private appBannerSubject;
7
+ private appConfirmationSubject;
8
+ constructor(state: KoniState);
9
+ fetchMktCampaignData(timeout?: number): void;
10
+ init(): void;
11
+ fetchPopupData(): Promise<void>;
12
+ fetchBannerData(): Promise<void>;
13
+ fetchConfirmationData(): Promise<void>;
14
+ subscribePopupsData(callback: (data: AppPopupData[]) => void): import("rxjs").Subscription;
15
+ subscribeBannersData(callback: (data: AppBannerData[]) => void): import("rxjs").Subscription;
16
+ subscribeConfirmationsData(callback: (data: AppConfirmationData[]) => void): import("rxjs").Subscription;
17
+ getAppPopupsData(): AppPopupData[];
18
+ getAppBannersData(): AppBannerData[];
19
+ getAppConfirmationsData(): AppConfirmationData[];
20
+ handleMktCampaignData<T extends AppCommonData>(data: T[]): Promise<T[]>;
21
+ private checkActiveAndPlatformCondition;
22
+ private checkCampaignExistTime;
23
+ private checkBalanceCondition;
24
+ private checkEarningCondition;
25
+ private checkNftCondition;
26
+ private checkCrowdloanCondition;
27
+ private checkHasMoneyCondition;
28
+ private getAllConditions;
29
+ private filterCampaignFunc;
30
+ }