diff --git a/frontend/src/app/core/services/web-node.service.ts b/frontend/src/app/core/services/web-node.service.ts index f70f24ec19..2cf88833f7 100644 --- a/frontend/src/app/core/services/web-node.service.ts +++ b/frontend/src/app/core/services/web-node.service.ts @@ -1,7 +1,7 @@ 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({ @@ -9,8 +9,7 @@ import { HttpClient } from '@angular/common/http'; }) export class WebNodeService { - private readonly backendSubject$: BehaviorSubject = new BehaviorSubject(null); - private backend: any; + private readonly webnode$: BehaviorSubject = new BehaviorSubject(null); private webNodeKeyPair: { publicKey: string, privateKey: string }; constructor(private http: HttpClient) { @@ -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 { - return this.backendSubject$.asObservable().pipe( + return this.webnode$.asObservable().pipe( filter(Boolean), switchMap(handle => from((handle as any).status())), ); } get blockProducerStats$(): Observable { - return this.backendSubject$.asObservable().pipe( + return this.webnode$.asObservable().pipe( filter(Boolean), switchMap(handle => from((handle as any).stats().block_producer())), ); } get peers$(): Observable { - return this.backendSubject$.asObservable().pipe( + return this.webnode$.asObservable().pipe( filter(Boolean), switchMap(handle => from(any(handle).state().peers())), ); } get messageProgress$(): Observable { - return this.backendSubject$.asObservable().pipe( + return this.webnode$.asObservable().pipe( filter(Boolean), switchMap(handle => from((handle as any).state().message_progress())), ); } get sync$(): Observable { - return this.backendSubject$.asObservable().pipe( + return this.webnode$.asObservable().pipe( filter(Boolean), switchMap(handle => from((handle as any).stats().sync())), ); } get accounts$(): Observable { - 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 { - 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 { - 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 { - return this.backendSubject$.asObservable().pipe( + return this.webnode$.asObservable().pipe( filter(Boolean), switchMap(handle => from((handle as any).transaction_pool().get())), ); diff --git a/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.effects.ts b/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.effects.ts index e2a87c43b8..54f5215991 100644 --- a/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.effects.ts +++ b/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.effects.ts @@ -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'; @@ -38,22 +39,23 @@ export class BenchmarksWalletsEffects extends MinaRustBaseEffect) { - super(store, selectMinaState); this.getWallets$ = createEffect(() => this.actions$.pipe( - ofType(BENCHMARKS_WALLETS_GET_WALLETS), - this.latestActionState(), - 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(), + 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, []), )); diff --git a/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.service.ts b/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.service.ts index df3fe16830..8fafa4ff04 100644 --- a/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.service.ts +++ b/frontend/src/app/features/benchmarks/wallets/benchmarks-wallets.service.ts @@ -4035,7 +4035,7 @@ export class BenchmarksWalletsService { } getAccounts(): Observable[]> { - return this.rust.get('/accounts').pipe( + return this.rust.get('/accounts').pipe( map(wallets => wallets.map(wallet => { return ({ privateKey: WALLETS.find(w => w.publicKey === wallet.public_key)?.privateKey, @@ -4140,3 +4140,9 @@ export class BenchmarksWalletsService { }); } } + +export interface AccountsResponse { + public_key: string; + nonce: number; + balance: number; +} diff --git a/frontend/src/app/layout/server-status/server-status.component.html b/frontend/src/app/layout/server-status/server-status.component.html index dc9225e4ec..f72efa14a8 100644 --- a/frontend/src/app/layout/server-status/server-status.component.html +++ b/frontend/src/app/layout/server-status/server-status.component.html @@ -24,7 +24,7 @@
+ [class.can-add-nodes]="switchForbidden">