From 7d9dda797173e038e358a6f1effba6285bb2c3cd Mon Sep 17 00:00:00 2001 From: ravinsp <33562092+ravinsp@users.noreply.github.com> Date: Thu, 14 Jul 2022 21:06:12 +0530 Subject: [PATCH] Updated nodejs contract lib version. --- .../code-templates/nodejs/starter-contract/package.json | 2 +- .../nodejs/starter-contract/src/_projname_.js | 8 ++++---- .../nodejs/starter-contract/src/contract.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/code-templates/nodejs/starter-contract/package.json b/docker/code-templates/nodejs/starter-contract/package.json index 4ece906..1c74d1a 100644 --- a/docker/code-templates/nodejs/starter-contract/package.json +++ b/docker/code-templates/nodejs/starter-contract/package.json @@ -7,7 +7,7 @@ "start": "npm run build && hpdevkit deploy dist" }, "dependencies": { - "hotpocket-nodejs-contract": "0.5.3", + "hotpocket-nodejs-contract": "0.5.4", "@vercel/ncc": "0.34.0" } } \ No newline at end of file diff --git a/docker/code-templates/nodejs/starter-contract/src/_projname_.js b/docker/code-templates/nodejs/starter-contract/src/_projname_.js index e4667bd..2a302ae 100644 --- a/docker/code-templates/nodejs/starter-contract/src/_projname_.js +++ b/docker/code-templates/nodejs/starter-contract/src/_projname_.js @@ -7,7 +7,7 @@ const dataFile = 'datafile.txt' export class _projname_ { sendOutput; // This function must be wired up by the caller. - async handleRequest(userPubKey, message, isReadOnly) { + async handleRequest(userPublicKey, message, isReadOnly) { // This sample application defines two simple messages. 'get' and 'set'. // It's up to the application to decide the structure and contents of messages. @@ -16,7 +16,7 @@ export class _projname_ { // Retrieved previously saved data and return to the user. const data = await this.getData(); - await this.sendOutput(userPubKey, { + await this.sendOutput(userPublicKey, { type: 'data_result', data: data }) @@ -28,7 +28,7 @@ export class _projname_ { await this.setData(message.data); } else { - await this.sendOutput(userPubKey, { + await this.sendOutput(userPublicKey, { type: 'error', error: 'Set data not supported in readonly mode' }) @@ -36,7 +36,7 @@ export class _projname_ { } else { - await this.sendOutput(userPubKey, { + await this.sendOutput(userPublicKey, { type: 'error', error: 'Unknown message type' }) diff --git a/docker/code-templates/nodejs/starter-contract/src/contract.js b/docker/code-templates/nodejs/starter-contract/src/contract.js index 50bd552..67f8637 100644 --- a/docker/code-templates/nodejs/starter-contract/src/contract.js +++ b/docker/code-templates/nodejs/starter-contract/src/contract.js @@ -10,9 +10,9 @@ async function contract(ctx) { const app = new _projname_(); // Wire-up output emissions from the application before we pass user inputs to it. - app.sendOutput = async (userPubKey, output) => { + app.sendOutput = async (userPublicKey, output) => { // In Hot Pocket, each user is represented by their Ed25519 public key. - const user = ctx.users.find(userPubKey); + const user = ctx.users.find(userPublicKey); await user.send(output) } @@ -40,7 +40,7 @@ async function contract(ctx) { const message = JSON.parse(buf); // Pass the JSON message to our application logic component. - await app.handleRequest(userPubKey, message, isReadOnly); + await app.handleRequest(userPublicKey, message, isReadOnly); } } }