@subwallet/extension-base 1.1.67-0 → 1.1.68-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.
@@ -3,11 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LANGUAGE = exports.CURRENCY = void 0;
6
+ exports.REMIND_EXPORT_ACCOUNT = exports.LATEST_SESSION = exports.LANGUAGE = exports.CURRENCY = void 0;
7
7
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
9
 
10
10
  const LANGUAGE = 'current-language';
11
11
  exports.LANGUAGE = LANGUAGE;
12
12
  const CURRENCY = 'current-currency';
13
- exports.CURRENCY = CURRENCY;
13
+ exports.CURRENCY = CURRENCY;
14
+ const REMIND_EXPORT_ACCOUNT = 'remind_export_account';
15
+ exports.REMIND_EXPORT_ACCOUNT = REMIND_EXPORT_ACCOUNT;
16
+ const LATEST_SESSION = 'general.latest-session';
17
+ exports.LATEST_SESSION = LATEST_SESSION;
@@ -35,6 +35,7 @@ var _constants3 = require("@subwallet/extension-base/services/request-service/co
35
35
  var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
36
36
  var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
37
37
  var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
38
+ var _storage = require("@subwallet/extension-base/storage");
38
39
  var _stores = require("@subwallet/extension-base/stores");
39
40
  var _types3 = require("@subwallet/extension-base/types");
40
41
  var _utils4 = require("@subwallet/extension-base/utils");
@@ -94,11 +95,13 @@ class KoniExtension {
94
95
  this.#lockTimeOut = setTimeout(() => {
95
96
  if (!this.#skipAutoLock) {
96
97
  this.keyringLock();
98
+ updateLatestSession(Date.now());
97
99
  }
98
100
  }, this.#timeAutoLock * 60 * 1000);
99
101
  } else if (this.#alwaysLock) {
100
102
  if (!this.#firstTime) {
101
103
  this.keyringLock();
104
+ updateLatestSession(Date.now());
102
105
  }
103
106
  }
104
107
  }
@@ -106,6 +109,12 @@ class KoniExtension {
106
109
  this.#firstTime = false;
107
110
  }
108
111
  };
112
+ const updateLatestSession = time => {
113
+ _storage.SWStorage.instance.setItem(_constants.LATEST_SESSION, JSON.stringify({
114
+ remind: true,
115
+ timeCalculate: time
116
+ }));
117
+ };
109
118
  this.#koniState.settingService.getSettings(updateTimeAutoLock);
110
119
  this.#koniState.settingService.getSubject().subscribe({
111
120
  next: updateTimeAutoLock
