Skip to content

Commit 1e73a80

Browse files
authored
Merge branch 'blocknative:develop' into capsule-dependency-version-upgrade
2 parents 49ab770 + 07b5aab commit 1e73a80

File tree

11 files changed

+85
-39
lines changed

11 files changed

+85
-39
lines changed

docs/src/routes/docs/[...4]wallets/[...6]coinbase/+page.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,29 @@ npm install @web3-onboard/coinbase
2929

3030
```typescript
3131
type CoinbaseWalletOptions = {
32-
/** @optional Use dark theme */
32+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase Use dark theme */
3333
darkMode?: boolean
34-
/** @optional whether to connect mobile web app via WalletLink, defaults to false */
34+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase whether to connect mobile web app via WalletLink, defaults to false */
3535
enableMobileWalletLink?: boolean
36-
/** @optional whether or not to reload dapp automatically after disconnect, defaults to true */
36+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase whether or not to reload dapp automatically after disconnect, defaults to true */
3737
reloadOnDisconnect?: boolean
38+
/** Type of Coinbase wallets to support - options : 'all' | 'smartWalletOnly' | 'eoaOnly' - Default to `all` */
39+
supportedWalletType?: 'all' | 'smartWalletOnly' | 'eoaOnly'
3840
}
3941
```
4042
43+
## Smart Wallet
44+
45+
Starting at `@web3-onboard/coinbase` version 2.3.0 smart wallet support has been added. A smart wallet lives in your browser, no extensions or app installs needed. Use passkeys for signing, with enterprise-grade security without complex seed phrases. One wallet, one address, works universally across major L2s and onchain apps. [More info on Coinbase smart wallets](https://www.coinbase.com/wallet/smart-wallet).
46+
4147
## Usage
4248
4349
```typescript
4450
import Onboard from '@web3-onboard/core'
4551
import coinbaseWalletModule from '@web3-onboard/coinbase'
4652

4753
// initialize the module with options
48-
const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true })
54+
const coinbaseWalletSdk = coinbaseWalletModule()
4955

5056
// can also initialize with no options...
5157
// const coinbaseWalletSdk = coinbaseWalletSdk()

packages/coinbase/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# @web3-onboard/coinbase
22

33
## Wallet module for connecting Coinbase Wallet SDK to web3-onboard
4+
45
See [Coinbase Wallet Developer Docs](https://docs.cloud.coinbase.com/wallet-sdk/docs)
56

67
### Install
@@ -11,23 +12,29 @@ See [Coinbase Wallet Developer Docs](https://docs.cloud.coinbase.com/wallet-sdk/
1112

1213
```typescript
1314
type CoinbaseWalletOptions = {
14-
/** @optional Use dark theme */
15+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase Use dark theme */
1516
darkMode?: boolean
16-
/** @optional whether to connect mobile web app via WalletLink, defaults to false */
17+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase whether to connect mobile web app via WalletLink, defaults to false */
1718
enableMobileWalletLink?: boolean
18-
/** @optional whether or not to reload dapp automatically after disconnect, defaults to true */
19+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase whether or not to reload dapp automatically after disconnect, defaults to true */
1920
reloadOnDisconnect?: boolean
21+
/** Type of Coinbase wallets to support - options : 'all' | 'smartWalletOnly' | 'eoaOnly' - Default to `all` */
22+
supportedWalletType?: 'all' | 'smartWalletOnly' | 'eoaOnly'
2023
}
2124
```
2225
26+
## Smart Wallet
27+
28+
Starting at `@web3-onboard/coinbase` version 2.3.0 smart wallet support has been added. A smart wallet lives in your browser, no extensions or app installs needed. Use passkeys for signing, with enterprise-grade security without complex seed phrases. One wallet, one address, works universally across major L2s and onchain apps. [More info on Coinbase smart wallets](https://www.coinbase.com/wallet/smart-wallet).
29+
2330
## Usage
2431
2532
```typescript
2633
import Onboard from '@web3-onboard/core'
2734
import coinbaseWalletModule from '@web3-onboard/coinbase'
2835

2936
// initialize the module with options
30-
const coinbaseWalletSdk = coinbaseWalletModule({ darkMode: true })
37+
const coinbaseWalletSdk = coinbaseWalletModule()
3138

3239
// can also initialize with no options...
3340
// const coinbaseWalletSdk = coinbaseWalletModule()

packages/coinbase/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/coinbase",
3-
"version": "2.3.0",
3+
"version": "2.4.0-alpha.1",
44
"description": "Coinbase SDK wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",
@@ -31,7 +31,8 @@
3131
"confirmed",
3232
"Injected Wallet",
3333
"Crypto",
34-
"Crypto Wallet"
34+
"Crypto Wallet",
35+
"Smart Wallet"
3536
],
3637
"repository": {
3738
"type": "git",
@@ -58,7 +59,7 @@
5859
"typescript": "^5.4.5"
5960
},
6061
"dependencies": {
61-
"@coinbase/wallet-sdk": "3.9.2",
62-
"@web3-onboard/common": "^2.4.0"
62+
"@coinbase/wallet-sdk": "4.0.3",
63+
"@web3-onboard/common": "^2.4.1-alpha.1"
6364
}
6465
}

