@subwallet/extension-base 1.2.6-1 → 1.2.6-2

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.
@@ -1471,6 +1471,9 @@ export interface CampaignButton {
1471
1471
  type: CampaignAction;
1472
1472
  metadata: Record<string, any> | null;
1473
1473
  }
1474
+ export interface ShowCampaignPopupRequest {
1475
+ value: boolean;
1476
+ }
1474
1477
  export declare enum CampaignDataType {
1475
1478
  NOTIFICATION = "notification",
1476
1479
  BANNER = "banner"
@@ -1732,6 +1735,8 @@ export interface KoniRequestSignatures {
1732
1735
  'pri(campaign.unlockDot.canMint)': [RequestUnlockDotCheckCanMint, boolean];
1733
1736
  'pri(campaign.unlockDot.subscribe)': [RequestUnlockDotSubscribeMintedData, UnlockDotTransactionNft, UnlockDotTransactionNft];
1734
1737
  'pri(campaign.banner.subscribe)': [null, CampaignBanner[], CampaignBanner[]];
1738
+ 'pri(campaign.popup.subscribeVisibility)': [null, ShowCampaignPopupRequest, ShowCampaignPopupRequest];
1739
+ 'pri(campaign.popup.toggle)': [ShowCampaignPopupRequest, null];
1735
1740
  'pri(campaign.banner.complete)': [RequestCampaignBannerComplete, boolean];
1736
1741
  'pri(buyService.tokens.subscribe)': [null, Record<string, BuyTokenInfo>, Record<string, BuyTokenInfo>];
1737
1742
  'pri(buyService.services.subscribe)': [null, Record<string, BuyServiceInfo>, Record<string, BuyServiceInfo>];
@@ -7,6 +7,8 @@ exports._getXcmBeneficiary = _getXcmBeneficiary;
7
7
  exports._getXcmDestWeight = _getXcmDestWeight;
8
8
  exports._getXcmMultiAssets = _getXcmMultiAssets;
9
9
  exports._getXcmMultiLocation = _getXcmMultiLocation;
10
+ exports._getXcmUnstableWarning = _getXcmUnstableWarning;
11
+ exports._isXcmTransferUnstable = _isXcmTransferUnstable;
10
12
  var _chainList = require("@subwallet/chain-list");
11
13
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
12
14
  var _utilCrypto = require("@polkadot/util-crypto");
@@ -55,6 +57,19 @@ function _getXcmMultiLocation(originChainInfo, destChainInfo, version, recipient
55
57
  }
56
58
  };
57
59
  }
60
+ function _isXcmTransferUnstable(originChainInfo, destChainInfo) {
61
+ return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo);
62
+ }
63
+ function _getXcmUnstableWarning(originChainInfo) {
64
+ switch (originChainInfo.slug) {
65
+ case _chainList.COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB:
66
+ return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a transaction fee of 2 DOT. Continue at your own risk';
67
+ case _chainList.COMMON_CHAIN_SLUGS.KUSAMA_ASSET_HUB:
68
+ return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a transaction fee of 0.4 KSM. Continue at your own risk';
69
+ default:
70
+ return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a large transaction fee. Continue at your own risk';
71
+ }
72
+ }
58
73
 
59
74
  // ---------------------------------------------------------------------------------------------------------------------
60
75
 
@@ -3946,6 +3946,21 @@ class KoniExtension {
3946
3946
  }
3947
3947
  return true;
3948
3948
  }
3949
+ async subscribeCampaignPopupVisibility(id, port) {
3950
+ const cb = (0, _subscriptions.createSubscription)(id, port);
3951
+ const popupVisibilitySubscription = this.#koniState.campaignService.subscribeCampaignPopupVisibility().subscribe(rs => {
3952
+ cb(rs);
3953
+ });
3954
+ this.createUnsubscriptionHandle(id, popupVisibilitySubscription.unsubscribe);
3955
+ port.onDisconnect.addListener(() => {
3956
+ this.cancelSubscription(id);
3957
+ });
3958
+ return Promise.resolve(this.#koniState.campaignService.getIsPopupVisible());
3959
+ }
3960
+ toggleCampaignPopup(value) {
3961
+ this.#koniState.campaignService.toggleCampaignPopup(value);
3962
+ return null;
3963
+ }
3949
3964
 
3950
3965
  /* Campaign */
3951
3966
 
