react-native-fula
This package is a bridge to use the Fula protocols in the react-native. It uses WNFS to create the Merkle dag from files and folders and transfer the DAG using Graphsync to the nodes.
Installation
npm install react-native-fula
Usage
import { fula } from 'react-native-fula';
const peerId
= newClient(
identity: string,
storePath: string,
bloxAddr: string,
exchange: 'noop'|'',
autoFlush: boolean,
useRelay: boolean,
refresh: boolean?
)
[
peerId,
cid,
private_ref
]
=
await fula.init(
identity: string,
storePath: string,
bloxAddr: string,
exchange: 'noop'|'',
autoFlush: boolean,
useRelay: boolean,
refresh: boolean?
);
const cid
=
await fula.mkdir(
path: string
);
const cid
=
await fula.writeFile(
fulaTargetFilename: string,
localFilename: string
);
const localFilePath
=
await fula.readFile(
fulaTargetFilename: string,
localFilename: string
);
const fileList
=
await fula.ls(
path: string,
);
const cid
=
await fula.rm(
path: string,
);
const cid
=
await fula.cp(
sourcePath: string,
targetPath: string,
);
const cid
=
await fula.mv(
sourcePath: string,
targetPath: string,
);
const result
=
await fula.isReady(
filesystemCheck: boolean
);
const result
=
await fula.checkConnection(
timeout: number?
);
const result
=
await fula.checkFailedActions(
retry: boolean
timeout: number?
);
const result
=
await fula.listFailedActions(
cids: string[]
);
const result
=
await fula.setAuth(
peerId: string,
allow: boolean,
);
await fula.shutdown();
const result
=
await fula.logout(
identity: string,
storePath: string,
);
Polkadot type creation
You can follow the documentation here: https://polkadot.js.org/docs/api/examples/promise/typegen
Alternatively you do the below on a Linux or WSL inside the react-native-fula folder:
curl -H "Content-Type: application/json" -d "{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}" https://node3.functionyard.fula.network > edgeware.json
yarn build:polkadot
Testing
Open a cmd or terminal as admin (sudo)
corepack enable
Then cd to the react-native-fula
folder (no need for admin, sudo) and run:
yarn install
to run the example app, run:
yarn example android
Roadmap
Please note the following might not be done in order:
Other related libraries
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT