JS/TS Peer for the Fluence p2p network
Go to file
Pavel 619c8a6d6a
Update builtins to new version (#27)
* Update builtins to new version

* Running integration tests in docker container
2021-02-25 15:33:37 +03:00
.github/workflows Improve tests (#18) 2021-02-14 00:35:02 +03:00
doc Returned built-in Aquamarine calls, updated docs (#11) 2021-01-29 16:48:27 +03:00
src Update builtins to new version (#27) 2021-02-25 15:33:37 +03:00
types Back to Apache 2.0 (#83) 2020-05-14 17:30:17 +03:00
.eslintrc.js Tetraplets (#1) 2020-12-23 17:24:22 +03:00
.gitignore Big refactoring (#8) 2021-01-19 15:47:49 +03:00
.npmignore Builtin methods, update aquamarine (#960) 2020-10-23 14:01:21 +03:00
.prettierrc.js Tetraplets (#1) 2020-12-23 17:24:22 +03:00
CONTRIBUTING.md Returned built-in Aquamarine calls, updated docs (#11) 2021-01-29 16:48:27 +03:00
jest.config.js Improve tests (#18) 2021-02-14 00:35:02 +03:00
LICENSE Returned built-in Aquamarine calls, updated docs (#11) 2021-01-29 16:48:27 +03:00
package-lock.json Update interpreter (#26) 2021-02-24 14:51:24 +03:00
package.json Update interpreter (#26) 2021-02-24 14:51:24 +03:00
README.md Update builtins to new version (#27) 2021-02-25 15:33:37 +03:00
tsconfig.json Big refactoring (#8) 2021-01-19 15:47:49 +03:00

Fluence JS SDK

npm

Official SDK for building web-based applications for Fluence

About Fluence

Fluence is an open application platform where apps can build on each other, share data and users

Layer Tech Scale State Based on
Execution FCE Single peer Disk, network, external processes Wasm, IT, Wasmer*
Composition Aquamarine Involved peers Results and signatures ⇅, π-calculus
Topology TrustGraph, DHT* Distributed with Kademlia* algo Actual state of the network libp2p
Security & Accounting Blockchain Whole network Licenses & payments substrate?
aquamarine scheme

Installation

With npm

npm install @fluencelabs/fluence

With yarn

yarn add @fluencelabs/fluence

Getting started

Pick a node to connect to the Fluence network. The easiest way to do so is by using fluence-network-environment package

import { dev } from '@fluencelabs/fluence-network-environment';

export const relayNode = dev[0];

Initialize client

import { createClient, FluenceClient } from '@fluencelabs/fluence';

const client = await createClient(relayNode);

Respond to service function calls

subscribeToEvent(client, 'helloService', 'helloFunction', (args) => {
    const [networkInfo] = args;
    console.log(networkInfo);
});

Make a particle

const particle = new Particle(
    `
    (seq
        (call myRelay ("peer" "identify") [] result)
        (call %init_peer_id% ("helloService" "helloFunction") [result])
    )`,
    {
        myRelay: client.relayPeerId,
    },
);

Send it to the network

await sendParticle(client, particle);

Observe the result in browser console

{
    "external_addresses": ["/ip4/1.2.3.4/tcp/7777", "/dns4/dev.fluence.dev/tcp/19002"]
}

Documentation

SDK Reference: readme.io

Detailed guide on building applications: readme.io

Sample applications:

  • FluentPad: a collaborative text editor with users online status synchronization
  • Other demos: (Chat app, Social feed app, Blog platform app)

About Fluence

Developing

Setting up Dev

Install node packages

npm install

Running tests

Tests are split into unit and integration categories. By default integration tests require a locally running Fluence node with 4310 port open for ws connections. The dependency can be started with docker

 docker run --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence:freeze -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj

To run all tests in interactive mode

npm run test

To run only unit tests

npm run test:unit

To run only integration tests

npm run test:unit

To run all tests

npm run test:all

Contributing

While the project is still in the early stages of development, you are welcome to track progress and contribute. As the project is undergoing rapid changes, interested contributors should contact the team before embarking on larger pieces of work. All contributors should consult with and agree to our basic contributing rules.

License

Apache 2.0