diff --git a/package-lock.json b/package-lock.json index 75eadaa..d7f4c00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "buffer": "^6.0.3", "chai": "^4.3.4", "node-fetch": "^2.6.1", - "rjsvm": "^0.3.0", + "rjsvm": "^0.3.2", "xrpio": "^0.3.0", "xrpl": "^2.7.0" }, @@ -3119,9 +3119,9 @@ } }, "node_modules/rjsvm": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz", - "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz", + "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==", "dependencies": { "axios": "^1.7.7", "stream-http": "^3.2.0", @@ -6618,9 +6618,9 @@ } }, "rjsvm": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz", - "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz", + "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==", "requires": { "axios": "^1.7.7", "stream-http": "^3.2.0", diff --git a/package.json b/package.json index 7e2c819..471bc31 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "buffer": "^6.0.3", "chai": "^4.3.4", "node-fetch": "^2.6.1", - "rjsvm": "^0.3.0", + "rjsvm": "^0.3.2", "xrpio": "^0.3.0", "xrpl": "^2.7.0" }, diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json index 9078df9..9227209 100644 --- a/src/frontend/package-lock.json +++ b/src/frontend/package-lock.json @@ -26,7 +26,7 @@ "buffer": "^6.0.3", "modern-normalize": "^1.1.0", "process": "^0.11.10", - "rjsvm": "^0.3.0", + "rjsvm": "^0.3.2", "rxjs": "~7.5.0", "tslib": "^2.3.0", "xrpio": "^0.3.0", @@ -11639,9 +11639,9 @@ } }, "node_modules/rjsvm": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz", - "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz", + "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==", "dependencies": { "axios": "^1.7.7", "stream-http": "^3.2.0", @@ -22544,9 +22544,9 @@ } }, "rjsvm": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.0.tgz", - "integrity": "sha512-BQSOA7ao2feNl5dyhaAH3A2LJkj7zr3fIsWktlGFbICOa9NZGuZiwLIehf/YaeMhDCOzYe10troHlhU8BCis7w==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/rjsvm/-/rjsvm-0.3.2.tgz", + "integrity": "sha512-plaK9+hlTUlEA9W7fZo1wOjnIrwxC0oiFPogvScW/vcHEMsVHJ8Vlmk8hMbhA29X6DA0+VezDtnQ9XFIdLLMSg==", "requires": { "axios": "^1.7.7", "stream-http": "^3.2.0", diff --git a/src/frontend/package.json b/src/frontend/package.json index 1267268..b8f3e80 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -30,7 +30,7 @@ "buffer": "^6.0.3", "modern-normalize": "^1.1.0", "process": "^0.11.10", - "rjsvm": "^0.3.0", + "rjsvm": "^0.3.2", "rxjs": "~7.5.0", "tslib": "^2.3.0", "xrpio": "^0.3.0", diff --git a/src/frontend/src/app/app.component.html b/src/frontend/src/app/app.component.html index 9f6090b..00b1643 100644 --- a/src/frontend/src/app/app.component.html +++ b/src/frontend/src/app/app.component.html @@ -1,19 +1,66 @@
+
-
+
+
+

Wallets in use

+ +
+ +
+ + +
+ + + + + + + + +
+ +
+
+ + +
+ + + + + + + + +
+
+ +
+
+
+
+ +
+

Shout Something

@@ -21,20 +68,27 @@
+ [(ngModel)]="newShout.title" name="title" size="45" /> + [(ngModel)]="newShout.body" name="body" cols="43" rows="15"> + [(ngModel)]="newShout.from" name="from" size="45" />
@@ -42,7 +96,7 @@
-
+

Syncing application state

@@ -56,9 +110,14 @@
-
+
-

{{shout.title}}

+

+ {{shout.title}} + + + +

{{shout.body}} diff --git a/src/frontend/src/app/app.component.ts b/src/frontend/src/app/app.component.ts index 88bddf3..5d184d6 100644 --- a/src/frontend/src/app/app.component.ts +++ b/src/frontend/src/app/app.component.ts @@ -1,12 +1,15 @@ import { Component, OnInit } from '@angular/core'; import { ShoutboxDataService } from './services/ShoutboxData.service'; +import { makeTestnetWallet } from './util/TestnetUtils'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], }) -export class AppComponent implements OnInit{ +export class AppComponent implements OnInit { + lastMessageHash = "" + contractAddress = ""; initializing = true waiting = false title = 'httXrp Shoutbox'; @@ -15,34 +18,53 @@ export class AppComponent implements OnInit{ newShout = { title: "", body: "", - from: "" + from: "", + hash: "" + } + userWallet = { + address: "", + secret: "" + } + drainWallet = { + address: "", + secret: "" } constructor( private dataService: ShoutboxDataService - ){} + ) { + this.contractAddress = dataService.getContractAddress() + } submitShout = () => { this.sending = true this.dataService.submitShout(this.newShout) - .then(() => { - this.newShout = { - title: "", - body: "", - from: "" - } - }) - .finally(() => { - this.sending = false - this.waiting = true - setTimeout(() => {this.waiting = false}, 20000) - }) + .then((hash) => { + this.newShout = { + title: "", + body: "", + from: "", + hash: "" + } + this.lastMessageHash = hash + }) + .finally(() => { + this.sending = false + this.waiting = true + setTimeout(() => { this.waiting = false }, 20000) + }) } - ngOnInit(){ - this.dataService.initialize((shout:any) => { - this.shouts.unshift(shout) - this.initializing = false + ngOnInit() { + Promise.all([makeTestnetWallet(), makeTestnetWallet()]).then(([userWallet, drainWallet]) => { + console.log(userWallet, drainWallet) + this.userWallet = userWallet + this.drainWallet = drainWallet + + this.dataService.initialize((shout: any) => { + this.shouts.unshift(shout) + this.initializing = false + }, userWallet, drainWallet) }) } } diff --git a/src/frontend/src/app/app.module.ts b/src/frontend/src/app/app.module.ts index 4752ecc..453abfc 100644 --- a/src/frontend/src/app/app.module.ts +++ b/src/frontend/src/app/app.module.ts @@ -6,7 +6,7 @@ import { AppComponent } from './app.component'; import { CdsModule } from '@cds/angular'; import { ClarityModule } from '@clr/angular'; -import { ClarityIcons, homeIcon } from '@cds/core/icon'; +import { ClarityIcons, homeIcon, linkIcon } from '@cds/core/icon'; import { ShoutboxDataService } from './services/ShoutboxData.service'; import { FormsModule } from '@angular/forms'; @@ -27,5 +27,6 @@ import { FormsModule } from '@angular/forms'; export class AppModule { constructor() { ClarityIcons.addIcons(homeIcon); + ClarityIcons.addIcons(linkIcon); } } diff --git a/src/frontend/src/app/services/ShoutboxData.service.ts b/src/frontend/src/app/services/ShoutboxData.service.ts index f7deb6c..1d3d650 100644 --- a/src/frontend/src/app/services/ShoutboxData.service.ts +++ b/src/frontend/src/app/services/ShoutboxData.service.ts @@ -1,5 +1,4 @@ import { Injectable } from "@angular/core"; -import { makeTestnetWallet } from "../util/TestnetUtils"; import { z } from 'zod'; declare const RJSVM: any; @@ -16,15 +15,12 @@ export class ShoutboxDataService { private dataWriter = undefined as any public submitShout = async (shout: any) => { - await this.dataWriter.callEndpoint('submit', shout, 10) + return await this.dataWriter.callEndpoint('submit', shout, 10) } + public getContractAddress = () => listeningAddress - initialize = async (onData:Function) => { - - const [userWallet, drainWallet] = await Promise.all([makeTestnetWallet(), makeTestnetWallet()]) - - console.log(userWallet, drainWallet) + initialize = async (onData:Function, userWallet?:any, drainWallet?:any) => { this.dataWriter = new Datawriter({ receiveAddress: drainWallet.address, @@ -74,8 +70,8 @@ export class ShoutboxDataService { const RJSVM_Contract = { submit: { - implementation: function (env:any, shout:any) { - console.log(shout); + implementation: function (env:any, shout: any) { + shout.hash = env.hash; (this as any).state.shouts.unshift(shout) }, visibility: 'public', diff --git a/src/frontend/src/index.html b/src/frontend/src/index.html index 64aef13..18ede80 100644 --- a/src/frontend/src/index.html +++ b/src/frontend/src/index.html @@ -11,7 +11,7 @@ - +