diff --git a/docs/pages/sdk/v3-to-v4-changes.mdx b/docs/pages/sdk/v3-to-v4-changes.mdx new file mode 100644 index 0000000..b5f7a97 --- /dev/null +++ b/docs/pages/sdk/v3-to-v4-changes.mdx @@ -0,0 +1,123 @@ +# CoinbaseWalletSDK Changes (v3 to v4) + +This page details changes between versions 3.x and 4.x of the [Coinbase Wallet SDK](https://github.com/coinbase/coinbase-wallet-sdk). + +## CoinbaseWalletSDK + +### CoinbaseWalletSDKOptions + +```ts +// v4 +type CoinbaseWalletSDKOptions = { + appName?: string | undefined; + appLogoUrl?: string | null | undefined; + appChainIds?: number[] | undefined; +}; +``` + +#### New (v4 only): + +- `appChainIds?: number[]` + - An array of chain IDs your dapp supports + - The first chain in this array will be used as the default chain. + - Removes the need for non-mainnet dapps to request switching chains before making first request. + - Default value is `[1]` (mainnet) + +#### Deprecated (v3 only): + +- `enableMobileWalletLink` (enabled by default in v4) +- `jsonRpcUrl` +- `reloadOnDisconnect` +- `uiConstructor` +- `overrideIsMetaMask` +- `overrideIsCoinbaseWallet` +- `diagnosticLogger` +- `reloadOnDisconnect` +- `headlessMode` + +### Deprecated functions +- `CoinbaseWalletSDK.disconnect()` is deprecated + - dapps should call `CoinbaseWalletProvider.disconnect()` instead +- `CoinbaseWalletSDK.setAppInfo()` is deprecated + - Dapps should pass in `appName` and `appLogoUrl` via `CoinbaseWalletSDKOptions` + +### `makeWeb3Provider` + +#### Signature + ```ts + // v3 + makeWeb3Provider(jsonRpcUrl?: string, chainId?: number): CoinbaseWalletProvider + + // v4 // [!code focus] + makeWeb3Provider(preference: Preference = { options: 'all' }): ProviderInterface // [!code focus] + ``` +#### Parameters + ```ts + interface Preference { + options: 'all' | 'smartWalletOnly' | 'eoaOnly'; + keysUrl?: string; + } + ``` + - `options` + - `'all'` (default) show both smart wallet and EOA options + - `'smartWalletOnly'` only show smart wallet option + - `'eoaOnly'` only show EOA option + - `keysUrl` + - You probably don't need this. Use only if you'd like to use a frontend other than `"https://keys.coinbase.com/connect"` as your connection popup. +#### Return type + ```ts + export interface ProviderInterface extends EventEmitter { + request(args: RequestArguments): Promise; + disconnect(): Promise; + on(event: 'connect', listener: (info: ProviderConnectInfo) => void): this; + on(event: 'disconnect', listener: (error: ProviderRpcError) => void): this; + on(event: 'chainChanged', listener: (chainId: string) => void): this; + on(event: 'accountsChanged', listener: (accounts: string[]) => void): this; + on(event: 'message', listener: (message: ProviderMessage) => void): this; + } + ``` + +## CoinbaseWalletProvider + +### `connect` event fix +- v3 returned `chainIdStr` instead of `chainId`. +- v4 is [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193#connect) compliant. + +```ts +// v4 +interface ProviderConnectInfo { readonly chainId: string; } +on(event: 'connect', listener: (info: ProviderConnectInfo) => void): this; +``` + + +### Deprecated functionality + +#### Instance properties + +- `isCoinbaseBrowser: boolean` +- `qrUrl?: string | null` +- `reloadOnDisconnect: boolean` + +#### Getter methods + +- `selectedAddress` +- `networkVersion` +- `isWalletLink` +- `ismetaMask` +- `host` + +#### Methods + +- `disableReloadOnDisconnect` +- `setProviderInfo` +- `setAppInfo` +- `close` +- `send` +- `sendAsync` +- `scanQRCode` +- `genericRequest` +- `connectAndSignIn` +- `selectProvider` +- `supportsSubscriptions` +- `subscribe` +- `unsubscribe` diff --git a/vocs.config.ts b/vocs.config.ts index 8105dd8..8948f4d 100644 --- a/vocs.config.ts +++ b/vocs.config.ts @@ -99,6 +99,10 @@ export default defineConfig({ text: "makeWeb3Provider", link: "/sdk/makeWeb3Provider", }, + { + text: "Upgrading from 3.x", + link: "/sdk/v3-to-v4-changes", + }, ], }, {