-
Notifications
You must be signed in to change notification settings - Fork 3
feat: examples #67
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
Merged
feat: examples #67
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8844ecc
chore(examples): init examples
cbrzn 03f3e80
chore(examples): ens, etherem & ipfs
cbrzn b220aa8
chore: update readme
cbrzn d3c9448
chore(ci): add examples
cbrzn 3093fca
chore(examples): use constant for uris
cbrzn 5649146
chore(examples/ens): ethereumPluginUri -> ethereumWalletUri
cbrzn 4224576
chore(ci): fix example script
cbrzn e743867
chore(ci/examples): add yarn install step
cbrzn ffb41be
chore(examples): add instruction to spin up local ipfs node
cbrzn ac33cae
chore: fix readmes
cbrzn 0daaf7d
chore(example): add note of docker needed in ipfs example
cbrzn 29296dc
chore(examples): rename hello world to logger
cbrzn 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 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 |
|---|---|---|
|
|
@@ -23,4 +23,5 @@ polywrap.deployment.txt | |
| **/.pytest_cache/ | ||
| **/__pycache__/ | ||
| **/dist/ | ||
| poetry.lock | ||
| poetry.lock | ||
| examples/yarn.lock | ||
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 @@ | ||
| # Contributing | ||
|
|
||
| Thank you for considering contributing to the Polywrap Javascript Client! We welcome contributions from the community to help improve and enhance the project. Look through this repository's [issues](https://github.com/polywrap/javascript-client/issues) to see what we're focused on solving. | ||
|
|
||
|
|
||
| ## Pre-Requisites | ||
| To be able to fully build and test all functionality within the JS Client, you'll need the following programs installed: | ||
|
|
||
| `nvm` | ||
| `yarn` | ||
|
|
||
| ## Installation | ||
|
|
||
| From the root directory, run `nvm install && nvm use` to install the correct version of Node.JS. Next, run `yarn` to install all dependencies for all packages. | ||
|
|
||
| ## Build | ||
|
|
||
| Running `yarn build` from the root directory will build all packages. After this, if you'd like to rebuild an individual package you're making changes to, simply run `yarn build` within the specific `./packages/...` folder you're working in. | ||
|
|
||
|
|
||
| ## Test | ||
|
|
||
| Run `yarn test` from the root to test everything, and `yarn test` within a specific package folder to test just that package. | ||
|
|
||
|
|
||
| ## Feedback and Discussions | ||
|
|
||
| For questions, suggestions, or discussions, open an issue or create a discussion within the [Polywrap Discord](https://discord.polywrap.io). | ||
|
|
||
| Happy coding! |
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 |
|---|---|---|
| @@ -1,82 +1,48 @@ | ||
|  | ||
|  | ||
|
|
||
| [**Polywrap**](https://polywrap.io/) is a developer tool that enables easy integration of Web3 protocols into any application. It makes it possible for applications on any platform, written in any language, to read and write data to Web3 protocols. | ||
| # Javascript Client | ||
|
|
||
| # Getting Started | ||
|
|
||
| Have questions or want to get involved? Join our community [Discord](https://discord.polywrap.io) or [open an issue](https://github.com/polywrap/javascript-client/issues) on Github. | ||
|
|
||
| For detailed information about Polywrap and the WRAP standard, visit our [developer documentation](https://docs.polywrap.io/). | ||
|
|
||
| # Contributing | ||
|
|
||
| The Polywrap project is completely open-source and we welcome contributors of all levels. | ||
|
|
||
| Come visit our [Github issues](https://github.com/polywrap/javascript-client/issues) to see the problems we're focused on solving. Here are some of our tags for issues and what they mean: | ||
|
|
||
| - `good first issue` - These are good first issues for newcomers to learn about how our project works | ||
|
|
||
| - `pri-0`, `pri-1` and `pri-2` - These are our priority issues, with `pri-0` being our highest priority and `pri-2` being lower. | ||
|
|
||
| - `alpha-blocker` - We're in pre-alpha right now and to get to alpha, we need to resolve all alpha blocker issues | ||
|
|
||
| - `beta-blocker` - After our alpha release, we'll start working towards releasing our beta! These are the blockers for us in reaching that milestone. | ||
|
|
||
| Below are a series of steps to get started with our monorepo after you've cloned it into your local repository. | ||
|
|
||
| Before contributing to this repository, please read the [developer guidelines](DEV_GUIDELINES.md). | ||
|
|
||
| ## Pre-reqs | ||
|
|
||
| You'll need the following installed before building your wrapper: | ||
|
|
||
| `nvm` | ||
|
|
||
| `yarn` | ||
|
|
||
| `docker` | ||
|
|
||
| `docker-compose` | ||
| Implementation of the Polywrap client in JavaScript. | ||
|
|
||
| ## Installation | ||
|
|
||
| To ensure all of your project's dependencies are installed, from inside your project's directory, simply run: | ||
|
|
||
| ``` | ||
| nvm install && nvm use | ||
| yarn | ||
| npm install @polywrap/client | ||
| # or | ||
| yarn add @polywrap/client | ||
| ``` | ||
|
|
||
| ## Build | ||
|
|
||
| Run the following to compile the monorepo: | ||
|
|
||
| `yarn build` | ||
|
|
||
| ## Test | ||
|
|
||
| Run the following to test if the build worked: | ||
|
|
||
| ``` | ||
| yarn test | ||
| ``` | ||
| ## Getting Started | ||
|
|
||
| ## Lint | ||
| Create a new Polywrap client config builder instance, add the bundles you want to use, and then create a new Polywrap client instance with the config. | ||
|
|
||
| To lint your project directory, run the following: | ||
| ```typescript | ||
| import { | ||
| PolywrapClient, | ||
| PolywrapClientConfigBuilder | ||
| } from "@polywrap/client"; | ||
|
|
||
| ``` | ||
| yarn lint | ||
| ``` | ||
| const builder = new PolywrapClientConfigBuilder(); | ||
| builder.addBundle("sys"); | ||
| const client = new PolywrapClient(builder.build()); | ||
|
|
||
| To auto-fix lint errors: | ||
| const result = await client.invoke<boolean>({ | ||
| uri: "wrapscan.io/polywrap/logging@1.0.0", | ||
| method: "info", | ||
| args: { | ||
| message: "Hello from hello world wrap!", | ||
| } | ||
| }); | ||
|
|
||
| if (!result.ok) { | ||
| throw Error("Log message error: " + result.error); | ||
| } | ||
| ``` | ||
| yarn lint:fix | ||
| ``` | ||
|
|
||
| # Resources | ||
| - [Website](https://polywrap.io/) | ||
|
|
||
| - [Documentation](https://docs.polywrap.io/) | ||
| - [Forum](https://forum.polywrap.io/) | ||
| - [Examples](./examples/) | ||
| - [Features supported](https://github.com/polywrap/client-readiness/tree/main/clients/js/src/features) | ||
|
|
||
| # Support | ||
|
|
||
| For any questions or problems, please visit our [Discord](https://discord.polywrap.io). |
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,55 @@ | ||
| # Polywrap JS Client Examples | ||
|
|
||
| Before running any example you must run `yarn` in the `examples` folder | ||
|
|
||
| ## File System | ||
|
|
||
| Invokes the File System plugin; which creates, reads and deletes a file | ||
| ``` | ||
| $ yarn run:fs | ||
| ``` | ||
|
|
||
| ## Http | ||
|
|
||
| Invokes the HTTP plugin, doing GET and POST requests | ||
| ``` | ||
| $ yarn run:http | ||
| ``` | ||
|
|
||
| ## Ipfs | ||
|
|
||
| Invoke the IPFS Client wrap; adds file to a local IPFS node, and then retrieves it. | ||
| Before running this example, you must instantiate a local IPFS node by running the following command: | ||
|
|
||
| _NOTE: This command requires Docker to be installed on your machine._ | ||
| ``` | ||
| $ npx polywrap infra up --modules=eth-ens-ipfs | ||
| ``` | ||
| And now you can run the example: | ||
| ``` | ||
| $ yarn run:ipfs | ||
| ``` | ||
|
|
||
| ## Logger | ||
|
|
||
| Invokes the logger wrap, which interacts with the logger plugin. It shows a console.log message from WASM world | ||
| ``` | ||
| $ yarn run:logger | ||
| ``` | ||
|
|
||
| ## Ethereum | ||
|
|
||
| Invoke the Ethers core & util wraps, and uses the Ethereum Wallet plugin. It gets the balance of the Staking contract and then parses it from Wei to Eth. Also, it executes the sign typed data method | ||
|
|
||
| ``` | ||
| $ yarn run:ethereum | ||
| ``` | ||
|
|
||
| ## ENS | ||
|
|
||
| Invoke the ENS wrap, it gets the resolver & content hash of vitalik.eth | ||
| ``` | ||
| $ yarn run:ens | ||
| ``` | ||
|
|
||
|
|
||
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,25 @@ | ||
| { | ||
| "name": "polywrap-js-examples", | ||
| "description": "Polywrap Client JS examples", | ||
| "license": "MIT", | ||
| "scripts": { | ||
| "run:fs": "ts-node src/filesystem.ts", | ||
| "run:http": "ts-node src/http.ts", | ||
| "run:logger": "ts-node src/logger.ts", | ||
| "run:ipfs": "ts-node src/ipfs.ts", | ||
| "run:ethereum": "ts-node src/ethereum.ts", | ||
| "run:ens": "ts-node src/ens.ts" | ||
| }, | ||
| "devDependencies": { | ||
| "@polywrap/client-js": "../packages/client", | ||
| "@polywrap/file-system-plugin-js": "0.12.0-pre.0", | ||
| "@polywrap/http-plugin-js": "0.12.0-pre.0", | ||
| "@polywrap/logger-plugin-js": "0.12.0-pre.0", | ||
| "@polywrap/ethereum-wallet-js": "0.1.0", | ||
| "ts-node": "10.9.1", | ||
| "typescript": "4.9.5" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } |
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.