diff --git a/frontend/.gitignore b/frontend/.gitignore index 98a344c6f..64b7777ea 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -50,6 +50,8 @@ Thumbs.db src/resources/assets.json src/resources/assets.minimal.json +src/resources/assets-testnet.json +src/resources/assets-testnet.minimal.json src/resources/pools.json # environment config diff --git a/frontend/src/app/services/assets.service.ts b/frontend/src/app/services/assets.service.ts index 4f35532a9..8331ab7d1 100644 --- a/frontend/src/app/services/assets.service.ts +++ b/frontend/src/app/services/assets.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { shareReplay } from 'rxjs/operators'; +import { shareReplay, switchMap } from 'rxjs/operators'; import { StateService } from './state.service'; @Injectable({ @@ -21,8 +21,16 @@ export class AssetsService { apiBaseUrl = this.stateService.env.NGINX_PROTOCOL + '://' + this.stateService.env.NGINX_HOSTNAME + ':' + this.stateService.env.NGINX_PORT; } - this.getAssetsJson$ = this.httpClient.get(apiBaseUrl + '/resources/assets.json').pipe(shareReplay()); - this.getAssetsMinimalJson$ = this.httpClient.get(apiBaseUrl + '/resources/assets.minimal.json').pipe(shareReplay()); - this.getMiningPools$ = this.httpClient.get(apiBaseUrl + '/resources/pools.json').pipe(shareReplay()); + this.getAssetsJson$ = this.stateService.networkChanged$ + .pipe( + switchMap(() => this.httpClient.get(`${apiBaseUrl}/resources/assets${this.stateService.network === 'liquidtestnet' ? '-testnet' : ''}.json`)), + shareReplay(1), + ); + this.getAssetsMinimalJson$ = this.stateService.networkChanged$ + .pipe( + switchMap(() => this.httpClient.get(`${apiBaseUrl}/resources/assets${this.stateService.network === 'liquidtestnet' ? '-testnet' : ''}.minimal.json`)), + shareReplay(1), + ); + this.getMiningPools$ = this.httpClient.get(apiBaseUrl + '/resources/pools.json').pipe(shareReplay(1)); } } diff --git a/frontend/sync-assets.js b/frontend/sync-assets.js index 36fb623fd..b1dc4090d 100644 --- a/frontend/sync-assets.js +++ b/frontend/sync-assets.js @@ -42,9 +42,17 @@ if (configContent.BASE_MODULE && configContent.BASE_MODULE === 'liquid') { assetsMinimalJsonUrl = 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.minimal.json'; } +const testnetAssetsJsonUrl = 'https://raw.githubusercontent.com/Blockstream/asset_registry_testnet_db/master/index.json'; +const testnetAssetsMinimalJsonUrl = 'https://raw.githubusercontent.com/Blockstream/asset_registry_testnet_db/master/index.minimal.json'; + console.log('Downloading assets'); download(PATH + 'assets.json', assetsJsonUrl); console.log('Downloading assets minimal'); download(PATH + 'assets.minimal.json', assetsMinimalJsonUrl); console.log('Downloading mining pools info'); download(PATH + 'pools.json', poolsJsonUrl); +console.log('Downloading testnet assets'); +download(PATH + 'assets-testnet.json', testnetAssetsJsonUrl); +console.log('Downloading testnet assets minimal'); +download(PATH + 'assets-testnet.minimal.json', testnetAssetsMinimalJsonUrl); +