2021-04-12 02:07:18 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2021-04-15 11:51:02 +03:00
|
|
|
import {createClient, registerServiceFunction} from "@fluencelabs/fluence";
|
2021-04-23 17:21:58 +03:00
|
|
|
import {testNet} from "@fluencelabs/fluence-network-environment";
|
2021-05-25 13:35:52 +03:00
|
|
|
import {helloWorld} from "./compiled/helloWorld";
|
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
|
|
|
|
const client = await createClient(testNet[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
|
|
|
|
registerServiceFunction(client, "service-id", "addNameToHello", (args: any[], _) => {
|
|
|
|
return `Hello, ${args[0]}!`
|
|
|
|
})
|
|
|
|
|
|
|
|
// call an aqua function thet presented in ../aqua/helloWorld.aqua
|
|
|
|
const result = await helloWorld(client, "NAME");
|
|
|
|
console.log(result)
|
2021-04-28 20:16:27 +03:00
|
|
|
|
2021-04-26 19:14:07 +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-05-25 13:35:52 +03:00
|
|
|
console.log(err)
|
|
|
|
process.exit(1)
|
2021-04-28 03:26:26 +03:00
|
|
|
})
|