import { Fluence } from "@fluencelabs/fluence"; import { krasnodar } from "@fluencelabs/fluence-network-environment"; import { registerCalc, CalcDef } from "./_aqua/calc"; class Calc implements CalcDef { private _state: number = 0; add(n: number) { this._state += n; } subtract(n: number) { this._state -= n; } multiply(n: number) { this._state *= n; } divide(n: number) { this._state /= n; } reset() { this._state = 0; } getResult() { return this._state; } } const keypress = async () => { process.stdin.setRawMode(true); return new Promise((resolve) => process.stdin.once("data", () => { process.stdin.setRawMode(false); resolve(); }) ); }; async function main() { await Fluence.start({ connectTo: krasnodar[0], }); registerCalc(new Calc()); console.log("application started"); console.log("peer id is: ", Fluence.getStatus().peerId); console.log("relay is: ", Fluence.getStatus().relayPeerId); console.log("press any key to continue"); await keypress(); await Fluence.stop(); } main();