Skip to content

Commit 624a38a

Browse files
feat: support coinbase wallet sdk configuration (#2405)
* feat: support coinbase wallet sdk configuration * chore: add notes to example dapp to update later * fix: typed destructuring fix: interface * chore: tweak docs * chore: changeset --------- Co-authored-by: Daniel Sinclair <[email protected]>
1 parent c6388c4 commit 624a38a

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

.changeset/brave-kiwis-fix.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
"@rainbow-me/rainbowkit": patch
3+
---
4+
5+
The `coinbaseWallet` connector now supports additional SDK configuration options to enable [Paymasters](https://docs.base.org/identity/smart-wallet/guides/paymasters) and [Sub Accounts](https://docs.base.org/identity/smart-wallet/guides/sub-accounts) for your dapp.
6+
7+
```tsx
8+
import { coinbaseWallet } from '@rainbow-me/rainbowkit/wallets';
9+
10+
// Configure Paymaster for gas sponsorship
11+
coinbaseWallet.paymasterUrls = {
12+
[base.id]: '...'
13+
};
14+
15+
// Enable Sub Accounts
16+
coinbaseWallet.subAccounts = {
17+
enableAutoSubAccounts: true,
18+
defaultSpendLimits: {
19+
// ...
20+
}
21+
};
22+
```

packages/example/src/wagmi.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ const avalanche = {
131131
// Testing `preference` type
132132
coinbaseWallet.preference = 'all';
133133

134+
// TODO: Add subAccounts, paymasterUrls
135+
134136
export const config = getDefaultConfig({
135137
appName: 'RainbowKit Demo',
136138
projectId,

packages/rainbowkit/src/wallets/walletConnectors/coinbaseWallet/coinbaseWallet.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ export interface CoinbaseWalletOptions {
1111
appIcon?: string;
1212
}
1313

14-
interface CoinbaseWallet {
14+
// supports preference, paymasterUrls, subAccounts
15+
type AcceptedCoinbaseWalletParameters = Omit<
16+
CoinbaseWalletParameters<'4'>,
17+
'headlessMode' | 'version' | 'appName' | 'appLogoUrl'
18+
>;
19+
20+
interface CoinbaseWallet extends AcceptedCoinbaseWalletParameters {
1521
(params: CoinbaseWalletOptions): Wallet;
16-
preference?: CoinbaseWalletParameters<'4'>['preference'];
1722
}
1823

1924
export const coinbaseWallet: CoinbaseWallet = ({ appName, appIcon }) => {
@@ -99,10 +104,15 @@ export const coinbaseWallet: CoinbaseWallet = ({ appName, appIcon }) => {
99104
},
100105
}),
101106
createConnector: (walletDetails: WalletDetailsParams) => {
107+
// Extract all AcceptedCoinbaseWalletParameters from coinbaseWallet
108+
// This approach avoids type errors for properties not yet in upstream connector
109+
const { ...optionalConfig }: AcceptedCoinbaseWalletParameters =
110+
coinbaseWallet as any;
111+
102112
const connector: CreateConnectorFn = coinbaseConnector({
103113
appName,
104114
appLogoUrl: appIcon,
105-
preference: coinbaseWallet.preference,
115+
...optionalConfig,
106116
});
107117

108118
return createConnector((config) => ({

site/data/en-US/docs/custom-wallet-list.mdx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,31 @@ import { bybitWallet } from '@rainbow-me/rainbowkit/wallets';
180180

181181
This wallet connector supports both the Coinbase Wallet app and extension, as well as Coinbase Smart Wallet on Web.
182182

183-
A `preference` argument is available to control whether Smart Wallet is enabled and available for users. Preference based behavior is documented [here](https://www.smartwallet.dev/sdk/makeWeb3Provider#parameters).
183+
A `preference` argument is available to control whether Smart Wallet is preferred or disabled for your users. Preference based behavior is documented [here](https://docs.base.org/identity/smart-wallet/technical-reference/sdk/#options-optional).
184184

185-
Smart Wallet will be enabled by default with `all` in early June, without a further upgrade.
186-
187-
Developers can test Smart Wallet with `sepolia` and `baseSepolia` chains today by setting `smartWalletOnly` and including `coinbaseWallet` in their wallet list like so:
185+
Additional configuration options for control of [Paymasters](https://docs.base.org/identity/smart-wallet/guides/paymasters) and [Sub Accounts](https://docs.base.org/identity/smart-wallet/guides/sub-accounts) can be found in the Coinbase Wallet SDK docs [here](https://docs.base.org/identity/smart-wallet/technical-reference/sdk#parameters).
188186

189187
```tsx
190188
import { coinbaseWallet } from '@rainbow-me/rainbowkit/wallets';
191189

192-
// Enable Coinbase Smart Wallet for testing
190+
// Limit your dApp to only Smart Wallet
193191
coinbaseWallet.preference = 'smartWalletOnly';
192+
193+
// Limit your dApp to the Coinbase Wallet app
194+
coinbaseWallet.preference = 'eoaOnly';
195+
196+
// Configure the Paymaster for gas sponsorship
197+
coinbaseWallet.paymasterUrls: {
198+
[base.id]: '...'
199+
}
200+
201+
// Enable Sub Accounts
202+
coinbaseWallet.subAccounts: {
203+
enableAutoSubAccounts: true,
204+
defaultSpendLimits: {
205+
...
206+
}
207+
}
194208
```
195209

196210
#### Coin98 Wallet

0 commit comments

Comments
 (0)