Merge branch 'master' into block-audit-feature

This commit is contained in:
wiz 2022-10-31 14:46:05 +09:00 committed by GitHub
commit 45273f9309
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 6 deletions

View file

@ -106,6 +106,20 @@
</div> </div>
</div> </div>
<div id="electrs" *ngIf="whichTab === 'electrs'">
<div class="doc-content no-sidebar">
<div class="doc-item-container">
<p class='subtitle'>Hostname</p>
<p>{{plainHostname}}</p>
<p class="subtitle">Port</p>
<p>{{electrsPort}}</p>
<p class="subtitle">SSL</p>
<p>Enabled</p>
<p class="note" *ngIf="network.val !== 'signet'">Electrum RPC interface for Bitcoin Signet is <a href="/signet/docs/api/electrs">publicly available</a>. Electrum RPC interface for all other networks is available to <a href='/enterprise'>sponsors</a> only—whitelisting is required.</p>
</div>
</div>
</div>
</div> </div>
</ng-container> </ng-container>

View file

@ -1,7 +1,21 @@
.center {
text-align: center;
}
.note {
font-style: italic;
}
.text-small { .text-small {
font-size: 12px; font-size: 12px;
} }
.container-xl {
display: flex;
min-height: 75vh;
flex-direction: column;
}
code { code {
background-color: #1d1f31; background-color: #1d1f31;
font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New; font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New;
@ -116,6 +130,10 @@ li.nav-item {
float: right; float: right;
} }
.doc-content.no-sidebar {
width: 100%
}
h3 { h3 {
margin: 2rem 0 0 0; margin: 2rem 0 0 0;
} }

View file

@ -12,6 +12,8 @@ import { FaqTemplateDirective } from '../faq-template/faq-template.component';
styleUrls: ['./api-docs.component.scss'] styleUrls: ['./api-docs.component.scss']
}) })
export class ApiDocsComponent implements OnInit, AfterViewInit { export class ApiDocsComponent implements OnInit, AfterViewInit {
plainHostname = document.location.hostname;
electrsPort = 0;
hostname = document.location.hostname; hostname = document.location.hostname;
network$: Observable<string>; network$: Observable<string>;
active = 0; active = 0;
@ -82,6 +84,20 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
this.network$.subscribe((network) => { this.network$.subscribe((network) => {
this.active = (network === 'liquid' || network === 'liquidtestnet') ? 2 : 0; this.active = (network === 'liquid' || network === 'liquidtestnet') ? 2 : 0;
switch( network ) {
case "":
this.electrsPort = 50002; break;
case "mainnet":
this.electrsPort = 50002; break;
case "testnet":
this.electrsPort = 60002; break;
case "signet":
this.electrsPort = 60602; break;
case "liquid":
this.electrsPort = 51002; break;
case "liquidtestnet":
this.electrsPort = 51302; break;
}
}); });
} }

View file

@ -32,6 +32,15 @@
</ng-template> </ng-template>
</li> </li>
<li [ngbNavItem]="3" *ngIf="showElectrsTab" role="presentation">
<a ngbNavLink [routerLink]="['/docs/api/electrs' | relativeUrl]" role="tab">API - Electrum RPC</a>
<ng-template ngbNavContent>
<app-api-docs [whichTab]="'electrs'"></app-api-docs>
</ng-template>
</li>
</ul> </ul>
<div id="main-tab-content" [ngbNavOutlet]="nav"></div> <div id="main-tab-content" [ngbNavOutlet]="nav"></div>

View file

@ -15,6 +15,7 @@ export class DocsComponent implements OnInit {
env: Env; env: Env;
showWebSocketTab = true; showWebSocketTab = true;
showFaqTab = true; showFaqTab = true;
showElectrsTab = true;
@HostBinding('attr.dir') dir = 'ltr'; @HostBinding('attr.dir') dir = 'ltr';
@ -34,14 +35,18 @@ export class DocsComponent implements OnInit {
} else if( url[1].path === "rest" ) { } else if( url[1].path === "rest" ) {
this.activeTab = 1; this.activeTab = 1;
this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`); this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`);
} else { } else if( url[1].path === "websocket" ) {
this.activeTab = 2; this.activeTab = 2;
this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`); this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`);
} else {
this.activeTab = 3;
this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`);
} }
this.env = this.stateService.env; this.env = this.stateService.env;
this.showWebSocketTab = ( ! ( ( this.stateService.network === "bisq" ) || ( this.stateService.network === "liquidtestnet" ) ) ); this.showWebSocketTab = ( ! ( ( this.stateService.network === "bisq" ) || ( this.stateService.network === "liquidtestnet" ) ) );
this.showFaqTab = ( this.env.BASE_MODULE === 'mempool' ) ? true : false; this.showFaqTab = ( this.env.BASE_MODULE === 'mempool' ) ? true : false;
this.showElectrsTab = this.stateService.env.OFFICIAL_MEMPOOL_SPACE && ( this.stateService.network !== "bisq" );
document.querySelector<HTMLElement>( "html" ).style.scrollBehavior = "smooth"; document.querySelector<HTMLElement>( "html" ).style.scrollBehavior = "smooth";
} }

View file

@ -62,15 +62,15 @@ export const languages = languageDict;
// expects path to start with a leading '/' // expects path to start with a leading '/'
export function parseLanguageUrl(path) { export function parseLanguageUrl(path) {
const parts = path.split('/'); const parts = path.split('/').filter(part => part.length);
let lang; let lang;
let rest; let rest;
if (languages[parts[1]]) { if (languages[parts[0]]) {
lang = parts[1]; lang = parts[0];
rest = '/' + parts.slice(2).join('/'); rest = '/' + parts.slice(1).join('/');
} else { } else {
lang = null; lang = null;
rest = path; rest = '/' + parts.join('/');
} }
if (lang === 'en') { if (lang === 'en') {
lang = null; lang = null;