forked from WalletConnect/walletconnect-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update_kotlin_docs
- Loading branch information
Showing
27 changed files
with
379 additions
and
273 deletions.
There are no files selected for viewing
This file contains 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 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,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/) |
This file contains 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 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 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 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,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. | ||
}); | ||
``` |
This file contains 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 |
---|---|---|
|
@@ -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 | ||
|
This file contains 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 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,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 }); | ||
``` |
This file contains 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 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 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
Oops, something went wrong.