Skip to content

Commit

Permalink
Merge branch 'main' into update_kotlin_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Talhaali00 authored Oct 24, 2022
2 parents c18260f + b2be9b4 commit 019b3c5
Show file tree
Hide file tree
Showing 27 changed files with 379 additions and 273 deletions.
80 changes: 47 additions & 33 deletions docs/introduction/cloud-explorer.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,74 @@ If you would like to edit or claim an existing cloud explorer item, email us at

The Cloud Explorer API currently offers the following functionality:

- [Listings](#listings-api) - Allows for fetching of wallets and dApps listed in the [WalletConnect Cloud Explorer](https://explorer.walletconnect.com/).
- [Logo](#logo-api) - Provides logo assets in different sizes for a given Cloud explorer entry.
- [Listings](#listings) - Allows for fetching of wallets and dApps listed in the [WalletConnect Cloud Explorer](https://explorer.walletconnect.com/).
- [Logos](#logos) - Provides logo assets in different sizes for a given Cloud explorer entry.

### Listings

By default listings endpoints return all data for provided type. You can use following query params to return paginated data or search for a specific listing by its name:

| Param | Description |
| ------- | ----------------------------------------------------------------------------------- |
| entries | Specifies how many entries will be returned (must be used together with page param) |
| page | Specifies current page (must be used with entries param) |
| search | Returns listings whose name matches provided search query |
| version | Specifies WalletConnect supported version (1 or 2) |
| Param | Required? | Description |
| --------- | --------- | ------------------------------------------------------------------------------------------------------------ |
| projectId | Required | Your WalletConnect Cloud Project ID (from [cloud.walletconnect.com](https://cloud.walletconnect.com/)) |
| entries | | Specifies how many entries will be returned (must be used together with page param) |
| page | | Specifies current page (must be used with entries param) |
| search | | Returns listings whose name matches provided search query |
| version | | Specifies WalletConnect supported version (1 or 2) |
| chains | | Returns listings that support at least one of the provided chains<br/>(e.g. `?chains=eip155:1,eip155:137`) |
| platforms | | Returns listings that support at least one of the provided platforms<br/>(e.g. `?platforms=ios,android,mac`) |

#### `GET /v1/wallets`
#### `GET /v3/wallets`

Returns a JSON object containing all wallets listed in the cloud explorer. <br />
[See Example](https://explorer-api.walletconnect.com/v1/wallets?entries=5&page=1)
Returns a JSON object containing all wallets listed in the cloud explorer.

#### `GET /v1/dapps`
Examples:

Returns a JSON object containing all dApps listed in the public cloud explorer. <br />
[See Example](https://explorer-api.walletconnect.com/v1/dapps?entries=5&page=1)
- `GET https://explorer-api.walletconnect.com/v3/wallets?projectId=YOUR_PROJECT_ID&entries=5&page=1`

#### `GET /v1/hybrid`
#### `GET /v3/dapps`

Returns a JSON object containing all hybrids listed in the public cloud explorer. <br />
[See Example](https://explorer-api.walletconnect.com/v1/hybrid?entries=5&page=1)
Returns a JSON object containing all dApps listed in the public cloud explorer.

#### `GET /v1/all`
Examples:

Returns a JSON object containing all entries listed in the public cloud explorer. <br />
[See Example](https://explorer-api.walletconnect.com/v1/all?entries=5&page=1)
- `GET https://explorer-api.walletconnect.com/v3/dapps?projectId=YOUR_PROJECT_ID&entries=5&page=1`

### Logo v1
#### `GET /v3/hybrid`

| Param | Description |
| ----- | -------------------------------------------------------------------------------- |
| size | Determines resolution of returned image can be one of: `sm`, `md` or `lg` |
| id | Corresponds to a cloud explorer entry's id field as returned by the Listings API |
Returns a JSON object containing all hybrids listed in the public cloud explorer.

#### `GET /v1/logo/:size/:id`
Examples:

Returns the image source of the logo for `id` sized according `size`. <br />
[See Example](https://explorer-api.walletconnect.com/v1/logo/lg/d2ae9c3c2782806fd6db704bf40ef0238af9470d7964ae566114a033f4a9a110)
- `GET https://explorer-api.walletconnect.com/v3/hybrid?projectId=YOUR_PROJECT_ID&entries=5&page=1`

### Logo v2
#### `GET /v3/all`

Returns a JSON object containing all entries listed in the public cloud explorer.

Examples:

- `GET https://explorer-api.walletconnect.com/v3/all?projectId=YOUR_PROJECT_ID&entries=5&page=1`

### Logos

#### Path Parameters

| Param | Description |
| ----- | ---------------------------------------------------------------------------------------- |
| size | Determines resolution of returned image can be one of: `sm`, `md` or `lg` |
| id | Corresponds to a cloud explorer entry's `image_id` field as returned by the Listings API |
| id | Corresponds to a Cloud Explorer entry's `image_id` field as returned by the Listings API |

#### Query Parameters

| Param | Required? | Description |
| --------- | --------- | ------------------------------------------------------------------------------------------------------ |
| projectId | Required | Your WalletConnect Cloud Project ID (from [cloud.walletconnect.com](https://cloud.walletconnect.com/)) |

#### `GET /v3/logo/:size/:image_id`

Returns the image source of the logo for `image_id` sized according `size`.

#### `GET /v2/logo/:size/:image_id`
Examples:

Returns the image source of the logo for `image_id` sized according `size`. <br />
[See Example](https://explorer-api.walletconnect.com/v2/logo/md/32a77b79-ffe8-42c3-61a7-3e02e019ca00)
- `GET https://explorer-api.walletconnect.com/v3/logo/md/32a77b79-ffe8-42c3-61a7-3e02e019ca00?projectId=YOUR_PROJECT_ID`
11 changes: 11 additions & 0 deletions docs/introduction/web3modal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Web3Modal

Your on-ramp to web3 multichain. Web3Modal is a versatile library that makes it super easy to connect users with your Dapp and start interacting with the blockchain.

## Github

The Web3Modal Github can be found at [https://github.com/WalletConnect/web3modal](https://github.com/WalletConnect/web3modal).

## Docs

See thew quick start guide, customization options, and full docs at [https://web3modal.com/](https://web3modal.com/)
7 changes: 0 additions & 7 deletions docs/javascript/auth/dapp-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ description: Quick Start For Dapps using Auth Client
---

# Dapp Usage

:::caution
**The WalletConnect Auth SDK is currently in Alpha and is not production-ready**.

Its public API and associated documentation may still see significant and breaking changes.
:::

:::info
For an example implementation, please refer to our [`react-dapp-auth` example](https://github.com/WalletConnect/web-examples/tree/main/dapps/react-dapp-auth).
:::
Expand Down
11 changes: 2 additions & 9 deletions docs/javascript/auth/installation.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Installation

:::caution
**The WalletConnect Auth SDK is currently in Alpha and is not production-ready**.

Its public API and associated documentation may still see significant and breaking changes.
:::

## 1. Obtain Project ID

Head over to [WalletConnect Cloud](https://cloud.walletconnect.com/) to sign in or sign up. Create (or use an existing) project and copy its associated Project ID. We will need this in a later step.
Expand All @@ -19,6 +12,6 @@ For additional type packages refer to our [TypeScript Guide](../guides/typescrip
:::

```bash npm2yarn
npm i @walletconnect/auth-client
npm i better-sqlite3 # required for @walletconnect/core in Node envs
npm install @walletconnect/auth-client
npm install better-sqlite3 # required for @walletconnect/core in Node envs
```
7 changes: 0 additions & 7 deletions docs/javascript/auth/wallet-usage.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Wallet Usage

:::caution
**The WalletConnect Auth SDK is currently in Alpha and is not production-ready**.

Its public API and associated documentation may still see significant and breaking changes.
:::

:::info
For an example implementation, please refer to our [`react-wallet-auth` example](https://github.com/WalletConnect/web-examples/tree/main/wallets/react-wallet-auth).
:::
Expand Down
66 changes: 66 additions & 0 deletions docs/javascript/core/pairing-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Pairing API

## Useful Links

- [Pairing API Spec](../../specs/core/pairing/README.md)
- [Implementation](https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/core/src/controllers/pairing.ts)
- [Types](https://github.com/WalletConnect/walletconnect-monorepo/blob/v2.0/packages/types/src/core/pairing.ts)

### Description

The Pairing API is a lightweight API for establishing an encrypted, protocol-agnostic communication layer between peers. Its purpose is to provide a secure channel for proposing protocols or sending requests between dapp and wallet.

### Context

WalletConnect currently offers Sign and Auth SDKs. To allow a reusable communication channel between peers, the Pairing API exposes a standard interface and allows for sending and receiving multi-protocol requests over a single pairing.

Each SDK uses the same implementation of `core/pairing` (via `@walletconnect/core`) to manage pairings. To run multiple SDKs side-by-side (e.g. Sign and Auth), please refer to the [Sharing a Core instance](../guides/shared-core.md) guide.

## Using the Pairing API

The methods listed below are limited to only the public methods of the Pairing API that we recommend you interact with directly.
For an exhaustive list, please refer to the spec and/or implementation linked under [Useful Links](#useful-links) above.

The keyword `sdkClient` is used here as a placeholder for any WalletConnect SDK that implements the Pairing API (e.g. `signClient`, `authClient`, ...).

```ts
// Creates a new (inactive) pairing. Returns the URI for a peer to consume via `pair`, as well as the pairing topic.
const {topic, uri} = await sdkClient.core.pairing.create()

// Pair with a peer's proposed pairing, extracted from the provided `uri` parameter.
await sdkClient.core.pairing.pair({ uri: "wc:1b3eda3f4..." })

// Activate a previously created pairing (e.g. after the peer has paired), by providing the pairing topic.
await sdkClient.core.pairing.activate({ topic: "1b3eda3f4..." })

// Updates the expiry of an existing pairing, by providing the pairing topic and an `expiry` in seconds (e.g. `60` for one minute from now)
await sdkClient.core.pairing.updateExpiry({ topic: "1b3eda3f4...", expiry: 60 })

// Updates the expiry of an existing pairing, by providing the pairing topic and the desired metadata.
await sdkClient.core.pairing.updateMetadata({ topic: "1b3eda3f4...", metadata: { name: "MyDapp", ... } })

// Returns an array of all existing pairings.
const pairings = sdkClient.core.pairing.getPairings()

// Pings a pairing's peer, by providing the pairing topic.
await sdkClient.core.pairing.ping({ topic: "1b3eda3f4..." })

// Disconnects/Removes a pairing, by providing the pairing topic.
await sdkClient.core.pairing.disconnect({ topic: "1b3eda3f4..." })
```

## Listeners for pairing-related events

The Pairing API currently emits the following events:

- `pairing_ping`
- `pairing_delete`
- `pairing_expire`

Any of these events can be listened for via the standard Node [`EventEmitter` interface](https://nodejs.org/api/events.html#class-eventemitter):

```ts
sdkClient.pairing.events.on("pairing_delete", ({ id, topic }) => {
// clean up after the pairing for `topic` was deleted.
});
```
4 changes: 2 additions & 2 deletions docs/javascript/guides/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

:::info

For Node.js, the WalletConnect client additionally requires `better-sqlite3` to manage storage internally.
For Node.js, the WalletConnect SignClient additionally requires `lokijs` to manage storage internally.

:::

```bash npm2yarn
npm install --save @walletconnect/sign-client@rc better-sqlite3
npm install --save @walletconnect/sign-client [email protected]
```

## Create Session
Expand Down
4 changes: 2 additions & 2 deletions docs/javascript/guides/react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

:::info

For React Native, the WalletConnect client additionally requires `@react-native-async-storage/async-storage`, `react-native-get-random-values` and `@walletconnect/react-native-compat`
For React Native, the WalletConnect SignClient additionally requires `@react-native-async-storage/async-storage`, `react-native-get-random-values` and `@walletconnect/react-native-compat`
to manage storage internally and provide all necessary polyfills.

:::

```bash npm2yarn
npm install --save @walletconnect/sign-client@rc @walletconnect/react-native-compat@rc @react-native-async-storage/async-storage react-native-get-random-values
npm install --save @walletconnect/sign-client @walletconnect/react-native-compat @react-native-async-storage/async-storage react-native-get-random-values
```

## Set Up
Expand Down
34 changes: 34 additions & 0 deletions docs/javascript/guides/shared-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Shared Core Instance

WalletConnect's SDKs are designed to share common logic and resources via the `@walletconnect/core` package.

**If you intend to leverage multiple SDKs together (e.g. Sign + Auth), it is highly recommended to instantiate
a single `Core` instance and pass it to the relevant SDKs.** This avoids each SDK creating its own `Core` instance,
and thus duplicating computation, memory allocation, event listeners etc.

In the following example, we first instantiate a `Core` instance, and then proceed to instantiate both the Sign
and Auth SDK with this shared `Core`:

```ts
import { Core } from "@walletconnect/core";
import SignClient from "@walletconnect/sign-client";
import { AuthClient } from "@walletconnect/auth-client";

// First instantiate a separate `Core` instance.
const core = new Core({
projectId: "<YOUR_PROJECT_ID>",
});

const metadata = {
name: "Example Dapp",
description: "Example Dapp",
url: "#",
icons: ["https://walletconnect.com/walletconnect-logo.png"],
};

// Pass `core` to the SignClient on init.
const signClient = await SignClient.init({ core, metadata });

// Pass `core` to the AuthClient on init.
const authClient = await AuthClient.init({ core, metadata });
```
4 changes: 2 additions & 2 deletions docs/javascript/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ All our SDKs are written in and support TypeScript. Following type packages are
### @walletconnect/types

```bash npm2yarn
npm install --save @walletconnect/types@rc
npm install --save @walletconnect/types
```

### @walletconnect/jsonrpc-types

```bash npm2yarn
npm install --save @walletconnect/jsonrpc-types@rc
npm install --save @walletconnect/jsonrpc-types
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ description: Quick Start For Dapps using Standalone Client

This library is compatible with NodeJS, browsers and React-Native applications \(NodeJS modules require polyfills for React-Native\).

## Install

```bash npm2yarn
npm install --save @walletconnect/sign-client@rc @walletconnect/types@rc
```
:::info
For an example implementation, please refer to our `react-dapp-v2` [example](https://github.com/WalletConnect/web-examples/tree/main/dapps/react-dapp-v2).
:::

## Create a Session

Expand All @@ -32,21 +30,25 @@ const signClient = await SignClient.init({

**2. Add listeners for desired `SignClient` events.**

:::info
To listen to pairing-related events, please follow the guidance for [Pairing API event listeners](../core/pairing-api.md).
:::

```javascript
client.on("session_event", ({ event }) => {
signClient.on("session_event", ({ event }) => {
// Handle session events, such as "chainChanged", "accountsChanged", etc.
});

client.on("session_update", ({ topic, params }) => {
signClient.on("session_update", ({ topic, params }) => {
const { namespaces } = params;
const _session = client.session.get(topic);
const _session = signClient.session.get(topic);
// Overwrite the `namespaces` of the existing session with the incoming one.
const updatedSession = { ..._session, namespaces };
// Integrate the updated session state into your dapp state.
onSessionUpdate(updatedSession);
});

client.on("session_delete", () => {
signClient.on("session_delete", () => {
// Session was deleted -> reset the dapp state, clean up from user session, etc.
});
```
Expand All @@ -59,8 +61,8 @@ import QRCodeModal from "@walletconnect/qrcode-modal";
// ...

try {
const { uri, approval } = await client.connect({
// Optionally: pass a known prior pairing (e.g. from `client.pairing.values`) to skip the `uri` step.
const { uri, approval } = await signClient.connect({
// Optionally: pass a known prior pairing (e.g. from `signClient.core.pairing.getPairings()`) to skip the `uri` step.
pairingTopic: pairing?.topic,
// Provide the namespaces and chains (e.g. `eip155` for EVM-based chains) we want to use in this session.
requiredNamespaces: {
Expand Down Expand Up @@ -102,7 +104,7 @@ try {
Once the session has been established successfully, you can start making JSON-RPC requests to be approved and signed by the wallet:

```javascript
const result = await client.request({
const result = await signClient.request({
topic: session.topic,
chainId: "eip155:1",
request: {
Expand Down
14 changes: 1 addition & 13 deletions docs/javascript/sign/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,5 @@ For platform-specific instructions, refer to our [React Native](../guides/react-
:::

```bash npm2yarn
npm install --save @walletconnect/sign-client@rc
```

## 3. Initialize Client

Initialize client by passing `projectId` we created before.

```js
import SignClient from "@walletconnect/sign-client";

const signClient = await SignClient.init({
projectId: "<YOUR_PROJECT_ID>",
});
npm install --save @walletconnect/sign-client
```
Loading

0 comments on commit 019b3c5

Please sign in to comment.