Skip to content

Commit 797f658

Browse files
authored
Frontend - Remove Dashboard Resyncs (#785)
1 parent 78f045d commit 797f658

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+11647
-582
lines changed

.idea/vcs.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ testem.log
4040
# System files
4141
.DS_Store
4242
Thumbs.db
43+
44+
# Open Mina
45+
/src/assets/webnode/pkg
46+
/src/assets/webnode/circuit-blobs

frontend/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,40 @@ This is a simple Angular application that will help you to see the behaviour of
77
### 1. Node.js v20.11.1
88

99
#### MacOS
10+
1011
```bash
1112
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
1213
brew install [email protected]
1314
```
1415

1516
#### Linux
17+
1618
```bash
1719
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
1820
source ~/.bashrc
1921
nvm install 20.11.1
2022
```
2123

2224
#### Windows
25+
2326
Download [Node.js v20.11.1](https://nodejs.org/) from the official website, open the installer and follow the prompts to complete the installation.
2427

2528
### 2. Angular CLI v16.2.0
29+
2630
```bash
2731
npm install -g @angular/[email protected]
2832
```
2933

3034
### 3. Installation
35+
3136
Open a terminal and navigate to this project's root directory
3237

3338
```bash
3439
cd PROJECT_LOCATION/openmina/frontend
3540
```
41+
3642
Install the dependencies
43+
3744
```bash
3845
npm install
3946
```
@@ -43,3 +50,24 @@ npm install
4350
```bash
4451
npm start
4552
```
53+
54+
# Using O1JS wrapper
55+
56+
as of now, o1js is not prepared to work with Angular, therefore we need to use the wrapper that is provided in the `src/assets/o1js` folder. This wrapper is a simple javascript webpack based application that will allow us to use the o1js library in our Angular application.
57+
58+
How to use it:
59+
60+
1. Open a terminal and navigate to the `src/assets/o1js` folder
61+
2. Install the dependencies
62+
63+
```bash
64+
npm install
65+
```
66+
67+
3. Build the wrapper
68+
69+
```bash
70+
npm run build-o1jswrapper
71+
```
72+
73+
4. That's it. Now you can use your code from o1js-wrapper inside the Angular application by using `BenchmarksWalletsZkService => o1jsInterface`

frontend/package-lock.json

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

frontend/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"watch": "ng build --watch --configuration development",
1111
"tests": "npx cypress open --config baseUrl=http://localhost:4200",
1212
"tests:headless": "npx cypress run --headless --config baseUrl=http://localhost:4200",
13-
"docker": "npm run build:prod && docker buildx build --platform linux/amd64 -t openmina/frontend:latest . && docker push openmina/frontend:latest",
14-
"replace-assertion": "node replace-assertion.js"
13+
"docker": "npm run build:prod && docker buildx build --platform linux/amd64 -t openmina/frontend:latest . && docker push openmina/frontend:latest"
1514
},
1615
"private": true,
1716
"dependencies": {
@@ -39,7 +38,6 @@
3938
"mathjs": "^12.3.0",
4039
"mina-signer": "^3.0.7",
4140
"ngx-json-viewer": "^3.2.1",
42-
"o1js": "^1.8.0",
4341
"rxjs": "~7.8.0",
4442
"tslib": "^2.3.0",
4543
"zone.js": "~0.13.0"

frontend/src/app/app.component.ts

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ 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-
// }
29-
30-
declare const $: any;
3111

3212
@Component({
3313
selector: 'app-root',
@@ -38,7 +18,7 @@ declare const $: any;
3818
})
3919
export class AppComponent extends ManualDetection implements OnInit {
4020

41-
menu$: Observable<AppMenu> = this.store.select(AppSelectors.menu);
21+
protected readonly menu$: Observable<AppMenu> = this.store.select(AppSelectors.menu);
4222
subMenusLength: number = 0;
4323
hideToolbar: boolean = CONFIG.hideToolbar;
4424

@@ -51,108 +31,13 @@ export class AppComponent extends ManualDetection implements OnInit {
5131
}
5232
}
5333

54-
async ngOnInit() {
34+
ngOnInit(): void {
5535
if (!this.hideToolbar && !CONFIG.hideNodeStats) {
5636
this.scheduleNodeUpdates();
5737
}
5838
this.listenToWindowResizing();
59-
// console.log('Start');
60-
// // this.startZK();
61-
// console.log('Finish!');
62-
// try {
63-
// await this.loadScript('assets/o1js/main.js');
64-
// // Now the script is loaded, and you can access the exported variable
65-
// if (typeof (window as any).$ !== 'undefined') {
66-
// const $ = (window as any).$;
67-
// console.log('Script loaded:', $);
68-
// // Use $ here
69-
// $.default.gql4();
70-
// } else {
71-
// console.error('$ is not defined after loading the script');
72-
// }
73-
// } catch (error) {
74-
// console.error('Error loading script:', error);
75-
// }
76-
}
77-
78-
loadScript(scriptUrl: string): Promise<void> {
79-
return new Promise((resolve, reject) => {
80-
const script = document.createElement('script');
81-
script.src = scriptUrl;
82-
script.onload = () => resolve();
83-
script.onerror = (error) => reject(error);
84-
document.body.appendChild(script);
85-
});
8639
}
8740

88-
// async startZK() {
89-
// //@ts-ignore
90-
// declareMethods(Square, { update: [Field] });
91-
//
92-
// const useProof = false;
93-
//
94-
// const Local = await Mina.LocalBlockchain({ proofsEnabled: useProof });
95-
// Mina.setActiveInstance(Local);
96-
//
97-
// const deployerAccount = Local.testAccounts[0];
98-
// const deployerKey = deployerAccount.key;
99-
// const senderAccount = Local.testAccounts[1];
100-
// const senderKey = senderAccount.key;
101-
// // ----------------------------------------------------
102-
//
103-
// // Create a public/private key pair. The public key is your address and where you deploy the zkApp to
104-
// const zkAppPrivateKey = PrivateKey.random();
105-
// const zkAppAddress = zkAppPrivateKey.toPublicKey();
106-
//
107-
// // create an instance of Square - and deploy it to zkAppAddress
108-
// const zkAppInstance = new Square(zkAppAddress);
109-
// const deployTxn = await Mina.transaction(deployerAccount, async () => {
110-
// AccountUpdate.fundNewAccount(deployerAccount);
111-
// await zkAppInstance.deploy();
112-
// });
113-
// await deployTxn.sign([deployerKey, zkAppPrivateKey]).send();
114-
//
115-
// // get the initial state of Square after deployment
116-
// const num0 = zkAppInstance.num.get();
117-
// console.log('state after init:', num0.toString());
118-
//
119-
// // ----------------------------------------------------
120-
//
121-
// const txn1 = await Mina.transaction(senderAccount, async () => {
122-
// await zkAppInstance.update(Field(9));
123-
// });
124-
// await txn1.prove();
125-
// await txn1.sign([senderKey]).send();
126-
//
127-
// const num1 = zkAppInstance.num.get();
128-
// console.log('state after txn1:', num1.toString());
129-
//
130-
// // ----------------------------------------------------
131-
//
132-
// try {
133-
// const txn2 = await Mina.transaction(senderAccount, async () => {
134-
// await zkAppInstance.update(Field(75));
135-
// });
136-
// await txn2.prove();
137-
// await txn2.sign([senderKey]).send();
138-
// } catch (error: any) {
139-
// console.log(error.message);
140-
// }
141-
// const num2 = zkAppInstance.num.get();
142-
// console.log('state after txn2:', num2.toString());
143-
//
144-
// // ----------------------------------------------------
145-
//
146-
// const txn3 = await Mina.transaction(senderAccount, async () => {
147-
// await zkAppInstance.update(Field(81));
148-
// });
149-
// await txn3.prove();
150-
// await txn3.sign([senderKey]).send();
151-
//
152-
// const num3 = zkAppInstance.num.get();
153-
// console.log('state after txn3:', num3.toString());
154-
// }
155-
15641
private scheduleNodeUpdates(): void {
15742
timer(1000, 5000).subscribe(() => this.store.dispatch(AppActions.getNodeDetails()));
15843
}

0 commit comments

Comments
 (0)