Skip to content
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

Support Node.js #65

Merged
merged 17 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
19 changes: 18 additions & 1 deletion manta-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ yarn install manta.js
1. `git clone https://github.com/Manta-Network/sdk.git`
2. `cd sdk/manta-js/package`
3. `yarn`
4. `yarn build`
4. `yarn build` for use in browser or `yarn build-node` for use in node.js
5. add `"manta.js": "file:/{LOCAL PATH OF sdk/manta-js/package}` to your project's package.json
6. `yarn upgrade manta.js` in your project's directory

Expand All @@ -27,6 +27,23 @@ All methods are called through the `MantaPrivateWallet` class.

Refer to `/examples` for more thorough examples, and how to run them.

## Node Specific

If running in node.js the wasm module assumes browser DOM exists, you must export Web API functions from node in your project as seen below.

```javascript
import fetch from 'node-fetch';

// @ts-ignore
global.fetch = fetch;
// @ts-ignore
global.Headers = fetch.Headers;
// @ts-ignore
global.Request = fetch.Request;
// @ts-ignore
global.Response = fetch.Response;
```

## Initialization

The `Environment` flag specifies whether to connect to a local node, or the use an actual node from the network.
Expand Down
Loading