Skip to content

Commit

Permalink
docs(gno-js): Add provider instantiation docs (#2427)
Browse files Browse the repository at this point in the history
While using `gno-js` and reading the [related
docs](https://docs.gno.land/reference/gno-js-client/gno-js-provider), I
saw the message saying that it's based on `tm2-js-client` with related
link.
This is useful to understand how it works and see the available methods
from the base Provider classes, but doesn't inform the developer about
how he should instantiate a provider with `gno-js-client`, the name of
the providers isn't mentioned anywhere and I had to guess it (or use my
IDE autocomplete) and look at other projects using it to find out.

This PR adds a small section to the documentation page with explicit
instantiation examples to fix this (without repeating too much info,
parameters for example are linked to `tm2-js-client`, but could be
extended in the future and documented here).

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
  • Loading branch information
RezaRahemtola and leohhhn authored Nov 15, 2024
1 parent 38736e7 commit 6c5329d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/reference/gno-js-client/gno-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ id: gno-js-provider
The `Gno Provider` is an extension on the `tm2-js-client` `Provider`,
outlined [here](../tm2-js-client/Provider/provider.md). Both JSON-RPC and WS providers are included with the package.

## Instantiation

### new GnoWSProvider

Creates a new instance of the Gno WebSocket Provider, based on [`tm2-js-client` `WSProvider`](../tm2-js-client/Provider/ws-provider.md).

#### Parameters

Same as [`tm2-js-client` `WSProvider`](../tm2-js-client/Provider/ws-provider.md).

#### Usage

```ts
new GnoWSProvider('ws://staging.gno.land:26657/ws');
// provider with WS connection is created
```

### new GnoJSONRPCProvider

Creates a new instance of the Gno JSON-RPC Provider, based on [`tm2-js-client` `JSONRPCProvider`](../tm2-js-client/Provider/json-rpc-provider.md).

#### Parameters

Same as [`tm2-js-client` `JSONRPCProvider`](../tm2-js-client/Provider/json-rpc-provider.md).

#### Usage

```ts
new GnoJSONRPCProvider('http://staging.gno.land:36657');
// provider is created
```

## Realm Methods

### getRenderOutput
Expand Down

0 comments on commit 6c5329d

Please sign in to comment.