@@ -4564,6 +4579,10 @@ class KoniExtension {
4564
4579
  return this.unlockDotCheckCanMint(request);
4565
4580
  case 'pri(campaign.unlockDot.subscribe)':
4566
4581
  return this.unlockDotSubscribeMintedData(id, port, request);
4582
+ case 'pri(campaign.popup.subscribeVisibility)':
4583
+ return this.subscribeCampaignPopupVisibility(id, port);
4584
+ case 'pri(campaign.popup.toggle)':
4585
+ return this.toggleCampaignPopup(request);
4567
4586
 
4568
4587
  /* Campaign */
4569
4588
 
@@ -1517,6 +1517,7 @@ class KoniState {
1517
1517
  this.waitSleeping = sleeping.promise;
1518
1518
 
1519
1519
  // Stopping services
1520
+ this.campaignService.stop();
1520
1521
  await Promise.all([this.cron.stop(), this.subscription.stop()]);
1521
1522
  await this.pauseAllNetworks(undefined, 'IDLE mode');
1522
1523
  await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop()]);
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.2.6-1'
16
+ version: '1.2.6-2'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
8
8
  var _utils = require("@subwallet/extension-base/utils");
9
9
  var _fetchStaticData = require("@subwallet/extension-base/utils/fetchStaticData");
10
+ var _rxjs = require("rxjs");
10
11
  var _helpers = require("./helpers");
11
12
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
12
13
  // SPDX-License-Identifier: Apache-2.0
@@ -14,6 +15,9 @@ var _helpers = require("./helpers");
14
15
  const targetEnvs = ['extension', 'mobile'];
15
16
  class CampaignService {
16
17
  #state;
18
+ popupVisibilitySubject = new _rxjs.BehaviorSubject({
19
+ value: true
20
+ });
17
21
  constructor(state) {
18
22
  this.#state = state;
19
23
  }
@@ -108,6 +112,15 @@ class CampaignService {
108
112
  }
109
113
  this.#state.eventService.emit('campaign.ready', true);
110
114
  }
115
+ getIsPopupVisible() {
116
+ return this.popupVisibilitySubject.value;
117
+ }
118
+ toggleCampaignPopup(value) {
119
+ this.popupVisibilitySubject.next(value);
120
+ }
121
+ subscribeCampaignPopupVisibility() {
122
+ return this.popupVisibilitySubject;
123
+ }
111
124
  async runCampaign() {
112
125
  await this.#state.eventService.waitCampaignReady;
113
126
  const campaigns = (await this.getProcessingCampaign()).filter(data => data.type === _KoniTypes.CampaignDataType.NOTIFICATION);
@@ -156,5 +169,10 @@ class CampaignService {
156
169
  });
157
170
  }
158
171
  }
172
+ stop() {
173
+ this.toggleCampaignPopup({
174
+ value: true
175
+ });
176
+ }
159
177
  }
160
178
  exports.default = CampaignService;
@@ -54,7 +54,7 @@ class BaseNativeStakingPoolHandler extends _base.default {
54
54
  }
55
55
  try {
56
56
  const rs = await this.state.subscanService.getRewardHistoryList(this.chain, address);
57
- const items = rs.list;
57
+ const items = rs === null || rs === void 0 ? void 0 : rs.list;
58
58
  if (items) {
59
59
  for (const item of items) {
60
60
  const now = new Date();
@@ -300,6 +300,13 @@ class SubscanService {
300
300
  throw new _SWError.SWError('SubscanService.getRewardHistoryList', await rs.text());
301
301
  }
302
302
  const jsonData = await rs.json();
303
+ const returnData = jsonData.data;
304
+ if (!returnData) {
305
+ return {
306
+ count: 0,
307
+ list: null
308
+ };
309
+ }
303
310
  return jsonData.data;
304
311
  }, 2);
305
312
  }
@@ -47,3 +47,5 @@ export declare function _getXcmMultiLocation(originChainInfo: _ChainInfo, destCh
47
47
  interior: unknown;
48
48
  };
49
49
  };
50
+ export declare function _isXcmTransferUnstable(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
51
+ export declare function _getXcmUnstableWarning(originChainInfo: _ChainInfo): string;
@@ -46,6 +46,19 @@ export function _getXcmMultiLocation(originChainInfo, destChainInfo, version, re
46
46
  }
47
47
  };
48
48
  }
