Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions frontend/src/app/core/services/web-node.service.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, filter, from, fromEvent, map, merge, Observable, of, switchMap, tap } from 'rxjs';
import base from 'base-x';
import { any, log } from '@openmina/shared';
import { any } from '@openmina/shared';
import { HttpClient } from '@angular/common/http';

@Injectable({
providedIn: 'root',
})
export class WebNodeService {

private readonly backendSubject$: BehaviorSubject<any> = new BehaviorSubject<any>(null);
private backend: any;
private readonly webnode$: BehaviorSubject<any> = new BehaviorSubject<any>(null);
private webNodeKeyPair: { publicKey: string, privateKey: string };

constructor(private http: HttpClient) {
Expand Down Expand Up @@ -42,79 +41,74 @@ export class WebNodeService {
console.log(wasm);
return from(wasm.run(this.webNodeKeyPair.privateKey));
}),
tap((jsHandle: any) => {
this.backend = jsHandle;
tap((webnode: any) => {
console.log('----------------WEBNODE----------------');
console.log(jsHandle);
this.backendSubject$.next(jsHandle);
console.log(webnode);
this.webnode$.next(webnode);
}),
switchMap(() => this.backendSubject$.asObservable()),
switchMap(() => this.webnode$.asObservable()),
filter(Boolean),
);
}

get webNodeKeys(): { publicKey: string, privateKey: string } {
return this.webNodeKeyPair;
}

get status$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).status())),
);
}

get blockProducerStats$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).stats().block_producer())),
);
}

get peers$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from(any(handle).state().peers())),
);
}

get messageProgress$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).state().message_progress())),
);
}

get sync$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).stats().sync())),
);
}

get accounts$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).ledger().latest().accounts().all())),
);
}

get bestChainUserCommands$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).transition_frontier().best_chain().user_commands())),
);
}

sendPayment$(payment: any): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).transaction_pool().inject().payment(payment))),
);
}

