Fix FluenceJS node example

This commit is contained in:
Pavel Murygin 2022-02-09 15:14:41 +03:00
parent 1d1cd3f90c
commit e34e15afa8
5 changed files with 13 additions and 3 deletions

View File

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

View File

@ -1,6 +1,6 @@
import "./calc.aqua"
const PEER ?= "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3"
const PEER ?= "12D3KooWKETqJdR26urWDbkRAVRdPQhcYNSJNGMBTn1zuE9kjQmo"
const RELAY ?= "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e"
func demoCalculation() -> f32:

View File

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

View File

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

View File

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