Skip to content

Commit

Permalink
Merge pull request #243 from logion-network/feature/update-doc
Browse files Browse the repository at this point in the history
Update doc
  • Loading branch information
gdethier authored Mar 29, 2024
2 parents dda1c41 + 70af40f commit fe80699
Show file tree
Hide file tree
Showing 24 changed files with 576 additions and 419 deletions.
2 changes: 1 addition & 1 deletion packages/multiversx/typedoc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "MultiversX",
"name": "multiversx",
"entryPoints": [
"./src/index.ts"
]
Expand Down
2 changes: 1 addition & 1 deletion website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.docusaurus
.cache-loader

/docs/api
/docs/reference

# Misc
.DS_Store
Expand Down
4 changes: 2 additions & 2 deletions website/docs/client/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "Client",
"position": 3,
"position": 2,
"link": {
"type": "generated-index",
"description": "The client to interact with logion network."
"description": "The Logion client"
}
}
25 changes: 9 additions & 16 deletions website/docs/client/authentication.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
---
sidebar_position: 1
sidebar_position: 2
description: How to authenticate a Polkadot account to logion network.
---

# Authentication

## Authenticate with ad-hoc keyring
Below example shows how to use an embedded signer in order to authenticate `client`. This approach is not recommended in production,
a [browser extension](/docs/category/extension) should be used instead.

```typescript
import { LogionClient, KeyringSigner } from '@logion/client';
import { Keyring } from '@polkadot/api';

const keyring = new Keyring();
keyring.addFromUri("0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a"); // Alice
const keypair = keyring.addFromUri("0xe5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a"); // Alice
const signer = new KeyringSigner(keyring);

const client = await LogionClient.create({
rpcEndpoints: [ 'wss://rpc01.logion.network' ], // A list of websocket endpoints
directoryEndpoint: 'https://directory.logion.network' // A logion directory
});

// Authenticate Alice
const authenticatedClient = await client.authenticate([
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" ],
let authenticatedClient = await client.authenticate(
[ keypair.address ],
signer
);
```
Now you can use authenticatedClient to interact with the network.

## Authenticate with Polkadot\{.js\}

In order to connect a webapp to logion-network, it is recommended to use [polkadot\{.js\} app](../extension/polkadot-js.md) extension.
// Later on, refresh the session (session's TTL is 1 hour)
authenticatedClient = await authenticatedClient.refreshTokens(DateTime.now());
```
5 changes: 4 additions & 1 deletion website/docs/client/balance-transactions.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---
sidebar_position: 2
sidebar_position: 3
description: How to access to the balance and do transactions.
---

# Balance and Transactions

The Logion network relies on the LGNT token. This section is about accessing you LGNT balance and transactions.
It also shows how to transfer LGNTs.

## State

:::note
Expand Down
Binary file modified website/docs/client/img/identity-loc-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions website/docs/client/img/identity-loc-state.puml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ OpenLoc : OPEN
RejectedRequest : REVIEW_REJECTED
ClosedLoc : CLOSED
AcceptedRequest : REVIEW_ACCEPTED
[*] -right-> PendingRequest: requestIdentityLoc\n(draft: false)
[*] --> DraftRequest: requestIdentityLoc\n(draft: true)
[*] -right-> PendingRequest: request___Loc\n(draft: false)
[*] --> DraftRequest: request___Loc\n(draft: true)
DraftRequest --> DraftRequest: addMetadata(),\n addFile(),\n deleteMetadata(),\n deleteFile(),\n
DraftRequest --> PendingRequest: submit()
PendingRequest --> decision
Expand Down
Binary file removed website/docs/client/img/protection-state.png
Binary file not shown.
14 changes: 0 additions & 14 deletions website/docs/client/img/protection-state.puml

This file was deleted.

93 changes: 93 additions & 0 deletions website/docs/client/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
sidebar_position: 1
description: The basics about the Logion client.
---

# Introduction

Each Logion node runs

* a Substrate service for block production,
* IPFS/IPFS cluster services running a private IPFS network,
* a private database service,
* a logion off-chain service exposing a REST API.

In addition to the Logion nodes, a Logion network also includes

* RPC nodes for accessing the chain,
* a directory service exposing the identity data of the Logion Legal Officer.

Logion's client interacts with the Logion chain (through RPC nodes), the REST API exposed by each node of the network and the directory.
The other services are publicly accessible.

The client's purpose is to merge data coming from the chain and the nodes
and expose a unified view. In order to access private data, the client has to be authenticated (see [here](./authentication.md)).

The client is able to run in several environments:

- a browser,
- a Node.JS application,
- a React Native based mobile app.

In function of the environment, the client will be instantiated differently (see below).

Another key concept is data caching. The client needs to interact with many data sources over the network. In order to
optimize the use of bandwidth, data are cached and retrieved only when needed. The client relies on "states" to handle
the different caches. A state is an immutable object, when the developer calls a mutating method on the state, a new
state instance is returned and the previous state is discarded.

Examples of how to work with states are given further in the documentation, see for instance [here](../client/loc.md).

There are several Logion networks:

- DEV: the network used for testing new developments, very unstable, should not be used unless part of the Logion developers team.
- TEST: a stable sandbox network that can be leveraged by developers to test their own developments using the Logion platform.
- MVP: Logion's production environment. Be sure to test your developments first in TEST before interacting with MVP.

The network to connect to is chosen at client instantiation, see below for examples.

## Instantiate the client in the browser

```typescript
import { Environment } from "@logion/client";
import { newLogionClient } from '@logion/client-browser';

const client = await newLogionClient(Environment.TEST);
```

## Instantiate the client in a Node.JS application

```typescript
import { Environment } from "@logion/client";
import { newLogionClient } from '@logion/client-node';

const client = await newLogionClient(Environment.TEST);
```

## Instantiate the client in a React Native mobile app

The SDK currently supports 2 "frameworks":

- [Expo](https://expo.dev/)
- [React Native FS](https://github.com/itinance/react-native-fs)

For Expo:

```typescript
import { Environment } from "@logion/client";
import { newLogionClient } from '@logion/client-expo';

const client = await newLogionClient(Environment.TEST);
```

For React Native FS:

```typescript
import { Environment } from "@logion/client";
import { newLogionClient } from '@logion/client-react-native-fs';

const client = await newLogionClient(Environment.TEST);
```

Make sure to check the README of both packages for further instructions about how to
integrate the Logion SDK in those environments.
Loading

0 comments on commit fe80699

Please sign in to comment.