mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-04-28 13:12:16 +00:00
204 lines
6.3 KiB
TypeScript
204 lines
6.3 KiB
TypeScript
|
/**
|
||
|
*
|
||
|
* This file is auto-generated. Do not edit manually: changes may be erased.
|
||
|
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
|
||
|
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
|
||
|
* Aqua version: 0.7.4-336
|
||
|
*
|
||
|
*/
|
||
|
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
|
||
|
import {
|
||
|
CallParams,
|
||
|
callFunction,
|
||
|
registerService,
|
||
|
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v3';
|
||
|
|
||
|
|
||
|
// Services
|
||
|
|
||
|
// Functions
|
||
|
|
||
|
|
||
|
export function test1(
|
||
|
config?: {ttl?: number}
|
||
|
): Promise<number>;
|
||
|
|
||
|
export function test1(
|
||
|
peer: FluencePeer,
|
||
|
config?: {ttl?: number}
|
||
|
): Promise<number>;
|
||
|
|
||
|
export function test1(...args: any) {
|
||
|
|
||
|
let script = `
|
||
|
(xor
|
||
|
(seq
|
||
|
(seq
|
||
|
(seq
|
||
|
(seq
|
||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||
|
(par
|
||
|
(seq
|
||
|
(par
|
||
|
(call %init_peer_id% ("math" "add") [1 2] add-0)
|
||
|
(call %init_peer_id% ("math" "mul") [3 5] mul)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "sub") [add-0 mul] sub-0)
|
||
|
)
|
||
|
(seq
|
||
|
(call %init_peer_id% ("math" "mul") [2 3] mul-0)
|
||
|
(call %init_peer_id% ("math" "div") [mul-0 2] div)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "sub") [sub-0 div] sub)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "add") [sub 5] add)
|
||
|
)
|
||
|
(xor
|
||
|
(call %init_peer_id% ("callbackSrv" "response") [add])
|
||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||
|
)
|
||
|
)
|
||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||
|
)
|
||
|
`
|
||
|
return callFunction(
|
||
|
args,
|
||
|
{
|
||
|
"functionName" : "test1",
|
||
|
"arrow" : {
|
||
|
"tag" : "arrow",
|
||
|
"domain" : {
|
||
|
"tag" : "labeledProduct",
|
||
|
"fields" : {
|
||
|
|
||
|
}
|
||
|
},
|
||
|
"codomain" : {
|
||
|
"tag" : "unlabeledProduct",
|
||
|
"items" : [
|
||
|
{
|
||
|
"tag" : "scalar",
|
||
|
"name" : "u64"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
"names" : {
|
||
|
"relay" : "-relay-",
|
||
|
"getDataSrv" : "getDataSrv",
|
||
|
"callbackSrv" : "callbackSrv",
|
||
|
"responseSrv" : "callbackSrv",
|
||
|
"responseFnName" : "response",
|
||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||
|
"errorFnName" : "error"
|
||
|
}
|
||
|
},
|
||
|
script
|
||
|
)
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
export function test2(
|
||
|
config?: {ttl?: number}
|
||
|
): Promise<number>;
|
||
|
|
||
|
export function test2(
|
||
|
peer: FluencePeer,
|
||
|
config?: {ttl?: number}
|
||
|
): Promise<number>;
|
||
|
|
||
|
export function test2(...args: any) {
|
||
|
|
||
|
let script = `
|
||
|
(xor
|
||
|
(seq
|
||
|
(seq
|
||
|
(seq
|
||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||
|
(par
|
||
|
(seq
|
||
|
(seq
|
||
|
(par
|
||
|
(seq
|
||
|
(par
|
||
|
(seq
|
||
|
(seq
|
||
|
(seq
|
||
|
(seq
|
||
|
(call %init_peer_id% ("math" "mul") [2 2] mul)
|
||
|
(call %init_peer_id% ("math" "sub") [mul 2] sub-1)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "pow") [2 sub-1] pow-0)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "pow") [2 pow-0] pow)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "add") [pow 2] add-1)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "mul") [3 5] mul-0)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "sub") [add-1 mul-0] sub-0)
|
||
|
)
|
||
|
(seq
|
||
|
(call %init_peer_id% ("math" "mul") [2 3] mul-1)
|
||
|
(call %init_peer_id% ("math" "div") [mul-1 2] div)
|
||
|
)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "sub") [sub-0 div] sub)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "add") [sub 5] add-0)
|
||
|
)
|
||
|
(seq
|
||
|
(call %init_peer_id% ("math" "rem") [4 2] rem)
|
||
|
(call %init_peer_id% ("math" "sub") [rem 2] sub-2)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
(call %init_peer_id% ("math" "add") [add-0 sub-2] add)
|
||
|
)
|
||
|
(xor
|
||
|
(call %init_peer_id% ("callbackSrv" "response") [add])
|
||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||
|
)
|
||
|
)
|
||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||
|
)
|
||
|
`
|
||
|
return callFunction(
|
||
|
args,
|
||
|
{
|
||
|
"functionName" : "test2",
|
||
|
"arrow" : {
|
||
|
"tag" : "arrow",
|
||
|
"domain" : {
|
||
|
"tag" : "labeledProduct",
|
||
|
"fields" : {
|
||
|
|
||
|
}
|
||
|
},
|
||
|
"codomain" : {
|
||
|
"tag" : "unlabeledProduct",
|
||
|
"items" : [
|
||
|
{
|
||
|
"tag" : "scalar",
|
||
|
"name" : "u64"
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
"names" : {
|
||
|
"relay" : "-relay-",
|
||
|
"getDataSrv" : "getDataSrv",
|
||
|
"callbackSrv" : "callbackSrv",
|
||
|
"responseSrv" : "callbackSrv",
|
||
|
"responseFnName" : "response",
|
||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||
|
"errorFnName" : "error"
|
||
|
}
|
||
|
},
|
||
|
script
|
||
|
)
|
||
|
}
|