mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-06-24 09:21:47 +00:00
update a client, delete as unknown
, add par, on, complex example with multiple imports
This commit is contained in:
BIN
aqua-hll.jar
BIN
aqua-hll.jar
Binary file not shown.
992
package-lock.json
generated
992
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@
|
|||||||
"typescript": "^4.2.4"
|
"typescript": "^4.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/fluence": "0.9.34",
|
"@fluencelabs/fluence": "0.9.39",
|
||||||
"@fluencelabs/fluence-network-environment": "1.0.8"
|
"@fluencelabs/fluence-network-environment": "1.0.8"
|
||||||
},
|
},
|
||||||
"description": "Minimal template for aquamarine project."
|
"description": "Minimal template for aquamarine project."
|
||||||
|
10
src/aqua/complex.aqua
Normal file
10
src/aqua/complex.aqua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import "helloWorld.aqua"
|
||||||
|
import "println.aqua"
|
||||||
|
import "on.aqua"
|
||||||
|
import "func.aqua"
|
||||||
|
|
||||||
|
func doStuff(a: string):
|
||||||
|
str <- Srv.str()
|
||||||
|
par Println.print(str)
|
||||||
|
par on a:
|
||||||
|
Peer.identify()
|
@ -7,4 +7,10 @@ service Peer("peer"):
|
|||||||
func getPeerExternalAddresses(otherNodePeerId: string) -> []string:
|
func getPeerExternalAddresses(otherNodePeerId: string) -> []string:
|
||||||
on otherNodePeerId:
|
on otherNodePeerId:
|
||||||
res <- Peer.identify()
|
res <- Peer.identify()
|
||||||
|
<- res.external_addresses
|
||||||
|
|
||||||
|
-- it could be possible to use `via` to built complex routes
|
||||||
|
func getDistantAddresses(target: string, viaNode: string) -> []string:
|
||||||
|
on target via viaNode:
|
||||||
|
res <- Peer.identify()
|
||||||
<- res.external_addresses
|
<- res.external_addresses
|
7
src/aqua/par.aqua
Normal file
7
src/aqua/par.aqua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
service ParAbb("parabb"):
|
||||||
|
call: -> string
|
||||||
|
|
||||||
|
func parFunc( node: string ):
|
||||||
|
par y <- ParAbb.call()
|
||||||
|
par on node:
|
||||||
|
t <- ParAbb.call()
|
6
src/complex.ts
Normal file
6
src/complex.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import {FluenceClient} from "@fluencelabs/fluence";
|
||||||
|
import {doStuff} from "./compiled/complex";
|
||||||
|
|
||||||
|
export async function complexCall(client: FluenceClient) {
|
||||||
|
await doStuff(client, client.relayPeerId!)
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import {FluenceClient} from "@fluencelabs/fluence";
|
import {FluenceClient} from "@fluencelabs/fluence";
|
||||||
import {foldFunc, parFoldFunc} from "./compiled/fold";
|
import {foldFunc, parFoldFunc} from "./compiled/fold";
|
||||||
|
|
||||||
export async function foldCall(client: FluenceClient) {
|
export async function foldCall(client: FluenceClient) {
|
||||||
foldFunc(client, ["1", "2", "3"])
|
await foldFunc(client, ["1", "2", "3"])
|
||||||
parFoldFunc(client, ["4", "5", "6"])
|
await parFoldFunc(client, ["4", "5", "6"])
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
|
|||||||
|
|
||||||
export async function funcCall(client: FluenceClient) {
|
export async function funcCall(client: FluenceClient) {
|
||||||
registerServiceFunction(client, "srv", "str", (args: any[], _) => {
|
registerServiceFunction(client, "srv", "str", (args: any[], _) => {
|
||||||
return `some str` as unknown as object
|
return `some str`
|
||||||
})
|
})
|
||||||
|
|
||||||
const res = await testFunc(client);
|
const res = await testFunc(client);
|
||||||
|
@ -3,7 +3,7 @@ import {helloWorld} from "./compiled/helloWorld";
|
|||||||
|
|
||||||
export async function helloWorldCall(client: FluenceClient) {
|
export async function helloWorldCall(client: FluenceClient) {
|
||||||
registerServiceFunction(client, "StringExtra", "addNameToHello", (args: any[], _) => {
|
registerServiceFunction(client, "StringExtra", "addNameToHello", (args: any[], _) => {
|
||||||
return `Hello, ${args[0]}!` as unknown as object
|
return `Hello, ${args[0]}!`
|
||||||
})
|
})
|
||||||
|
|
||||||
const hello = await helloWorld(client, "NAME");
|
const hello = await helloWorld(client, "NAME");
|
||||||
|
@ -2,6 +2,6 @@ import {FluenceClient} from "@fluencelabs/fluence";
|
|||||||
import {ifElseCall} from "./compiled/if";
|
import {ifElseCall} from "./compiled/if";
|
||||||
|
|
||||||
export async function ifCall(client: FluenceClient) {
|
export async function ifCall(client: FluenceClient) {
|
||||||
ifElseCall(client, false)
|
await ifElseCall(client, false)
|
||||||
ifElseCall(client, true)
|
await ifElseCall(client, true)
|
||||||
}
|
}
|
11
src/index.ts
11
src/index.ts
@ -14,6 +14,8 @@ import {funcCall} from "./funcCall";
|
|||||||
import {helloWorldCall} from "./helloWorldCall";
|
import {helloWorldCall} from "./helloWorldCall";
|
||||||
import {foldCall} from "./foldCall";
|
import {foldCall} from "./foldCall";
|
||||||
import {ifCall} from "./if";
|
import {ifCall} from "./if";
|
||||||
|
import {parCall} from "./parCall";
|
||||||
|
import {complexCall} from "./complex";
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const client = await createClient(testNet[0]);
|
const client = await createClient(testNet[0]);
|
||||||
@ -23,15 +25,16 @@ const main = async () => {
|
|||||||
return {}
|
return {}
|
||||||
})
|
})
|
||||||
|
|
||||||
callArrowCall(client)
|
await callArrowCall(client)
|
||||||
foldCall(client)
|
await foldCall(client)
|
||||||
ifCall(client)
|
await ifCall(client)
|
||||||
|
await parCall(client)
|
||||||
|
|
||||||
await helloWorldCall(client)
|
await helloWorldCall(client)
|
||||||
await funcCall(client)
|
await funcCall(client)
|
||||||
await onCall(client)
|
await onCall(client)
|
||||||
await dataAliasCall(client)
|
await dataAliasCall(client)
|
||||||
|
await complexCall(client)
|
||||||
|
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
|
10
src/parCall.ts
Normal file
10
src/parCall.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import {FluenceClient, registerServiceFunction} from "@fluencelabs/fluence";
|
||||||
|
import {parFunc} from "./compiled/par";
|
||||||
|
|
||||||
|
export async function parCall(client: FluenceClient) {
|
||||||
|
registerServiceFunction(client, "parabb", "call", (args: any[], _) => {
|
||||||
|
return `Hello, ${args[0]}!`
|
||||||
|
})
|
||||||
|
|
||||||
|
await parFunc(client, client.relayPeerId!)
|
||||||
|
}
|
Reference in New Issue
Block a user