From e34e15afa8c78c9b7c1ff76441d48e2f340fd16f Mon Sep 17 00:00:00 2001 From: Pavel Murygin Date: Wed, 9 Feb 2022 15:14:41 +0300 Subject: [PATCH] Fix FluenceJS node example --- fluence-js-examples/hello-world/package.json | 1 + .../node-example/aqua/demo-calculation.aqua | 2 +- fluence-js-examples/node-example/package.json | 1 + fluence-js-examples/node-example/run_calculation.sh | 3 +++ fluence-js-examples/node-example/src/index.ts | 9 +++++++-- 5 files changed, 13 insertions(+), 3 deletions(-) create mode 100755 fluence-js-examples/node-example/run_calculation.sh diff --git a/fluence-js-examples/hello-world/package.json b/fluence-js-examples/hello-world/package.json index e604128..7558358 100644 --- a/fluence-js-examples/hello-world/package.json +++ b/fluence-js-examples/hello-world/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "scripts": { + "prestart": "npm run compile-aqua", "start": "node -r ts-node/register src/index.ts", "compile-aqua": "aqua --import . -i ./aqua/ -o ./src/_aqua", "watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\"" diff --git a/fluence-js-examples/node-example/aqua/demo-calculation.aqua b/fluence-js-examples/node-example/aqua/demo-calculation.aqua index 06f5044..be7c68b 100644 --- a/fluence-js-examples/node-example/aqua/demo-calculation.aqua +++ b/fluence-js-examples/node-example/aqua/demo-calculation.aqua @@ -1,6 +1,6 @@ import "./calc.aqua" -const PEER ?= "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3" +const PEER ?= "12D3KooWKETqJdR26urWDbkRAVRdPQhcYNSJNGMBTn1zuE9kjQmo" const RELAY ?= "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e" func demoCalculation() -> f32: diff --git a/fluence-js-examples/node-example/package.json b/fluence-js-examples/node-example/package.json index c309431..9bce9db 100644 --- a/fluence-js-examples/node-example/package.json +++ b/fluence-js-examples/node-example/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "scripts": { + "prestart": "npm run compile-aqua", "start": "node -r ts-node/register src/index.ts", "compile-aqua": "aqua --import . -i ./aqua/ -o ./src/_aqua", "watch-aqua": "chokidar \"**/*.aqua\" -c \"npm run compile-aqua\"" diff --git a/fluence-js-examples/node-example/run_calculation.sh b/fluence-js-examples/node-example/run_calculation.sh new file mode 100755 index 0000000..bae8768 --- /dev/null +++ b/fluence-js-examples/node-example/run_calculation.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +npx aqua run --input ./aqua/demo-calculation.aqua --func 'demoCalculation()' --addr /dns4/stage.fluence.dev/tcp/19001/wss/p2p/12D3KooWHCJbJKGDfCgHSoCuK9q4STyRnVveqLoXAPBbXHTZx9Cv diff --git a/fluence-js-examples/node-example/src/index.ts b/fluence-js-examples/node-example/src/index.ts index ff45e12..1db12b1 100644 --- a/fluence-js-examples/node-example/src/index.ts +++ b/fluence-js-examples/node-example/src/index.ts @@ -1,4 +1,4 @@ -import { Fluence } from "@fluencelabs/fluence"; +import { Fluence, KeyPair } from "@fluencelabs/fluence"; import { krasnodar } from "@fluencelabs/fluence-network-environment"; import { registerCalc, CalcDef } from "./_aqua/calc"; @@ -40,9 +40,14 @@ const keypress = async () => { ); }; +const relay = krasnodar[0]; +// generated with `npx aqua create_keypair` +const skBytes = "tOpsT08fvYMnRypj3VtSoqWMN5W/AptKsP39yanlkg4="; + async function main() { await Fluence.start({ - connectTo: krasnodar[0], + connectTo: relay, + KeyPair: await KeyPair.fromEd25519SK(Buffer.from(skBytes, "base64")), }); registerCalc(new Calc());