@thirdweb-dev/wallets
Version:
<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a h
158 lines • 5.72 kB
TypeScript
import { QRModalOptions } from "../connectors/wallet-connect/qrModalOptions";
import { Connector } from "../interfaces/connector";
import { AbstractClientWallet, WalletOptions } from "./base";
export type WC2_QRModalOptions = QRModalOptions;
type ConnectWithQrCodeArgs = {
chainId?: number;
onQrCodeUri: (uri: string) => void;
onConnected: (accountAddress: string) => void;
};
export type WalletConnectOptions = {
/**
* Your project’s unique identifier that can be obtained at cloud.walletconnect.com. Enables following functionalities within Web3Modal: wallet and chain logos, optional WalletConnect RPC, support for all wallets from our Explorer and WalletConnect v2 support. Defaults to undefined.
*
* https://docs.walletconnect.com/2.0/web3modal/options#projectid-required
*/
projectId?: string;
/**
* Whether to display the QR Code Modal.
*
* Defaults to `true`.
*/
qrcode?: boolean;
/**
* WalletConnect's [options](https://docs.walletconnect.com/advanced/walletconnectmodal/options) to customize the QR Code Modal.
*/
qrModalOptions?: WC2_QRModalOptions;
};
/**
* Wallet interface to connect a wallet using [WalletConnect](https://docs.walletconnect.com/) protocol by either opening the official WalletConnect Modal or by displaying a custom QR Code.
*
* @example
* ```javascript
* import { WalletConnect } from "@thirdweb-dev/wallets";
*
* const wallet = new WalletConnect();
*
* wallet.connect();
* ```
*
* @wallet
*/
export declare class WalletConnect extends AbstractClientWallet<WalletConnectOptions> {
private _walletConnectConnector?;
private _provider?;
connector?: Connector;
static id: string;
static meta: {
name: string;
iconURL: string;
};
get walletName(): "WalletConnect";
projectId: NonNullable<WalletConnectOptions["projectId"]>;
qrcode: WalletConnectOptions["qrcode"];
/**
*
* @param options -
* The `options` object includes the following properties:
*
* ### projectId (recommended)
* Your project's unique identifier. It can be obtained at [cloud.walletconnect.com](https://cloud.walletconnect.com). It is highly recommended to use your own project id and only use the default one for testing purposes.
*
* It enables the following functionalities within WalletConnect's web3modal:
*
* - wallet and chain logos
* - optional WalletConnect RPC
* - support for all wallets from our Explorer and WalletConnect v2 support
*
* Defaults to thirdweb's common project id.
*
* ### clientId (recommended)
* Provide `clientId` to use the thirdweb RPCs for given `chains`
*
* You can create a client ID for your application from [thirdweb dashboard](https://thirdweb.com/create-api-key).
*
* ### chains (optional)
* Provide an array of chains you want to support.
*
* Must be an array of `Chain` objects, from the [`@thirdweb-dev/chains`](https://www.npmjs.com/package/\@thirdweb-dev/chains) package.
*
* Defaults to our [default chains](/react/react.thirdwebprovider#default-chains).
*
*
* ### dappMetadata
* Information about your app that the wallet will display when your app tries to connect to it.
*
* Must be an object containing `name`, `url`, and optionally `description` and `logoUrl` properties.
*
* ```javascript
* import { WalletConnect } from "@thirdweb-dev/wallets";
*
* const walletWithOptions = new WalletConnect({
* dappMetadata: {
* name: "thirdweb powered dApp",
* url: "https://thirdweb.com",
* description: "thirdweb powered dApp",
* logoUrl: "https://thirdweb.com/favicon.ico",
* },
* });
* ```
*
* ### qrcode (optional)
* Whether to display the Wallet Connect QR code Modal or not.
*
* Must be a `boolean`. Defaults to `true`.
*
* ### qrModalOptions
* WalletConnect's [options](https://docs.walletconnect.com/advanced/walletconnectmodal/options) to customize the QR Code Modal.
*
*/
constructor(options?: WalletOptions<WalletConnectOptions>);
protected getConnector(): Promise<Connector>;
private _maybeThrowError;
private _onConnect;
private _onDisconnect;
private _onChange;
private _onMessage;
private _onSessionRequestSent;
private _setupListeners;
private _removeListeners;
/**
* Connect to the wallet using a QR code.
* You can use this method to display a QR code. User can scan this QR code from the Wallet mobile app to connect to your dapp.
*
* @example
* ```typescript
* wallet.connectWithQrCode({
* chainId: 1,
* onQrCodeUri(qrCodeUri) {
* // render the QR code with `qrCodeUri`
* },
* onConnected(accountAddress) {
* // update UI to show connected state
* },
* })
* ```
*
* @param options -
* The options object contains the following properties/method:
*
* ### chainId (optional)
* If provided, wallet will prompt the user to switch to the network with the given `chainId` after connecting.
*
* ### onQrCodeUri
* A callback to get the QR code URI to display to the user.
*
* ### onConnected
* A callback that is called when the user has connected their wallet using the QR code.
*/
connectWithQrCode(options: ConnectWithQrCodeArgs): Promise<void>;
/**
* @internal
*/
connectWithModal(options?: {
chainId?: number;
}): Promise<void>;
}
export {};
//# sourceMappingURL=wallet-connect.d.ts.map