get transactionPool$(): Observable<any> {
return this.backendSubject$.asObservable().pipe(
return this.webnode$.asObservable().pipe(
filter(Boolean),
switchMap(handle => from((handle as any).transaction_pool().get())),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { Injectable } from '@angular/core';
import { MinaState, selectMinaState } from '@app/app.setup';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Effect } from '@openmina/shared';
import { forkJoin, map, switchMap } from 'rxjs';
import { EMPTY, forkJoin, map, switchMap } from 'rxjs';
import { Store } from '@ngrx/store';
import {
BENCHMARKS_WALLETS_CLOSE,
BENCHMARKS_WALLETS_GET_ALL_TXS,
BENCHMARKS_WALLETS_GET_ALL_TXS_SUCCESS,
BENCHMARKS_WALLETS_GET_WALLETS,
BENCHMARKS_WALLETS_GET_WALLETS_SUCCESS,
BENCHMARKS_WALLETS_SEND_TX_SUCCESS,
BENCHMARKS_WALLETS_SEND_TXS, BENCHMARKS_WALLETS_SEND_ZKAPPS, BENCHMARKS_WALLETS_SEND_ZKAPPS_SUCCESS,
BenchmarksWalletsActions,
BenchmarksWalletsActions, BenchmarksWalletsClose,
BenchmarksWalletsGetWallets,
BenchmarksWalletsSendTxs,
} from '@benchmarks/wallets/benchmarks-wallets.actions';
Expand All @@ -38,22 +39,23 @@ export class BenchmarksWalletsEffects extends MinaRustBaseEffect<BenchmarksWalle
private zkService: BenchmarksWalletsZkService,
private mempoolService: MempoolService,
store: Store<MinaState>) {

super(store, selectMinaState);

this.getWallets$ = createEffect(() => this.actions$.pipe(
ofType(BENCHMARKS_WALLETS_GET_WALLETS),
this.latestActionState<BenchmarksWalletsGetWallets>(),
switchMap(({ action }) => this.benchmarksService.getAccounts().pipe(
switchMap(payload => {
const actions = [];
if (action.payload?.initialRequest) {
actions.push({ type: BENCHMARKS_WALLETS_GET_ALL_TXS });
}
actions.push({ type: BENCHMARKS_WALLETS_GET_WALLETS_SUCCESS, payload });
return actions;
}),
)),
ofType(BENCHMARKS_WALLETS_GET_WALLETS, BENCHMARKS_WALLETS_CLOSE),
this.latestActionState<BenchmarksWalletsGetWallets | BenchmarksWalletsClose>(),
switchMap(({ action }) => action.type === BENCHMARKS_WALLETS_CLOSE
? EMPTY
: this.benchmarksService.getAccounts().pipe(
switchMap(payload => {
const actions = [];
if (action.payload?.initialRequest) {
actions.push({ type: BENCHMARKS_WALLETS_GET_ALL_TXS });
}
actions.push({ type: BENCHMARKS_WALLETS_GET_WALLETS_SUCCESS, payload });
return actions;
}),
)),
catchErrorAndRepeat(MinaErrorType.GENERIC, BENCHMARKS_WALLETS_GET_WALLETS_SUCCESS, []),
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4035,7 +4035,7 @@ export class BenchmarksWalletsService {
}

getAccounts(): Observable<Pick<BenchmarksWallet, 'publicKey' | 'privateKey' | 'minaTokens' | 'nonce'>[]> {
return this.rust.get<any[]>('/accounts').pipe(
return this.rust.get<AccountsResponse[]>('/accounts').pipe(
map(wallets => wallets.map(wallet => {
return ({
privateKey: WALLETS.find(w => w.publicKey === wallet.public_key)?.privateKey,
Expand Down Expand Up @@ -4140,3 +4140,9 @@ export class BenchmarksWalletsService {
});
}
}

export interface AccountsResponse {
public_key: string;
nonce: number;
balance: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
</ng-container>
<div class="node-status fx-row-vert-cent bg-surface h-sm border-rad-6 p-relative z-1 mr-10"
[class.can-add-nodes]="canAddNodes">
[class.can-add-nodes]="switchForbidden">
<ng-container *ngIf="!switchForbidden && !hideNodeStats">
<div class="shine-parent overflow-hidden p-absolute z-0 border-rad-6">
<div *ngIf="details.status === AppNodeStatus.CATCHUP || details.status === AppNodeStatus.BOOTSTRAP"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
}
}

.chip::before {
border-top-right-radius: 0 !important;
border-bottom-right-radius: 0 !important;
}

.shine-parent {
height: calc(100% + 3px);
width: calc(100% - 2px);
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/app/layout/toolbar/loading.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
} from '@network/bootstrap-stats/network-bootstrap-stats.actions';
import { BLOCK_PRODUCTION_PREFIX } from '@block-production/block-production.actions';
import {
BENCHMARKS_WALLETS_CLOSE,
BENCHMARKS_WALLETS_GET_ALL_TXS,
BENCHMARKS_WALLETS_GET_ALL_TXS_SUCCESS,
BENCHMARKS_WALLETS_GET_WALLETS, BENCHMARKS_WALLETS_GET_WALLETS_SUCCESS,
Expand Down Expand Up @@ -154,6 +155,8 @@ export function loadingReducer(state: LoadingState = initialState, action: Featu
return remove(state, BENCHMARKS_WALLETS_GET_WALLETS);
case BENCHMARKS_WALLETS_GET_ALL_TXS_SUCCESS:
return remove(state, BENCHMARKS_WALLETS_GET_ALL_TXS);
case BENCHMARKS_WALLETS_CLOSE:
return remove(state, [BENCHMARKS_WALLETS_GET_WALLETS, BENCHMARKS_WALLETS_GET_ALL_TXS]);

default:
return state;
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.