packages/coinbase/src/index.ts

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
import { WalletInit } from '@web3-onboard/common'
1+
import type { WalletInit, WalletInterface } from '@web3-onboard/common'
22

33
function coinbaseWallet({
4+
supportedWalletType = 'all',
45
darkMode = false,
56
enableMobileWalletLink = false,
67
reloadOnDisconnect = true
78
}: {
8-
/** @optional Use dark theme */
9+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase Use dark theme */
910
darkMode?: boolean
10-
/** @optional whether to connect mobile web app via WalletLink, defaults to false */
11+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase whether to connect mobile web app via WalletLink, defaults to false */
1112
enableMobileWalletLink?: boolean
12-
/** @optional whether or not to reload dapp automatically after disconnect, defaults to true */
13+
/** @deprecated Deprecated after version 2.2.7 of @web3-onboard/coinbase whether or not to reload dapp automatically after disconnect, defaults to true */
1314
reloadOnDisconnect?: boolean
15+
/** Type of Coinbase wallets to support - options : 'all' | 'smartWalletOnly' | 'eoaOnly' - Default to `all` */
16+
supportedWalletType?: 'all' | 'smartWalletOnly' | 'eoaOnly'
1417
} = {}): WalletInit {
1518
return () => {
1619
return {
1720
label: 'Coinbase Wallet',
1821
getIcon: async () => (await import('./icon.js')).default,
19-
getInterface: async ({ chains, appMetadata }) => {
20-
const [chain] = chains
22+
getInterface: async ({
23+
chains,
24+
appMetadata
25+
}): Promise<WalletInterface> => {
26+
if (enableMobileWalletLink || reloadOnDisconnect || darkMode) {
27+
console.warn(
28+
'darkMode, enableMobileWalletLink and reloadOnDisconnect init props are deprecated after version 2.2.7 of @web3-onboard/coinbase'
29+
)
30+
}
2131
const { name, icon } = appMetadata || {}
2232

2333
// according to https://github.com/wagmi-dev/wagmi/issues/383
@@ -31,29 +41,43 @@ function coinbaseWallet({
3141
? (CoinbaseWalletSDK as any).default
3242
: CoinbaseWalletSDK
3343
) as typeof CoinbaseWalletSDK
44+
const { isHex, toHex, createEIP1193Provider, fromHex } = await import(
45+
'@web3-onboard/common'
46+
)
3447

3548
const base64 = window.btoa(icon || '')
3649
const appLogoUrl = `data:image/svg+xml;base64,${base64}`
3750

51+
const appChainIds = chains.map(({ id }) =>
52+
fromHex(id as `0x${string}`, 'number')
53+
)
54+
3855
const instance = new CoinbaseWalletSDKConstructor({
3956
appName: name || '',
4057
appLogoUrl,
41-
darkMode,
42-
enableMobileWalletLink,
43-
reloadOnDisconnect
58+
appChainIds
4459
})
4560

46-
const coinbaseWalletProvider = instance.makeWeb3Provider(
47-
chain.rpcUrl,
48-
parseInt(chain.id)
49-
)
61+
const coinbaseWalletProvider = instance.makeWeb3Provider({
62+
options: supportedWalletType
63+
})
5064

5165
// patch the chainChanged event
5266
const on = coinbaseWalletProvider.on.bind(coinbaseWalletProvider)
67+
5368
coinbaseWalletProvider.on = (event, listener) => {
69+
// @ts-ignore
5470
on(event, val => {
5571
if (event === 'chainChanged') {
56-
listener(`0x${(val as number).toString(16)}`)
72+
let hexVal: string
73+
if (isHex(val)) {
74+
hexVal = val
75+
} else {
76+
hexVal = toHex(val)
77+
}
78+
79+
// @ts-ignore
80+
listener(hexVal)
5781
return
5882
}
5983

@@ -62,9 +86,11 @@ function coinbaseWallet({
6286

6387
return coinbaseWalletProvider
6488
}
89+
const provider = createEIP1193Provider(coinbaseWalletProvider)
90+
provider.removeListener = (event, func) => {}
6591

6692
return {
67-
provider: coinbaseWalletProvider,
93+
provider,
6894
instance
6995
}
7096
}

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/common",
3-
"version": "2.4.0",
3+
"version": "2.4.1-alpha.1",
44
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
55
"keywords": [
66
"Ethereum",

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export {
1313

1414
export * from './types.js'
1515
export * from './validation.js'
16+
export { parseEther, isHex, toHex, fromHex } from 'viem'

packages/common/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { ConnectionInfo } from 'ethers/lib/utils'
22
import EventEmitter from 'eventemitter3'
33
import type { TypedData as EIP712TypedData } from 'eip-712'
4+
import type { Address } from 'viem'
5+
export type { Address } from 'viem'
46
export type { TypedData as EIP712TypedData } from 'eip-712'
57

68
/**
@@ -300,7 +302,6 @@ export interface EthSignTransactionRequest {
300302
params: [TransactionObject]
301303
}
302304

303-
export type Address = `0x${string}`
304305
type Message = string
305306
export interface EthSignMessageRequest {
306307
method: 'eth_sign'

packages/demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"@web3-onboard/capsule": "2.2.0-alpha.1",
3434
"@web3-onboard/cede-store": "^2.3.0",
3535
"@web3-onboard/core": "2.22.0",
36-
"@web3-onboard/coinbase": "^2.3.0",
36+
"@web3-onboard/coinbase": "^2.4.0-alpha.1",
3737
"@web3-onboard/dcent": "^2.2.7",
3838
"@web3-onboard/enkrypt": "^2.1.0",
3939
"@web3-onboard/fortmatic": "^2.1.0",

packages/demo/src/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
const onboard = Onboard({
262262
wallets: [
263263
// metamaskSDKWallet,
264-
// coinbaseWallet,
264+
coinbaseWallet,
265265
injected,
266266
ledger,
267267
trezor,

packages/enkrypt/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
},
5757
"license": "MIT",
5858
"devDependencies": {
59-
"@ethersproject/providers": "^5.5.0",
6059
"@types/node": "^17.0.21",
6160
"ts-node": "^10.2.1",
6261
"typescript": "^5.4.5",

yarn.lock

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,16 +783,13 @@
783783
preact "^10.16.0"
784784
sha.js "^2.4.11"
785785

786-
"@coinbase/wallet-sdk@3.9.2":
787-
version "3.9.2"
788-
resolved "https://registry.yarnpkg.com/@coinbase/wallet-sdk/-/wallet-sdk-3.9.2.tgz#757d6652d0972eb8804c50e3923a05242833caf1"
789-
integrity sha512-SyfUlG0DzgRu2WQ8+c7DpFEIe8Bt/nxyP1hcExDUXF7cHaopdAU43djT8SLIWH8Li40ZK9VBGVuNIK/pwHR9LA==
786+
"@coinbase/wallet-sdk@4.0.3":
787+
version "4.0.3"
788+
resolved "https://registry.yarnpkg.com/@coinbase/wallet-sdk/-/wallet-sdk-4.0.3.tgz#fd52dd4c168c35979c7b3294018a6f78d163a593"
789+
integrity sha512-y/OGEjlvosikjfB+wk+4CVb9OxD1ob9cidEBLI5h8Hxaf/Qoob2XoVT1uvhtAzBx34KpGYSd+alKvh/GCRre4Q==
790790
dependencies:
791-
bn.js "^5.2.1"
792791
buffer "^6.0.3"
793792
clsx "^1.2.1"
794-
eth-block-tracker "^7.1.0"
795-
eth-json-rpc-filters "^6.0.0"
796793
eventemitter3 "^5.0.1"
797794
keccak "^3.0.3"
798795
preact "^10.16.0"
@@ -5740,6 +5737,14 @@
57405737
"@walletconnect/window-getters" "^1.0.1"
57415738
tslib "1.14.1"
57425739

5740+
"@web3-onboard/common@2.4.0", "@web3-onboard/common@^2.4.0":
5741+
version "2.4.0"
5742+
resolved "https://registry.yarnpkg.com/@web3-onboard/common/-/common-2.4.0.tgz#dcc61ef095bd09eb3ba47a9752d6fb75ba53fd9b"
5743+
integrity sha512-WS+/+giBbBFTnIUcphGWIas+KZJ+JjYNNPVj/N3EUrrc0nSbmtFkD3hqvz8f1GH2C0p547FEdIwahZL3+MtROw==
5744+
dependencies:
5745+
joi "17.9.1"
5746+
viem "2.12.0"
5747+
57435748
"@web3-react/abstract-connector@^6.0.7":
57445749
version "6.0.7"
57455750
resolved "https://registry.yarnpkg.com/@web3-react/abstract-connector/-/abstract-connector-6.0.7.tgz#401b3c045f1e0fab04256311be49d5144e9badc6"

0 commit comments

Comments
 (0)