-
Notifications
You must be signed in to change notification settings - Fork 5
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
19 changed files
with
525 additions
and
394 deletions.
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 |
---|---|---|
@@ -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" | ||
} | ||
} |
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 |
---|---|---|
@@ -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()); | ||
``` |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Binary file not shown.
This file was deleted.
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,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 (throught 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 envrironment, 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 bandwith, 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. |
Oops, something went wrong.