mirror of
https://github.com/EvernodeXRPL/hp-devkit.git
synced 2026-04-29 15:37:58 +00:00
Added bash script to launch the hp-devkit in linux (#2)
This commit is contained in:
committed by
GitHub
parent
b2996fbcea
commit
5b6bf10fdc
2
docker/code-templates/nodejs/starter-contract/.gitignore
vendored
Normal file
2
docker/code-templates/nodejs/starter-contract/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
index.js
|
||||
41
docker/code-templates/nodejs/starter-contract/package-lock.json
generated
Normal file
41
docker/code-templates/nodejs/starter-contract/package-lock.json
generated
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "_projname_",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "_projname_",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@vercel/ncc": "0.34.0",
|
||||
"hotpocket-nodejs-contract": "0.5.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@vercel/ncc": {
|
||||
"version": "0.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz",
|
||||
"integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==",
|
||||
"bin": {
|
||||
"ncc": "dist/ncc/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/hotpocket-nodejs-contract": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/hotpocket-nodejs-contract/-/hotpocket-nodejs-contract-0.5.6.tgz",
|
||||
"integrity": "sha512-Q52cE5lYGoVGvdUl3cDYixAh27QxzFF6JFaOm1+HoXU36dsKxZfDeJLGCfnDf4XcgEytM2mPE9STWUV+mdHqEg=="
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/ncc": {
|
||||
"version": "0.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz",
|
||||
"integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A=="
|
||||
},
|
||||
"hotpocket-nodejs-contract": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/hotpocket-nodejs-contract/-/hotpocket-nodejs-contract-0.5.6.tgz",
|
||||
"integrity": "sha512-Q52cE5lYGoVGvdUl3cDYixAh27QxzFF6JFaOm1+HoXU36dsKxZfDeJLGCfnDf4XcgEytM2mPE9STWUV+mdHqEg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ const dataFile = 'datafile.txt'
|
||||
export class _projname_ {
|
||||
sendOutput; // This function must be wired up by the caller.
|
||||
|
||||
async handleRequest(userPublicKey, message, isReadOnly) {
|
||||
async handleRequest(user, 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(userPublicKey, {
|
||||
await this.sendOutput(user, {
|
||||
type: 'data_result',
|
||||
data: data
|
||||
})
|
||||
@@ -28,7 +28,7 @@ export class _projname_ {
|
||||
await this.setData(message.data);
|
||||
}
|
||||
else {
|
||||
await this.sendOutput(userPublicKey, {
|
||||
await this.sendOutput(user, {
|
||||
type: 'error',
|
||||
error: 'Set data not supported in readonly mode'
|
||||
})
|
||||
@@ -36,7 +36,7 @@ export class _projname_ {
|
||||
|
||||
}
|
||||
else {
|
||||
await this.sendOutput(userPublicKey, {
|
||||
await this.sendOutput(user, {
|
||||
type: 'error',
|
||||
error: 'Unknown message type'
|
||||
})
|
||||
|
||||
@@ -10,9 +10,7 @@ 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 (userPublicKey, output) => {
|
||||
// In HotPocket, each user is represented by their Ed25519 public key.
|
||||
const user = ctx.users.find(userPublicKey);
|
||||
app.sendOutput = async (user, output) => {
|
||||
await user.send(output)
|
||||
}
|
||||
|
||||
@@ -40,7 +38,7 @@ async function contract(ctx) {
|
||||
const message = JSON.parse(buf);
|
||||
|
||||
// Pass the JSON message to our application logic component.
|
||||
await app.handleRequest(userPublicKey, message, isReadOnly);
|
||||
await app.handleRequest(user, message, isReadOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user