Skip to content

Commit fe614f4

Browse files
authored
Frontend - Adapt frontend to new API changes (#726)
Frontend - Adapt frontend to new API changes
1 parent fdf7f74 commit fe614f4

30 files changed

+831
-621
lines changed

frontend/angular.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
"prefix": "mina",
3030
"architect": {
3131
"build": {
32-
"builder": "@angular-devkit/build-angular:browser",
32+
"builder": "@angular-builders/custom-webpack:browser",
3333
"options": {
34+
"customWebpackConfig": {
35+
"path": "./webpack.config.js"
36+
},
3437
"outputPath": "dist/frontend",
3538
"index": "src/index.html",
3639
"main": "src/main.ts",
@@ -123,7 +126,7 @@
123126
"defaultConfiguration": "production"
124127
},
125128
"serve": {
126-
"builder": "@angular-devkit/build-angular:dev-server",
129+
"builder": "@angular-builders/custom-webpack:dev-server",
127130
"configurations": {
128131
"production": {
129132
"browserTarget": "frontend:build:production"

frontend/package-lock.json

Lines changed: 101 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
"@ngrx/store": "^16.2.0",
3232
"@openmina/shared": "^0.102.0",
3333
"base-x": "^5.0.0",
34+
"bs58check": "^4.0.0",
3435
"buffer": "^6.0.3",
3536
"d3": "^7.8.4",
3637
"eigen": "^0.2.2",
3738
"mathjs": "^12.3.0",
3839
"mina-signer": "^3.0.7",
3940
"ngx-json-viewer": "^3.2.1",
41+
"o1js": "^1.7.0",
4042
"rxjs": "~7.8.0",
4143
"tslib": "^2.3.0",
4244
"zone.js": "~0.13.0"

frontend/src/app/app.component.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ import { AppSelectors } from '@app/app.state';
88
import { AppActions } from '@app/app.actions';
99
import { Observable, timer } from 'rxjs';
1010
import { CONFIG } from '@shared/constants/config';
11+
// import { AccountUpdate, declareMethods, Field, method, Mina, PrivateKey, SmartContract, State, state } from 'o1js';
12+
13+
// export class Square extends SmartContract {
14+
// @state(Field) num = State<Field>();
15+
//
16+
// override init() {
17+
// super.init();
18+
// this.num.set(Field(3));
19+
// }
20+
//
21+
// // @method
22+
// async update(square: Field) {
23+
// const currentState = this.num.get();
24+
// this.num.requireEquals(currentState);
25+
// square.assertEquals(currentState.mul(currentState));
26+
// this.num.set(square);
27+
// }
28+
// }
1129

1230
@Component({
1331
selector: 'app-root',
@@ -36,8 +54,80 @@ export class AppComponent extends ManualDetection implements OnInit {
3654
this.scheduleNodeUpdates();
3755
}
3856
this.listenToWindowResizing();
57+
// console.log('Start');
58+
// this.startZK();
59+
// console.log('Finish!');
3960
}
4061

62+
63+
// async startZK() {
64+
// //@ts-ignore
65+
// declareMethods(Square, { update: [Field] });
66+
//
67+
// const useProof = false;
68+
//
69+
// const Local = await Mina.LocalBlockchain({ proofsEnabled: useProof });
70+
// Mina.setActiveInstance(Local);
71+
//
72+
// const deployerAccount = Local.testAccounts[0];
73+
// const deployerKey = deployerAccount.key;
74+
// const senderAccount = Local.testAccounts[1];
75+
// const senderKey = senderAccount.key;
76+
// // ----------------------------------------------------
77+
//
78+
// // Create a public/private key pair. The public key is your address and where you deploy the zkApp to
79+
// const zkAppPrivateKey = PrivateKey.random();
80+
// const zkAppAddress = zkAppPrivateKey.toPublicKey();
81+
//
82+
// // create an instance of Square - and deploy it to zkAppAddress
83+
// const zkAppInstance = new Square(zkAppAddress);
84+
// const deployTxn = await Mina.transaction(deployerAccount, async () => {
85+
// AccountUpdate.fundNewAccount(deployerAccount);
86+
// await zkAppInstance.deploy();
87+
// });
88+
// await deployTxn.sign([deployerKey, zkAppPrivateKey]).send();
89+
//
90+
// // get the initial state of Square after deployment
91+
// const num0 = zkAppInstance.num.get();
92+
// console.log('state after init:', num0.toString());
93+
//
94+
// // ----------------------------------------------------
95+
//
96+
// const txn1 = await Mina.transaction(senderAccount, async () => {
97+
// await zkAppInstance.update(Field(9));
98+
// });
99+
// await txn1.prove();
100+
// await txn1.sign([senderKey]).send();
101+
//
102+
// const num1 = zkAppInstance.num.get();
103+
// console.log('state after txn1:', num1.toString());
104+
//
105+
// // ----------------------------------------------------
106+
//
107+
// try {
108+
// const txn2 = await Mina.transaction(senderAccount, async () => {
109+
// await zkAppInstance.update(Field(75));
110+
// });
111+
// await txn2.prove();
112+
// await txn2.sign([senderKey]).send();
113+
// } catch (error: any) {
114+
// console.log(error.message);
115+
// }
116+
// const num2 = zkAppInstance.num.get();
117+
// console.log('state after txn2:', num2.toString());
118+
//
119+
// // ----------------------------------------------------
120+
//
121+
// const txn3 = await Mina.transaction(senderAccount, async () => {
122+
// await zkAppInstance.update(Field(81));
123+
// });
124+
// await txn3.prove();
125+
// await txn3.sign([senderKey]).send();
126+
//
127+
// const num3 = zkAppInstance.num.get();
128+
// console.log('state after txn3:', num3.toString());
129+
// }
130+
41131
private scheduleNodeUpdates(): void {
42132
timer(1000, 5000).subscribe(() => this.store.dispatch(AppActions.getNodeDetails()));
43133
}

frontend/src/app/app.effects.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { getFirstFeature, isFeatureEnabled } from '@shared/constants/config';
1212
import { RustService } from '@core/services/rust.service';
1313
import { BaseEffect } from '@shared/base-classes/mina-rust-base.effect';
1414
import { WebNodeService } from '@core/services/web-node.service';
15+
import { catchErrorAndRepeat2 } from '@shared/constants/store-functions';
16+
import { MinaErrorType } from '@shared/types/error-preview/mina-error-type.enum';
17+
import { AppNodeStatus } from '@shared/types/app/app-node-details.type';
1518

1619
const INIT_EFFECTS = '@ngrx/effects/init';
1720

@@ -82,6 +85,18 @@ export class AppEffects extends BaseEffect {
8285
switchMap(() => this.appService.getActiveNodeDetails()),
8386
tap(() => this.requestInProgress = false),
8487
map(details => AppActions.getNodeDetailsSuccess({ details })),
88+
catchErrorAndRepeat2(MinaErrorType.GENERIC, AppActions.getNodeDetailsSuccess({
89+
details: {
90+
status: AppNodeStatus.OFFLINE,
91+
blockHeight: null,
92+
blockTime: null,
93+
peers: 0,
94+
download: 0,
95+
upload: 0,
96+
transactions: 0,
97+
snarks: 0,
98+
},
99+
})),
85100
));
86101
}
87102
}

frontend/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AppComponent } from './app.component';
55
import { AppRouting } from './app.routing';
66
import { MatSidenavModule } from '@angular/material/sidenav';
77
import {
8+
CopyComponent,
89
GlobalErrorHandlerService,
910
HorizontalMenuComponent,
1011
NgrxRouterStoreModule,
@@ -79,6 +80,7 @@ export class AppGlobalErrorhandler implements ErrorHandler {
7980
OpenminaEagerSharedModule,
8081
HorizontalMenuComponent,
8182
ReactiveFormsModule,
83+
CopyComponent,
8284
],
8385
providers: [
8486
THEME_PROVIDER,

frontend/src/app/app.routing.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const routes: Routes = [
6868
loadChildren: () => import('./features/benchmarks/benchmarks.module').then(m => m.BenchmarksModule),
6969
title: BENCHMARKS_TITLE,
7070
},
71+
{
72+
path: 'zk',
73+
loadChildren: () => import('./features/zk/zk.module').then(m => m.ZkModule),
74+
title: BENCHMARKS_TITLE,
75+
},
7176
{
7277
path: '**',
7378
redirectTo: getFirstFeature(),

0 commit comments

Comments
 (0)