181 lines
5.9 KiB
TypeScript
Raw Normal View History

/**
*
* 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
2022-08-05 17:09:51 +03:00
* Aqua version: 0.7.4-336
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
import {
CallParams,
callFunction,
registerService,
2022-04-12 15:41:53 +03:00
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v3';
// Services
export interface CoServiceDef {
call: (callParams: CallParams<null>) => string | Promise<string>;
}
export function registerCoService(service: CoServiceDef): void;
export function registerCoService(serviceId: string, service: CoServiceDef): void;
export function registerCoService(peer: FluencePeer, service: CoServiceDef): void;
export function registerCoService(peer: FluencePeer, serviceId: string, service: CoServiceDef): void;
export function registerCoService(...args: any) {
registerService(
args,
{
"defaultServiceId" : "coservice-id",
2022-04-12 15:41:53 +03:00
"functions" : {
"tag" : "labeledProduct",
"fields" : {
"call" : {
"tag" : "arrow",
"domain" : {
"tag" : "nil"
},
"codomain" : {
"tag" : "unlabeledProduct",
"items" : [
{
"tag" : "scalar",
"name" : "string"
}
]
}
}
}
2022-04-12 15:41:53 +03:00
}
}
);
}
// Functions
export function coFunc(
node: string,
c: (arg0: { air_version: string; external_addresses: string[]; node_version: string; }, callParams: CallParams<'arg0'>) => void | Promise<void>,
config?: {ttl?: number}
): Promise<void>;
export function coFunc(
peer: FluencePeer,
node: string,
c: (arg0: { air_version: string; external_addresses: string[]; node_version: string; }, callParams: CallParams<'arg0'>) => void | Promise<void>,
config?: {ttl?: number}
): Promise<void>;
export function coFunc(...args: any) {
let script = `
(xor
(seq
(seq
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "node") [] node)
)
(call %init_peer_id% ("coservice-id" "call") [] y)
)
(call -relay- ("op" "noop") [])
)
(xor
(seq
(seq
(call node ("peer" "identify") [] t)
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "c") [t])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(null)
)
)
(call -relay- ("op" "noop") [])
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
)
(call %init_peer_id% ("coservice-id" "call") [] x)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
`
return callFunction(
args,
{
"functionName" : "coFunc",
2022-04-12 15:41:53 +03:00
"arrow" : {
"tag" : "arrow",
"domain" : {
"tag" : "labeledProduct",
"fields" : {
"node" : {
"tag" : "scalar",
"name" : "string"
},
"c" : {
"tag" : "arrow",
"domain" : {
"tag" : "unlabeledProduct",
"items" : [
{
"tag" : "struct",
"name" : "Info",
"fields" : {
"air_version" : {
"tag" : "scalar",
"name" : "string"
},
"external_addresses" : {
"tag" : "array",
"type" : {
"tag" : "scalar",
"name" : "string"
}
},
"node_version" : {
"tag" : "scalar",
"name" : "string"
}
}
}
2022-04-12 15:41:53 +03:00
]
},
"codomain" : {
"tag" : "nil"
}
}
}
2022-04-12 15:41:53 +03:00
},
"codomain" : {
"tag" : "nil"
}
2022-04-12 15:41:53 +03:00
},
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}