diff --git a/backend-assemblyscript/step3-finished-app/assembly/model.ts b/backend-assemblyscript/step3-finished-app/assembly/model.ts index 34a503f..8439325 100644 --- a/backend-assemblyscript/step3-finished-app/assembly/model.ts +++ b/backend-assemblyscript/step3-finished-app/assembly/model.ts @@ -10,7 +10,7 @@ export function addMessage(message: string, username: string): void { query(request); } -export function getMessages(username: string | null, offset: u32, count: u32): string { +export function getMessages(username: string | null, offset: i64, count: i64): string { let limitClause = ` LIMIT ` + count.toString() + ` OFFSET ` + offset.toString() + ` `; if (username) { let whereClause = ` WHERE username = "` + username + `" `; diff --git a/backend-assemblyscript/step3-finished-app/assembly/request.ts b/backend-assemblyscript/step3-finished-app/assembly/request.ts index 8d8a2a8..4ab3a4b 100644 --- a/backend-assemblyscript/step3-finished-app/assembly/request.ts +++ b/backend-assemblyscript/step3-finished-app/assembly/request.ts @@ -26,10 +26,10 @@ export class PostRequest extends Request { export class FetchRequest extends Request { public readonly username: string | null; - public readonly offset: u32; - public readonly count: u32; + public readonly offset: i64; + public readonly count: i64; - constructor(username: string | null, offset: u32, count: u32) { + constructor(username: string | null, offset: i64, count: i64) { super(); this.action = Action.Fetch; this.username = username; @@ -78,13 +78,18 @@ class RequestJSONEventsHandler extends JSONHandler { public message: string; public username: string; public filter_handle: string | null; - public offset: u32; - public count: u32; + public offset: i64 = 0; + public count: i64 = 100; + + setInteger(name: string, value: i64): void { + if (name == "offset") { + this.offset = value; + } else if (name == "count") { + this.count = value; + } + } setString(name: string, value: string): void { - this.offset = 0; - this.count = 100; - if (name == "action") { this.action = value; } else if (name == "message") { @@ -92,11 +97,6 @@ class RequestJSONEventsHandler extends JSONHandler { } else if (name == "username") { this.username = value; this.filter_handle = value; - } else if (name == "offset") { - this.offset = U32.parseInt(value); - } else if (name == "count") { - this.count = U32.parseInt(value); } - // json scheme is not strict, so we won't throw an error on excess fields } } diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index 5eac968..617b873 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -9,6 +9,28 @@ import ConnectionToggle from "./ConnectionToggle"; class App extends Component { + componentDidMount() { + console.log(` + +Hello, Fluencer! +Thank you for trying Fluence out! +You can find docs at https://fluence.dev +Check out http://dash.fluence.network to deploy your own SQL DB instance +Check out https://github.com/fluencelabs/tutorials for more Fluence examples +If you have any questions, feel free to join our Discord https://fluence.chat :) + +You can send requests to Fluence network straight from console: + +// send the message and don't wait for a response +fluenceSession.requestAsync('{"action": "Post", "message": "Hello, Fluence!", "username": "fluencer"}') + +// get the last message, decode response as a string and print it in the console +fluenceSession.request('{"action": "Fetch", "offset": 0, "limit": 1}').then((r) => r.asString()).then(console.log) + + +`) + } + render() { return (