Browse Source

Work after api break

master
nitowa 2 months ago
parent
commit
9d64d43230

+ 904
- 82
package-lock.json
File diff suppressed because it is too large
View File


+ 2
- 1
package.json View File

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

+ 3
- 3
src/Configuration.ts View File

@@ -1,8 +1,8 @@
1 1
 
2 2
 export const config = {
3 3
   "oracle": true,
4
-  "secret": "sEdVwoxNkoxvRxRDaShXwWzVUkrgztd",
5
-  "treasuryAddress": "rnhVAr4ri5aTBUfoEzi4PPgc5yVo7jrAa5",
6
-  "contractAddress": "rakoA9cbkj9SbArhsQAiYFqm1fYYeWvrji", //pk: sEdVYHB7KJuK8jB1HF6Q8HQq62izZ9f
4
+  "secret": "sEd7WCM4AD8r19eyPfiG7nx6Vkx1bbU",
5
+  "treasuryAddress": "rhfkTrKqRNKFyY3wWqaHLSxgwfc1eMfvWz",
6
+  "contractAddress": "rrha5qSA3KUxwLYCBtm1z13KMPwsPFpvQ3", //pk: sEdVr3HmJooxVApTdqCKp4gVHrBBqUr
7 7
   "rippleNode": "wss://s.altnet.rippletest.net:51233",
8 8
 }

+ 1236
- 136
src/frontend/package-lock.json
File diff suppressed because it is too large
View File


+ 3
- 0
src/frontend/package.json View File

@@ -26,11 +26,14 @@
26 26
     "@cds/core": "6.6.2",
27 27
     "@clr/angular": "^15.12.0",
28 28
     "@clr/ui": "^15.12.0",
29
+    "axios": "^1.7.7",
29 30
     "buffer": "^6.0.3",
30 31
     "modern-normalize": "^1.1.0",
31 32
     "process": "^0.11.10",
33
+    "rjsvm": "^0.3.0",
32 34
     "rxjs": "~7.5.0",
33 35
     "tslib": "^2.3.0",
36
+    "xrpio": "^0.3.0",
34 37
     "zod": "^3.22.4",
35 38
     "zone.js": "~0.11.4"
36 39
   },

+ 23
- 5
src/frontend/src/app/app.component.html View File

@@ -20,23 +20,41 @@
20 20
 
21 21
               <div class="card-block">
22 22
                 <clr-input-container>
23
-                  <input clrInput [disabled]="sending"  required placeholder="Title" type="text" [(ngModel)]="newShout.title" name="title" />
23
+                  <input clrInput [disabled]="sending" required placeholder="Title" type="text"
24
+                    [(ngModel)]="newShout.title" name="title" />
24 25
                 </clr-input-container>
25
-                <textarea clrTextarea [disabled]="sending" required placeholder="Shout Body" type="text" [(ngModel)]="newShout.body"
26
-                  name="body"></textarea>
26
+                <textarea clrTextarea [disabled]="sending" required placeholder="Shout Body" type="text"
27
+                  [(ngModel)]="newShout.body" name="body"></textarea>
27 28
                 <clr-input-container>
28
-                  <input clrInput [disabled]="sending" required placeholder="Your Name" type="text" [(ngModel)]="newShout.from" name="from" />
29
+                  <input clrInput [disabled]="sending" required placeholder="Your Name" type="text"
30
+                    [(ngModel)]="newShout.from" name="from" />
29 31
                 </clr-input-container>
30 32
               </div>
31 33
               <div class="card-footer">
32 34
                 <button class="btn btn-success" (click)="submitShout()"
33
-                  [disabled]="!loginForm.form.valid || sending">Shout</button> <span *ngIf="sending">Sending...</span>
35
+                  [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>
34 38
               </div>
35 39
             </form>
36 40
           </div>
37 41
         </div>
38 42
       </div>
39 43
 
44
+      <div class="clr-row" *ngIf="initializing">
45
+        <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
46
+          <div class="card">
47
+            <h3 class="card-header">Syncing application state</h3>
48
+            <div class="card-block">
49
+              <div class="card-text">
50
+                <span class="spinner spinner-inline">Loading...</span>
51
+                <span>Loading...</span>
52
+              </div>
53
+            </div>
54
+          </div>
55
+        </div>
56
+      </div>
57
+
40 58
       <div class="clr-row" *ngFor="let shout of shouts">
41 59
         <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
42 60
           <div class="card">

+ 8
- 1
src/frontend/src/app/app.component.ts View File

@@ -7,6 +7,8 @@ import { ShoutboxDataService } from './services/ShoutboxData.service';
7 7
   styleUrls: ['./app.component.scss'],
8 8
 })
9 9
 export class AppComponent implements OnInit{
10
+  initializing = true
11
+  waiting = false
10 12
   title = 'httXrp Shoutbox';
11 13
   shouts: any[] = []
12 14
   sending = false
@@ -32,10 +34,15 @@ export class AppComponent implements OnInit{
32 34
     })
33 35
     .finally(() => {
34 36
       this.sending = false
37
+      this.waiting = true
38
+      setTimeout(() => {this.waiting = false}, 20000)
35 39
     })
36 40
   }
37 41
 
38 42
   ngOnInit(){
39
-    this.shouts = this.dataService.history
43
+    this.dataService.initialize((shout:any) => {
44
+      this.shouts.unshift(shout)
45
+      this.initializing = false
46
+    })
40 47
   }
41 48
 }

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

@@ -7,7 +7,7 @@ import { CdsModule } from '@cds/angular';
7 7
 import { ClarityModule } from '@clr/angular';
8 8
 
9 9
 import { ClarityIcons, homeIcon } from '@cds/core/icon';
10
-import { ShoutboxDataService, initShoutboxSvc } from './services/ShoutboxData.service';
10
+import { ShoutboxDataService } from './services/ShoutboxData.service';
11 11
 import { FormsModule } from '@angular/forms';
12 12
 
13 13
 @NgModule({
@@ -21,12 +21,6 @@ import { FormsModule } from '@angular/forms';
21 21
   ],
22 22
   providers: [
23 23
     ShoutboxDataService,
24
-    {
25
-      provide: APP_INITIALIZER,
26
-      useFactory: initShoutboxSvc,
27
-      deps: [ShoutboxDataService],
28
-      multi: true
29
-    }
30 24
   ],
31 25
   bootstrap: [AppComponent],
32 26
 })

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

@@ -7,7 +7,7 @@ declare const RJSVM_Builder: any;
7 7
 declare const Datawriter: any;
8 8
 
9 9
 const xrpNode = "wss://s.altnet.rippletest.net:51233"
10
-const listeningAddress = "rB4v4taosTUvuup8prxj2wbrBMbmvmxgXx"
10
+const listeningAddress = "rMBYWyxGx1b5zEjJKF18TTwF5X3vP2WyjR"
11 11
 
12 12
 @Injectable()
13 13
 export class ShoutboxDataService {
@@ -20,9 +20,12 @@ export class ShoutboxDataService {
20 20
     }
21 21
 
22 22
 
23
-    initialize = async () => {
23
+    initialize = async (onData:Function) => {
24 24
 
25 25
         const [userWallet, drainWallet] = await Promise.all([makeTestnetWallet(), makeTestnetWallet()])
26
+
27
+        console.log(userWallet, drainWallet)
28
+
26 29
         this.dataWriter = new Datawriter({
27 30
             receiveAddress: drainWallet.address,
28 31
             sendWallet: userWallet,
@@ -72,6 +75,7 @@ export class ShoutboxDataService {
72 75
         const RJSVM_Contract = {
73 76
             submit: {
74 77
                 implementation: function (env:any, shout:any) {
78
+                    console.log(shout);
75 79
                     (this as any).state.shouts.unshift(shout)
76 80
                 },
77 81
                 visibility: 'public',
@@ -95,12 +99,8 @@ export class ShoutboxDataService {
95 99
         await rjsvm.connect()
96 100
 
97 101
         rjsvm.on('error', console.log)
98
-        rjsvm.on('submit', console.log)
102
+        rjsvm.on('submit', onData)
99 103
 
100 104
         this.history = rjsvm.state.shouts
101 105
     }
102
-}
103
-
104
-export function initShoutboxSvc(svc: ShoutboxDataService): () => Promise<any> {
105
-    return svc.initialize;
106 106
 }

+ 14
- 14
src/frontend/src/app/util/TestnetUtils.ts View File

@@ -1,14 +1,14 @@
1
-export const makeTestnetWallet = () : Promise<{ secret: string, address: string }> => fetch('https://faucet.altnet.rippletest.net/accounts', {
2
-    method: 'POST',
3
-    headers: {
4
-        'Accept': 'application/json',
5
-        'Content-Type': 'application/json'
6
-    },
7
-}).then((raw:any) => {
8
-    return raw.json().then((content:any) => {
9
-        return({
10
-            secret: content.account.secret,
11
-            address: content.account.address
12
-        });
13
-    })
14
-});
1
+import axios from 'axios';
2
+
3
+export const makeTestnetWallet = async () : Promise<any> => {
4
+    try{
5
+        const response = await axios.post('https://faucet.altnet.rippletest.net/accounts', {})
6
+        return ({
7
+            secret: response.data.seed,
8
+            address: response.data.account.address
9
+        })
10
+    
11
+    }catch(e){
12
+        console.log(e)
13
+    }
14
+}

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

@@ -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.2.5/lib/browser/rjsvm.browser.js"></script>
14
+  <script src="https://cdn.jsdelivr.net/npm/rjsvm@0.3.1/lib/browser/rjsvm.browser.js"></script>
15 15
 </head>
16 16
 <body cds-text="body" cds-theme="dark">
17 17
   <app-root></app-root>

Loading…
Cancel
Save