Skip to content

Commit

Permalink
Merge pull request #1889 from blocknative/release/2.24.9
Browse files Browse the repository at this point in the history
Release 2.24.9 (docs)
  • Loading branch information
Adamj1232 authored Aug 29, 2023
2 parents 6954284 + 3cab2b6 commit ac2806b
Show file tree
Hide file tree
Showing 16 changed files with 398 additions and 461 deletions.
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@
"@web3-onboard/taho": "^2.0.5",
"@web3-onboard/torus": "^2.2.5",
"@web3-onboard/transaction-preview": "^2.0.8",
"@web3-onboard/trezor": "^2.4.2",
"@web3-onboard/trezor": "^2.4.3",
"@web3-onboard/trust": "^2.0.4",
"@web3-onboard/uauth": "^2.1.1",
"@web3-onboard/venly": "^2.0.0",
"@web3-onboard/walletconnect": "^2.4.2",
"@web3-onboard/walletconnect": "^2.4.6",
"@web3-onboard/web3auth": "^2.2.3",
"@web3-onboard/xdefi": "^2.0.4",
"@web3-onboard/zeal": "^2.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Introduction
import walletModal from '$lib/assets/connect-modal.svg'
</script>

# Web3-Onboard
# Web3 Onboard

The best way to connect a wallet 🚀

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

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.

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.
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.

**Setup your Account**
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.
Expand Down
68 changes: 31 additions & 37 deletions docs/src/routes/docs/[...4]wallets/[...26]walletconnect/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ npm install @web3-onboard/walletconnect
</TabPanel>
</Tabs>

## Options

```typescript
type WalletConnectOptions = {
Expand All @@ -38,26 +37,6 @@ type WalletConnectOptions = {
*/
handleUri?: (uri: string) => Promise<unknown>
} & (
| {
/**
* @deprecated
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
* To use version 1 a custom bridge url will need to be provided.
* Support will be completely remove from Web3-Onboard in the future
*/
version: 1
/**
* Custom URL Bridge must be defined for V1 usage.
* WalletConnect no longer supports a v1 bridge.
* Upgrading to use WalletConnect v2 is recommended.
* A potential bridge can be found here: 'https://derelay.rabby.io'
*/
bridge: string
connectFirstChainId?: boolean
qrcodeModalOptions?: {
mobileLinks: string[]
}
}
| {
/**
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
Expand Down Expand Up @@ -87,12 +66,37 @@ type WalletConnectOptions = {
* `undefined` by default, see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
*/
qrModalOptions?: EthereumProviderOptions['qrModalOptions']
/**
* Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign']
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods
*/
additionalRequiredMethods?: string[] | undefined
/**
* Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4']
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
*/
additionalOptionalMethods?: string[] | undefined
}
| {
/**
* @deprecated
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
* To use version 1 a custom bridge url will need to be provided.
* Support will be completely remove from Web3-Onboard in the future
*/
version: 1
/**
* Custom URL Bridge must be defined for V1 usage.
* WalletConnect no longer supports a v1 bridge.
* Upgrading to use WalletConnect v2 is recommended.
* A potential bridge can be found here: 'https://derelay.rabby.io'
*/
bridge: string
connectFirstChainId?: boolean
qrcodeModalOptions?: {
mobileLinks: string[]
}
}
)
```
Expand Down Expand Up @@ -132,26 +136,16 @@ const onboard = Onboard({
wallets: [
walletConnect
//... other wallets
],
chains: [
// chains that are passed as optional chains to WC wallet after cleaning and parsing as number[]
{
id: '0x2105',
token: 'ETH',
label: 'Base',
rpcUrl: 'https://mainnet.base.org'
},
{
id: '0x89',
token: 'MATIC',
label: 'Polygon',
rpcUrl: 'https://matic-mainnet.chainstacklabs.com'
}
// ...
]
})

const connectedWallets = await onboard.connectWallet()

// Assuming only wallet connect is connected, index 0
// `instance` will give insight into the WalletConnect info
// such as namespaces, methods, chains, etc per wallet connected
const { instance } = connectedWallets[0]

