Skip to content
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
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@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-alpha.1",
"@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 @@ -87,6 +87,11 @@ 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
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@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-alpha.1",
"@web3-onboard/web3auth": "^2.2.2",
"@web3-onboard/xdefi": "^2.0.5-alpha.1",
"@web3-onboard/zeal": "^2.0.3",
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',
additionalOptionalMethods: ['someSillyShit']
})
const portis = portisModule({
apiKey: 'b2b7586f-2b1e-4c30-a7fb-c2d1533b153b'
Expand Down
5 changes: 5 additions & 0 deletions packages/walletconnect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ 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
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-alpha.1",
"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
19 changes: 13 additions & 6 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,6 +35,7 @@ function walletConnect(options: WalletConnectOptions): WalletInit {
requiredChains,
optionalChains,
qrModalOptions,
additionalRequiredMethods,
additionalOptionalMethods,
dappUrl
} = options
Expand All @@ -56,10 +58,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 +104,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 +119,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
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