@subwallet/extension-base 1.1.50-0 → 1.1.51-1

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.
@@ -3270,20 +3270,16 @@ class KoniExtension {
3270
3270
  }
3271
3271
  async subscribeAssetRegistry(id, port) {
3272
3272
  const cb = (0, _subscriptions.createSubscription)(id, port);
3273
- let ready = false;
3273
+ await this.#koniState.eventService.waitAssetOnlineReady;
3274
3274
  const assetRegistrySubscription = this.#koniState.subscribeAssetRegistry().subscribe({
3275
3275
  next: rs => {
3276
- if (ready) {
3277
- cb(rs);
3278
- }
3276
+ cb(rs);
3279
3277
  }
3280
3278
  });
3281
3279
  this.createUnsubscriptionHandle(id, assetRegistrySubscription.unsubscribe);
3282
3280
  port.onDisconnect.addListener(() => {
3283
3281
  this.cancelSubscription(id);
3284
3282
  });
3285
- await this.#koniState.eventService.waitAssetReady;
3286
- ready = true;
3287
3283
  return this.#koniState.getAssetRegistry();
3288
3284
  }
3289
3285
  subscribeMultiChainAssetMap(id, port) {
@@ -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.50-0'
16
+ version: '1.1.51-1'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -520,39 +520,38 @@ class ChainService {
520
520
  }
521
521
  this.logger.log('Finished updating latest price IDs');
522
522
  }
