update fluence-js hello-world and fluence-js node

This commit is contained in:
Pavel Murygin 2021-12-28 22:09:21 +03:00
parent f9667003bc
commit 3baced7834
9 changed files with 4873 additions and 554 deletions

View File

@ -0,0 +1,3 @@
# fluence
src/_aqua/*

File diff suppressed because it is too large Load Diff

View File

@ -11,14 +11,14 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@fluencelabs/aqua": "^0.4.0-234",
"@fluencelabs/aqua-lib": "^0.1.14",
"@fluencelabs/aqua": "^0.5.2-256",
"@fluencelabs/aqua-lib": "^0.3.2",
"chokidar-cli": "^3.0.0",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
},
"dependencies": {
"@fluencelabs/fluence": "^0.14.3",
"@fluencelabs/fluence": "0.17.0",
"@fluencelabs/fluence-network-environment": "1.0.10"
}
}

View File

@ -1,190 +0,0 @@
/**
*
* 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.4.0-234
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
import {
CallParams,
callFunction,
registerService,
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v2';
// Services
export interface HelloWorldDef {
getFortune: (callParams: CallParams<null>) => string | Promise<string>;
hello: (str: string, callParams: CallParams<'str'>) => void | Promise<void>;
}
export function registerHelloWorld(service: HelloWorldDef): void;
export function registerHelloWorld(serviceId: string, service: HelloWorldDef): void;
export function registerHelloWorld(peer: FluencePeer, service: HelloWorldDef): void;
export function registerHelloWorld(peer: FluencePeer, serviceId: string, service: HelloWorldDef): void;
export function registerHelloWorld(...args: any) {
registerService(
args,
{
"defaultServiceId" : "hello-world",
"functions" : [
{
"functionName" : "getFortune",
"argDefs" : [
],
"returnType" : {
"tag" : "primitive"
}
},
{
"functionName" : "hello",
"argDefs" : [
{
"name" : "str",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
}
]
}
);
}
// Functions
export function sayHello(config?: {ttl?: number}): Promise<void>;
export function sayHello(peer: FluencePeer, config?: {ttl?: number}): Promise<void>;
export function sayHello(...args: any) {
let script = `
(xor
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("hello-world" "hello") ["Hello, world!"])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
`
return callFunction(
args,
{
"functionName" : "sayHello",
"returnType" : {
"tag" : "void"
},
"argDefs" : [
],
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}
export function tellFortune(config?: {ttl?: number}): Promise<string>;
export function tellFortune(peer: FluencePeer, config?: {ttl?: number}): Promise<string>;
export function tellFortune(...args: any) {
let script = `
(xor
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("hello-world" "getFortune") [] res)
)
(xor
(call %init_peer_id% ("callbackSrv" "response") [res])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
`
return callFunction(
args,
{
"functionName" : "tellFortune",
"returnType" : {
"tag" : "primitive"
},
"argDefs" : [
],
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}
export function getRelayTime(config?: {ttl?: number}): Promise<number>;
export function getRelayTime(peer: FluencePeer, config?: {ttl?: number}): Promise<number>;
export function getRelayTime(...args: any) {
let script = `
(xor
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(xor
(call -relay- ("peer" "timestamp_ms") [] ts)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(xor
(call %init_peer_id% ("callbackSrv" "response") [ts])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
`
return callFunction(
args,
{
"functionName" : "getRelayTime",
"returnType" : {
"tag" : "primitive"
},
"argDefs" : [
],
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}

View File

@ -0,0 +1,3 @@
# fluence
src/_aqua/*

File diff suppressed because it is too large Load Diff

View File

@ -11,13 +11,13 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@fluencelabs/aqua": "^0.4.0-234",
"@fluencelabs/aqua": "^0.5.2-256",
"chokidar-cli": "^3.0.0",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
},
"dependencies": {
"@fluencelabs/fluence": "^0.14.3",
"@fluencelabs/fluence": "0.17.0",
"@fluencelabs/fluence-network-environment": "1.0.10"
}
}

View File

@ -1,117 +0,0 @@
/**
*
* 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.4.0-234
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
import {
CallParams,
callFunction,
registerService,
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v2';
// Services
export interface CalcDef {
add: (n: number, callParams: CallParams<'n'>) => void | Promise<void>;
divide: (n: number, callParams: CallParams<'n'>) => void | Promise<void>;
getResult: (callParams: CallParams<null>) => number | Promise<number>;
multiply: (n: number, callParams: CallParams<'n'>) => void | Promise<void>;
reset: (callParams: CallParams<null>) => void | Promise<void>;
subtract: (n: number, callParams: CallParams<'n'>) => void | Promise<void>;
}
export function registerCalc(service: CalcDef): void;
export function registerCalc(serviceId: string, service: CalcDef): void;
export function registerCalc(peer: FluencePeer, service: CalcDef): void;
export function registerCalc(peer: FluencePeer, serviceId: string, service: CalcDef): void;
export function registerCalc(...args: any) {
registerService(
args,
{
"defaultServiceId" : "calc",
"functions" : [
{
"functionName" : "add",
"argDefs" : [
{
"name" : "n",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
},
{
"functionName" : "divide",
"argDefs" : [
{
"name" : "n",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
},
{
"functionName" : "getResult",
"argDefs" : [
],
"returnType" : {
"tag" : "primitive"
}
},
{
"functionName" : "multiply",
"argDefs" : [
{
"name" : "n",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
},
{
"functionName" : "reset",
"argDefs" : [
],
"returnType" : {
"tag" : "void"
}
},
{
"functionName" : "subtract",
"argDefs" : [
{
"name" : "n",
"argType" : {
"tag" : "primitive"
}
}
],
"returnType" : {
"tag" : "void"
}
}
]
}
);
}
// Functions

View File

@ -1,98 +0,0 @@
/**
*
* 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.4.0-234
*
*/
import { Fluence, FluencePeer } from '@fluencelabs/fluence';
import {
CallParams,
callFunction,
registerService,
} from '@fluencelabs/fluence/dist/internal/compilerSupport/v2';
// Services
// Functions
export function demoCalculation(config?: {ttl?: number}): Promise<number>;
export function demoCalculation(peer: FluencePeer, config?: {ttl?: number}): Promise<number>;
export function demoCalculation(...args: any) {
let script = `
(xor
(seq
(seq
(seq
(seq
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call -relay- ("op" "noop") [])
)
(call "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e" ("op" "noop") [])
)
(xor
(seq
(seq
(seq
(seq
(call "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3" ("calc" "add") [10])
(call "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3" ("calc" "multiply") [5])
)
(call "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3" ("calc" "subtract") [8])
)
(call "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3" ("calc" "divide") [6])
)
(call "12D3KooWLBkw4Tz8bRoSriy5WEpHyWfU11jEK3b5yCa7FBRDRWH3" ("calc" "getResult") [] res)
)
(seq
(seq
(seq
(call "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e" ("op" "noop") [])
(call -relay- ("op" "noop") [])
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
(call -relay- ("op" "noop") [])
)
)
)
(call "12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e" ("op" "noop") [])
)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "response") [res])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
`
return callFunction(
args,
{
"functionName" : "demoCalculation",
"returnType" : {
"tag" : "primitive"
},
"argDefs" : [
],
"names" : {
"relay" : "-relay-",
"getDataSrv" : "getDataSrv",
"callbackSrv" : "callbackSrv",
"responseSrv" : "callbackSrv",
"responseFnName" : "response",
"errorHandlingSrv" : "errorHandlingSrv",
"errorFnName" : "error"
}
},
script
)
}