Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion .github/workflows/ci-javascript.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ jobs:
Test:
runs-on: ubuntu-latest
timeout-minutes: 60
if: ${{ always() }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -116,3 +115,50 @@ jobs:

- name: Test
run: yarn test

Examples:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: (yarn install --nonInteractive --frozen-lockfile --prefer-offline || yarn install --nonInteractive --frozen-lockfile --prefer-offline)

- name: Build
run: yarn build

- name: Instantiate IPFS node
run: npx polywrap infra up --modules=eth-ens-ipfs

- name: Examples
run: |
cd examples
yarn
yarn run:logger
yarn run:fs
yarn run:http
yarn run:ipfs
yarn run:ethereum
yarn run:ens
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ polywrap.deployment.txt
**/.pytest_cache/
**/__pycache__/
**/dist/
poetry.lock
poetry.lock
examples/yarn.lock
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
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!
55 changes: 0 additions & 55 deletions DEV_GUIDELINES.md

This file was deleted.

98 changes: 32 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,48 @@
![Public Release Announcement](https://user-images.githubusercontent.com/5522128/177473887-2689cf25-7937-4620-8ca5-17620729a65d.png)
![polywrap-banner](https://raw.githubusercontent.com/polywrap/branding/master/assets/banner.png)

[**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).
55 changes: 55 additions & 0 deletions examples/README.md
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
```


25 changes: 25 additions & 0 deletions examples/package.json
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"
}
}
Loading