Browse Source

frontend work

master
nitowa 1 month ago
parent
commit
ec746cd1a2

+ 7
- 7
package-lock.json View File

12
         "buffer": "^6.0.3",
12
         "buffer": "^6.0.3",
13
         "chai": "^4.3.4",
13
         "chai": "^4.3.4",
14
         "node-fetch": "^2.6.1",
14
         "node-fetch": "^2.6.1",
15
-        "rjsvm": "^0.3.0",
15
+        "rjsvm": "^0.3.2",
16
         "xrpio": "^0.3.0",
16
         "xrpio": "^0.3.0",
17
         "xrpl": "^2.7.0"
17
         "xrpl": "^2.7.0"
18
       },
18
       },
3119
       }
3119
       }
3120
     },
3120
     },
3121
     "node_modules/rjsvm": {
3121
     "node_modules/rjsvm": {
3122
-      "version": "0.3.0",
3123
-      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz",
3124
-      "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==",
3122
+      "version": "0.3.2",
3123
+      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz",
3124
+      "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==",
3125
       "dependencies": {
3125
       "dependencies": {
3126
         "axios": "^1.7.7",
3126
         "axios": "^1.7.7",
3127
         "stream-http": "^3.2.0",
3127
         "stream-http": "^3.2.0",
6618
       }
6618
       }
6619
     },
6619
     },
6620
     "rjsvm": {
6620
     "rjsvm": {
6621
-      "version": "0.3.0",
6622
-      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz",
6623
-      "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==",
6621
+      "version": "0.3.2",
6622
+      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz",
6623
+      "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==",
6624
       "requires": {
6624
       "requires": {
6625
         "axios": "^1.7.7",
6625
         "axios": "^1.7.7",
6626
         "stream-http": "^3.2.0",
6626
         "stream-http": "^3.2.0",

+ 1
- 1
package.json View File

21
     "buffer": "^6.0.3",
21
     "buffer": "^6.0.3",
22
     "chai": "^4.3.4",
22
     "chai": "^4.3.4",
23
     "node-fetch": "^2.6.1",
23
     "node-fetch": "^2.6.1",
24
-    "rjsvm": "^0.3.0",
24
+    "rjsvm": "^0.3.2",
25
     "xrpio": "^0.3.0",
25
     "xrpio": "^0.3.0",
26
     "xrpl": "^2.7.0"
26
     "xrpl": "^2.7.0"
27
   },
27
   },

+ 7
- 7
src/frontend/package-lock.json View File

26
         "buffer": "^6.0.3",
26
         "buffer": "^6.0.3",
27
         "modern-normalize": "^1.1.0",
27
         "modern-normalize": "^1.1.0",
28
         "process": "^0.11.10",
28
         "process": "^0.11.10",
29
-        "rjsvm": "^0.3.0",
29
+        "rjsvm": "^0.3.2",
30
         "rxjs": "~7.5.0",
30
         "rxjs": "~7.5.0",
31
         "tslib": "^2.3.0",
31
         "tslib": "^2.3.0",
32
         "xrpio": "^0.3.0",
32
         "xrpio": "^0.3.0",
11639
       }
11639
       }
11640
     },
11640
     },
11641
     "node_modules/rjsvm": {
11641
     "node_modules/rjsvm": {
11642
-      "version": "0.3.0",
11643
-      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz",
11644
-      "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==",
11642
+      "version": "0.3.2",
11643
+      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz",
11644
+      "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==",
11645
       "dependencies": {
11645
       "dependencies": {
11646
         "axios": "^1.7.7",
11646
         "axios": "^1.7.7",
11647
         "stream-http": "^3.2.0",
11647
         "stream-http": "^3.2.0",
22544
       }
22544
       }
22545
     },
22545
     },
