Skip to content

Commit df7480f

Browse files
Adamj1232taylorjdawsonlaurencedelislehackableleightkt
authored
Merge pull request #1888 from blocknative/release/2.24.9
* Add link & update nomenclature (#1881) added link that was missing for quickstart & updated to Web3 Onboard. * Update Trezor to 9.0.11 (#1882) * Update Trezor to 9.0.11 Getting error: TypeError: Cannot destructure property 'BridgeV2' of 'transport_1.default' as it is undefined. This seems to have changed recently (within the last couple of days) as this is breaking in one of our automated tests. Info: @trezor/connect v9.0.7 How to reproduce This happens consistently when trying to import the module. Update to 9.0.11 should solve this * Update package.json version to 2.4.3-alpha.1 --------- Co-authored-by: Kat Leight <33187102+leightkt@users.noreply.github.com> * feat: updated xdefi icon (#1870) * feat: updated xdefi icon * chore: package version bumps * Update packages/xdefi/package.json * chore: updated package.json --------- Co-authored-by: Kat Leight <33187102+leightkt@users.noreply.github.com> * Feat/add additional required methods props to wc (#1883) * add ability to pass additionalRequiredMethods in WalletConnectOptions * bump minor version to alpha.1 * add documentation for additionalRequiredMethods * bump @walletconnect/ethereum-provider to ^2.10.0 * Add to internal demo and docs, update readme --------- Co-authored-by: Kat Leight <33187102+leightkt@users.noreply.github.com> Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com> * Bump versions and yarn, add WC instance return for session info --------- Co-authored-by: Taylor Dawson <taylorjdawson@gmail.com> Co-authored-by: Laurence <53497147+laurencedelisle@users.noreply.github.com> Co-authored-by: Rohan <me@rohandey.com> Co-authored-by: Kat Leight <33187102+leightkt@users.noreply.github.com> Co-authored-by: Jackson Hong <jacksonhong_@outlook.com> Co-authored-by: marc <marcsednaoui@hotmail.com>
2 parents 42e240a + 3cab2b6 commit df7480f

File tree

16 files changed

+398
-461
lines changed

16 files changed

+398
-461
lines changed

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@
7676
"@web3-onboard/taho": "^2.0.5",
7777
"@web3-onboard/torus": "^2.2.5",
7878
"@web3-onboard/transaction-preview": "^2.0.8",
79-
"@web3-onboard/trezor": "^2.4.2",
79+
"@web3-onboard/trezor": "^2.4.3",
8080
"@web3-onboard/trust": "^2.0.4",
8181
"@web3-onboard/uauth": "^2.1.1",
8282
"@web3-onboard/venly": "^2.0.0",
83-
"@web3-onboard/walletconnect": "^2.4.2",
83+
"@web3-onboard/walletconnect": "^2.4.6",
8484
"@web3-onboard/web3auth": "^2.2.3",
8585
"@web3-onboard/xdefi": "^2.0.4",
8686
"@web3-onboard/zeal": "^2.0.4",

docs/src/routes/docs/[...1]overview/[...1]introduction/+page.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Introduction
66
import walletModal from '$lib/assets/connect-modal.svg'
77
</script>
88

9-
# Web3-Onboard
9+
# Web3 Onboard
1010

1111
The best way to connect a wallet 🚀
1212

@@ -57,7 +57,7 @@ web3-onboard supports all EVM networks. Supporting a new network is simply a mat
5757

5858
Using a Blocknative API key with web3-onboard on the free plan will allow you to gain the benefits of Blocknative balance & transaction services. Blocknative has a free forever plan you can always use.
5959

60-
This step is not required to use web3-onboard. You can skip to the **Quickstart** step below if you want to use web3-onboard without API services or if you already have a Blocknative account & API key.
60+
This step is not required to use web3-onboard. You can skip to the [**Quickstart**](/docs/overview/introduction#quickstart) step below if you want to use web3-onboard without API services or if you already have a Blocknative account & API key.
6161

6262
**Setup your Account**
6363
Go to the Account Dashboard at [https://explorer.blocknative.com/account](https://explorer.blocknative.com/account) and setup an account with an email address. You will receive an email to confirm your account.

docs/src/routes/docs/[...4]wallets/[...26]walletconnect/+page.md

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ npm install @web3-onboard/walletconnect
2929
</TabPanel>
3030
</Tabs>
3131

32-
## Options
3332

3433
```typescript
3534
type WalletConnectOptions = {
@@ -38,26 +37,6 @@ type WalletConnectOptions = {
3837
*/
3938
handleUri?: (uri: string) => Promise<unknown>
4039
} & (
41-
| {
42-
/**
43-
* @deprecated
44-
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
45-
* To use version 1 a custom bridge url will need to be provided.
46-
* Support will be completely remove from Web3-Onboard in the future
47-
*/
48-
version: 1
49-
/**
50-
* Custom URL Bridge must be defined for V1 usage.
51-
* WalletConnect no longer supports a v1 bridge.
52-
* Upgrading to use WalletConnect v2 is recommended.
53-
* A potential bridge can be found here: 'https://derelay.rabby.io'
54-
*/
55-
bridge: string
56-
connectFirstChainId?: boolean
57-
qrcodeModalOptions?: {
58-
mobileLinks: string[]
59-
}
60-
}
6140
| {
6241
/**
6342
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
@@ -87,12 +66,37 @@ type WalletConnectOptions = {
8766
* `undefined` by default, see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
8867
*/
8968
qrModalOptions?: EthereumProviderOptions['qrModalOptions']
69+
/**
70+
* Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign']
71+
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods
72+
*/
73+
additionalRequiredMethods?: string[] | undefined
9074
/**
9175
* Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4']
9276
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
9377
*/
9478
additionalOptionalMethods?: string[] | undefined
9579
}
80+
| {
81+
/**
82+
* @deprecated
83+
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
84+
* To use version 1 a custom bridge url will need to be provided.
85+
* Support will be completely remove from Web3-Onboard in the future
86+
*/
87+
version: 1
88+
/**
89+
* Custom URL Bridge must be defined for V1 usage.
90+
* WalletConnect no longer supports a v1 bridge.
91+
* Upgrading to use WalletConnect v2 is recommended.
92+
* A potential bridge can be found here: 'https://derelay.rabby.io'
93+
*/
94+
bridge: string
95+
connectFirstChainId?: boolean
96+
qrcodeModalOptions?: {
97+
mobileLinks: string[]
98+
}
99+
}
96100
)
97101
```
98102
@@ -132,26 +136,16 @@ const onboard = Onboard({
132136
wallets: [
133137
walletConnect
134138
//... other wallets
135-
],
136-
chains: [
137-
// chains that are passed as optional chains to WC wallet after cleaning and parsing as number[]
138-
{
139-
id: '0x2105',
140-
token: 'ETH',
141-
label: 'Base',
142-
rpcUrl: 'https://mainnet.base.org'
143-
},
144-
{
145-
id: '0x89',
146-
token: 'MATIC',
147-
label: 'Polygon',
148-
rpcUrl: 'https://matic-mainnet.chainstacklabs.com'
149-
}
150-
// ...
151139
]
152140
})
153141

154142
const connectedWallets = await onboard.connectWallet()
143+
144+
// Assuming only wallet connect is connected, index 0
145+
// `instance` will give insight into the WalletConnect info
146+
// such as namespaces, methods, chains, etc per wallet connected
147+
const { instance } = connectedWallets[0]
148+
155149
console.log(connectedWallets)
156150
```
157151

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-monorepo",
3-
"version": "2.24.8",
3+
"version": "2.24.9",
44
"private": true,
55
"workspaces": {
66
"packages": [

packages/demo/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
"@web3-onboard/taho": "^2.0.5",
5353
"@web3-onboard/torus": "^2.2.4",
5454
"@web3-onboard/transaction-preview": "^2.0.7",
55-
"@web3-onboard/trezor": "^2.4.2",
55+
"@web3-onboard/trezor": "^2.4.3",
5656
"@web3-onboard/trust": "^2.0.3",
5757
"@web3-onboard/uauth": "^2.1.2",
5858
"@web3-onboard/venly": "^2.0.0",
59-
"@web3-onboard/walletconnect": "^2.4.5",
59+
"@web3-onboard/walletconnect": "^2.4.6",
6060
"@web3-onboard/web3auth": "^2.2.2",
61-
"@web3-onboard/xdefi": "^2.0.3",
61+
"@web3-onboard/xdefi": "^2.0.5",
6262
"@web3-onboard/zeal": "^2.0.3",
6363
"vconsole": "^3.15.1"
6464
},

packages/demo/src/App.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@
117117
118118
const walletConnect = walletConnectModule({
119119
handleUri: uri => console.log(uri),
120-
projectId: 'f6bd6e2911b56f5ac3bc8b2d0e2d7ad5'
120+
projectId: 'f6bd6e2911b56f5ac3bc8b2d0e2d7ad5',
121+
dappUrl: 'https://www.onboard.blocknative.com'
121122
})
122123
const portis = portisModule({
123124
apiKey: 'b2b7586f-2b1e-4c30-a7fb-c2d1533b153b'

packages/trezor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/trezor",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "Trezor hardware 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",
@@ -66,6 +66,6 @@
6666
"eth-crypto": "^2.1.0",
6767
"ethereumjs-util": "^7.1.3",
6868
"hdkey": "^2.0.1",
69-
"@trezor/connect-web": "^9.0.8"
69+
"@trezor/connect-web": "^9.0.11"
7070
}
7171
}

packages/walletconnect/README.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@ type WalletConnectOptions = {
1919
*/
2020
handleUri?: (uri: string) => Promise<unknown>
2121
} & (
22-
| {
23-
/**
24-
* @deprecated
25-
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
26-
* To use version 1 a custom bridge url will need to be provided.
27-
* Support will be completely remove from Web3-Onboard in the future
28-
*/
29-
version: 1
30-
/**
31-
* Custom URL Bridge must be defined for V1 usage.
32-
* WalletConnect no longer supports a v1 bridge.
33-
* Upgrading to use WalletConnect v2 is recommended.
34-
* A potential bridge can be found here: 'https://derelay.rabby.io'
35-
*/
36-
bridge: string
37-
connectFirstChainId?: boolean
38-
qrcodeModalOptions?: {
39-
mobileLinks: string[]
40-
}
41-
}
4222
| {
4323
/**
4424
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
@@ -68,12 +48,37 @@ type WalletConnectOptions = {
6848
* `undefined` by default, see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
6949
*/
7050
qrModalOptions?: EthereumProviderOptions['qrModalOptions']
51+
/**
52+
* Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign']
53+
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods
54+
*/
55+
additionalRequiredMethods?: string[] | undefined
7156
/**
7257
* Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4']
7358
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
7459
*/
7560
additionalOptionalMethods?: string[] | undefined
7661
}
62+
| {
63+
/**
64+
* @deprecated
65+
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
66+
* To use version 1 a custom bridge url will need to be provided.
67+
* Support will be completely remove from Web3-Onboard in the future
68+
*/
69+
version: 1
70+
/**
71+
* Custom URL Bridge must be defined for V1 usage.
72+
* WalletConnect no longer supports a v1 bridge.
73+
* Upgrading to use WalletConnect v2 is recommended.
74+
* A potential bridge can be found here: 'https://derelay.rabby.io'
75+
*/
76+
bridge: string
77+
connectFirstChainId?: boolean
78+
qrcodeModalOptions?: {
79+
mobileLinks: string[]
80+
}
81+
}
7782
)
7883
```
7984
@@ -117,5 +122,11 @@ const onboard = Onboard({
117122
})
118123

119124
const connectedWallets = await onboard.connectWallet()
125+
126+
// Assuming only wallet connect is connected, index 0
127+
// `instance` will give insight into the WalletConnect info
128+
// such as namespaces, methods, chains, etc per wallet connected
129+
const { instance } = connectedWallets[0]
130+
120131
console.log(connectedWallets)
121132
```

packages/walletconnect/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/walletconnect",
3-
"version": "2.4.5",
3+
"version": "2.4.6",
44
"description": "WalletConnect SDK 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",
@@ -61,7 +61,7 @@
6161
"dependencies": {
6262
"@ethersproject/providers": "5.5.0",
6363
"@walletconnect/client": "^1.8.0",
64-
"@walletconnect/ethereum-provider": "2.9.2",
64+
"@walletconnect/ethereum-provider": "^2.10.0",
6565
"@walletconnect/modal": "2.6.1",
6666
"@walletconnect/qrcode-modal": "^1.8.0",
6767
"@web3-onboard/common": "^2.3.3",

packages/walletconnect/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export type WalletConnectOptions = {
5959
* `undefined` by default, see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
6060
*/
6161
qrModalOptions?: EthereumProviderOptions['qrModalOptions']
62+
/**
63+
* Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign']
64+
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods
65+
*/
66+
additionalRequiredMethods?: string[] | undefined
6267
/**
6368
* Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4']
6469
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options

packages/walletconnect/src/v2.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { CoreTypes } from '@walletconnect/types'
2-
import type { EthereumProvider } from '@walletconnect/ethereum-provider'
1+
import { REQUIRED_METHODS } from '@walletconnect/ethereum-provider'
32
import type { EthereumProviderOptions } from '@walletconnect/ethereum-provider/dist/types/EthereumProvider'
3+
import type { EthereumProvider } from '@walletconnect/ethereum-provider'
4+
import type { CoreTypes } from '@walletconnect/types'
45

56
import type {
67
Chain,
@@ -34,10 +35,13 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
3435
requiredChains,
3536
optionalChains,
3637
qrModalOptions,
38+
additionalRequiredMethods,
3739
additionalOptionalMethods,
3840
dappUrl
3941
} = options
4042

43+
let instance: unknown
44+
4145
return () => {
4246
return {
4347
label: 'WalletConnect',
@@ -56,10 +60,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
5660

5761
const getMetaData = (): CoreTypes.Metadata | undefined => {
5862
if (!appMetadata) return undefined
59-
const url =
60-
dappUrl ||
61-
appMetadata.explore ||
62-
''
63+
const url = dappUrl || appMetadata.explore || ''
6364

6465
!url &&
6566
!url.length &&
@@ -105,6 +106,13 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
105106
optionalChains.map(chainID => parseInt(chainID))
106107
: chains.map(({ id }) => parseInt(id, 16))
107108

109+
const requiredMethodsSet = new Set(
110+
additionalRequiredMethods && Array.isArray(additionalRequiredMethods)
111+
? [...additionalRequiredMethods, ...REQUIRED_METHODS]
112+
: REQUIRED_METHODS
113+
)
114+
const requiredMethods = Array.from(requiredMethodsSet)
115+
108116
const optionalMethods =
109117
additionalOptionalMethods && Array.isArray(additionalOptionalMethods)
110118
? [...additionalOptionalMethods, ...methods]
@@ -113,6 +121,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
113121
const connector = await EthereumProvider.init({
114122
projectId,
115123
chains: requiredChainsParsed, // default to mainnet
124+
methods: requiredMethods,
116125
optionalChains: optionalChainsParsed,
117126
optionalMethods,
118127
showQrModal: true,
@@ -202,7 +211,10 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
202211
})
203212

204213
this.disconnect = () => {
205-
if (this.connector.session) this.connector.disconnect()
214+
if (this.connector.session) {
215+
this.connector.disconnect()
216+
instance = null
217+
}
206218
}
207219

208220
if (options && handleUri) {
@@ -224,6 +236,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
224236

225237
const checkForSession = () => {
226238
const session = this.connector.session
239+
instance = session
227240
if (session) {
228241
this.emit('accountsChanged', this.connector.accounts)
229242
this.emit('chainChanged', this.connector.chainId)
@@ -279,6 +292,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
279292
// update ethereum provider to load accounts & chainId
280293
const accounts = this.connector.accounts
281294
const chainId = this.connector.chainId
295+
instance = this.connector.session
282296
const hexChainId = `0x${chainId.toString(16)}`
283297
this.emit('chainChanged', hexChainId)
284298
return resolve(accounts)
@@ -330,7 +344,8 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
330344
}
331345

332346
return {
333-
provider: new EthProvider({ chains, connector })
347+
provider: new EthProvider({ chains, connector }),
348+
instance
334349
}
335350
}
336351
}

packages/walletconnect/src/validation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const wcOptions = Joi.object({
3030
requiredChains: Joi.array().items(Joi.number()).optional(),
3131
optionalChains: Joi.array().items(Joi.number()).optional(),
3232
qrModalOptions: Joi.object().optional(),
33+
additionalRequiredMethods: Joi.array().items(Joi.string()).optional(),
3334
additionalOptionalMethods: Joi.array().items(Joi.string()).optional()
3435
})
3536

0 commit comments

Comments
 (0)