2021-04-30 10:36:55 +00:00
|
|
|
|
-- Default public interface of Fluence nodes
|
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
alias Field : []string
|
|
|
|
|
alias Argument : []string
|
|
|
|
|
alias Bytes : []u8
|
|
|
|
|
alias PeerId : string
|
2021-07-02 15:53:53 +00:00
|
|
|
|
alias Pairs : [][]string
|
|
|
|
|
alias Base58String : string
|
2021-07-22 16:36:51 +00:00
|
|
|
|
alias Hash : string
|
2021-07-02 15:53:53 +00:00
|
|
|
|
|
2021-08-12 11:44:44 +00:00
|
|
|
|
-- There are two types of dependencies: named and by-hash.
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- name:foobar – specifies dependency by module name, points to a module with import name 'foobar'
|
|
|
|
|
-- hash:04dc884... – specifies dependency by module hash
|
2021-08-12 11:44:44 +00:00
|
|
|
|
-- By-hash dependencies are preffered since they are determenistic
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- while by-name dependency can yield different modules at different points in time
|
|
|
|
|
alias Dependency : string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
data Service:
|
|
|
|
|
id: string
|
|
|
|
|
blueprint_id: string
|
|
|
|
|
owner_id: string
|
|
|
|
|
|
|
|
|
|
data FunctionSignature:
|
|
|
|
|
arguments: []Argument
|
|
|
|
|
name: string
|
|
|
|
|
output_types: []string
|
|
|
|
|
|
|
|
|
|
data RecordType:
|
|
|
|
|
fields: []Field
|
|
|
|
|
id: u64
|
|
|
|
|
name: string
|
|
|
|
|
|
|
|
|
|
data Interface:
|
|
|
|
|
function_signatures: []FunctionSignature
|
|
|
|
|
record_types: []RecordType
|
|
|
|
|
|
|
|
|
|
data Info:
|
|
|
|
|
external_addresses: []string
|
|
|
|
|
|
|
|
|
|
data ModuleConfig:
|
|
|
|
|
name: string
|
|
|
|
|
|
|
|
|
|
data Module:
|
|
|
|
|
name: string
|
|
|
|
|
hash: string
|
|
|
|
|
config: ModuleConfig
|
|
|
|
|
|
2021-07-05 12:26:22 +00:00
|
|
|
|
data AddBlueprint:
|
2021-04-29 12:22:39 +00:00
|
|
|
|
name: string
|
2021-07-02 15:53:53 +00:00
|
|
|
|
dependencies: []Dependency
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
data Blueprint:
|
|
|
|
|
id: string
|
|
|
|
|
name: string
|
2021-07-05 12:26:22 +00:00
|
|
|
|
dependencies: []Dependency
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
data ScriptInfo:
|
|
|
|
|
id: string
|
|
|
|
|
src: string
|
|
|
|
|
failures: u32
|
|
|
|
|
interval: string
|
|
|
|
|
owner: string
|
|
|
|
|
|
|
|
|
|
data Contact:
|
|
|
|
|
peer_id: string
|
|
|
|
|
addresses: []string
|
|
|
|
|
|
|
|
|
|
service Op("op"):
|
2021-06-03 14:57:39 +00:00
|
|
|
|
-- does nothing
|
|
|
|
|
noop()
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
2021-07-02 16:00:05 +00:00
|
|
|
|
-- returns length of the passed array
|
|
|
|
|
array_length(array: []string) -> u32
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
2021-06-03 14:57:39 +00:00
|
|
|
|
-- takes any number of arguments and wraps them into a single array
|
2021-10-26 14:47:46 +00:00
|
|
|
|
-- see the doc on varargs https://doc.fluence.dev/aqua-book/libraries/aqua-lib#functions-with-a-variable-number-of-arguments
|
|
|
|
|
array(a: string, b: string, c: string, d: string) -> []string
|
|
|
|
|
|
2021-06-03 14:57:39 +00:00
|
|
|
|
-- takes any number of arrays and flattens them by concatenating
|
2021-10-26 14:47:46 +00:00
|
|
|
|
-- see the doc on varargs https://doc.fluence.dev/aqua-book/libraries/aqua-lib#functions-with-a-variable-number-of-arguments
|
|
|
|
|
concat(a: []string, b: []string, c: []string, d: []string) -> []string
|
|
|
|
|
|
2021-06-03 14:57:39 +00:00
|
|
|
|
-- takes a single argument and returns it back
|
|
|
|
|
identity(s: ?string) -> ?string
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
|
|
|
|
-- encodes string's utf8 bytes as base58
|
2021-07-02 15:53:53 +00:00
|
|
|
|
string_to_b58(s: string) -> Base58String
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
|
|
|
|
-- decodes base58 to bytes to utf8 string
|
|
|
|
|
-- throws error on invalid UTF8
|
2021-07-02 15:53:53 +00:00
|
|
|
|
string_from_b58(b: Base58String) -> string
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
|
|
|
|
-- encodes bytes as base58
|
2021-07-02 15:53:53 +00:00
|
|
|
|
bytes_to_b58(bs: []u8) -> Base58String
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
|
|
|
|
-- decodes base58 to bytes
|
2021-07-02 15:53:53 +00:00
|
|
|
|
bytes_from_b58(b: Base58String) -> []u8
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Applies SHA256 to the given string
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- Argument: s - string to apply sha256 to (hash is applied to utf8 bytes of s)
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Returns: returns sha256 multihash encoded as base58
|
2021-07-02 15:53:53 +00:00
|
|
|
|
sha256_string(s: string) -> Base58String
|
2021-08-12 11:44:44 +00:00
|
|
|
|
|
2021-07-22 16:36:51 +00:00
|
|
|
|
-- concatenate strings (in AIR it takes any number of arguments)
|
|
|
|
|
concat_strings(a: string, b: string) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Peer("peer"):
|
|
|
|
|
-- Checks if there is a direct connection to the peer identified by a given PeerId
|
|
|
|
|
-- Argument: PeerId – id of the peer to check if there's a connection with
|
|
|
|
|
-- Returns: bool - true if connected to the peer, false otherwise
|
2021-04-30 10:36:55 +00:00
|
|
|
|
is_connected(peer: PeerId) -> bool
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Initiates a connection to the specified peer
|
|
|
|
|
-- Arguments:
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- id - id of the target peer
|
|
|
|
|
-- multiaddrs – an array of target peer's addresses
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Returns: bool - true if connection was successful
|
2021-07-02 15:53:53 +00:00
|
|
|
|
connect(id: PeerId, multiaddrs: ?[]string) -> bool
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Resolves the contact of a peer via Kademlia
|
|
|
|
|
-- Argument: PeerId – id of the target peer
|
|
|
|
|
-- Returns: Contact - true if connection was successful
|
2021-04-30 10:36:55 +00:00
|
|
|
|
get_contact(peer: PeerId) -> Contact
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get information about the peer
|
2021-04-30 10:36:55 +00:00
|
|
|
|
identify() -> Info
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get Unix timestamp in milliseconds
|
2021-04-30 10:36:55 +00:00
|
|
|
|
timestamp_ms() -> u64
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get Unix timestamp in seconds
|
2021-04-30 10:36:55 +00:00
|
|
|
|
timestamp_sec() -> u64
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
2021-11-24 06:52:21 +00:00
|
|
|
|
-- Blocks for the given number of milliseconds. Meant to be used within `par` blocks.
|
|
|
|
|
-- message is returned after duration has passed
|
|
|
|
|
timeout(duration_ms: u64, message: string) -> string
|
2021-11-21 15:48:47 +00:00
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
service Kademlia("kad"):
|
|
|
|
|
-- Instructs node to return the locally-known nodes
|
|
|
|
|
-- in the Kademlia neighborhood for a given key
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- Arguments:
|
|
|
|
|
-- key – base58 string
|
|
|
|
|
-- already_hashed – default false; if set to true, key is considered to be a SHA256 multihash
|
|
|
|
|
-- count – default 20; limits number of returned nodes
|
|
|
|
|
neighborhood(key: Base58String, already_hashed: ?bool, count: ?u32) -> []PeerId
|
2021-10-26 14:47:46 +00:00
|
|
|
|
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Merges given lists and sorts them by distance to target
|
|
|
|
|
-- Arguments:
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- target – base58 string; result is sorted by XOR distance to target
|
|
|
|
|
-- left – list of base58 strings
|
|
|
|
|
-- right – list of base58 strings
|
2021-08-12 11:44:44 +00:00
|
|
|
|
-- count – how many items to return; default 20
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Returns: list of base58 strings sorted by distance to target; list will contain at most count elements
|
2021-07-02 15:53:53 +00:00
|
|
|
|
merge(target: Base58String, left: []string, right: []string, count: ?u32) -> []string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Srv("srv"):
|
|
|
|
|
-- Used to create a service on a certain node
|
|
|
|
|
-- Arguments:
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- blueprint_id – ID of the blueprint that has been added to the node specified in the service call by the dist add_blueprint service.
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Returns: service_id – the service ID of the created service.
|
2021-04-30 10:36:55 +00:00
|
|
|
|
create(blueprint_id: string) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
2021-04-29 15:01:10 +00:00
|
|
|
|
-- Used to remove a service from a certain node
|
|
|
|
|
-- Arguments:
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- service_id – ID of the service to remove
|
2021-04-30 10:36:55 +00:00
|
|
|
|
remove(service_id: string)
|
2021-04-29 15:01:10 +00:00
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Returns a list of services running on a peer
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list() -> []Service
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Adds an alias on service, so, service could be called
|
|
|
|
|
-- not only by service_id but by alias as well.
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- Arguments:
|
|
|
|
|
-- alias - settable service name
|
|
|
|
|
-- service_id – ID of the service whose interface you want to name.
|
2021-04-30 10:36:55 +00:00
|
|
|
|
add_alias(alias: string, service_id: string)
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
2021-06-03 13:36:34 +00:00
|
|
|
|
-- Resolves given alias to a service id
|
|
|
|
|
-- If there's no such alias, throws an error
|
|
|
|
|
-- Returns: service id associated with the given alias
|
|
|
|
|
resolve_alias(alias: string) -> string
|
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Retrieves the functional interface of a service running
|
|
|
|
|
-- on the node specified in the service call
|
|
|
|
|
-- Argument: service_id – ID of the service whose interface you want to retrieve.
|
2021-06-18 16:53:57 +00:00
|
|
|
|
get_interface(service_id: string) -> Interface
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Dist("dist"):
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- Constructs a ModuleConfig structure
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- module_name - import name of the module
|
|
|
|
|
-- mem_pages_count - Maximum memory size accessible by a module in Wasm pages (64 Kb)
|
|
|
|
|
-- logger_enabled - Defines whether Marine should provide a special host log_utf8_string function for this module
|
|
|
|
|
-- preopened_files - Files available for this module. Module can access only files from this list
|
|
|
|
|
-- envs - environment variables available for this module
|
2021-08-12 11:44:44 +00:00
|
|
|
|
-- mapped_dirs - Directory mapping, e.g. [["/sites", "./web/data"]] so all
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- reads & writes to /sites will actually to go ./web/data
|
2021-08-12 11:44:44 +00:00
|
|
|
|
-- mounted_binaries - Mapping of host binaries available to call from module,
|
|
|
|
|
-- e.g. [["curl", "/usr/bin/curl"]] will allow module to
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- call /usr/bin/curl binary as function 'curl'
|
|
|
|
|
-- logging_mask - Binary mask to enable & disable logging targets. Targets are
|
|
|
|
|
-- configured in WasmLoggerBuilder::with_target_map
|
|
|
|
|
-- mem_pages_count - Maximum memory size accessible by a module in Wasm pages (64 Kb)
|
2021-07-05 12:26:22 +00:00
|
|
|
|
make_module_config(name: string, mem_pages_count: ?u32, logger_enabled: ?bool, preopened_files: ?[]string, envs: ?Pairs, mapped_dirs: ?Pairs, mounted_binaries: ?Pairs, logging_mask: ?i32) -> ModuleConfig
|
|
|
|
|
|
2021-07-22 16:36:51 +00:00
|
|
|
|
-- Constructs a ModuleConfig structure
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- module_name - import name of the module
|
|
|
|
|
default_module_config(module_name: string) -> ModuleConfig
|
|
|
|
|
|
|
|
|
|
|
2021-07-05 12:26:22 +00:00
|
|
|
|
-- Used to add modules to the node specified in the service call
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- bytes – a base64 string containing the .wasm module to add.
|
|
|
|
|
-- config – module info
|
|
|
|
|
-- Returns: blake3 hash of the module
|
|
|
|
|
add_module(wasm_b56_content: Bytes, conf: ModuleConfig) -> string
|
2021-07-02 15:53:53 +00:00
|
|
|
|
|
2021-07-22 16:36:51 +00:00
|
|
|
|
-- Adds module by copying it from Particle Vault directory
|
|
|
|
|
-- Arguments:
|
|
|
|
|
-- path – path or a filename
|
|
|
|
|
-- config - module config
|
|
|
|
|
add_module_from_vault(path: string, config: ModuleConfig) -> Hash
|
|
|
|
|
|
2021-04-29 12:22:39 +00:00
|
|
|
|
-- Get a list of modules available on the node
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list_modules() -> []Module
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Get the interface of a module
|
2021-04-30 10:36:55 +00:00
|
|
|
|
get_interface(module_id: string) -> Interface
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- Creates Blueprint structure from from blueprint name and dependencies (modules)
|
2021-07-05 12:26:22 +00:00
|
|
|
|
make_blueprint(name: string, dependencies: []Dependency) -> AddBlueprint
|
|
|
|
|
-- Add a blueprint to the node
|
|
|
|
|
add_blueprint(blueprint: AddBlueprint) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Used to get the blueprints available on the node specified in the service call.
|
|
|
|
|
-- A blueprint is an object of the following structure
|
2021-04-30 10:36:55 +00:00
|
|
|
|
list_blueprints() -> []Blueprint
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
service Script("script"):
|
|
|
|
|
-- Adds the given script to a node
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- Arguments:
|
|
|
|
|
-- air_script - raw AIR script without any undefined variables
|
|
|
|
|
-- interval - if not set, script will be ran only once
|
2021-08-12 11:44:44 +00:00
|
|
|
|
-- if set, script will be ran once in the interval
|
2021-07-02 15:53:53 +00:00
|
|
|
|
-- (NOTE: actual interval may vary by up to 3 seconds)
|
2021-11-21 15:48:47 +00:00
|
|
|
|
add(air_script: string, interval: ?u64) -> string
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Removes recurring script from a node. Only a creator of the script can delete it
|
2021-04-30 10:36:55 +00:00
|
|
|
|
remove(script_id: string) -> bool
|
2021-04-29 12:22:39 +00:00
|
|
|
|
|
|
|
|
|
-- Returns a list of existing scripts on the node.
|
|
|
|
|
-- Each object in the list is of the following structure
|
2021-12-06 13:36:38 +00:00
|
|
|
|
list() -> []ScriptInfo
|
2021-12-13 15:38:57 +00:00
|
|
|
|
|
|
|
|
|
service Sig("sig"):
|
|
|
|
|
-- Signs data with the current peer's key.
|
|
|
|
|
-- Can only be called on %init_peer_id%
|
|
|
|
|
-- Accepts data only from the following sources:
|
|
|
|
|
-- trust-graph.get_trust_bytes
|
|
|
|
|
-- trust-graph.get_revocation_bytes
|
|
|
|
|
-- registry.get_key_bytes
|
|
|
|
|
-- registry.get_record_bytes
|
|
|
|
|
-- Argument: data - byte array to sign
|
|
|
|
|
-- Returns: signature as a byte array
|
|
|
|
|
sign(data: []u8) -> []u8
|
|
|
|
|
|
|
|
|
|
-- Given the data and signature both as byte arrays, returns true if the signature is correct, false otherwise.
|
|
|
|
|
verify(signature: []u8, data: []u8) -> bool
|