Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
roxaneletourneau committed Nov 5, 2024
1 parent c1580f5 commit ced7349
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 10 deletions.
3 changes: 1 addition & 2 deletions apps/taquito-test-dapp/src/lib/Wallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
events: [],
methods: [PermissionScopeMethods.TEZOS_SEND, PermissionScopeMethods.TEZOS_SIGN, PermissionScopeMethods.TEZOS_GET_ACCOUNTS],
},
pairingTopic,
registryUrl: "https://www.tezos.help/wcdata/"
pairingTopic
});
const allAccounts = wallet.getAccounts();
await updateStore(wallet, allAccounts);
Expand Down
14 changes: 7 additions & 7 deletions docs/wallet_connect_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The first step is to instantiate `WalletConnect2` by passing your dapp details a
import { WalletConnect2 } from "@taquito/wallet-connect-2";

const walletConnect = await WalletConnect2.init({
projectId: "YOUR_PROJECT_ID", // Your Project ID gives you access to WalletConnect Cloud
projectId: "YOUR_PROJECT_ID", // Your Project ID gives you access to Reown Cloud
metadata: {
name: "YOUR_DAPP_NAME",
description: "YOUR_DAPP_DESCRIPTION",
Expand All @@ -22,7 +22,7 @@ const walletConnect = await WalletConnect2.init({
},
});
```
`YOUR_PROJECT_ID` can be obtained from [WalletConnect Cloud](https://cloud.walletconnect.com/sign-in)
`YOUR_PROJECT_ID` can be obtained from [Reown Cloud](https://cloud.reown.com)

The second step is to establish a connection to a wallet using the `requestPermissions` method:

Expand All @@ -33,10 +33,11 @@ await walletConnect.requestPermissions({
permissionScope: {
networks: [NetworkType.GHOSTNET],
methods: [
PermissionScopeMethods.TEZOS_SEND, PermissionScopeMethods.TEZOS_SIGN
PermissionScopeMethods.TEZOS_SEND,
PermissionScopeMethods.TEZOS_SIGN,
PermissionScopeMethods.TEZOS_GET_ACCOUNTS
],
},
// registryUrl: "https://www.tezos.help/wcdata/"
}
});
```

Expand Down Expand Up @@ -80,7 +81,6 @@ WalletConnect2.init({
networks: [NetworkType.GHOSTNET],
methods: [PermissionScopeMethods.TEZOS_SEND],
},
// registryUrl: 'https://www.tezos.help/wcdata/',
})
.then(() => {
Tezos.setWalletProvider(walletConnect);
Expand All @@ -99,7 +99,7 @@ WalletConnect2.init({

## Sign payload with `WalletConnect2`

The `signPayload` method of `WalletConnect2` can be called to sign a payload. The response will be a string representing the signature. The permission `PermissionScopeMethods.TEZOS_SIGN` must have been granted, or the error `MissingRequiredScope` will be thrown.
The `sign` method of `WalletConnect2` can be called to sign a payload. The response will be a string representing the signature. The permission `PermissionScopeMethods.TEZOS_SIGN` must have been granted, or the error `MissingRequiredScope` will be thrown.

## Events handling

Expand Down
58 changes: 58 additions & 0 deletions packages/taquito-wallet-connect-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Taquito Wallet Connect 2 / Reown package

_Documentation can be found [here](https://taquito.io/docs/wallet_connect_2)_

## General Information

`@taquito/wallet-connect-2` is an npm package that provides developers a way to connect a dapp built with Taquito to a wallet giving the freedom to the users of the dapp to choose the wallet via the WalletConnect/Reown protocol. The `WalletConnect2` class implements the `WalletProvider` interface, providing an alternative to `BeaconWallet`.
Note: Currently, a QR code is displayed to establish a connection with a wallet. As more Tezos wallets integrate with WalletConnect, we plan showing a list of available wallets alongside the QR code.

## Install

Install the package as follows

```
npm install @taquito/wallet-connect-2
```

## Usage

Create a wallet instance with defined option parameters and set the wallet provider using `setWalletProvider` to the `TezosToolkit` instance

```ts
import { TezosToolkit } from '@taquito/taquito';
import { WalletConnect2 } from '@taquito/wallet-connect-2';

const wallet = await WalletConnect2.init({
projectId: "861613623da99d7285aaad8279a87ee9", // Your Project ID gives you access to WalletConnect Cloud.
metadata: {
name: "Taquito Test Dapp",
description: "Test Taquito with WalletConnect2",
icons: [],
url: "",
},
});

await wallet.requestPermissions({
permissionScope: {
networks: [NetworkType.GHOSTNET],
events: [],
methods: [
PermissionScopeMethods.TEZOS_SEND,
PermissionScopeMethods.TEZOS_SIGN,
PermissionScopeMethods.TEZOS_GET_ACCOUNTS
],
}
});

const Tezos = new TezosToolkit('https://YOUR_PREFERRED_RPC_URL');
Tezos.setWalletProvider(wallet);
```

## Additional Info

See the top-level [https://github.com/ecadlabs/taquito](https://github.com/ecadlabs/taquito) file for details on reporting issues, contributing and versioning.

## Disclaimer

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export * from './types';

const TEZOS_PLACEHOLDER = 'tezos';

/**
* @description The `WalletConnect2` class implements the `WalletProvider` interface, providing an alternative to `BeaconWallet`.
* This package enables dapps built with Taquito to connect to wallets via the WalletConnect/Reown protocol.
*
* @note Currently, a QR code is displayed to establish a connection with a wallet. As more Tezos wallets integrate with WalletConnect,
* we plan showing a list of available wallets alongside the QR code.
*/
export class WalletConnect2 implements WalletProvider {
public signClient: Client;
private session: SessionTypes.Struct | undefined;
Expand Down Expand Up @@ -298,7 +305,6 @@ export class WalletConnect2 implements WalletProvider {
return this.activeAccount;
}

// TODO need test-dapp test
/**
* @description Access the public key of the active account
* @error ActiveAccountUnspecified thrown when there are multiple Tezos account in the session and none is set as the active one
Expand Down

0 comments on commit ced7349

Please sign in to comment.