49
+ export function _isXcmTransferUnstable(originChainInfo, destChainInfo) {
50
+ return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo);
51
+ }
52
+ export function _getXcmUnstableWarning(originChainInfo) {
53
+ switch (originChainInfo.slug) {
54
+ case COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB:
55
+ return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a transaction fee of 2 DOT. Continue at your own risk';
56
+ case COMMON_CHAIN_SLUGS.KUSAMA_ASSET_HUB:
57
+ return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a transaction fee of 0.4 KSM. Continue at your own risk';
58
+ default:
59
+ return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a large transaction fee. Continue at your own risk';
60
+ }
61
+ }
49
62
 
50
63
  // ---------------------------------------------------------------------------------------------------------------------
51
64
 
@@ -239,6 +239,8 @@ export default class KoniExtension {
239
239
  private unlockDotSubscribeMintedData;
240
240
  private subscribeProcessingBanner;
241
241
  private completeCampaignBanner;
242
+ private subscribeCampaignPopupVisibility;
243
+ private toggleCampaignPopup;
242
244
  private subscribeBuyTokens;
243
245
  private subscribeBuyServices;
244
246
  private subscribeSwapPairs;
@@ -3840,6 +3840,21 @@ export default class KoniExtension {
3840
3840
  }
3841
3841
  return true;
3842
3842
  }
3843
+ async subscribeCampaignPopupVisibility(id, port) {
3844
+ const cb = createSubscription(id, port);
3845
+ const popupVisibilitySubscription = this.#koniState.campaignService.subscribeCampaignPopupVisibility().subscribe(rs => {
3846
+ cb(rs);
3847
+ });
3848
+ this.createUnsubscriptionHandle(id, popupVisibilitySubscription.unsubscribe);
3849
+ port.onDisconnect.addListener(() => {
3850
+ this.cancelSubscription(id);
3851
+ });
3852
+ return Promise.resolve(this.#koniState.campaignService.getIsPopupVisible());
3853
+ }
3854
+ toggleCampaignPopup(value) {
3855
+ this.#koniState.campaignService.toggleCampaignPopup(value);
3856
+ return null;
3857
+ }
3843
3858
 
3844
3859
  /* Campaign */
3845
3860
 
@@ -4458,6 +4473,10 @@ export default class KoniExtension {
4458
4473
  return this.unlockDotCheckCanMint(request);
4459
4474
  case 'pri(campaign.unlockDot.subscribe)':
4460
4475
  return this.unlockDotSubscribeMintedData(id, port, request);
4476
+ case 'pri(campaign.popup.subscribeVisibility)':
4477
+ return this.subscribeCampaignPopupVisibility(id, port);
4478
+ case 'pri(campaign.popup.toggle)':
4479
+ return this.toggleCampaignPopup(request);
4461
4480
 
4462
4481
  /* Campaign */
4463
4482
 
@@ -1493,6 +1493,7 @@ export default class KoniState {
1493
1493
  this.waitSleeping = sleeping.promise;
1494
1494
 
1495
1495
  // Stopping services
1496
+ this.campaignService.stop();
1496
1497
  await Promise.all([this.cron.stop(), this.subscription.stop()]);
1497
1498
  await this.pauseAllNetworks(undefined, 'IDLE mode');
1498
1499
  await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop()]);
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.2.6-1",
20
+ "version": "1.2.6-2",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1921,11 +1921,11 @@
1921
1921
  "@reduxjs/toolkit": "^1.9.1",
1922
1922
  "@sora-substrate/type-definitions": "^1.17.7",
1923
1923
  "@substrate/connect": "^0.8.9",
1924
- "@subwallet/chain-list": "0.2.67",
1925
- "@subwallet/extension-base": "^1.2.6-1",
1926
- "@subwallet/extension-chains": "^1.2.6-1",
1927
- "@subwallet/extension-dapp": "^1.2.6-1",
1928
- "@subwallet/extension-inject": "^1.2.6-1",
1924
+ "@subwallet/chain-list": "0.2.69",
1925
+ "@subwallet/extension-base": "^1.2.6-2",
1926
+ "@subwallet/extension-chains": "^1.2.6-2",
1927
+ "@subwallet/extension-dapp": "^1.2.6-2",
1928
+ "@subwallet/extension-inject": "^1.2.6-2",
1929
1929
  "@subwallet/keyring": "^0.1.5",
