-
Notifications
You must be signed in to change notification settings - Fork 49
IPFS plugin separation of concerns #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dOrgJelli
merged 30 commits into
prealpha-dev
from
pileks-ipfs-plugin-separation-of-concerns
Jun 27, 2022
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ebf6541
separate ipfs plugin and ipfs-resolver plugin, add ipfs plugin interface
pileks 32731d2
Merge branch 'prealpha-dev' into pileks-ipfs-plugin-separation-of-con…
pileks ff46e3f
fix up new plugins for polywrap rename
pileks b9db16b
Fix build issues introduced by new interface
pileks 74d8d03
fix default-client-config
pileks 924badb
fix lint
pileks e96b5e1
IPFS plugin basic tests
pileks 5e04429
Remove redundant method in ipfs plugin, refactor
pileks 1d76be3
fix test breaking in CI
pileks 9378615
Increase jest timeout for CI
pileks ecaf297
IPFS URI Resolver basic test
pileks 52643e1
add e2e test for ipfs-resolver-plugin-js
pileks fd936b3
increase timeout for ipfs-resolver tests
pileks 7caad9f
Merge remote-tracking branch 'origin/prealpha-dev' into pileks-ipfs-p…
pileks 459cc2e
fix package.json
pileks 11a2e9d
remove catToString from IPFS interface and plugin
pileks 289a72f
resolve PR comments
pileks 45d11dd
Merge remote-tracking branch 'origin/prealpha-dev' into pileks-ipfs-p…
pileks 28c5bc0
removed unused functions and types
nerfZael d1751eb
refactored ipfs client handling in tests
nerfZael e1aead0
locked dependencies and replaced the deprecated cids package with the…
nerfZael 7fba2be
Merge pull request #949 from polywrap/nerfzael-uri-resolver-test-fixes
dOrgJelli fc355e2
Code style changes
pileks 989a19f
Merge remote-tracking branch 'origin/prealpha-dev' into pileks-ipfs-p…
pileks 85f03ad
update yarn.lock
pileks 539c77a
Merge remote-tracking branch 'origin/prealpha-dev' into pileks-ipfs-p…
pileks 098b5d0
fix IPFS plugin manifest import redirect
pileks 3b3d37d
IPFS Resolver manifest correct name
pileks 48707c2
merge prealpha-dev
dOrgJelli b056f87
remove unnecessary .gitignore + .nvmrc files
dOrgJelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| TODO |
This file contains hidden or 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,16 @@ | ||
| { | ||
| "name": "@polywrap/ipfs-interface", | ||
| "description": "Polywrap Ipfs Interface", | ||
| "private": true, | ||
| "version": "0.0.1-prealpha.89", | ||
| "scripts": { | ||
| "build": "node ../../../dependencies/node_modules/polywrap/bin/polywrap build", | ||
| "lint": "eslint --color -c ../../../.eslintrc.js .", | ||
| "test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs", | ||
| "test:env:down": "npx polywrap infra down --modules=eth-ens-ipfs", | ||
| "deploy": "node ../../../dependencies/node_modules/polywrap/bin/polywrap deploy" | ||
| }, | ||
| "devDependencies": { | ||
| "polywrap": "0.0.1-prealpha.89" | ||
| } | ||
| } |
This file contains hidden or 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,5 @@ | ||
| format: 0.0.1-prealpha.1 | ||
| stages: | ||
| ipfs_deploy: | ||
| package: ipfs | ||
| uri: fs/./build |
This file contains hidden or 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,5 @@ | ||
| format: 0.0.1-prealpha.9 | ||
| name: IPFS | ||
| language: interface | ||
| deploy: ./polywrap.deploy.yaml | ||
| schema: ./src/schema.graphql |
This file contains hidden or 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,30 @@ | ||
| type Module { | ||
| cat(cid: String!, options: Options): Bytes! | ||
|
|
||
| resolve(cid: String!, options: Options): ResolveResult | ||
|
|
||
| addFile(data: Bytes!): String! | ||
| } | ||
|
|
||
| type ResolveResult { | ||
| cid: String! | ||
| provider: String! | ||
| } | ||
|
|
||
| type Options { | ||
| """ | ||
| Timeout (in ms) for the operation. | ||
| Fallback providers are used if timeout is reached. | ||
| """ | ||
| timeout: UInt32 | ||
|
|
||
| """ | ||
| The IPFS provider to be used | ||
| """ | ||
| provider: String | ||
|
|
||
| """ | ||
| Disable querying providers in parallel when resolving URIs | ||
| """ | ||
| disableParallelRequests: Boolean | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,5 +1,90 @@ | ||
| /* eslint-disable @typescript-eslint/no-empty-function */ | ||
| // TODO: create client, add plugin, test all the methods | ||
| describe("TODO", () => { | ||
| it("TODO", () => {}); | ||
| import { PolywrapClient } from "@polywrap/client-js"; | ||
| import { | ||
| initTestEnvironment, | ||
| providers, | ||
| stopTestEnvironment, | ||
| } from "@polywrap/test-env-js"; | ||
|
|
||
| import { ipfsPlugin } from ".."; | ||
| import { IpfsClient, IpfsFileInfo } from "../utils/IpfsClient"; | ||
| import { Ipfs_Module } from "../wrap"; | ||
|
|
||
| const createIpfsClient = require("@dorgjelli-test/ipfs-http-client-lite"); | ||
|
|
||
| jest.setTimeout(300000); | ||
|
|
||
| describe("IPFS Plugin", () => { | ||
| let client: PolywrapClient; | ||
| let ipfs: IpfsClient; | ||
|
|
||
| const sampleFileTextContents = "Hello World!"; | ||
| let sampleFileIpfsInfo: IpfsFileInfo; | ||
| const sampleFileBuffer = Buffer.from(sampleFileTextContents, "utf-8"); | ||
|
|
||
| beforeAll(async () => { | ||
| await initTestEnvironment(); | ||
| ipfs = createIpfsClient(providers.ipfs); | ||
|
|
||
| client = new PolywrapClient({ | ||
| plugins: [ | ||
| { | ||
| uri: "wrap://ens/ipfs.polywrap.eth", | ||
| plugin: ipfsPlugin({ | ||
| provider: providers.ipfs, | ||
| }), | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| let ipfsAddResult = await ipfs.add(sampleFileBuffer); | ||
| sampleFileIpfsInfo = ipfsAddResult[0]; | ||
| }); | ||
|
|
||
| afterAll(async () => { | ||
| await stopTestEnvironment(); | ||
| }); | ||
|
|
||
| it("Should cat a file successfully", async () => { | ||
| expect(sampleFileIpfsInfo).toBeDefined(); | ||
|
|
||
| let result = await Ipfs_Module.cat( | ||
| { cid: sampleFileIpfsInfo.hash.toString() }, | ||
| client | ||
| ); | ||
|
|
||
| expect(result.error).toBeFalsy(); | ||
|
|
||
| expect(result.data).toEqual(sampleFileBuffer); | ||
| }); | ||
|
|
||
| it("Should resolve a file successfully", async () => { | ||
| expect(sampleFileIpfsInfo).toBeDefined(); | ||
|
|
||
| let result = await Ipfs_Module.resolve( | ||
| { cid: sampleFileIpfsInfo.hash.toString() }, | ||
| client | ||
| ); | ||
|
|
||
| expect(result.error).toBeFalsy(); | ||
|
|
||
| expect(result.data).toEqual({ | ||
| cid: `/ipfs/${sampleFileIpfsInfo.hash.toString()}`, | ||
| provider: providers.ipfs, | ||
| }); | ||
| }); | ||
|
|
||
| it("Should add a file successfully", async () => { | ||
| const expectedContents = "A new sample file"; | ||
| const contentsBuffer = Buffer.from(expectedContents, "utf-8"); | ||
|
|
||
| let result = await Ipfs_Module.addFile({ data: contentsBuffer }, client); | ||
|
|
||
| expect(result.error).toBeFalsy(); | ||
|
|
||
| expect(result.data).toBeTruthy(); | ||
|
|
||
| const addedFileBuffer = await ipfs.cat(result.data as string); | ||
|
|
||
| expect(contentsBuffer).toEqual(addedFileBuffer); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.