523
- handleLatestAssetData(_latestAssetInfo, _latestAssetLogoMap) {
523
+ handleLatestAssetData(latestAssetInfo, latestAssetLogoMap) {
524
524
  try {
525
- let needUpdate = false;
526
- const latestAssetInfo = _latestAssetInfo || {};
527
- const latestAssetLogoMap = _latestAssetLogoMap || {};
528
- const latestAssetPatch = JSON.stringify(latestAssetInfo);
529
- const latestAssetLogoPatch = JSON.stringify(latestAssetLogoMap);
530
- if (this.assetMapPatch !== latestAssetPatch) {
531
- needUpdate = true;
532
- const assetRegistry = {
533
- ..._chainList.ChainAssetMap,
534
- ...latestAssetInfo
535
- };
536
- this.assetMapPatch = latestAssetPatch;
537
- this.dataMap.assetRegistry = assetRegistry;
538
- this.assetRegistrySubject.next(assetRegistry);
539
- }
540
- if (this.assetLogoPatch !== latestAssetLogoPatch) {
541
- const logoMap = {
542
- ..._chainList.AssetLogoMap,
543
- ...latestAssetLogoMap
544
- };
545
- this.assetLogoPatch = latestAssetLogoPatch;
546
- this.assetLogoMapSubject.next(logoMap);
525
+ if (latestAssetInfo) {
526
+ const latestAssetPatch = JSON.stringify(latestAssetInfo);
527
+ if (this.assetMapPatch !== latestAssetPatch) {
528
+ const assetRegistry = {
529
+ ..._chainList.ChainAssetMap,
530
+ ...latestAssetInfo
531
+ };
532
+ this.assetMapPatch = latestAssetPatch;
533
+ this.dataMap.assetRegistry = assetRegistry;
534
+ this.assetRegistrySubject.next(assetRegistry);
535
+ this.autoEnableTokens().then(() => {
536
+ this.eventService.emit('asset.updateState', '');
537
+ }).catch(console.error);
538
+ }
547
539
  }
548
- if (needUpdate) {
549
- this.autoEnableTokens().then(() => {
550
- this.eventService.emit('asset.updateState', '');
551
- }).catch(console.error);
540
+ if (latestAssetLogoMap) {
541
+ const latestAssetLogoPatch = JSON.stringify(latestAssetLogoMap);
542
+ if (this.assetLogoPatch !== latestAssetLogoPatch) {
543
+ const logoMap = {
544
+ ..._chainList.AssetLogoMap,
545
+ ...latestAssetLogoMap
546
+ };
547
+ this.assetLogoPatch = latestAssetLogoPatch;
548
+ this.assetLogoMapSubject.next(logoMap);
549
+ }
552
550
  }
553
551
  } catch (e) {
554
552
  console.error('Error fetching latest asset data');
555
553
  }
554
+ this.eventService.emit('asset.online.ready', true);
556
555
  this.logger.log('Finished updating latest asset');
557
556
  }
558
557
  async autoEnableTokens() {
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.fetchPatchData = fetchPatchData;
8
- var _packageInfo = require("@subwallet/chain-list/packageInfo");
9
8
  var _crossFetch = _interopRequireDefault(require("cross-fetch"));
10
9
  // Copyright 2019-2022 @subwallet/extension-base
11
10
  // SPDX-License-Identifier: Apache-2.0
@@ -13,9 +12,10 @@ var _crossFetch = _interopRequireDefault(require("cross-fetch"));
13
12
  const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
14
13
  const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
15
14
  const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
15
+ const ChainListVersion = '0.2.53';
16
16
  async function fetchPatchData(slug) {
17
17
  try {
18
- const fetchPromise = (0, _crossFetch.default)(`${fetchDomain}/patch/${_packageInfo.packageInfo.version}/${slug}`);
18
+ const fetchPromise = (0, _crossFetch.default)(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
19
19
  const timeout = new Promise(resolve => {
20
20
  const id = setTimeout(() => {
21
21
  clearTimeout(id);
@@ -29,6 +29,7 @@ class EventService extends _eventemitter.default {
29
29
  this.waitInjectReady = _utils.TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
30
30
  this.waitChainReady = this.generateWaitPromise('chain.ready');
31
31
  this.waitAssetReady = this.generateWaitPromise('asset.ready');
32
+ this.waitAssetOnlineReady = this.generateWaitPromise('asset.online.ready');
32
33
  this.waitMigrateReady = this.generateWaitPromise('migration.done');
33
34
  this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
34
35
  this.waitBuyTokenReady = this.generateWaitPromise('buy.tokens.ready');
@@ -3184,20 +3184,16 @@ export default class KoniExtension {
3184
3184
  }
3185
3185
  async subscribeAssetRegistry(id, port) {
3186
3186
  const cb = createSubscription(id, port);
3187
- let ready = false;
3187
+ await this.#koniState.eventService.waitAssetOnlineReady;
3188
3188
  const assetRegistrySubscription = this.#koniState.subscribeAssetRegistry().subscribe({
3189
3189
  next: rs => {
3190
- if (ready) {
3191
- cb(rs);
3192
- }
3190
+ cb(rs);
3193
3191
  }
3194
3192
  });
3195
3193
  this.createUnsubscriptionHandle(id, assetRegistrySubscription.unsubscribe);
3196
3194
  port.onDisconnect.addListener(() => {
3197
3195
  this.cancelSubscription(id);
3198
3196
  });
3199
- await this.#koniState.eventService.waitAssetReady;
3200
- ready = true;
3201
3197
  return this.#koniState.getAssetRegistry();
3202
3198
  }
3203
3199
  subscribeMultiChainAssetMap(id, port) {
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.50-0",
20
+ "version": "1.1.51-1",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1802,10 +1802,10 @@
1802
1802
  "@sora-substrate/type-definitions": "^1.17.7",
1803
1803
  "@substrate/connect": "^0.7.26",
1804
1804
  "@subwallet/chain-list": "0.2.53",
1805
- "@subwallet/extension-base": "^1.1.50-0",
1806
- "@subwallet/extension-chains": "^1.1.50-0",
1807
- "@subwallet/extension-dapp": "^1.1.50-0",
1808
- "@subwallet/extension-inject": "^1.1.50-0",
1805
+ "@subwallet/extension-base": "^1.1.51-1",
1806
+ "@subwallet/extension-chains": "^1.1.51-1",
1807
+ "@subwallet/extension-dapp": "^1.1.51-1",
1808
+ "@subwallet/extension-inject": "^1.1.51-1",
1809
1809
  "@subwallet/keyring": "^0.1.3",
1810
1810
  "@subwallet/ui-keyring": "^0.1.3",
1811
1811
  "@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.50-0'
10
+ version: '1.1.51-1'
11
11
  };
@@ -86,7 +86,7 @@ export declare class ChainService {
86
86
  handleLatestProviderData(latestChainInfo: _ChainInfo[]): void;
87
87
  handleLatestAssetRef(latestBlockedAssetRefList: string[], latestAssetRefMap: Record<string, _AssetRef> | null): void;
88
88
  handleLatestPriceId(latestPriceIds: Record<string, string | null>): void;
89
- handleLatestAssetData(_latestAssetInfo: Record<string, _ChainAsset> | null, _latestAssetLogoMap: Record<string, string> | null): void;
89
+ handleLatestAssetData(latestAssetInfo: Record<string, _ChainAsset> | null, latestAssetLogoMap: Record<string, string> | null): void;
90
90
  autoEnableTokens(): Promise<void>;
91
91
  handleLatestData(): void;
92
92
  private initApis;
@@ -503,39 +503,38 @@ export class ChainService {
503
503
  }
504
504
  this.logger.log('Finished updating latest price IDs');
505
505
  }
506
- handleLatestAssetData(_latestAssetInfo, _latestAssetLogoMap) {
506
+ handleLatestAssetData(latestAssetInfo, latestAssetLogoMap) {
507
507
  try {
508
- let needUpdate = false;
509
- const latestAssetInfo = _latestAssetInfo || {};
510
- const latestAssetLogoMap = _latestAssetLogoMap || {};
511
- const latestAssetPatch = JSON.stringify(latestAssetInfo);
512
- const latestAssetLogoPatch = JSON.stringify(latestAssetLogoMap);
513
- if (this.assetMapPatch !== latestAssetPatch) {
514
- needUpdate = true;
515
- const assetRegistry = {
516
- ...ChainAssetMap,
517
- ...latestAssetInfo
518
- };
519
- this.assetMapPatch = latestAssetPatch;
520
- this.dataMap.assetRegistry = assetRegistry;
521
- this.assetRegistrySubject.next(assetRegistry);
522
- }
523
- if (this.assetLogoPatch !== latestAssetLogoPatch) {
524
- const logoMap = {
525
- ...AssetLogoMap,
526
- ...latestAssetLogoMap
527
- };
528
- this.assetLogoPatch = latestAssetLogoPatch;
529
- this.assetLogoMapSubject.next(logoMap);
508
+ if (latestAssetInfo) {
509
+ const latestAssetPatch = JSON.stringify(latestAssetInfo);
510
+ if (this.assetMapPatch !== latestAssetPatch) {
511
+ const assetRegistry = {
512
+ ...ChainAssetMap,
513
+ ...latestAssetInfo
514
+ };
515
+ this.assetMapPatch = latestAssetPatch;
516
+ this.dataMap.assetRegistry = assetRegistry;
517
+ this.assetRegistrySubject.next(assetRegistry);
518
+ this.autoEnableTokens().then(() => {
519
+ this.eventService.emit('asset.updateState', '');
520
+ }).catch(console.error);
521
+ }
530
522
  }
531
- if (needUpdate) {
532
- this.autoEnableTokens().then(() => {
533
- this.eventService.emit('asset.updateState', '');
534
- }).catch(console.error);
523
+ if (latestAssetLogoMap) {
524
+ const latestAssetLogoPatch = JSON.stringify(latestAssetLogoMap);
525
+ if (this.assetLogoPatch !== latestAssetLogoPatch) {
526
+ const logoMap = {
527
+ ...AssetLogoMap,
528
+ ...latestAssetLogoMap
529
+ };
530
+ this.assetLogoPatch = latestAssetLogoPatch;
531
+ this.assetLogoMapSubject.next(logoMap);
532
+ }
535
533
  }
536
534
  } catch (e) {
537
535
  console.error('Error fetching latest asset data');
538
536
  }
537
+ this.eventService.emit('asset.online.ready', true);
539
538
  this.logger.log('Finished updating latest asset');
540
539
  }
541
540
  async autoEnableTokens() {
@@ -1,14 +1,14 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { packageInfo as chainListInfo } from '@subwallet/chain-list/packageInfo';
5
4
  import fetch from 'cross-fetch';
6
5
  const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
7
6
  const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
8
7
  const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
8
+ const ChainListVersion = '0.2.53';
9
9
  export async function fetchPatchData(slug) {
10
10
  try {
11
- const fetchPromise = fetch(`${fetchDomain}/patch/${chainListInfo.version}/${slug}`);
11
+ const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
12
12
  const timeout = new Promise(resolve => {
13
13
  const id = setTimeout(() => {
14
14
  clearTimeout(id);
@@ -11,6 +11,7 @@ export declare class EventService extends EventEmitter<EventRegistry> {
11
11
  readonly waitInjectReady: Promise<boolean>;
12
12
  readonly waitChainReady: Promise<boolean>;
13
13
  readonly waitAssetReady: Promise<boolean>;
14
+ readonly waitAssetOnlineReady: Promise<boolean>;
14
15
  readonly waitMigrateReady: Promise<boolean>;
15
16
  readonly waitCampaignReady: Promise<boolean>;
16
17
  readonly waitBuyTokenReady: Promise<boolean>;
@@ -22,6 +22,7 @@ export class EventService extends EventEmitter {
22
22
  this.waitInjectReady = TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
23
23
  this.waitChainReady = this.generateWaitPromise('chain.ready');
24
24
  this.waitAssetReady = this.generateWaitPromise('asset.ready');
25
+ this.waitAssetOnlineReady = this.generateWaitPromise('asset.online.ready');
25
26
  this.waitMigrateReady = this.generateWaitPromise('migration.done');
26
27
  this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
27
28
  this.waitBuyTokenReady = this.generateWaitPromise('buy.tokens.ready');
@@ -23,6 +23,7 @@ export interface EventRegistry {
23
23
  'chain.add': [string];
24
24
  'chain.updateState': [string];
25
25
  'asset.ready': [boolean];
26
+ 'asset.online.ready': [boolean];
26
27
  'asset.updateState': [string];
27
28
  'transaction.done': [SWTransaction];
28
29
  'transaction.failed': [SWTransaction | undefined];