22546
     "rjsvm": {
22546
     "rjsvm": {
22547
-      "version": "0.3.0",
22548
-      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz",
22549
-      "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==",
22547
+      "version": "0.3.2",
22548
+      "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz",
22549
+      "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==",
22550
       "requires": {
22550
       "requires": {
22551
         "axios": "^1.7.7",
22551
         "axios": "^1.7.7",
22552
         "stream-http": "^3.2.0",
22552
         "stream-http": "^3.2.0",

+ 1
- 1
src/frontend/package.json View File

30
     "buffer": "^6.0.3",
30
     "buffer": "^6.0.3",
31
     "modern-normalize": "^1.1.0",
31
     "modern-normalize": "^1.1.0",
32
     "process": "^0.11.10",
32
     "process": "^0.11.10",
33
-    "rjsvm": "^0.3.0",
33
+    "rjsvm": "^0.3.2",
34
     "rxjs": "~7.5.0",
34
     "rxjs": "~7.5.0",
35
     "tslib": "^2.3.0",
35
     "tslib": "^2.3.0",
36
     "xrpio": "^0.3.0",
36
     "xrpio": "^0.3.0",

+ 70
- 11
src/frontend/src/app/app.component.html View File

1
 <div class="main-container">
1
 <div class="main-container">
2
   <header class="header-2">
2
   <header class="header-2">
3
     <div class="branding">
3
     <div class="branding">
4
-      <a class="nav-link">
4
+      <a class="nav-link" target="_blank" [href]="'https://testnet.xrpl.org/accounts/'+contractAddress">
5
         <cds-icon shape="home" size="lg"></cds-icon>
5
         <cds-icon shape="home" size="lg"></cds-icon>
6
-        <span class="title">httXrp</span>
6
+        <span class="title">{{contractAddress}}</span>
7
       </a>
7
       </a>
8
     </div>
8
     </div>
9
     <div class="header-nav">
9
     <div class="header-nav">
10
       <a class="active nav-link nav-text">Shoutbox</a>
10
       <a class="active nav-link nav-text">Shoutbox</a>
11
     </div>
11
     </div>
12
   </header>
12
   </header>
13
+
13
   <div class="content-container">
14
   <div class="content-container">
14
     <div class="content-area">
15
     <div class="content-area">
15
       <div class="clr-row">
16
       <div class="clr-row">
16
-        <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
17
+        <div class="clr-col-lg-6 clr-col-md-8 clr-col-12">
18
+          <div class="card">
19
+            <h3 class="card-header">Wallets in use</h3>
20
+
21
+            <div class="clr-row">
22
+
23
+              <div class="clr-col-lg-6 clr-col-md-8 clr-col-12">
24
+      
25
+
26
+            <div class="card-block">
27
+              <clr-input-container>
28
+                <label>User Wallet 1 Address</label>
29
+                <input clrInput [disabled]="true" required type="text" [(ngModel)]="userWallet.address"
30
+                  name="title" size="29" />
31
+              </clr-input-container>
32
+              <clr-input-container>
33
+                <label>Secret</label>
34
+                <input clrInput [disabled]="true" required type="text" [(ngModel)]="userWallet.secret"
35
+                  name="title" size="29" />
36
+              </clr-input-container>
37
+            </div>
38
+
39
+            </div>
40
+            <div class="clr-col-lg-6 clr-col-md-8 clr-col-12">
41
+
42
+
43
+            <div class="card-block">
44
+              <clr-input-container>
45
+                <label>User Wallet 2 Address</label>
46
+                <input clrInput [disabled]="true" required type="text" [(ngModel)]="drainWallet.address"
47
+                  name="title" size="29" />
48
+              </clr-input-container>
49
+              <clr-input-container>
50
+                <label>Secret</label>
51
+                <input clrInput [disabled]="true" required type="text" [(ngModel)]="drainWallet.secret"
52
+                  name="title" size="29" />
53
+              </clr-input-container>
54
+            </div>
55
+          </div>
56
+
57
+          </div>
58
+          </div>
59
+        </div>
60
+      </div>
61
+
62
+      <div class="clr-row">
63
+        <div class="clr-col-lg-6 clr-col-md-8 clr-col-12">
17
           <div class="card">
64
           <div class="card">
18
             <h3 class="card-header">Shout Something</h3>
65
             <h3 class="card-header">Shout Something</h3>
19
             <form clrForm #loginForm="ngForm">
66
             <form clrForm #loginForm="ngForm">
21
               <div class="card-block">
68
               <div class="card-block">
22
                 <clr-input-container>
69
                 <clr-input-container>
23
                   <input clrInput [disabled]="sending" required placeholder="Title" type="text"
70
                   <input clrInput [disabled]="sending" required placeholder="Title" type="text"
24
-                    [(ngModel)]="newShout.title" name="title" />
71
+                    [(ngModel)]="newShout.title" name="title"  size="45" />
25
                 </clr-input-container>
72
                 </clr-input-container>
26
                 <textarea clrTextarea [disabled]="sending" required placeholder="Shout Body" type="text"
73
                 <textarea clrTextarea [disabled]="sending" required placeholder="Shout Body" type="text"
27
-                  [(ngModel)]="newShout.body" name="body"></textarea>
74
+                  [(ngModel)]="newShout.body" name="body" cols="43" rows="15"></textarea>
28
                 <clr-input-container>
75
                 <clr-input-container>
29
                   <input clrInput [disabled]="sending" required placeholder="Your Name" type="text"
76
                   <input clrInput [disabled]="sending" required placeholder="Your Name" type="text"
30
-                    [(ngModel)]="newShout.from" name="from" />
77
+                    [(ngModel)]="newShout.from" name="from" size="45" />
31
                 </clr-input-container>
78
                 </clr-input-container>
32
               </div>
79
               </div>
33
               <div class="card-footer">
80
               <div class="card-footer">
34
                 <button class="btn btn-success" (click)="submitShout()"
81
                 <button class="btn btn-success" (click)="submitShout()"
35
                   [disabled]="!loginForm.form.valid || sending">Shout</button>
82
                   [disabled]="!loginForm.form.valid || sending">Shout</button>
36
-                  <span *ngIf="sending">Sending...</span>
37
-                  <span *ngIf="waiting">It may take up to 30 seconds for the new entry to persist</span>
83
+                  
84
+                <span *ngIf="sending">Sending...</span>
85
+                <span *ngIf="waiting">
86
+                  TX <a [href]="'https://testnet.xrpl.org/transactions/'+lastMessageHash+'/detailed'" target="_blank">
87
+                    <cds-icon shape="link"></cds-icon>
88
+                  </a>
89
+                  <br />
90
+                  It may take up to 30 seconds for the new entry to persist
91
+                </span>
38
               </div>
92
               </div>
39
             </form>
93
             </form>
40
           </div>
94
           </div>
42
       </div>
96
       </div>
43
 
97
 
44
       <div class="clr-row" *ngIf="initializing">
98
       <div class="clr-row" *ngIf="initializing">
45
-        <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
99
+        <div class="clr-col-lg-6 clr-col-md-8 clr-col-12">
46
           <div class="card">
100
           <div class="card">
47
             <h3 class="card-header">Syncing application state</h3>
101
             <h3 class="card-header">Syncing application state</h3>
48
             <div class="card-block">
102
             <div class="card-block">
56
       </div>
110
       </div>
57
 
111
 
58
       <div class="clr-row" *ngFor="let shout of shouts">
112
       <div class="clr-row" *ngFor="let shout of shouts">
59
-        <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
113
+        <div class="clr-col-lg-6 clr-col-md-8 clr-col-12">
60
           <div class="card">
114
           <div class="card">
61
-            <h3 class="card-header">{{shout.title}}</h3>
115
+            <h3 class="card-header">
116
+              {{shout.title}} 
117
+              <a [href]="'https://testnet.xrpl.org/transactions/'+shout.hash+'/detailed'" target="_blank">
118
+                <cds-icon shape="link"></cds-icon>
119
+              </a>
120
+            </h3>            
62
             <div class="card-block">
121
             <div class="card-block">
63
               <div class="card-text">
122
               <div class="card-text">
64
                 {{shout.body}}
123
                 {{shout.body}}

+ 41
- 19
src/frontend/src/app/app.component.ts View File

1
 import { Component, OnInit } from '@angular/core';
1
 import { Component, OnInit } from '@angular/core';
2
 import { ShoutboxDataService } from './services/ShoutboxData.service';
2
 import { ShoutboxDataService } from './services/ShoutboxData.service';
3
+import { makeTestnetWallet } from './util/TestnetUtils';
3
 
4
 
4
 @Component({
5
 @Component({
5
   selector: 'app-root',
6
   selector: 'app-root',
6
   templateUrl: './app.component.html',
7
   templateUrl: './app.component.html',
7
   styleUrls: ['./app.component.scss'],
8
   styleUrls: ['./app.component.scss'],
8
 })
9
 })
9
-export class AppComponent implements OnInit{
10
+export class AppComponent implements OnInit {
11
+  lastMessageHash = ""
12
+  contractAddress = "";
10
   initializing = true
13
   initializing = true
11
   waiting = false
14
   waiting = false
12
   title = 'httXrp Shoutbox';
15
   title = 'httXrp Shoutbox';
15
   newShout = {
18
   newShout = {
16
     title: "",
19
     title: "",
17
     body: "",
20
     body: "",
18
-    from: ""
21
+    from: "",
22
+    hash: ""
23
+  }
24
+  userWallet = {
25
+    address: "",
26
+    secret: ""
27
+  }
28
+  drainWallet = {
29
+    address: "",
30
+    secret: ""
19
   }
31
   }
20
 
32
 
21
   constructor(
33
   constructor(
22
     private dataService: ShoutboxDataService
34
     private dataService: ShoutboxDataService
23
-  ){}
35
+  ) {
36
+    this.contractAddress = dataService.getContractAddress()
37
+  }
24
 
38
 
25
   submitShout = () => {
39
   submitShout = () => {
26
     this.sending = true
40
     this.sending = true
27
     this.dataService.submitShout(this.newShout)
41
     this.dataService.submitShout(this.newShout)
28
-    .then(() => {
29
-      this.newShout = {
30
-        title: "",
31
-        body: "",
32
-        from: ""
33
-      }
34
-    })
35
-    .finally(() => {
36
-      this.sending = false
37
-      this.waiting = true
38
-      setTimeout(() => {this.waiting = false}, 20000)
39
-    })
42
+      .then((hash) => {
43
+        this.newShout = {
44
+          title: "",
45
+          body: "",
46
+          from: "",
47
+          hash: ""
48
+        }
49
+        this.lastMessageHash = hash
50
+      })
51
+      .finally(() => {
52
+        this.sending = false
53
+        this.waiting = true
54
+        setTimeout(() => { this.waiting = false }, 20000)
55
+      })
40
   }
56
   }
41
 
57
 
42
-  ngOnInit(){
43
-    this.dataService.initialize((shout:any) => {
44
-      this.shouts.unshift(shout)
45
-      this.initializing = false
58
+  ngOnInit() {
59
+    Promise.all([makeTestnetWallet(), makeTestnetWallet()]).then(([userWallet, drainWallet]) => {
60
+      console.log(userWallet, drainWallet)
61
+      this.userWallet = userWallet
62
+      this.drainWallet = drainWallet
63
+
64
+      this.dataService.initialize((shout: any) => {
65
+        this.shouts.unshift(shout)
66
+        this.initializing = false
67
+      }, userWallet, drainWallet)
46
     })
68
     })
47
   }
69
   }
48
 }
70
 }

+ 2
- 1
src/frontend/src/app/app.module.ts View File

6
 import { CdsModule } from '@cds/angular';
6
 import { CdsModule } from '@cds/angular';
7
 import { ClarityModule } from '@clr/angular';
7
 import { ClarityModule } from '@clr/angular';
8
 
8
 
9
-import { ClarityIcons, homeIcon } from '@cds/core/icon';
9
+import { ClarityIcons, homeIcon, linkIcon } from '@cds/core/icon';
10
 import { ShoutboxDataService } from './services/ShoutboxData.service';
10
 import { ShoutboxDataService } from './services/ShoutboxData.service';
11
 import { FormsModule } from '@angular/forms';
11
 import { FormsModule } from '@angular/forms';
12
 
12
 
27
 export class AppModule {
27
 export class AppModule {
28
   constructor() {
28
   constructor() {
29
     ClarityIcons.addIcons(homeIcon);
29
     ClarityIcons.addIcons(homeIcon);
30
+    ClarityIcons.addIcons(linkIcon);
30
   }
31
   }
31
 }
32
 }

+ 5
- 9
src/frontend/src/app/services/ShoutboxData.service.ts View File

1
 import { Injectable } from "@angular/core";
1
 import { Injectable } from "@angular/core";
2
-import { makeTestnetWallet } from "../util/TestnetUtils";
3
 import { z } from 'zod';
2
 import { z } from 'zod';
4
 
3
 
5
 declare const RJSVM: any;
4
 declare const RJSVM: any;
16
     private dataWriter = undefined as any
15
     private dataWriter = undefined as any
17
 
16
 
18
     public submitShout = async (shout: any) => {
17
     public submitShout = async (shout: any) => {
19
-        await this.dataWriter.callEndpoint('submit', shout, 10)
18
+        return await this.dataWriter.callEndpoint('submit', shout, 10)
20
     }
19
     }
21
 
20
 
21
+    public getContractAddress = () => listeningAddress
22
 
22
 
23
-    initialize = async (onData:Function) => {
24
-
25
-        const [userWallet, drainWallet] = await Promise.all([makeTestnetWallet(), makeTestnetWallet()])
26
-
27
-        console.log(userWallet, drainWallet)
23
+    initialize = async (onData:Function, userWallet?:any, drainWallet?:any) => {
28
 
24
 
29
         this.dataWriter = new Datawriter({
25
         this.dataWriter = new Datawriter({
30
             receiveAddress: drainWallet.address,
26
             receiveAddress: drainWallet.address,
74
     
70
     
75
         const RJSVM_Contract = {
71
         const RJSVM_Contract = {
76
             submit: {
72
             submit: {
77
-                implementation: function (env:any, shout:any) {
78
-                    console.log(shout);
73
+                implementation: function (env:any, shout: any) {
74
+                    shout.hash = env.hash;
79
                     (this as any).state.shouts.unshift(shout)
75
                     (this as any).state.shouts.unshift(shout)
80
                 },
76
                 },
81
                 visibility: 'public',
77
                 visibility: 'public',

+ 1
- 1
src/frontend/src/index.html View File

11
   <meta name="viewport" content="width=device-width, initial-scale=1">
11
   <meta name="viewport" content="width=device-width, initial-scale=1">
12
   <link rel="icon" type="image/x-icon" href="favicon.ico">
12
   <link rel="icon" type="image/x-icon" href="favicon.ico">
13
 
13
 
14
-  <script src="https://cdn.jsdelivr.net/npm/rjsvm@0.3.1/lib/browser/rjsvm.browser.js"></script>
14
+  <script src="https://cdn.jsdelivr.net/npm/rjsvm@0.3.2/lib/browser/rjsvm.browser.js"></script>
15
 </head>
15
 </head>
16
 <body cds-text="body" cds-theme="dark">
16
 <body cds-text="body" cds-theme="dark">
17
   <app-root></app-root>
17
   <app-root></app-root>

Loading…
Cancel
Save