mirror of
https://github.com/fluencelabs/aqua-ipfs
synced 2025-04-24 15:32:15 +00:00
Compare commits
28 Commits
aqua-ipfs-
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
b6054cc05b | ||
|
459320d224 | ||
|
e3e89cf4d0 | ||
|
a1781d36cf | ||
|
41fbc08d11 | ||
|
cdaefbe536 | ||
|
32238f18c2 | ||
|
55414f6a2f | ||
|
d9736332dc | ||
|
6b152ca2ce | ||
|
5e3eab082e | ||
|
b98b9b17e2 | ||
|
e5e1e170dd | ||
|
b783c291d0 | ||
|
f184b1fff6 | ||
|
fcc40ebb1b | ||
|
a054a17bfb | ||
|
999406708f | ||
|
5f646664f1 | ||
|
812fa12506 | ||
|
e6749d1f05 | ||
|
f096a4efb4 | ||
|
6db2393482 | ||
|
e1ee67a80e | ||
|
1d55067965 | ||
|
7592e6e067 | ||
|
2efd569360 | ||
|
b99d790d71 |
2
.github/release-please/manifest.json
vendored
2
.github/release-please/manifest.json
vendored
@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.5.23"
|
||||
".": "0.6.0"
|
||||
}
|
||||
|
39
.github/renovate.json
vendored
39
.github/renovate.json
vendored
@ -1,39 +1,8 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base",
|
||||
":semanticCommitTypeAll(chore)"
|
||||
"github>fluencelabs/renovate",
|
||||
"github>fluencelabs/renovate:npm",
|
||||
"github>fluencelabs/renovate:cargo"
|
||||
],
|
||||
"enabledManagers": ["cargo", "npm", "github-actions", "pip_requirements"],
|
||||
"rangeStrategy": "pin",
|
||||
"schedule": "every weekend",
|
||||
"respectLatest": false,
|
||||
"packageRules": [
|
||||
{
|
||||
"matchManagers": ["cargo", "npm"],
|
||||
"matchPackagePatterns": [
|
||||
"@fluencelabs/.*",
|
||||
"fluence-.*",
|
||||
"marine-.*"
|
||||
],
|
||||
"semanticCommitType": "fix",
|
||||
"semanticCommitScope": "deps",
|
||||
"schedule": "at any time"
|
||||
},
|
||||
{
|
||||
"matchDepTypes": ["devDependencies"],
|
||||
"prPriority": -1,
|
||||
"semanticCommitType": "chore",
|
||||
"semanticCommitScope": "deps"
|
||||
},
|
||||
{
|
||||
"matchUpdateTypes": ["major"],
|
||||
"prConcurrentLimit": 1
|
||||
},
|
||||
{
|
||||
"matchManagers": ["github-actions"],
|
||||
"groupName": "all github-actions",
|
||||
"prPriority": -1
|
||||
}
|
||||
]
|
||||
"enabledManagers": ["cargo", "npm", "pip_requirements"]
|
||||
}
|
||||
|
1
.github/workflows/e2e.yml
vendored
1
.github/workflows/e2e.yml
vendored
@ -40,6 +40,7 @@ jobs:
|
||||
- snapshot
|
||||
uses: fluencelabs/nox/.github/workflows/build.yml@master
|
||||
with:
|
||||
ref: new-vault
|
||||
cargo-dependencies: |
|
||||
[
|
||||
{
|
||||
|
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@ -124,7 +124,7 @@ jobs:
|
||||
uses: baptiste0928/cargo-install@v2.0.0
|
||||
with:
|
||||
crate: cargo-workspaces
|
||||
version: v0.2.37
|
||||
version: v0.2.44
|
||||
|
||||
- name: Setup marine
|
||||
uses: fluencelabs/setup-marine@v1
|
||||
@ -141,7 +141,12 @@ jobs:
|
||||
cache-dependency-path: "aqua/package-lock.json"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i
|
||||
- name: Setup fcli
|
||||
uses: fluencelabs/setup-fluence@v1
|
||||
with:
|
||||
version: stable
|
||||
|
||||
- run: npm ci
|
||||
working-directory: aqua
|
||||
|
||||
- run: npm run build
|
||||
|
27
.github/workflows/run-tests.yml
vendored
27
.github/workflows/run-tests.yml
vendored
@ -50,6 +50,33 @@ jobs:
|
||||
command: clippy
|
||||
args: -Z unstable-options --all --manifest-path service/Cargo.toml
|
||||
|
||||
npm-build:
|
||||
name: "Check if npm run build works"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "18"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
# cache-dependency-path: "aqua/package-lock.json"
|
||||
# cache: "npm"
|
||||
|
||||
- name: Setup fcli
|
||||
uses: fluencelabs/setup-fluence@v1
|
||||
with:
|
||||
version: stable
|
||||
|
||||
- run: npm ci
|
||||
working-directory: aqua
|
||||
|
||||
- run: npm run build
|
||||
working-directory: aqua
|
||||
|
||||
|
||||
lints:
|
||||
name: Lints
|
||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -117,7 +117,7 @@ jobs:
|
||||
- name: Install fluence deps
|
||||
env:
|
||||
FLUENCE_USER_DIR: "${{ github.workspace }}/tmp/.fluence"
|
||||
run: npx fluence dependency npm install
|
||||
run: npx fluence dep install
|
||||
working-directory: aqua-tests
|
||||
|
||||
- name: Install ipfs
|
||||
|
77
CHANGELOG.md
77
CHANGELOG.md
@ -1,5 +1,82 @@
|
||||
# Changelog
|
||||
|
||||
## [0.6.0](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.31...aqua-ipfs-v0.6.0) (2024-02-22)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Support CallParameters and Particle Vault File Format ([#165](https://github.com/fluencelabs/aqua-ipfs/issues/165))
|
||||
|
||||
### Features
|
||||
|
||||
* Support CallParameters and Particle Vault File Format ([#165](https://github.com/fluencelabs/aqua-ipfs/issues/165)) ([e3e89cf](https://github.com/fluencelabs/aqua-ipfs/commit/e3e89cf4d0855712ad181894c0cf5668f8798ca5))
|
||||
|
||||
## [0.5.31](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.30...aqua-ipfs-v0.5.31) (2024-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **aqua-lib:** update aqua-lib ([#166](https://github.com/fluencelabs/aqua-ipfs/issues/166)) ([41fbc08](https://github.com/fluencelabs/aqua-ipfs/commit/41fbc08d11e0974b93a7c27209a493516c4fb8a8))
|
||||
|
||||
## [0.5.30](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.29...aqua-ipfs-v0.5.30) (2024-01-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **aqua-ipfs:** Update example ([#159](https://github.com/fluencelabs/aqua-ipfs/issues/159)) ([32238f1](https://github.com/fluencelabs/aqua-ipfs/commit/32238f18c2df5edfe39a43c051bf4f08d76721f4))
|
||||
|
||||
## [0.5.29](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.28...aqua-ipfs-v0.5.29) (2024-01-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **aqua-ipfs:** Use `aqua` keyword instead of `module` ([#153](https://github.com/fluencelabs/aqua-ipfs/issues/153)) ([d973633](https://github.com/fluencelabs/aqua-ipfs/commit/d9736332dcbe7b2389c650157d2c8a84b7386939))
|
||||
|
||||
## [0.5.28](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.27...aqua-ipfs-v0.5.28) (2023-12-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update dependency @fluencelabs/aqua-lib to v0.9.0 ([#139](https://github.com/fluencelabs/aqua-ipfs/issues/139)) ([e5e1e17](https://github.com/fluencelabs/aqua-ipfs/commit/e5e1e170dd8405cc720998e8522969e9248c73fb))
|
||||
* **deps:** update dependency @fluencelabs/fluence-network-environment to v1.1.2 ([#113](https://github.com/fluencelabs/aqua-ipfs/issues/113)) ([f184b1f](https://github.com/fluencelabs/aqua-ipfs/commit/f184b1fff68e84a7e987fa0afe56fb231ed62e6d))
|
||||
* **deps:** update rust crate marine-rs-sdk-test to 0.12.1 ([#137](https://github.com/fluencelabs/aqua-ipfs/issues/137)) ([b98b9b1](https://github.com/fluencelabs/aqua-ipfs/commit/b98b9b17e28ac61578d4abf5cf5489bfe2a17541))
|
||||
|
||||
## [0.5.27](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.26...aqua-ipfs-v0.5.27) (2023-12-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add memory limit into distro config ([#135](https://github.com/fluencelabs/aqua-ipfs/issues/135)) ([9994067](https://github.com/fluencelabs/aqua-ipfs/commit/999406708f958374e6ce43673f550e18bf651d80))
|
||||
|
||||
## [0.5.26](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.25...aqua-ipfs-v0.5.26) (2023-12-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update marine sdk's and configs ([#122](https://github.com/fluencelabs/aqua-ipfs/issues/122)) ([6db2393](https://github.com/fluencelabs/aqua-ipfs/commit/6db239348299451d5c3f3a2687fe53fae6b922c7))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **build:** fix npm build, add check for that ([#132](https://github.com/fluencelabs/aqua-ipfs/issues/132)) ([e6749d1](https://github.com/fluencelabs/aqua-ipfs/commit/e6749d1f05b1ad4ebf3aa4c3c166758e3288635e))
|
||||
* **deps:** rust toolchain 2023-12-06; cargo-workspaces 0.2.44 ([#126](https://github.com/fluencelabs/aqua-ipfs/issues/126)) ([f096a4e](https://github.com/fluencelabs/aqua-ipfs/commit/f096a4efb46d5c24513745c7bea376e88fea9631))
|
||||
* **release:** use fcli installer ([#134](https://github.com/fluencelabs/aqua-ipfs/issues/134)) ([812fa12](https://github.com/fluencelabs/aqua-ipfs/commit/812fa12506edca84c12a14dc1547c01182297d56))
|
||||
|
||||
## [0.5.25](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.24...aqua-ipfs-v0.5.25) (2023-12-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* tests ([1d55067](https://github.com/fluencelabs/aqua-ipfs/commit/1d550679653864d5ea8d5951113f258c415a0527))
|
||||
* **tests:** update package-lock to fix marine-js not found on fluence run ([#123](https://github.com/fluencelabs/aqua-ipfs/issues/123)) ([1d55067](https://github.com/fluencelabs/aqua-ipfs/commit/1d550679653864d5ea8d5951113f258c415a0527))
|
||||
|
||||
## [0.5.24](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.23...aqua-ipfs-v0.5.24) (2023-11-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update toolchain and deps ([#116](https://github.com/fluencelabs/aqua-ipfs/issues/116)) ([b99d790](https://github.com/fluencelabs/aqua-ipfs/commit/b99d790d71f452e3eb00eda39ac3d9cada7f7fb8))
|
||||
|
||||
## [0.5.23](https://github.com/fluencelabs/aqua-ipfs/compare/aqua-ipfs-v0.5.22...aqua-ipfs-v0.5.23) (2023-11-15)
|
||||
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
# yaml-language-server: $schema=schemas/project-secrets.json
|
||||
|
||||
# Defines project's secret keys that are used only in the scope of this particular Fluence project. You can manage project's keys using commands from `fluence key` group of commands
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/project-secrets.md
|
||||
|
||||
version: 0
|
||||
keyPairs:
|
||||
[
|
||||
{
|
||||
peerId: 12D3KooWAtJ3RXGiW2WzZYUk7XxAEyfwLdqJHsPXmb7xd1dY7uZK,
|
||||
secretKey: BNidntUryx+hxr7NK2z9nci23sMn3fURB6bTH1K2Ll4=,
|
||||
publicKey: CAESIA/dWDmfLpI+PmldVAgQblramknRSyfivJ5x/Y0W6EQC,
|
||||
name: test_put_get_dag
|
||||
},
|
||||
]
|
1
aqua-tests/.fluence/secrets/test_put_get_dag.txt
Normal file
1
aqua-tests/.fluence/secrets/test_put_get_dag.txt
Normal file
@ -0,0 +1 @@
|
||||
BNidntUryx+hxr7NK2z9nci23sMn3fURB6bTH1K2Ll4=
|
2
aqua-tests/.gitignore
vendored
2
aqua-tests/.gitignore
vendored
@ -1,7 +1,7 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
.fluence/*
|
||||
!.fluence/project-secrets.yaml
|
||||
!.fluence/secrets
|
||||
**/node_modules
|
||||
**/target/
|
||||
.repl_history
|
||||
|
@ -4,5 +4,14 @@
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md
|
||||
|
||||
version: 2
|
||||
aquaInputPath: src/aqua/main.aqua
|
||||
version: 8
|
||||
|
||||
aquaDependencies:
|
||||
"@fluencelabs/aqua-lib": 0.9.1
|
||||
"@fluencelabs/spell": 0.6.9
|
||||
|
||||
compileAqua:
|
||||
default:
|
||||
input: src/aqua/main.aqua
|
||||
output: src/compiled-aqua
|
||||
target: ts
|
||||
|
42525
aqua-tests/package-lock.json
generated
42525
aqua-tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
"version": "1.0.0",
|
||||
"description": "Aqua-IPFS tests",
|
||||
"dependencies": {
|
||||
"@fluencelabs/aqua-lib": "0.8.1",
|
||||
"@fluencelabs/aqua-lib": "0.10.1",
|
||||
"@fluencelabs/aqua-ipfs": "file:../aqua"
|
||||
},
|
||||
"scripts": {
|
||||
@ -28,7 +28,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/fluencelabs/aqua-ipfs",
|
||||
"devDependencies": {
|
||||
"@fluencelabs/cli": "0.5.4",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.14"
|
||||
"@fluencelabs/cli": "0.15.1",
|
||||
"@fluencelabs/fluence-network-environment": "1.1.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
aqua IpfsApi declares *
|
||||
|
||||
export get_and_cache
|
||||
export put, dag_put, dag_get, get_from, dag_get_from, cat_from
|
||||
export set_timeout, get_external_api_multiaddr
|
||||
export get_external_swarm_multiaddr, get_local_api_multiaddr
|
||||
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
|
||||
import "ipfs.aqua"
|
||||
|
||||
alias Multiaddr: string
|
||||
alias PeerId: string
|
||||
alias CID: string
|
||||
alias Path: string
|
||||
|
||||
-- Download file from remote IPFS node to Fluence node and then
|
||||
-- put that file to local IPFS node, effectively caching it on the local IPFS node.
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Ipfs declares *
|
||||
aqua Ipfs declares *
|
||||
|
||||
data IpfsCatResult:
|
||||
success: bool
|
||||
|
35839
aqua/package-lock.json
generated
35839
aqua/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@fluencelabs/aqua-ipfs",
|
||||
"version": "0.5.21",
|
||||
"version": "0.6.0",
|
||||
"description": "Aqua IPFS library",
|
||||
"files": [
|
||||
"*.aqua"
|
||||
],
|
||||
"dependencies": {
|
||||
"@fluencelabs/aqua-lib": "0.8.1"
|
||||
"@fluencelabs/aqua-lib": "0.10.1"
|
||||
},
|
||||
"scripts": {
|
||||
"generate-aqua": "../service/build.sh",
|
||||
@ -29,8 +29,5 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/fluencelabs/aqua-ipfs/issues"
|
||||
},
|
||||
"homepage": "https://github.com/fluencelabs/aqua-ipfs#readme",
|
||||
"devDependencies": {
|
||||
"@fluencelabs/cli": "0.5.3"
|
||||
}
|
||||
"homepage": "https://github.com/fluencelabs/aqua-ipfs#readme"
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Run example on TestNet
|
||||
While in `example` directory, `npm start` will run `index.ts` against Fluence TestNet
|
||||
While in `example` directory, `npm run start` will run `index.ts` against Fluence TestNet
|
||||
|
||||
# Run example locally
|
||||
1. Go to `local-network`
|
||||
2. Run `docker compose up -d` to start Fluence cluster of 3 nodes
|
||||
3. Go back to `../example`
|
||||
4. Run `npm run start:local`
|
||||
To run example locally:
|
||||
1. Spin up local environment through [Fluence CLI](https://github.com/fluencelabs/cli)'s `local` command
|
||||
2. Pass local fluence peers multi addresses to `main` in `index.ts`
|
||||
3. (Optional) Change `IPFS_MULTIADDR` to address of your preferred IPFS node
|
||||
|
@ -1,3 +1,4 @@
|
||||
module Exports
|
||||
aqua Exports
|
||||
|
||||
import put, get_from, set_timeout from "@fluencelabs/aqua-ipfs/ipfs-api.aqua"
|
||||
export put, get_from, set_timeout
|
||||
|
122
example/index.ts
122
example/index.ts
@ -13,94 +13,72 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Fluence, testNet, Relay } from "@fluencelabs/js-client";
|
||||
|
||||
import { put, get_from, set_timeout } from "./generated/export";
|
||||
import { Fluence } from "@fluencelabs/fluence";
|
||||
import { Node, testNet } from "@fluencelabs/fluence-network-environment";
|
||||
import { put, get_from, set_timeout } from "./generated/export.js";
|
||||
|
||||
const { create, urlSource } = require("ipfs-http-client");
|
||||
const all = require("it-all");
|
||||
const uint8ArrayConcat = require("uint8arrays/concat");
|
||||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import { create } from "kubo-rpc-client";
|
||||
import all from "it-all";
|
||||
import uint8ArrayConcat from "uint8arrays/concat.js";
|
||||
|
||||
let local: Node[] = [
|
||||
{
|
||||
peerId: "12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK",
|
||||
multiaddr:
|
||||
"/ip4/127.0.0.1/tcp/9990/ws/p2p/12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK",
|
||||
},
|
||||
{
|
||||
peerId: "12D3KooWRABanQHUn28dxavN9ZS1zZghqoZVAYtFpoN7FdtoGTFv",
|
||||
multiaddr:
|
||||
"/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWRABanQHUn28dxavN9ZS1zZghqoZVAYtFpoN7FdtoGTFv",
|
||||
},
|
||||
{
|
||||
peerId: "12D3KooWFpQ7LHxcC9FEBUh3k4nSCC12jBhijJv3gJbi7wsNYzJ5",
|
||||
multiaddr:
|
||||
"/ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWFpQ7LHxcC9FEBUh3k4nSCC12jBhijJv3gJbi7wsNYzJ5",
|
||||
},
|
||||
];
|
||||
// Multi address of the IPFS node
|
||||
// we will work with through the Fluence Network
|
||||
const IPFS_MULTIADDR = multiaddr("/dns4/ipfs.fluence.dev/tcp/5001");
|
||||
|
||||
/**
|
||||
* @param environment - array of fluence network nodes (two are needed)
|
||||
* @note Pass addresses of local nodes to experiment locally
|
||||
*/
|
||||
async function main(environment: Relay[]) {
|
||||
const relay = environment[0];
|
||||
const node = environment[1];
|
||||
|
||||
const ipfs = await create({ url: IPFS_MULTIADDR });
|
||||
console.log("📗 Created IPFS HTTP Client");
|
||||
|
||||
const content = "Hola, Fluence!";
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
const added = await ipfs.add(encoder.encode(content));
|
||||
console.log("📗 Uploaded content, got CID:", added.cid.toString());
|
||||
|
||||
let stream = await ipfs.cat(added.path);
|
||||
let data = uint8ArrayConcat(await all(stream));
|
||||
const decoder = new TextDecoder();
|
||||
console.log("📗 Retrieved content: ", decoder.decode(data));
|
||||
|
||||
await Fluence.connect(relay);
|
||||
const client = Fluence.getClient();
|
||||
|
||||
async function main(environment: Node[]) {
|
||||
// setLogLevel('DEBUG');
|
||||
await Fluence.start({ connectTo: environment[1] });
|
||||
console.log(
|
||||
"📗 created a fluence peer %s with relay %s",
|
||||
Fluence.getStatus().peerId,
|
||||
Fluence.getStatus().relayPeerId
|
||||
"📗 Created a Fluence Peer %s with Relay %s",
|
||||
client.getPeerId(),
|
||||
client.getRelayPeerId()
|
||||
);
|
||||
|
||||
let ipfsAddr = "https://stage.fluence.dev:15001";
|
||||
let ipfsMultiaddr =
|
||||
"/ip4/134.209.186.43/tcp/5001/p2p/12D3KooWEhCqQ9NBnmtSfNeXSNfhgccmH86xodkCUxZNEXab6pkw";
|
||||
const ipfs = create(ipfsAddr);
|
||||
console.log("📗 created ipfs client");
|
||||
// default IPFS timeout is 1 sec,
|
||||
// set to 10 secs to retrieve file from remote node
|
||||
await set_timeout(node.peerId, 10);
|
||||
console.log("📘 Ipfs.set_timeout");
|
||||
|
||||
await ipfs.id();
|
||||
console.log("📗 connected to ipfs");
|
||||
|
||||
let source = urlSource(
|
||||
"https://images.adsttc.com/media/images/5ecd/d4ac/b357/65c6/7300/009d/large_jpg/02C.jpg?1590547607"
|
||||
);
|
||||
const file = await ipfs.add(source);
|
||||
console.log("📗 uploaded file:", file);
|
||||
|
||||
let files = await ipfs.get(file.cid);
|
||||
for await (const file of files) {
|
||||
const content = uint8ArrayConcat(await all(file.content));
|
||||
console.log("📗 downloaded file of length ", content.length);
|
||||
}
|
||||
|
||||
// default IPFS timeout is 1 sec, set to 10 secs to retrieve file from remote node
|
||||
await set_timeout(environment[2].peerId, 10);
|
||||
|
||||
console.log("📘 file hash: ", file.cid);
|
||||
let getResult = await get_from(
|
||||
environment[2].peerId,
|
||||
file.cid.toString(),
|
||||
ipfsMultiaddr,
|
||||
{ ttl: 10000 }
|
||||
node.peerId,
|
||||
added.cid.toString(),
|
||||
IPFS_MULTIADDR.toString(),
|
||||
{ ttl: 20000 }
|
||||
);
|
||||
console.log("📘 Ipfs.get", getResult);
|
||||
console.log("📘 Ipfs.get_from", getResult);
|
||||
|
||||
let putResult = await put(environment[2].peerId, getResult.path, {
|
||||
ttl: 10000,
|
||||
let putResult = await put(node.peerId, getResult.path, {
|
||||
ttl: 20000,
|
||||
});
|
||||
console.log("📘 Ipfs.put", putResult);
|
||||
|
||||
return;
|
||||
await ipfs.stop();
|
||||
}
|
||||
|
||||
let args = process.argv.slice(2);
|
||||
var environment: Node[];
|
||||
if (args.length >= 1 && args[0] == "local") {
|
||||
environment = local;
|
||||
console.log("📘 Will connect to local nodes");
|
||||
} else {
|
||||
environment = testNet;
|
||||
console.log("📘 Will connect to testNet");
|
||||
}
|
||||
|
||||
main(environment)
|
||||
main(testNet)
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
|
15830
example/package-lock.json
generated
15830
example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,11 @@
|
||||
{
|
||||
"type": "module",
|
||||
"name": "ipfs-aqua-example",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple example of how to use ipfs-aqua in TS",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"compile-aqua": "aqua -i aqua -o generated",
|
||||
"compile-aqua": "fluence aqua -i aqua -o generated",
|
||||
"prebuild": "npm run compile-aqua",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js",
|
||||
@ -13,12 +14,11 @@
|
||||
"author": "Fluence Labs",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@fluencelabs/aqua-ipfs": "file:../aqua",
|
||||
"@fluencelabs/aqua-lib": "^0.8.1",
|
||||
"@fluencelabs/aqua": "0.7.4-322",
|
||||
"@fluencelabs/fluence": "^0.23.0",
|
||||
"@fluencelabs/fluence-network-environment": "^1.0.13",
|
||||
"ipfs-http-client": "^50.1.2",
|
||||
"@fluencelabs/aqua-ipfs": "^0.5.29",
|
||||
"@fluencelabs/aqua-lib": "^0.9.0",
|
||||
"@fluencelabs/js-client": "^0.4.2",
|
||||
"kubo-rpc-client": "^3.0.2",
|
||||
"@multiformats/multiaddr": "^12.1.1",
|
||||
"it-all": "^1.0.5",
|
||||
"uint8arrays": "^2.1.5"
|
||||
},
|
||||
|
@ -5,7 +5,7 @@
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
"module": "ES2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
@ -41,7 +41,7 @@
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2022-12-06"
|
||||
channel = "nightly-2023-12-06"
|
||||
targets = [ "x86_64-unknown-linux-gnu", "wasm32-wasi", "x86_64-apple-darwin" ]
|
||||
components = [ "rustfmt", "clippy" ]
|
||||
|
1998
service/Cargo.lock
generated
1998
service/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -5,3 +5,6 @@ members = [
|
||||
"distro",
|
||||
"types",
|
||||
]
|
||||
[workspace.dependencies]
|
||||
marine-rs-sdk = { version = "0.13.0", features = ["logger"] }
|
||||
marine-rs-sdk-test = "0.14.0"
|
||||
|
@ -1,3 +1,5 @@
|
||||
total_memory_limit = "Infinity"
|
||||
|
||||
[[module]]
|
||||
name = "ipfs_effector"
|
||||
mem_pages_count = 100
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "aqua-ipfs-distro"
|
||||
version = "0.5.20"
|
||||
version = "0.6.0"
|
||||
description = "distribution of aqua ipfs service"
|
||||
edition = "2021"
|
||||
build = "build.rs"
|
||||
@ -13,4 +13,4 @@ include = [ "/src", "/ipfs-service", "build.rs", "Cargo.toml" ]
|
||||
maplit = "1.0.2"
|
||||
|
||||
[build-dependencies]
|
||||
built = "0.5.2"
|
||||
built = "0.7.0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ipfs-effector"
|
||||
version = "0.5.20"
|
||||
version = "0.6.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
@ -10,17 +10,17 @@ name = "ipfs_effector"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
|
||||
marine-rs-sdk = { workspace = true }
|
||||
multiaddr = { version = "0.11.2", package = "fluence-fork-parity-multiaddr" }
|
||||
log = "0.4.14"
|
||||
log = "0.4.20"
|
||||
eyre = "0.6.8"
|
||||
serde_json = "1.0.64"
|
||||
itertools = "0.10.5"
|
||||
itertools = "0.12.0"
|
||||
|
||||
types = { path = "../types" }
|
||||
|
||||
[dev-dependencies]
|
||||
marine-rs-sdk-test = "0.10.0"
|
||||
marine-rs-sdk-test = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
marine-rs-sdk-test = "0.10.0"
|
||||
marine-rs-sdk-test = { workspace = true }
|
||||
|
@ -185,7 +185,7 @@ pub fn cat(hash: String, api_multiaddr: String, timeout_sec: u64) -> IpfsCatResu
|
||||
}
|
||||
|
||||
#[marine]
|
||||
#[link(wasm_import_module = "host")]
|
||||
#[host_import]
|
||||
extern "C" {
|
||||
/// Execute provided cmd as a parameters of ipfs cli, return result.
|
||||
pub fn ipfs(cmd: Vec<String>) -> MountedBinaryResult;
|
||||
|
@ -1,4 +1,5 @@
|
||||
modules_dir = "../../artifacts/"
|
||||
total_memory_limit = "Infinity"
|
||||
|
||||
[[module]]
|
||||
name = "ipfs_effector"
|
||||
|
@ -1,4 +1,5 @@
|
||||
modules_dir = "../../artifacts/"
|
||||
total_memory_limit = "Infinity"
|
||||
|
||||
[[module]]
|
||||
name = "ipfs_effector"
|
||||
|
@ -1,4 +1,5 @@
|
||||
modules_dir = "../../artifacts/"
|
||||
total_memory_limit = "Infinity"
|
||||
|
||||
[[module]]
|
||||
name = "ipfs_effector"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ipfs-pure"
|
||||
version = "0.5.20"
|
||||
version = "0.6.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
@ -10,18 +10,18 @@ name = "ipfs_pure"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
|
||||
marine-rs-sdk = { workspace = true }
|
||||
multiaddr = { version = "0.11.2", package = "fluence-fork-parity-multiaddr" }
|
||||
log = "0.4.14"
|
||||
log = "0.4.20"
|
||||
eyre = "0.6.8"
|
||||
toml = "0.5.8"
|
||||
serde = "1.0.152"
|
||||
bs58 = "0.4.0"
|
||||
toml = "0.8.8"
|
||||
serde = "1.0.188"
|
||||
bs58 = "0.5.0"
|
||||
|
||||
types = { path = "../types" }
|
||||
|
||||
[dev-dependencies]
|
||||
marine-rs-sdk-test = "0.10.0"
|
||||
marine-rs-sdk-test = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
marine-rs-sdk-test = "0.10.0"
|
||||
marine-rs-sdk-test = { workspace = true }
|
||||
|
@ -23,6 +23,7 @@ use types::{
|
||||
|
||||
use marine_rs_sdk::marine;
|
||||
use marine_rs_sdk::module_manifest;
|
||||
use marine_rs_sdk::ParticleParameters;
|
||||
use marine_rs_sdk::WasmLoggerBuilder;
|
||||
|
||||
use eyre::WrapErr;
|
||||
@ -110,6 +111,10 @@ pub fn get_peer_id(api_multiaddr: String, timeout: u64) -> eyre::Result<Protocol
|
||||
))
|
||||
}
|
||||
|
||||
fn vault_path(particle: &ParticleParameters) -> String {
|
||||
format!("/tmp/vault/{}-{}", particle.id, particle.token)
|
||||
}
|
||||
|
||||
#[marine]
|
||||
pub fn connect(multiaddr: String) -> IpfsResult {
|
||||
if Multiaddr::from_str(&multiaddr).is_err() {
|
||||
@ -167,8 +172,8 @@ pub fn get_from(hash: String, external_multiaddr: String) -> IpfsGetResult {
|
||||
return Err(eyre::eyre!("invalid multiaddr: {}", external_multiaddr)).into();
|
||||
}
|
||||
|
||||
let particle_id = marine_rs_sdk::get_call_parameters().particle_id;
|
||||
let particle_vault_path = format!("/tmp/vault/{}", particle_id);
|
||||
let particle = marine_rs_sdk::get_call_parameters().particle;
|
||||
let particle_vault_path = vault_path(&particle);
|
||||
let path = format!("{}/{}", particle_vault_path, hash);
|
||||
let get_result = ipfs_get(hash, &path, external_multiaddr, timeout);
|
||||
|
||||
@ -198,8 +203,8 @@ pub fn dag_get_from(hash: String, external_multiaddr: String) -> IpfsGetResult {
|
||||
return Err(eyre::eyre!("invalid multiaddr: {}", external_multiaddr)).into();
|
||||
}
|
||||
|
||||
let particle_id = marine_rs_sdk::get_call_parameters().particle_id;
|
||||
let particle_vault_path = format!("/tmp/vault/{}", particle_id);
|
||||
let particle = marine_rs_sdk::get_call_parameters().particle;
|
||||
let particle_vault_path = vault_path(&particle);
|
||||
let path = format!("{}/{}", particle_vault_path, hash);
|
||||
let get_result = ipfs_dag_get(hash, &path, external_multiaddr, timeout);
|
||||
|
||||
@ -240,7 +245,7 @@ pub fn get_external_api_multiaddr() -> IpfsMultiaddrResult {
|
||||
#[marine]
|
||||
pub fn set_external_api_multiaddr(multiaddr: String) -> IpfsResult {
|
||||
let call_parameters = marine_rs_sdk::get_call_parameters();
|
||||
if call_parameters.init_peer_id != call_parameters.service_creator_peer_id {
|
||||
if call_parameters.particle.init_peer_id != call_parameters.service_creator_peer_id {
|
||||
return eyre::Result::<()>::Err(eyre::eyre!(
|
||||
"only service creator can set external api multiaddr"
|
||||
))
|
||||
@ -291,7 +296,7 @@ pub fn get_local_api_multiaddr() -> IpfsMultiaddrResult {
|
||||
#[marine]
|
||||
pub fn set_local_api_multiaddr(multiaddr: String) -> IpfsResult {
|
||||
let call_parameters = marine_rs_sdk::get_call_parameters();
|
||||
if call_parameters.init_peer_id != call_parameters.service_creator_peer_id {
|
||||
if call_parameters.particle.init_peer_id != call_parameters.service_creator_peer_id {
|
||||
return eyre::Result::<()>::Err(eyre::eyre!(
|
||||
"only service creator can set local api multiaddr"
|
||||
))
|
||||
@ -320,7 +325,7 @@ pub fn get_external_swarm_multiaddr() -> IpfsMultiaddrResult {
|
||||
#[marine]
|
||||
pub fn set_external_swarm_multiaddr(multiaddr: String) -> IpfsResult {
|
||||
let call_parameters = marine_rs_sdk::get_call_parameters();
|
||||
if call_parameters.init_peer_id != call_parameters.service_creator_peer_id {
|
||||
if call_parameters.particle.init_peer_id != call_parameters.service_creator_peer_id {
|
||||
return eyre::Result::<()>::Err(eyre::eyre!(
|
||||
"only service creator can set external swarm multiaddr"
|
||||
))
|
||||
@ -371,7 +376,7 @@ pub fn set_timeout(timeout_sec: u64) {
|
||||
}
|
||||
|
||||
#[marine]
|
||||
#[link(wasm_import_module = "ipfs_effector")]
|
||||
#[module_import("ipfs_effector")]
|
||||
extern "C" {
|
||||
#[link_name = "connect"]
|
||||
pub fn ipfs_connect(
|
||||
|
@ -1,4 +1,5 @@
|
||||
modules_dir = "../../artifacts/"
|
||||
total_memory_limit = "Infinity"
|
||||
|
||||
[[module]]
|
||||
name = "ipfs_effector"
|
||||
|
@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "types"
|
||||
version = "0.5.17"
|
||||
version = "0.6.0"
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
|
||||
marine-rs-sdk = { workspace = true }
|
||||
eyre = "0.6.8"
|
||||
|
Loading…
x
Reference in New Issue
Block a user