Browse Source

Work after api break

master
nitowa 1 month 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
     "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
-    "xrpio": "^0.2.1",
24
+    "rjsvm": "^0.3.0",
25
+    "xrpio": "^0.3.0",
25
     "xrpl": "^2.7.0"
26
     "xrpl": "^2.7.0"
26
   },
27
   },
27
   "devDependencies": {
28
   "devDependencies": {

+ 3
- 3
src/Configuration.ts View File

1
 
1
 
2
 export const config = {
2
 export const config = {
3
   "oracle": true,
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
   "rippleNode": "wss://s.altnet.rippletest.net:51233",
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
     "@cds/core": "6.6.2",
26
     "@cds/core": "6.6.2",
27
     "@clr/angular": "^15.12.0",
27
     "@clr/angular": "^15.12.0",
28
     "@clr/ui": "^15.12.0",
28
     "@clr/ui": "^15.12.0",
29
+    "axios": "^1.7.7",
29
     "buffer": "^6.0.3",
30
     "buffer": "^6.0.3",
30
     "modern-normalize": "^1.1.0",
31
     "modern-normalize": "^1.1.0",
31
     "process": "^0.11.10",
32
     "process": "^0.11.10",
33
+    "rjsvm": "^0.3.0",
32
     "rxjs": "~7.5.0",
34
     "rxjs": "~7.5.0",
33
     "tslib": "^2.3.0",
35
     "tslib": "^2.3.0",
36
+    "xrpio": "^0.3.0",
34
     "zod": "^3.22.4",
37
     "zod": "^3.22.4",
35
     "zone.js": "~0.11.4"
38
     "zone.js": "~0.11.4"
36
   },
39
   },

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

20
 
20
 
21
               <div class="card-block">
21
               <div class="card-block">
22
                 <clr-input-container>
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
                 </clr-input-container>
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
                 <clr-input-container>
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
                 </clr-input-container>
31
                 </clr-input-container>
30
               </div>
32
               </div>
31
               <div class="card-footer">
33
               <div class="card-footer">
32
                 <button class="btn btn-success" (click)="submitShout()"
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
               </div>
38
               </div>
35
             </form>
39
             </form>
36
           </div>
40
           </div>
37
         </div>
41
         </div>
38
       </div>
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
       <div class="clr-row" *ngFor="let shout of shouts">
58
       <div class="clr-row" *ngFor="let shout of shouts">
41
         <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
59
         <div class="clr-col-lg-5 clr-col-md-8 clr-col-12">
42
           <div class="card">
60
           <div class="card">

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

7
   styleUrls: ['./app.component.scss'],
7
   styleUrls: ['./app.component.scss'],
8
 })
8
 })
9
 export class AppComponent implements OnInit{
9
 export class AppComponent implements OnInit{
10
+  initializing = true
11
+  waiting = false
10
   title = 'httXrp Shoutbox';
12
   title = 'httXrp Shoutbox';
11
   shouts: any[] = []
13
   shouts: any[] = []
12
   sending = false
14
   sending = false
32
     })
34
     })
33
     .finally(() => {
35
     .finally(() => {
34
       this.sending = false
36
       this.sending = false
37
+      this.waiting = true
38
+      setTimeout(() => {this.waiting = false}, 20000)
35
     })
39
     })
36
   }
40
   }
37
 
41
 
38
   ngOnInit(){
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
 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 } from '@cds/core/icon';
10
-import { ShoutboxDataService, initShoutboxSvc } 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
 
13
 @NgModule({
13
 @NgModule({
21
   ],
21
   ],
22
   providers: [
22
   providers: [
23
     ShoutboxDataService,
23
     ShoutboxDataService,
24
-    {
25
-      provide: APP_INITIALIZER,
26
-      useFactory: initShoutboxSvc,
27
-      deps: [ShoutboxDataService],
28
-      multi: true
29
-    }
30
   ],
24
   ],
31
   bootstrap: [AppComponent],
25
   bootstrap: [AppComponent],
32
 })
26
 })

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

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