Skip to content

Commit eff7107

Browse files
authored
[v4 react] Allow configuring qrcode and qrModalOptions on various wallet configurators (#3315)
1 parent fb6a07d commit eff7107

File tree

11 files changed

+225
-10
lines changed

11 files changed

+225
-10
lines changed

.changeset/red-peas-reflect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/react": minor
3+
---
4+
5+
Allow configuring WalletConnect `qrcode` and `qrModalOptions` from wallet configurator functions like `metamaskWallet`, `coreWallet`, `zerionWallet` etc

legacy_packages/react/src/wallet/wallets/coin98/coin98Wallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import { Coin98Wallet, getInjectedCoin98Provider } from "@thirdweb-dev/wallets";
77
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
88
import { useTWLocale } from "../../../evm/providers/locale-provider";
9+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
910

1011
const coin98WalletUris = {
1112
ios: "coin98://",
@@ -29,6 +30,22 @@ export type Coin98WalletConfigOptions = {
2930
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
3031
*/
3132
recommended?: boolean;
33+
34+
/**
35+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
36+
*
37+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
38+
*
39+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
40+
*/
41+
wcModal?:
42+
| {
43+
/**
44+
* Configure the style of Wallet Connect Modal.
45+
*/
46+
qrModalOptions?: QRModalOptions;
47+
}
48+
| boolean;
3249
};
3350

3451
/**
@@ -78,7 +95,11 @@ export const coin98Wallet = (
7895
const wallet = new Coin98Wallet({
7996
...walletOptions,
8097
projectId: options?.projectId,
81-
qrcode: false,
98+
qrcode: options?.wcModal ? true : false,
99+
qrModalOptions:
100+
typeof options?.wcModal === "object"
101+
? options?.wcModal?.qrModalOptions
102+
: undefined,
82103
});
83104

84105
return wallet;

legacy_packages/react/src/wallet/wallets/coreWallet/coreWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { handelWCSessionRequest } from "../handleWCSessionRequest";
1111
import { useTWLocale } from "../../../evm/providers/locale-provider";
1212
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
13+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
1314

1415
const coreWalletUris = {
1516
ios: "core://",
@@ -33,6 +34,22 @@ export type CoreWalletConfigOptions = {
3334
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
3435
*/
3536
recommended?: boolean;
37+
38+
/**
39+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
40+
*
41+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
42+
*
43+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
44+
*/
45+
wcModal?:
46+
| {
47+
/**
48+
* Configure the style of Wallet Connect Modal.
49+
*/
50+
qrModalOptions?: QRModalOptions;
51+
}
52+
| boolean;
3653
};
3754

3855
/**
@@ -81,7 +98,11 @@ export const coreWallet = (
8198
const wallet = new CoreWallet({
8299
...walletOptions,
83100
projectId: options?.projectId,
84-
qrcode: false,
101+
qrcode: options?.wcModal ? true : false,
102+
qrModalOptions:
103+
typeof options?.wcModal === "object"
104+
? options?.wcModal?.qrModalOptions
105+
: undefined,
85106
});
86107

87108
handelWCSessionRequest(wallet, coreWalletUris);

legacy_packages/react/src/wallet/wallets/defiWallet/cryptoDefiWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { useTWLocale } from "../../../evm/providers/locale-provider";
1111
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
1212
import { handelWCSessionRequest } from "../handleWCSessionRequest";
13+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
1314

1415
const cryptoDefiWalletUris = {
1516
ios: "dfw://",
@@ -33,6 +34,22 @@ export type CryptoDefiWalletConfigOptions = {
3334
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
3435
*/
3536
recommended?: boolean;
37+
38+
/**
39+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
40+
*
41+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
42+
*
43+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
44+
*/
45+
wcModal?:
46+
| {
47+
/**
48+
* Configure the style of Wallet Connect Modal.
49+
*/
50+
qrModalOptions?: QRModalOptions;
51+
}
52+
| boolean;
3653
};
3754

3855
/**
@@ -82,7 +99,11 @@ export const cryptoDefiWallet = (
8299
const wallet = new CryptoDefiWallet({
83100
...walletOptions,
84101
projectId: options?.projectId,
85-
qrcode: false,
102+
qrcode: options?.wcModal ? true : false,
103+
qrModalOptions:
104+
typeof options?.wcModal === "object"
105+
? options?.wcModal?.qrModalOptions
106+
: undefined,
86107
});
87108

88109
handelWCSessionRequest(wallet, cryptoDefiWalletUris);

legacy_packages/react/src/wallet/wallets/imtoken/imTokenWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import { ImTokenWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
77
import { useTWLocale } from "../../../evm/providers/locale-provider";
88
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
9+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
910

1011
const imTokenWalletUris = {
1112
ios: "imtokenv2://",
@@ -15,6 +16,22 @@ const imTokenWalletUris = {
1516
export type ImTokenWalletConfigOptions = {
1617
projectId?: string;
1718
recommended?: boolean;
19+
20+
/**
21+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
22+
*
23+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
24+
*
25+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
26+
*/
27+
wcModal?:
28+
| {
29+
/**
30+
* Configure the style of Wallet Connect Modal.
31+
*/
32+
qrModalOptions?: QRModalOptions;
33+
}
34+
| boolean;
1835
};
1936

2037
export const imTokenWallet = (
@@ -30,7 +47,11 @@ export const imTokenWallet = (
3047
const wallet = new ImTokenWallet({
3148
...walletOptions,
3249
projectId: options?.projectId,
33-
qrcode: false,
50+
qrcode: options?.wcModal ? true : false,
51+
qrModalOptions:
52+
typeof options?.wcModal === "object"
53+
? options?.wcModal?.qrModalOptions
54+
: undefined,
3455
});
3556

3657
return wallet;

legacy_packages/react/src/wallet/wallets/metamask/metamaskWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import { MetamaskConnectUI } from "./MetamaskConnectUI";
77
import { metamaskUris } from "./metamaskUris";
88
import { handelWCSessionRequest } from "../handleWCSessionRequest";
9+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
910

1011
/**
1112
* @wallet
@@ -35,6 +36,22 @@ export type MetamaskWalletConfigOptions = {
3536
* Default is `"walletconnect"`
3637
*/
3738
connectionMethod?: "walletConnect" | "metamaskBrowser";
39+
40+
/**
41+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
42+
*
43+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
44+
*
45+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
46+
*/
47+
wcModal?:
48+
| {
49+
/**
50+
* Configure the style of Wallet Connect Modal.
51+
*/
52+
qrModalOptions?: QRModalOptions;
53+
}
54+
| boolean;
3855
};
3956

4057
/**
@@ -89,7 +106,11 @@ export const metamaskWallet = (
89106
const wallet = new MetaMaskWallet({
90107
...walletOptions,
91108
projectId: options?.projectId,
92-
qrcode: false,
109+
qrcode: options?.wcModal ? true : false,
110+
qrModalOptions:
111+
typeof options?.wcModal === "object"
112+
? options?.wcModal?.qrModalOptions
113+
: undefined,
93114
});
94115

95116
if (connectionMethod === "walletConnect") {

legacy_packages/react/src/wallet/wallets/okx/okxWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
22
import { OKXWallet, getInjectedOKXProvider } from "@thirdweb-dev/wallets";
33
import { OKXConnectUI } from "./OKXConnectUI";
4+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
45

56
/**
67
* @wallet
@@ -18,6 +19,22 @@ export type OKXWalletConfigOptions = {
1819
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
1920
*/
2021
recommended?: boolean;
22+
23+
/**
24+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
25+
*
26+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
27+
*
28+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
29+
*/
30+
wcModal?:
31+
| {
32+
/**
33+
* Configure the style of Wallet Connect Modal.
34+
*/
35+
qrModalOptions?: QRModalOptions;
36+
}
37+
| boolean;
2138
};
2239

2340
/**
@@ -67,7 +84,11 @@ export const okxWallet = (
6784
const wallet = new OKXWallet({
6885
...walletOptions,
6986
projectId: options?.projectId,
70-
qrcode: false,
87+
qrcode: options?.wcModal ? true : false,
88+
qrModalOptions:
89+
typeof options?.wcModal === "object"
90+
? options?.wcModal?.qrModalOptions
91+
: undefined,
7192
});
7293

7394
return wallet;

legacy_packages/react/src/wallet/wallets/oneKey/oneKeyWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {
66
import { OneKeyWallet, getInjectedOneKeyProvider } from "@thirdweb-dev/wallets";
77
import { useTWLocale } from "../../../evm/providers/locale-provider";
88
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
9+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
910

1011
export const oneKeyWalletUris = {
1112
ios: "onekey-wallet://",
@@ -29,6 +30,22 @@ export type OneKeyWalletConfigOptions = {
2930
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
3031
*/
3132
recommended?: boolean;
33+
34+
/**
35+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
36+
*
37+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
38+
*
39+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
40+
*/
41+
wcModal?:
42+
| {
43+
/**
44+
* Configure the style of Wallet Connect Modal.
45+
*/
46+
qrModalOptions?: QRModalOptions;
47+
}
48+
| boolean;
3249
};
3350

3451
/**
@@ -78,7 +95,11 @@ export const oneKeyWallet = (
7895
const wallet = new OneKeyWallet({
7996
...walletOptions,
8097
projectId: options?.projectId,
81-
qrcode: false,
98+
qrcode: options?.wcModal ? true : false,
99+
qrModalOptions:
100+
typeof options?.wcModal === "object"
101+
? options?.wcModal?.qrModalOptions
102+
: undefined,
82103
});
83104

84105
return wallet;

legacy_packages/react/src/wallet/wallets/rabby/rabbyWallet.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
22
import { RabbyWallet, getInjectedRabbyProvider } from "@thirdweb-dev/wallets";
33
import { RabbyConnectUI } from "./RabbyConnectUI";
4+
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
45

56
/**
67
* @wallet
@@ -18,6 +19,22 @@ export type RabbyWalletConfigOptions = {
1819
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
1920
*/
2021
recommended?: boolean;
22+
23+
/**
24+
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
25+
*
26+
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
27+
*
28+
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
29+
*/
30+
wcModal?:
31+
| {
32+
/**
33+
* Configure the style of Wallet Connect Modal.
34+
*/
35+
qrModalOptions?: QRModalOptions;
36+
}
37+
| boolean;
2138
};
2239

2340
/**
@@ -64,7 +81,11 @@ export const rabbyWallet = (
6481
const wallet = new RabbyWallet({
6582
...walletOptions,
6683
projectId: options?.projectId,
67-
qrcode: false,
84+
qrcode: options?.wcModal ? true : false,
85+
qrModalOptions:
86+
typeof options?.wcModal === "object"
87+
? options?.wcModal?.qrModalOptions
88+
: undefined,
6889
});
6990

7091
return wallet;

0 commit comments

Comments
 (0)