1930
1930
  "@subwallet/ui-keyring": "^0.1.5",
1931
1931
  "@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.6-1'
10
+ version: '1.2.6-2'
11
11
  };
@@ -1,12 +1,18 @@
1
- import { CampaignData } from '@subwallet/extension-base/background/KoniTypes';
1
+ import { CampaignData, ShowCampaignPopupRequest } from '@subwallet/extension-base/background/KoniTypes';
2
2
  import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
3
+ import { BehaviorSubject } from 'rxjs';
3
4
  export default class CampaignService {
4
5
  #private;
6
+ private popupVisibilitySubject;
5
7
  constructor(state: KoniState);
6
8
  init(): void;
7
9
  private fetchCampaign;
10
+ getIsPopupVisible(): ShowCampaignPopupRequest;
11
+ toggleCampaignPopup(value: ShowCampaignPopupRequest): void;
12
+ subscribeCampaignPopupVisibility(): BehaviorSubject<ShowCampaignPopupRequest>;
8
13
  private runCampaign;
9
14
  getProcessingCampaign(): Promise<CampaignData[]>;
10
15
  subscribeProcessingCampaign(): import("dexie").Observable<CampaignData[]>;
11
16
  private completeCampaignNotification;
17
+ stop(): void;
12
18
  }
@@ -4,10 +4,14 @@
4
4
  import { CampaignDataType } from '@subwallet/extension-base/background/KoniTypes';
5
5
  import { TARGET_ENV } from '@subwallet/extension-base/utils';
6
6
  import { fetchStaticData } from '@subwallet/extension-base/utils/fetchStaticData';
7
+ import { BehaviorSubject } from 'rxjs';
7
8
  import { runCampaign } from "./helpers.js";
8
9
  const targetEnvs = ['extension', 'mobile'];
9
10
  export default class CampaignService {
10
11
  #state;
12
+ popupVisibilitySubject = new BehaviorSubject({
13
+ value: true
14
+ });
11
15
  constructor(state) {
12
16
  this.#state = state;
13
17
  }
@@ -102,6 +106,15 @@ export default class CampaignService {
102
106
  }
103
107
  this.#state.eventService.emit('campaign.ready', true);
104
108
  }
109
+ getIsPopupVisible() {
110
+ return this.popupVisibilitySubject.value;
111
+ }
112
+ toggleCampaignPopup(value) {
113
+ this.popupVisibilitySubject.next(value);
114
+ }
115
+ subscribeCampaignPopupVisibility() {
116
+ return this.popupVisibilitySubject;
117
+ }
105
118
  async runCampaign() {
106
119
  await this.#state.eventService.waitCampaignReady;
107
120
  const campaigns = (await this.getProcessingCampaign()).filter(data => data.type === CampaignDataType.NOTIFICATION);
@@ -150,4 +163,9 @@ export default class CampaignService {
150
163
  });
151
164
  }
152
165
  }
166
+ stop() {
167
+ this.toggleCampaignPopup({
168
+ value: true
169
+ });
170
+ }
153
171
  }
@@ -46,7 +46,7 @@ export default class BaseNativeStakingPoolHandler extends BasePoolHandler {
46
46
  }
47
47
  try {
48
48
  const rs = await this.state.subscanService.getRewardHistoryList(this.chain, address);
49
- const items = rs.list;
49
+ const items = rs === null || rs === void 0 ? void 0 : rs.list;
50
50
  if (items) {
51
51
  for (const item of items) {
52
52
  const now = new Date();
@@ -285,6 +285,13 @@ export class SubscanService {
285
285
  throw new SWError('SubscanService.getRewardHistoryList', await rs.text());
286
286
  }
287
287
  const jsonData = await rs.json();
288
+ const returnData = jsonData.data;
289
+ if (!returnData) {
290
+ return {
291
+ count: 0,
292
+ list: null
293
+ };
294
+ }
288
295
  return jsonData.data;
289
296
  }, 2);
290
297
  }
@@ -105,7 +105,7 @@ export interface ValidatorExtraInfo {
105
105
  }
106
106
  export interface PalletNominationPoolsBondedPoolInner {
107
107
  points: number;
108
- state: 'Open' | 'Destroying' | 'Locked';
108
+ state: 'Open' | 'Destroying' | 'Locked' | 'Blocked';
109
109
  memberCounter: number;
110
110
  roles: {
111
111
  depositor: string;