@@ -28,6 +28,7 @@ var _mintCampaignService = _interopRequireDefault(require("@subwallet/extension-
28
28
  var _NotificationService = _interopRequireDefault(require("@subwallet/extension-base/services/notification-service/NotificationService"));
29
29
  var _priceService = require("@subwallet/extension-base/services/price-service");
30
30
  var _requestService = _interopRequireDefault(require("@subwallet/extension-base/services/request-service"));
31
+ var _PopupHandler = require("@subwallet/extension-base/services/request-service/handler/PopupHandler");
31
32
  var _SettingService = _interopRequireDefault(require("@subwallet/extension-base/services/setting-service/SettingService"));
32
33
  var _DatabaseService = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/DatabaseService"));
33
34
  var _subscanService = require("@subwallet/extension-base/services/subscan-service");
@@ -35,6 +36,7 @@ var _subscanChainMap = require("@subwallet/extension-base/services/subscan-servi
35
36
  var _swapService = require("@subwallet/extension-base/services/swap-service");
36
37
  var _transactionService = _interopRequireDefault(require("@subwallet/extension-base/services/transaction-service"));
37
38
  var _walletConnectService = _interopRequireDefault(require("@subwallet/extension-base/services/wallet-connect-service"));
39
+ var _storage = require("@subwallet/extension-base/storage");
38
40
  var _AccountRef = _interopRequireDefault(require("@subwallet/extension-base/stores/AccountRef"));
39
41
  var _utils3 = require("@subwallet/extension-base/utils");
40
42
  var _parseTransaction = require("@subwallet/extension-base/utils/eth/parseTransaction");
@@ -245,6 +247,7 @@ class KoniState {
245
247
  // TODO: consider moving this to a separate service
246
248
  await this.dbService.stores.crowdloan.removeEndedCrowdloans();
247
249
  await this.startSubscription();
250
+ this.chainService.checkLatestData();
248
251
  }
249
252
  async initMantaPay(password) {
250
253
  var _this$chainService, _this$chainService$ma;
@@ -1363,6 +1366,27 @@ class KoniState {
1363
1366
  async completeConfirmation(request) {
1364
1367
  return await this.requestService.completeConfirmation(request);
1365
1368
  }
1369
+ onHandleRemindExportAccount() {
1370
+ const remindStatus = _storage.SWStorage.instance.getItem(_constants.REMIND_EXPORT_ACCOUNT);
1371
+ if (!remindStatus || !remindStatus.includes('done')) {
1372
+ const handleRemind = account => {
1373
+ if (account.address !== '') {
1374
+ // Open remind tab
1375
+ const url = `${chrome.runtime.getURL('index.html')}#/remind-export-account`;
1376
+ (0, _PopupHandler.openPopup)(url);
1377
+ subscription.unsubscribe();
1378
+ } else {
1379
+ setTimeout(() => {
1380
+ subscription.unsubscribe();
1381
+ }, 3000);
1382
+ }
1383
+ };
1384
+ const subscription = this.keyringService.currentAccountSubject.subscribe(handleRemind);
1385
+ }
1386
+ }
1387
+ onCheckToRemindUser() {
1388
+ this.onHandleRemindExportAccount();
1389
+ }
1366
1390
  onInstall() {
1367
1391
  // const singleModes = Object.values(_PREDEFINED_SINGLE_MODES);
1368
1392
 
@@ -1577,6 +1601,7 @@ class KoniState {
1577
1601
  await this.walletConnectService.resetWallet(resetAll);
1578
1602
  await this.chainService.init();
1579
1603
  this.afterChainServiceInit();
1604
+ this.chainService.checkLatestData();
1580
1605
  }
1581
1606
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1582
1607
  var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
@@ -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.1.67-0'
16
+ version: '1.1.68-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -478,7 +478,6 @@ class ChainService {
478
478
  await this.initAssetSettings();
479
479
  this.initAssetRefMap();
480
480
  await this.autoEnableTokens();
481
- this.checkLatestData();
482
481
  }
483
482
  initAssetRefMap() {
484
483
  this.dataMap.assetRefMap = _chainList.AssetRefMap;
@@ -547,10 +546,7 @@ class ChainService {
547
546
  if (latestAssetInfo) {
548
547
  const latestAssetPatch = JSON.stringify(latestAssetInfo);
549
548
  if (this.assetMapPatch !== latestAssetPatch) {
550
- const assetRegistry = filterAssetInfoMap(this.getChainInfoMap(), {
551
- ..._chainList.ChainAssetMap,
552
- ...latestAssetInfo
553
- });
549
+ const assetRegistry = filterAssetInfoMap(this.getChainInfoMap(), Object.assign({}, this.dataMap.assetRegistry, latestAssetInfo));
554
550
  this.assetMapPatch = latestAssetPatch;
555
551
  this.dataMap.assetRegistry = assetRegistry;
556
552
  this.assetRegistrySubject.next(assetRegistry);
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ exports.openPopup = openPopup;
7
8
  var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
8
9
  var _constants = require("@subwallet/extension-base/services/setting-service/constants");
9
10
  var _utils = require("@subwallet/extension-base/utils");
@@ -25,6 +26,19 @@ const NORMAL_WINDOW_OPTS = {
25
26
  type: 'normal',
26
27
  url: NOTIFICATION_URL
27
28
  };
29
+ function openPopup(url) {
30
+ chrome.windows.getCurrent(win => {
31
+ const popupOptions = {
32
+ ...POPUP_WINDOW_OPTS,
33
+ url
34
+ };
35
+ if (win) {
36
+ popupOptions.left = (win.left || 0) + (win.width || 0) - (popupOptions.width || 0) - 20;
37
+ popupOptions.top = (win.top || 0) + 110;
38
+ }
39
+ chrome.windows.create(popupOptions).catch(console.error);
40
+ });
41
+ }
28
42
  class PopupHandler {
29
43
  #requestService;
30
44
  #notification = _constants.DEFAULT_NOTIFICATION_TYPE;
@@ -1,2 +1,4 @@
1
1
  export declare const LANGUAGE = "current-language";
2
2
  export declare const CURRENCY = "current-currency";
3
+ export declare const REMIND_EXPORT_ACCOUNT = "remind_export_account";
4
+ export declare const LATEST_SESSION = "general.latest-session";
@@ -2,4 +2,6 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export const LANGUAGE = 'current-language';
5
- export const CURRENCY = 'current-currency';
5
+ export const CURRENCY = 'current-currency';
6
+ export const REMIND_EXPORT_ACCOUNT = 'remind_export_account';
7
+ export const LATEST_SESSION = 'general.latest-session';
@@ -10,7 +10,7 @@ import { withErrorLog } from '@subwallet/extension-base/background/handlers/help
10
10
  import { createSubscription } from '@subwallet/extension-base/background/handlers/subscriptions';
11
11
  import { AccountExternalErrorCode, BasicTxErrorType, BasicTxWarningCode, CampaignDataType, ChainType, ExternalRequestPromiseStatus, ExtrinsicType, MantaPayEnableMessage, StakingTxErrorType, StakingType, TransferTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
12
12
  import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
13
- import { ALL_ACCOUNT_KEY, ALL_GENESIS_HASH, XCM_FEE_RATIO, XCM_MIN_AMOUNT_RATIO } from '@subwallet/extension-base/constants';
13
+ import { ALL_ACCOUNT_KEY, ALL_GENESIS_HASH, LATEST_SESSION, XCM_FEE_RATIO, XCM_MIN_AMOUNT_RATIO } from '@subwallet/extension-base/constants';
14
14
  import { ALLOWED_PATH } from '@subwallet/extension-base/defaults';
15
15
  import { resolveAzeroAddressToDomain, resolveAzeroDomainToAddress } from '@subwallet/extension-base/koni/api/dotsama/domain';
16
16
  import { parseSubstrateTransaction } from '@subwallet/extension-base/koni/api/dotsama/parseTransaction';
@@ -31,6 +31,7 @@ import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/reques
31
31
  import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
32
32
  import { WALLET_CONNECT_EIP155_NAMESPACE } from '@subwallet/extension-base/services/wallet-connect-service/constants';
33
33
  import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectNamespace } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
34
+ import { SWStorage } from '@subwallet/extension-base/storage';
34
35
  import { AccountsStore } from '@subwallet/extension-base/stores';
35
36
  import { YieldPoolType } from '@subwallet/extension-base/types';
36
37
  import { BN_ZERO, convertSubjectInfoToAddresses, createTransactionFromRLP, isSameAddress, reformatAddress, signatureToHex, uniqueStringArray } from '@subwallet/extension-base/utils';
@@ -84,11 +85,13 @@ export default class KoniExtension {
84
85
  this.#lockTimeOut = setTimeout(() => {
85
86
  if (!this.#skipAutoLock) {
86
87
  this.keyringLock();
88
+ updateLatestSession(Date.now());
87
89
  }
88
90
  }, this.#timeAutoLock * 60 * 1000);
89
91
  } else if (this.#alwaysLock) {
90
92
  if (!this.#firstTime) {
91
93
  this.keyringLock();
94
+ updateLatestSession(Date.now());
92
95
  }
93
96
  }
94
97
  }
@@ -96,6 +99,12 @@ export default class KoniExtension {
96
99
  this.#firstTime = false;
97
100
  }
98
101
  };
102
+ const updateLatestSession = time => {
103
+ SWStorage.instance.setItem(LATEST_SESSION, JSON.stringify({
104
+ remind: true,
105
+ timeCalculate: time
106
+ }));
107
+ };
99
108
  this.#koniState.settingService.getSettings(updateTimeAutoLock);
100
109
  this.#koniState.settingService.getSubject().subscribe({
101
110
  next: updateTimeAutoLock
@@ -220,6 +220,8 @@ export default class KoniState {
220
220
  evmSendTransaction(id: string, url: string, networkKey: string, allowedAccounts: string[], transactionParams: EvmSendTransactionParams): Promise<string | undefined>;
221
221
  getConfirmationsQueueSubject(): BehaviorSubject<ConfirmationsQueue>;
222
222
  completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
223
+ private onHandleRemindExportAccount;
224
+ onCheckToRemindUser(): void;
223
225
  onInstall(): void;
224
226
  get activeNetworks(): Record<string, _ChainInfo>;
225
227
  get activeChainSlugs(): string[];
@@ -5,7 +5,7 @@ import { EvmProviderError } from '@subwallet/extension-base/background/errors/Ev
5
5
  import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
6
6
  import { isSubscriptionRunning, unsubscribe } from '@subwallet/extension-base/background/handlers/subscriptions';
7
7
  import { APIItemState, BasicTxErrorType, ChainType, EvmProviderErrorType, ExternalRequestPromiseStatus, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
8
- import { ALL_ACCOUNT_KEY, ALL_GENESIS_HASH, MANTA_PAY_BALANCE_INTERVAL } from '@subwallet/extension-base/constants';
8
+ import { ALL_ACCOUNT_KEY, ALL_GENESIS_HASH, MANTA_PAY_BALANCE_INTERVAL, REMIND_EXPORT_ACCOUNT } from '@subwallet/extension-base/constants';
9
9
  import { BalanceService } from '@subwallet/extension-base/services/balance-service';
10
10
  import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
11
11
  import BuyService from '@subwallet/extension-base/services/buy-service';
@@ -24,6 +24,7 @@ import MintCampaignService from '@subwallet/extension-base/services/mint-campaig
24
24
  import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
25
25
  import { PriceService } from '@subwallet/extension-base/services/price-service';
26
26
  import RequestService from '@subwallet/extension-base/services/request-service';
27
+ import { openPopup } from '@subwallet/extension-base/services/request-service/handler/PopupHandler';
27
28
  import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
28
29
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
29
30
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
@@ -31,6 +32,7 @@ import { SUBSCAN_API_CHAIN_MAP } from '@subwallet/extension-base/services/subsca
31
32
  import { SwapService } from '@subwallet/extension-base/services/swap-service';
32
33
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
33
34
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
35
+ import { SWStorage } from '@subwallet/extension-base/storage';
34
36
  import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
35
37
  import { isAccountAll, stripUrl, TARGET_ENV, wait } from '@subwallet/extension-base/utils';
36
38
  import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
@@ -237,6 +239,7 @@ export default class KoniState {
237
239
  // TODO: consider moving this to a separate service
238
240
  await this.dbService.stores.crowdloan.removeEndedCrowdloans();
239
241
  await this.startSubscription();
242
+ this.chainService.checkLatestData();
240
243
  }
241
244
  async initMantaPay(password) {
242
245
  var _this$chainService, _this$chainService$ma;
@@ -1340,6 +1343,27 @@ export default class KoniState {
1340
1343
  async completeConfirmation(request) {
1341
1344
  return await this.requestService.completeConfirmation(request);
1342
1345
  }
1346
+ onHandleRemindExportAccount() {
1347
+ const remindStatus = SWStorage.instance.getItem(REMIND_EXPORT_ACCOUNT);
1348
+ if (!remindStatus || !remindStatus.includes('done')) {
1349
+ const handleRemind = account => {
1350
+ if (account.address !== '') {
1351
+ // Open remind tab
1352
+ const url = `${chrome.runtime.getURL('index.html')}#/remind-export-account`;
1353
+ openPopup(url);
1354
+ subscription.unsubscribe();
1355
+ } else {
1356
+ setTimeout(() => {
1357
+ subscription.unsubscribe();
1358
+ }, 3000);
1359
+ }
1360
+ };
1361
+ const subscription = this.keyringService.currentAccountSubject.subscribe(handleRemind);
1362
+ }
1363
+ }
1364
+ onCheckToRemindUser() {
1365
+ this.onHandleRemindExportAccount();
1366
+ }
1343
1367
  onInstall() {
1344
1368
  // const singleModes = Object.values(_PREDEFINED_SINGLE_MODES);
1345
1369
 
@@ -1553,6 +1577,7 @@ export default class KoniState {
1553
1577
  await this.walletConnectService.resetWallet(resetAll);
1554
1578
  await this.chainService.init();
1555
1579
  this.afterChainServiceInit();
1580
+ this.chainService.checkLatestData();
1556
1581
  }
1557
1582
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1558
1583
  var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.67-0",
20
+ "version": "1.1.68-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1885,11 +1885,11 @@
1885
1885
  "@reduxjs/toolkit": "^1.9.1",
1886
1886
  "@sora-substrate/type-definitions": "^1.17.7",
1887
1887
  "@substrate/connect": "^0.8.9",
1888
- "@subwallet/chain-list": "0.2.63",
1889
- "@subwallet/extension-base": "^1.1.67-0",
1890
- "@subwallet/extension-chains": "^1.1.67-0",
1891
- "@subwallet/extension-dapp": "^1.1.67-0",
1892
- "@subwallet/extension-inject": "^1.1.67-0",
1888
+ "@subwallet/chain-list": "0.2.64",
1889
+ "@subwallet/extension-base": "^1.1.68-0",
1890
+ "@subwallet/extension-chains": "^1.1.68-0",
1891
+ "@subwallet/extension-dapp": "^1.1.68-0",
1892
+ "@subwallet/extension-inject": "^1.1.68-0",
1893
1893
  "@subwallet/keyring": "^0.1.5",
1894
1894
  "@subwallet/ui-keyring": "^0.1.5",
1895
1895
  "@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.67-0'
10
+ version: '1.1.68-0'
11
11
  };
@@ -455,7 +455,6 @@ export class ChainService {
455
455
  await this.initAssetSettings();
456
456
  this.initAssetRefMap();
457
457
  await this.autoEnableTokens();
458
- this.checkLatestData();
459
458
  }
460
459
  initAssetRefMap() {
461
460
  this.dataMap.assetRefMap = AssetRefMap;
@@ -523,10 +522,7 @@ export class ChainService {
523
522
  if (latestAssetInfo) {
524
523
  const latestAssetPatch = JSON.stringify(latestAssetInfo);
525
524
  if (this.assetMapPatch !== latestAssetPatch) {
526
- const assetRegistry = filterAssetInfoMap(this.getChainInfoMap(), {
527
- ...ChainAssetMap,
528
- ...latestAssetInfo
529
- });
525
+ const assetRegistry = filterAssetInfoMap(this.getChainInfoMap(), Object.assign({}, this.dataMap.assetRegistry, latestAssetInfo));
530
526
  this.assetMapPatch = latestAssetPatch;
531
527
  this.dataMap.assetRegistry = assetRegistry;
532
528
  this.assetRegistrySubject.next(assetRegistry);
@@ -1,4 +1,5 @@
1
1
  import RequestService from '@subwallet/extension-base/services/request-service';
2
+ export declare function openPopup(url: string): void;
2
3
  export default class PopupHandler {
3
4
  #private;
4
5
  constructor(requestService: RequestService);
@@ -19,6 +19,19 @@ const NORMAL_WINDOW_OPTS = {
19
19
  type: 'normal',
20
20
  url: NOTIFICATION_URL
21
21
  };
22
+ export function openPopup(url) {
23
+ chrome.windows.getCurrent(win => {
24
+ const popupOptions = {
25
+ ...POPUP_WINDOW_OPTS,
26
+ url
27
+ };
28
+ if (win) {
29
+ popupOptions.left = (win.left || 0) + (win.width || 0) - (popupOptions.width || 0) - 20;
30
+ popupOptions.top = (win.top || 0) + 110;
31
+ }
32
+ chrome.windows.create(popupOptions).catch(console.error);
33
+ });
34
+ }
22
35
  export default class PopupHandler {
23
36
  #requestService;
24
37
  #notification = DEFAULT_NOTIFICATION_TYPE;