console.log(connectedWallets)
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web3-onboard-monorepo",
"version": "2.24.8",
"version": "2.24.9",
"private": true,
"workspaces": {
"packages": [
Expand Down
6 changes: 3 additions & 3 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
"@web3-onboard/taho": "^2.0.5",
"@web3-onboard/torus": "^2.2.4",
"@web3-onboard/transaction-preview": "^2.0.7",
"@web3-onboard/trezor": "^2.4.2",
"@web3-onboard/trezor": "^2.4.3",
"@web3-onboard/trust": "^2.0.3",
"@web3-onboard/uauth": "^2.1.2",
"@web3-onboard/venly": "^2.0.0",
"@web3-onboard/walletconnect": "^2.4.5",
"@web3-onboard/walletconnect": "^2.4.6",
"@web3-onboard/web3auth": "^2.2.2",
"@web3-onboard/xdefi": "^2.0.3",
"@web3-onboard/xdefi": "^2.0.5",
"@web3-onboard/zeal": "^2.0.3",
"vconsole": "^3.15.1"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
const walletConnect = walletConnectModule({
handleUri: uri => console.log(uri),
projectId: 'f6bd6e2911b56f5ac3bc8b2d0e2d7ad5'
projectId: 'f6bd6e2911b56f5ac3bc8b2d0e2d7ad5',
dappUrl: 'https://www.onboard.blocknative.com'
})
const portis = portisModule({
apiKey: 'b2b7586f-2b1e-4c30-a7fb-c2d1533b153b'
Expand Down
4 changes: 2 additions & 2 deletions packages/trezor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/trezor",
"version": "2.4.2",
"version": "2.4.3",
"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.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -66,6 +66,6 @@
"eth-crypto": "^2.1.0",
"ethereumjs-util": "^7.1.3",
"hdkey": "^2.0.1",
"@trezor/connect-web": "^9.0.8"
"@trezor/connect-web": "^9.0.11"
}
}
51 changes: 31 additions & 20 deletions packages/walletconnect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@ type WalletConnectOptions = {
*/
handleUri?: (uri: string) => Promise<unknown>
} & (
| {
/**
* @deprecated
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
* To use version 1 a custom bridge url will need to be provided.
* Support will be completely remove from Web3-Onboard in the future
*/
version: 1
/**
* Custom URL Bridge must be defined for V1 usage.
* WalletConnect no longer supports a v1 bridge.
* Upgrading to use WalletConnect v2 is recommended.
* A potential bridge can be found here: 'https://derelay.rabby.io'
*/
bridge: string
connectFirstChainId?: boolean
qrcodeModalOptions?: {
mobileLinks: string[]
}
}
| {
/**
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
Expand Down Expand Up @@ -68,12 +48,37 @@ type WalletConnectOptions = {
* `undefined` by default, see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
*/
qrModalOptions?: EthereumProviderOptions['qrModalOptions']
/**
* Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign']
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods
*/
additionalRequiredMethods?: string[] | undefined
/**
* Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4']
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
*/
additionalOptionalMethods?: string[] | undefined
}
| {
/**
* @deprecated
* Version 1 of WalletConnect has been deprecated by the WC team and the WC bridge is not available.
* To use version 1 a custom bridge url will need to be provided.
* Support will be completely remove from Web3-Onboard in the future
*/
version: 1
/**
* Custom URL Bridge must be defined for V1 usage.
* WalletConnect no longer supports a v1 bridge.
* Upgrading to use WalletConnect v2 is recommended.
* A potential bridge can be found here: 'https://derelay.rabby.io'
*/
bridge: string
connectFirstChainId?: boolean
qrcodeModalOptions?: {
mobileLinks: string[]
}
}
)
```
Expand Down Expand Up @@ -117,5 +122,11 @@ const onboard = Onboard({
})

const connectedWallets = await onboard.connectWallet()

// Assuming only wallet connect is connected, index 0
// `instance` will give insight into the WalletConnect info
// such as namespaces, methods, chains, etc per wallet connected
const { instance } = connectedWallets[0]

console.log(connectedWallets)
```
4 changes: 2 additions & 2 deletions packages/walletconnect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/walletconnect",
"version": "2.4.5",
"version": "2.4.6",
"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.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -61,7 +61,7 @@
"dependencies": {
"@ethersproject/providers": "5.5.0",
"@walletconnect/client": "^1.8.0",
"@walletconnect/ethereum-provider": "2.9.2",
"@walletconnect/ethereum-provider": "^2.10.0",
"@walletconnect/modal": "2.6.1",
"@walletconnect/qrcode-modal": "^1.8.0",
"@web3-onboard/common": "^2.3.3",
Expand Down
5 changes: 5 additions & 0 deletions packages/walletconnect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export type WalletConnectOptions = {
* `undefined` by default, see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
*/
qrModalOptions?: EthereumProviderOptions['qrModalOptions']
/**
* Additional required methods to be added to the default list of ['eth_sendTransaction', 'personal_sign']
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/advanced/providers/ethereum#required-and-optional-methods
*/
additionalRequiredMethods?: string[] | undefined
/**
* Additional methods to be added to the default list of ['eth_sendTransaction', 'eth_signTransaction', 'personal_sign', 'eth_sign', 'eth_signTypedData', 'eth_signTypedData_v4']
* Passed methods to be included along with the defaults methods - see https://docs.walletconnect.com/2.0/web/walletConnectModal/options
Expand Down
31 changes: 23 additions & 8 deletions packages/walletconnect/src/v2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { CoreTypes } from '@walletconnect/types'
import type { EthereumProvider } from '@walletconnect/ethereum-provider'
import { REQUIRED_METHODS } from '@walletconnect/ethereum-provider'
import type { EthereumProviderOptions } from '@walletconnect/ethereum-provider/dist/types/EthereumProvider'
import type { EthereumProvider } from '@walletconnect/ethereum-provider'
import type { CoreTypes } from '@walletconnect/types'

import type {
Chain,
Expand Down Expand Up @@ -34,10 +35,13 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
requiredChains,
optionalChains,
qrModalOptions,
additionalRequiredMethods,
additionalOptionalMethods,
dappUrl
} = options

let instance: unknown

return () => {
return {
label: 'WalletConnect',
Expand All @@ -56,10 +60,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {

const getMetaData = (): CoreTypes.Metadata | undefined => {
if (!appMetadata) return undefined
const url =
dappUrl ||
appMetadata.explore ||
''
const url = dappUrl || appMetadata.explore || ''

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

const requiredMethodsSet = new Set(
additionalRequiredMethods && Array.isArray(additionalRequiredMethods)
? [...additionalRequiredMethods, ...REQUIRED_METHODS]
: REQUIRED_METHODS
)
const requiredMethods = Array.from(requiredMethodsSet)

const optionalMethods =
additionalOptionalMethods && Array.isArray(additionalOptionalMethods)
? [...additionalOptionalMethods, ...methods]
Expand All @@ -113,6 +121,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
const connector = await EthereumProvider.init({
projectId,
chains: requiredChainsParsed, // default to mainnet
methods: requiredMethods,
optionalChains: optionalChainsParsed,
optionalMethods,
showQrModal: true,
Expand Down Expand Up @@ -202,7 +211,10 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
})

this.disconnect = () => {
if (this.connector.session) this.connector.disconnect()
if (this.connector.session) {
this.connector.disconnect()
instance = null
}
}

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

const checkForSession = () => {
const session = this.connector.session
instance = session
if (session) {
this.emit('accountsChanged', this.connector.accounts)
this.emit('chainChanged', this.connector.chainId)
Expand Down Expand Up @@ -279,6 +292,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
// update ethereum provider to load accounts & chainId
const accounts = this.connector.accounts
const chainId = this.connector.chainId
instance = this.connector.session
const hexChainId = `0x${chainId.toString(16)}`
this.emit('chainChanged', hexChainId)
return resolve(accounts)
Expand Down Expand Up @@ -330,7 +344,8 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
}

return {
provider: new EthProvider({ chains, connector })
provider: new EthProvider({ chains, connector }),
instance
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/walletconnect/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const wcOptions = Joi.object({
requiredChains: Joi.array().items(Joi.number()).optional(),
optionalChains: Joi.array().items(Joi.number()).optional(),
qrModalOptions: Joi.object().optional(),
additionalRequiredMethods: Joi.array().items(Joi.string()).optional(),
additionalOptionalMethods: Joi.array().items(Joi.string()).optional()
})

Expand Down
Loading

0 comments on commit ac2806b

Please sign in to comment.