parent
9bfa04a712
commit
7f00e3de9c
@ -0,0 +1,16 @@
|
||||
<div fxLayout="row" fxLayoutAlign="start center" class="page-title-container">
|
||||
<fa-icon [icon]="faHandshake" class="page-title-img mr-1"></fa-icon>
|
||||
<span class="page-title">Peerswap</span>
|
||||
</div>
|
||||
<div fxLayout="column" class="padding-gap-x">
|
||||
<mat-card>
|
||||
<mat-card-content fxLayout="column">
|
||||
<nav mat-tab-nav-bar>
|
||||
<div role="tab" mat-tab-link *ngFor="let link of links" class="mat-tab-label" [active]="activeTab.link === link.link" (click)="activeTab = link" routerLink="{{link.link}}">{{link.name}}</div>
|
||||
</nav>
|
||||
<div fxLayout="column" fxFlex="100" fxLayoutAlign="space-between stretch" class="mat-tab-body-wrapper mb-2">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</div>
|
@ -0,0 +1,52 @@
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { StoreModule } from '@ngrx/store';
|
||||
|
||||
import { RootReducer } from '../../../../store/rtl.reducers';
|
||||
import { LNDReducer } from '../../../../lnd/store/lnd.reducers';
|
||||
import { CLNReducer } from '../../../../cln/store/cln.reducers';
|
||||
import { ECLReducer } from '../../../../eclair/store/ecl.reducers';
|
||||
import { LoopService } from '../../../services/loop.service';
|
||||
|
||||
import { PeerswapComponent } from './peerswap.component';
|
||||
import { SharedModule } from '../../../shared.module';
|
||||
import { mockDataService } from '../../../test-helpers/mock-services';
|
||||
import { CommonService } from '../../../services/common.service';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { DataService } from '../../../services/data.service';
|
||||
|
||||
describe('PeerswapComponent', () => {
|
||||
let component: PeerswapComponent;
|
||||
let fixture: ComponentFixture<PeerswapComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PeerswapComponent],
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
SharedModule,
|
||||
RouterTestingModule,
|
||||
StoreModule.forRoot({ root: RootReducer, lnd: LNDReducer, cln: CLNReducer, ecl: ECLReducer })
|
||||
],
|
||||
providers: [
|
||||
CommonService,
|
||||
{ provide: DataService, useClass: mockDataService }
|
||||
]
|
||||
}).
|
||||
compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PeerswapComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
});
|
@ -0,0 +1,41 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router, ResolveEnd, Event } from '@angular/router';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil, filter } from 'rxjs/operators';
|
||||
import { faHandshake } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-peerswap',
|
||||
templateUrl: './peerswap.component.html',
|
||||
styleUrls: ['./peerswap.component.scss']
|
||||
})
|
||||
export class PeerswapComponent implements OnInit, OnDestroy {
|
||||
|
||||
public faHandshake = faHandshake;
|
||||
public links = [{ link: 'peers', name: 'Peers' }, { link: 'psout', name: 'Peerswap Out' }, { link: 'psin', name: 'Peerswap In' }, { link: 'pscancelled', name: 'Cancelled Peerswaps' }];
|
||||
public activeTab = this.links[0];
|
||||
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor(private router: Router) { }
|
||||
|
||||
ngOnInit() {
|
||||
const linkFound = this.links.find((link) => this.router.url.includes(link.link));
|
||||
this.activeTab = linkFound ? linkFound : this.links[0];
|
||||
this.router.events.pipe(takeUntil(this.unSubs[0]), filter((e) => e instanceof ResolveEnd)).
|
||||
subscribe({
|
||||
next: (value: ResolveEnd | Event) => {
|
||||
const linkFound = this.links.find((link) => (<ResolveEnd>value).urlAfterRedirects.includes(link.link));
|
||||
this.activeTab = linkFound ? linkFound : this.links[0];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unSubs.forEach((completeSub) => {
|
||||
completeSub.next(<any>null);
|
||||
completeSub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
<h1>Swap Peers</h1>
|
@ -0,0 +1,35 @@
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SharedModule } from '../../../../shared.module';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { SwapPeersComponent } from './swap-peers.component';
|
||||
|
||||
describe('SwapPeersComponent', () => {
|
||||
let component: SwapPeersComponent;
|
||||
let fixture: ComponentFixture<SwapPeersComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SwapPeersComponent],
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
SharedModule
|
||||
],
|
||||
providers: []
|
||||
}).
|
||||
compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SwapPeersComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-peerswap-peers',
|
||||
templateUrl: './swap-peers.component.html',
|
||||
styleUrls: ['./swap-peers.component.scss']
|
||||
})
|
||||
export class SwapPeersComponent implements OnInit, OnDestroy {
|
||||
|
||||
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unSubs.forEach((completeSub) => {
|
||||
completeSub.next(<any>null);
|
||||
completeSub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
<h1>Peerswaps Cancelled</h1>
|
@ -0,0 +1,35 @@
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SharedModule } from '../../../../shared.module';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { PeerswapsCancelledComponent } from './swaps-cancelled.component';
|
||||
|
||||
describe('PeerswapsCancelledComponent', () => {
|
||||
let component: PeerswapsCancelledComponent;
|
||||
let fixture: ComponentFixture<PeerswapsCancelledComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PeerswapsCancelledComponent],
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
SharedModule
|
||||
],
|
||||
providers: []
|
||||
}).
|
||||
compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PeerswapsCancelledComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-peerswap-cancelled',
|
||||
templateUrl: './swaps-cancelled.component.html',
|
||||
styleUrls: ['./swaps-cancelled.component.scss']
|
||||
})
|
||||
export class PeerswapsCancelledComponent implements OnInit, OnDestroy {
|
||||
|
||||
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unSubs.forEach((completeSub) => {
|
||||
completeSub.next(<any>null);
|
||||
completeSub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
<h1>Peerswaps In</h1>
|
@ -0,0 +1,35 @@
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SharedModule } from '../../../../shared.module';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { PeerswapsInComponent } from './swaps-in.component';
|
||||
|
||||
describe('PeerswapsInComponent', () => {
|
||||
let component: PeerswapsInComponent;
|
||||
let fixture: ComponentFixture<PeerswapsInComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PeerswapsInComponent],
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
SharedModule
|
||||
],
|
||||
providers: []
|
||||
}).
|
||||
compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PeerswapsInComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-peer-swaps-in',
|
||||
templateUrl: './swaps-in.component.html',
|
||||
styleUrls: ['./swaps-in.component.scss'],
|
||||
})
|
||||
export class PeerswapsInComponent implements OnInit, OnDestroy {
|
||||
|
||||
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unSubs.forEach((completeSub) => {
|
||||
completeSub.next(<any>null);
|
||||
completeSub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
<h1>Peerswaps Out</h1>
|
@ -0,0 +1,35 @@
|
||||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { SharedModule } from '../../../../shared.module';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { PeerswapsOutComponent } from './swaps-out.component';
|
||||
|
||||
describe('PeerswapsOutComponent', () => {
|
||||
let component: PeerswapsOutComponent;
|
||||
let fixture: ComponentFixture<PeerswapsOutComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PeerswapsOutComponent],
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
SharedModule
|
||||
],
|
||||
providers: []
|
||||
}).
|
||||
compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PeerswapsOutComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
});
|
@ -0,0 +1,25 @@
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-peer-swaps-out',
|
||||
templateUrl: './swaps-out.component.html',
|
||||
styleUrls: ['./swaps-out.component.scss'],
|
||||
})
|
||||
export class PeerswapsOutComponent implements OnInit, OnDestroy {
|
||||
|
||||
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
|
||||
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unSubs.forEach((completeSub) => {
|
||||
completeSub.next(<any>null);
|
||||
completeSub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<div [perfectScrollbar] fxLayout="column" fxFlex="100">
|
||||
<div fxFlex="100" class="alert alert-info mt-1">
|
||||
<fa-icon [icon]="faInfoCircle" class="mr-1 alert-icon"></fa-icon>
|
||||
<span>Please ensure that <strong>peerswapd</strong> is running and accessible to RTL before enabling this service. Click <strong><a href="https://github.com/ElementsProject/peerswap" target="_blank">here</a></strong> to learn more about Core Lightning peerswap.</span>
|
||||
</div>
|
||||
<form fxLayout="column" fxFlex="100" fxLayoutAlign="start stretch" class="settings-container page-sub-title-container mt-1" #form="ngForm">
|
||||
<div fxLayout="column" fxFlex="50" fxLayoutAlign="start stretch">
|
||||
<mat-slide-toggle autoFocus class="mb-1" tabindex="1" color="primary" [(ngModel)]="enablePeerswap" name="peerswap">Enable Peerswap Service</mat-slide-toggle>
|
||||
</div>
|
||||
</form>
|
||||
<div fxLayout="row" class="mt-2">
|
||||
<!-- <button class="mr-1" mat-stroked-button color="primary" type="reset" (click)="onReset()" tabindex="4">Reset</button> -->
|
||||
<button mat-flat-button color="primary" type="submit" (click)="onUpdateService()" tabindex="5">Update</button>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,3 @@
|
||||
h4 {
|
||||
word-break: break-word;
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { ServicesEnum, UI_MESSAGES } from '../../../../services/consts-enums-functions';
|
||||
import { ConfigSettingsNode } from '../../../../models/RTLconfig';
|
||||
import { LoggerService } from '../../../../services/logger.service';
|
||||
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
|
||||
import { updateServiceSettings } from '../../../../../store/rtl.actions';
|
||||
import { RTLState } from '../../../../../store/rtl.state';
|
||||
import { setChildNodeSettingsLND } from '../../../../../lnd/store/lnd.actions';
|
||||
import { setChildNodeSettingsCL } from '../../../../../cln/store/cln.actions';
|
||||
import { setChildNodeSettingsECL } from '../../../../../eclair/store/ecl.actions';
|
||||
import { rootSelectedNode } from '../../../../../store/rtl.selector';
|
||||
|
||||
@Component({
|
||||
selector: 'rtl-peerswap-service-settings',
|
||||
templateUrl: './peerswap-service-settings.component.html',
|
||||
styleUrls: ['./peerswap-service-settings.component.scss']
|
||||
})
|
||||
export class PeerswapServiceSettingsComponent implements OnInit, OnDestroy {
|
||||
|
||||
public faInfoCircle = faInfoCircle;
|
||||
public selNode: ConfigSettingsNode | any;
|
||||
public enablePeerswap = false;
|
||||
unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
|
||||
|
||||
constructor(private logger: LoggerService, private store: Store<RTLState>) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.store.select(rootSelectedNode).
|
||||
pipe(takeUntil(this.unSubs[0])).
|
||||
subscribe((selNode) => {
|
||||
this.selNode = selNode;
|
||||
this.enablePeerswap = !!selNode?.settings.enablePeerswap;
|
||||
this.logger.info(selNode);
|
||||
});
|
||||
}
|
||||
|
||||
onUpdateService(): boolean | void {
|
||||
this.store.dispatch(updateServiceSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_PEERSWAP_SETTINGS, service: ServicesEnum.PEERSWAP, settings: { enablePeerswap: this.enablePeerswap } } }));
|
||||
this.store.dispatch(setChildNodeSettingsLND({
|
||||
payload: {
|
||||
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
|
||||
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers, enablePeerswap: this.selNode.settings.enablePeerswap
|
||||
}
|
||||
}));
|
||||
this.store.dispatch(setChildNodeSettingsCL({
|
||||
payload: {
|
||||
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
|
||||
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers, enablePeerswap: this.selNode.settings.enablePeerswap
|
||||
}
|
||||
}));
|
||||
this.store.dispatch(setChildNodeSettingsECL({
|
||||
payload: {
|
||||
userPersona: this.selNode.settings.userPersona, channelBackupPath: this.selNode.settings.channelBackupPath, selCurrencyUnit: this.selNode.settings.currencyUnit, currencyUnits: this.selNode.settings.currencyUnits, fiatConversion: this.selNode.settings.fiatConversion,
|
||||
lnImplementation: this.selNode.lnImplementation, swapServerUrl: this.selNode.settings.swapServerUrl, boltzServerUrl: this.selNode.settings.boltzServerUrl, enableOffers: this.selNode.settings.enableOffers, enablePeerswap: this.selNode.settings.enablePeerswap
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.unSubs.forEach((unsub) => {
|
||||
unsub.next();
|
||||
unsub.complete();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue