Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add change details for devs upgrading from 3.x #27

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions docs/pages/sdk/v3-to-v4-changes.mdx
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Suggested change
- An array of chain IDs your dapp supports
- An array of chain IDs your app supports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and everywhere else

- 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<T>(args: RequestArguments): Promise<T>;
disconnect(): Promise<void>;
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you say what v4 returns?

Suggested change
- v4 is [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193#connect) compliant.
- v4 is [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193#connect) compliant and returns ...


```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`
4 changes: 4 additions & 0 deletions vocs.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export default defineConfig({
text: "makeWeb3Provider",
link: "/sdk/makeWeb3Provider",
},
{
text: "Upgrading from 3.x",
link: "/sdk/v3-to-v4-changes",
},
],
},
{
Expand Down
Loading