2021-04-12 02:07:18 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2021-09-10 19:48:26 +03:00
|
|
|
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
2021-09-08 13:00:24 +03:00
|
|
|
import { krasnodar } from '@fluencelabs/fluence-network-environment';
|
2023-02-21 11:25:00 +04:00
|
|
|
import { helloWorld, registerStringExtra } from './compiled/examples/helloWorld.js';
|
2021-04-12 02:07:18 +03:00
|
|
|
|
|
|
|
const main = async () => {
|
2021-05-25 13:35:52 +03:00
|
|
|
// each compiled aqua function require a connected client
|
2021-09-10 19:48:26 +03:00
|
|
|
await Fluence.start({ connectTo: krasnodar[0] });
|
2021-05-25 13:35:52 +03:00
|
|
|
|
|
|
|
// example to how register a local service
|
|
|
|
// it could be used in aqua code as follows
|
|
|
|
// service StringExtra("service-id"):
|
|
|
|
// addNameToHello: string -> string
|
|
|
|
// see more in helloWorld.aqua
|
2021-09-08 13:00:24 +03:00
|
|
|
registerStringExtra({
|
|
|
|
addNameToHello: (arg0) => {
|
|
|
|
return `Hello, ${arg0}!`;
|
|
|
|
},
|
|
|
|
});
|
2021-05-25 13:35:52 +03:00
|
|
|
|
|
|
|
// call an aqua function thet presented in ../aqua/helloWorld.aqua
|
2021-09-08 13:00:24 +03:00
|
|
|
const result = await helloWorld('NAME');
|
|
|
|
console.log(result);
|
2021-04-28 20:16:27 +03:00
|
|
|
|
2021-10-07 13:55:10 +03:00
|
|
|
// uncomment to play with examples
|
2022-08-05 17:09:51 +03:00
|
|
|
// await runExamples();
|
2021-10-07 13:55:10 +03:00
|
|
|
|
2021-09-08 13:00:24 +03:00
|
|
|
process.exit(0);
|
2021-04-12 02:07:18 +03:00
|
|
|
};
|
|
|
|
|
2021-04-28 03:26:26 +03:00
|
|
|
main().catch((err) => {
|
2021-09-08 13:00:24 +03:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
});
|