Updated nodejs contract lib version.

This commit is contained in:
ravinsp
2022-07-14 21:06:12 +05:30
parent 5e6d8e519a
commit 7d9dda7971
3 changed files with 8 additions and 8 deletions

View File

@@ -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"
}
}

View File

@@ -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'
})

View File

@@ -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);
}
}
}