From ea04ea00489f8c8f320cf8b4456550d55c4cbc2d Mon Sep 17 00:00:00 2001 From: softsimon Date: Fri, 28 Jun 2024 11:28:41 +0900 Subject: [PATCH] Docs root network support --- frontend/src/app/docs/api-docs/api-docs.component.ts | 6 +++++- .../src/app/docs/code-template/code-template.component.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/docs/api-docs/api-docs.component.ts b/frontend/src/app/docs/api-docs/api-docs.component.ts index 76d9de8d0..b655b3969 100644 --- a/frontend/src/app/docs/api-docs/api-docs.component.ts +++ b/frontend/src/app/docs/api-docs/api-docs.component.ts @@ -72,7 +72,7 @@ export class ApiDocsComponent implements OnInit, AfterViewInit { this.auditEnabled = this.env.AUDIT; this.network$ = merge(of(''), this.stateService.networkChanged$).pipe( tap((network: string) => { - if (this.env.BASE_MODULE === 'mempool' && network !== '') { + if (this.env.BASE_MODULE === 'mempool' && network !== '' && this.env.ROOT_NETWORK === '') { this.baseNetworkUrl = `/${network}`; } else if (this.env.BASE_MODULE === 'liquid') { if (!['', 'liquid'].includes(network)) { @@ -195,6 +195,10 @@ export class ApiDocsComponent implements OnInit, AfterViewInit { } } + if (network === this.env.ROOT_NETWORK) { + curlNetwork = ''; + } + let text = code.codeTemplate.curl; for (let index = 0; index < curlResponse.length; index++) { const curlText = curlResponse[index]; diff --git a/frontend/src/app/docs/code-template/code-template.component.ts b/frontend/src/app/docs/code-template/code-template.component.ts index bd03f5b16..b31def01c 100644 --- a/frontend/src/app/docs/code-template/code-template.component.ts +++ b/frontend/src/app/docs/code-template/code-template.component.ts @@ -284,7 +284,7 @@ yarn add @mempool/liquid.js`; const headersString = code.headers ? ` -H "${code.headers}"` : ``; if (this.env.BASE_MODULE === 'mempool') { - if (this.network === 'main' || this.network === '') { + if (this.network === 'main' || this.network === '' || this.network === this.env.ROOT_NETWORK) { if (this.method === 'POST') { return `curl${headersString} -X POST -sSLd "${text}"`; } @@ -296,7 +296,7 @@ yarn add @mempool/liquid.js`; return `curl${headersString} -sSL "${this.hostname}/${this.network}${text}"`; } else if (this.env.BASE_MODULE === 'liquid') { if (this.method === 'POST') { - if (this.network !== 'liquid') { + if (this.network !== 'liquid' || this.network === this.env.ROOT_NETWORK) { text = text.replace('/api', `/${this.network}/api`); } return `curl${headersString} -X POST -sSLd "${text}"`;