Przeglądaj źródła

frontend work

master
nitowa 1 miesiąc temu
rodzic
commit
ec746cd1a2

+ 7
- 7
package-lock.json Wyświetl plik

@@ -12,7 +12,7 @@
12 12
         "buffer": "^6.0.3",
13 13
         "chai": "^4.3.4",
14 14
         "node-fetch": "^2.6.1",
15
-        "rjsvm": "^0.3.0",
15
+        "rjsvm": "^0.3.2",
16 16
         "xrpio": "^0.3.0",
17 17
         "xrpl": "^2.7.0"
18 18
       },
@@ -3119,9 +3119,9 @@
3119 3119
       }
3120 3120
     },
3121 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 3125
       "dependencies": {
3126 3126
         "axios": "^1.7.7",
3127 3127
         "stream-http": "^3.2.0",
@@ -6618,9 +6618,9 @@
6618 6618
       }
6619 6619
     },
6620 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 6624
       "requires": {
6625 6625
         "axios": "^1.7.7",
6626 6626
         "stream-http": "^3.2.0",

+ 1
- 1
package.json Wyświetl plik

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

+ 7
- 7
src/frontend/package-lock.json Wyświetl plik

@@ -26,7 +26,7 @@
26 26
         "buffer": "^6.0.3",
27 27
         "modern-normalize": "^1.1.0",
28 28
         "process": "^0.11.10",
29
-        "rjsvm": "^0.3.0",
29
+        "rjsvm": "^0.3.2",
30 30
         "rxjs": "~7.5.0",
31 31
         "tslib": "^2.3.0",
32 32
         "xrpio": "^0.3.0",
@@ -11639,9 +11639,9 @@
11639 11639
       }
11640 11640
     },
11641 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 11645
       "dependencies": {
11646 11646
         "axios": "^1.7.7",
11647 11647
         "stream-http": "^3.2.0",
@@ -22544,9 +22544,9 @@
22544 22544
       }
22545 22545
     },
22546 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 22550
       "requires": {
22551 22551
         "axios": "^1.7.7",
22552 22552
         "stream-http": "^3.2.0",

+ 1
- 1
src/frontend/package.json Wyświetl plik

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

+ 70
- 11
src/frontend/src/app/app.component.html Wyświetl plik

@@ -1,19 +1,66 @@
1 1
 <div class="main-container">
2 2
   <header class="header-2">
3 3
     <div class="branding">
4
-      <a class="nav-link">
4
+      <a class="nav-link" target="_blank" [href]="'https://testnet.xrpl.org/accounts/'+contractAddress">
5 5
         <cds-icon shape="home" size="lg"></cds-icon>
6
-        <span class="title">httXrp</span>
6
+        <span class="title">{{contractAddress}}</span>
7 7
       </a>
8 8
     </div>
9 9
     <div class="header-nav">
10 10
       <a class="active nav-link nav-text">Shoutbox</a>
11 11
     </div>
12 12
   </header>
13
+
13 14
   <div class="content-container">
14 15
     <div class="content-area">
15 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 64
           <div class="card">
18 65
             <h3 class="card-header">Shout Something</h3>
19 66
             <form clrForm #loginForm="ngForm">
@@ -21,20 +68,27 @@
21 68
               <div class="card-block">
22 69
                 <clr-input-container>
23 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 72
                 </clr-input-container>
26 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 75
                 <clr-input-container>
29 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 78
                 </clr-input-container>
32 79
               </div>
33 80
               <div class="card-footer">
34 81
                 <button class="btn btn-success" (click)="submitShout()"
35 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 92
               </div>
39 93
             </form>
40 94
           </div>
@@ -42,7 +96,7 @@
42 96
       </div>
43 97
 
44 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 100
           <div class="card">
47 101
             <h3 class="card-header">Syncing application state</h3>
48 102
             <div class="card-block">
@@ -56,9 +110,14 @@
56 110
       </div>
57 111
 
58 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 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 121
             <div class="card-block">
63 122
               <div class="card-text">
64 123
                 {{shout.body}}

+ 41
- 19
src/frontend/src/app/app.component.ts Wyświetl plik

@@ -1,12 +1,15 @@
1 1
 import { Component, OnInit } from '@angular/core';
2 2
 import { ShoutboxDataService } from './services/ShoutboxData.service';
3
+import { makeTestnetWallet } from './util/TestnetUtils';
3 4
 
4 5
 @Component({
5 6
   selector: 'app-root',
6 7
   templateUrl: './app.component.html',
7 8
   styleUrls: ['./app.component.scss'],
8 9
 })
9
-export class AppComponent implements OnInit{
10
+export class AppComponent implements OnInit {
11
+  lastMessageHash = ""
12
+  contractAddress = "";
10 13
   initializing = true
11 14
   waiting = false
12 15
   title = 'httXrp Shoutbox';
@@ -15,34 +18,53 @@ export class AppComponent implements OnInit{
15 18
   newShout = {
16 19
     title: "",
17 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 33
   constructor(
22 34
     private dataService: ShoutboxDataService
23
-  ){}
35
+  ) {
36
+    this.contractAddress = dataService.getContractAddress()
37
+  }
24 38
 
25 39
   submitShout = () => {
26 40
     this.sending = true
27 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 Wyświetl plik

@@ -6,7 +6,7 @@ import { AppComponent } from './app.component';
6 6
 import { CdsModule } from '@cds/angular';
7 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 10
 import { ShoutboxDataService } from './services/ShoutboxData.service';
11 11
 import { FormsModule } from '@angular/forms';
12 12
 
@@ -27,5 +27,6 @@ import { FormsModule } from '@angular/forms';
27 27
 export class AppModule {
28 28
   constructor() {
29 29
     ClarityIcons.addIcons(homeIcon);
30
+    ClarityIcons.addIcons(linkIcon);
30 31
   }
31 32
 }

+ 5
- 9
src/frontend/src/app/services/ShoutboxData.service.ts Wyświetl plik

@@ -1,5 +1,4 @@
1 1
 import { Injectable } from "@angular/core";
2
-import { makeTestnetWallet } from "../util/TestnetUtils";
3 2
 import { z } from 'zod';
4 3
 
5 4
 declare const RJSVM: any;
@@ -16,15 +15,12 @@ export class ShoutboxDataService {
16 15
     private dataWriter = undefined as any
17 16
 
18 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 25
         this.dataWriter = new Datawriter({
30 26
             receiveAddress: drainWallet.address,
@@ -74,8 +70,8 @@ export class ShoutboxDataService {
74 70
     
75 71
         const RJSVM_Contract = {
76 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 75
                     (this as any).state.shouts.unshift(shout)
80 76
                 },
81 77
                 visibility: 'public',

+ 1
- 1
src/frontend/src/index.html Wyświetl plik

@@ -11,7 +11,7 @@
11 11
   <meta name="viewport" content="width=device-width, initial-scale=1">
12 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 15
 </head>
16 16
 <body cds-text="body" cds-theme="dark">
17 17
   <app-root></app-root>

Ładowanie…
Anuluj
Zapisz