-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
Aqua, | ||
Call, | ||
Path, | ||
} from "@fluencelabs/aqua-api/aqua-api.js"; | ||
|
||
const aquaPath = new Path("test.aqua") | ||
// write function that we want to call and arguments | ||
const args = {num: 42} | ||
const call = new Call("getNumber(num)", args, aquaPath) | ||
|
||
// compile call | ||
const compilationResult = await Aqua.compile(call, []) | ||
|
||
|
||
/* | ||
// Compilation result definition | ||
export class CompilationResult { | ||
// List of service definitions to register in Fluence JS Client | ||
services: Record<string, ServiceDef> | ||
// List of function definitions to call in Fluence JS Client | ||
functions: Record<string, AquaFunction> | ||
// Definition of wrapped function to call in Fluence JS Client | ||
functionCall?: AquaFunction | ||
// List of errors. All other fields will be empty if `errors` not empty | ||
errors: string[] | ||
} | ||
*/ | ||
|
||
// get function definition, that describes types of arguments and results of a function | ||
// and AIR script | ||
const {funcDef, script} = compilationResult.functionCall |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "aqua-api-example", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"call": "node index.js" | ||
}, | ||
"author": "Fluence Labs", | ||
"type": "module", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@fluencelabs/aqua-api": "0.9.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## Aqua API Example | ||
|
||
An example of how to use Aqua API with Fluence Client. | ||
Documentation and description [here](https://fluence.dev/docs/aqua-book/aqua-js-api). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
func getNumber(number: u32) -> u32: | ||
<- number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Aqua API | ||
|
||
[Documentation](https://fluence.dev/docs/aqua-book/aqua-js-api) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters