aqua-playground/src/index.ts

36 lines
1.0 KiB
TypeScript
Raw Normal View History

2021-04-12 02:07:18 +03:00
#!/usr/bin/env node
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
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 () => {
// each compiled aqua function require a connected client
await Fluence.start({ connectTo: krasnodar[0] });
// 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
registerStringExtra({
addNameToHello: (arg0) => {
return `Hello, ${arg0}!`;
},
});
// call an aqua function thet presented in ../aqua/helloWorld.aqua
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
process.exit(0);
2021-04-12 02:07:18 +03:00
};
2021-04-28 03:26:26 +03:00
main().catch((err) => {
console.log(err);
process.exit(1);
});