aqua-playground/src/index.ts

31 lines
946 B
TypeScript
Raw Normal View History

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";
import {helloWorld} from "./compiled/helloWorld";
2021-04-12 02:07:18 +03:00
const main = async () => {
// 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
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)
2021-04-28 03:26:26 +03:00
})