Skip to content

Commit

Permalink
feat: Ledger connector with support for WalletConnect v2 (#1549)
Browse files Browse the repository at this point in the history
* feat: Ledger connector with support for WalletConnect v2

* Code review fixes

* Update Connect Kit dependency to final version

* Update README and docs

* Update package version

* Update packages/ledger/package.json

* Delete package level yarn.lock as it is unnecessary

* Default to WalletConnect v2

Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>

---------

Co-authored-by: Kat Leight <33187102+leightkt@users.noreply.github.com>
Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
  • Loading branch information
3 people authored Jun 28, 2023
1 parent 67fd651 commit 5846eb5
Show file tree
Hide file tree
Showing 7 changed files with 731 additions and 283 deletions.
55 changes: 50 additions & 5 deletions docs/src/routes/docs/[...4]wallets/[...13]ledger/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,45 @@ npm install @web3-onboard/core @web3-onboard/ledger

```typescript
interface LedgerOptions {
chainId?: number
bridge?: string
infuraId?: string
rpc?: { [chainId: number]: string }
/**
* Enable Ledger Connect Kit logs
*/
enableDebugLogs?: boolean
/**
* Defaults to walletConnectVersion: 1 - this behavior will be deprecated after the WalletConnect v1 sunset
*/
walletConnectVersion: 2
/**
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
*/
projectId: string
/**
* List of Required Chain IDs for Ledger Live to support in number format (integer or hex)
* Defaults to [1] - Ethereum
* The chains defined within the web3-onboard config will define the
* optional chains for the WalletConnect module
*/
requiredChains?: string[] | number[]
/**
* List of Required Methods for wallets to support
*/
requiredMethods?: string[]
/**
* List of Optional Methods for wallets to support
*/
optionalMethods?: string[]
/**
* List of Required Events for wallets to support
*/
requiredEvents?: string[]
/**
* List of Optional Events for wallets to support
*/
optionalEvents?: string[]
/**
* List of Chain ID to URL mapping
*/
rpcMap?: { [chainId: number]: string }
}
```

Expand All @@ -42,7 +77,17 @@ interface LedgerOptions {
import Onboard from '@web3-onboard/core'
import ledgerModule from '@web3-onboard/ledger'

const ledger = ledgerModule()
const ledger = ledgerModule({
walletConnectVersion: 2,
/**
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
*/
projectId: 'abc123...',
/**
* Chains required to be supported by all wallets connecting to your DApp
*/
requiredChains: [1, 137]
})

const onboard = Onboard({
// ... other Onboard options
Expand Down
55 changes: 50 additions & 5 deletions packages/ledger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,45 @@

```typescript
interface LedgerOptions {
chainId?: number
bridge?: string
infuraId?: string
rpc?: { [chainId: number]: string }
/**
* Enable Ledger Connect Kit logs
*/
enableDebugLogs?: boolean
/**
* Defaults to walletConnectVersion: 1 - this behavior will be deprecated after the WalletConnect v1 sunset
*/
walletConnectVersion: 2
/**
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
*/
projectId: string
/**
* List of Required Chain IDs for Ledger Live to support in number format (integer or hex)
* Defaults to [1] - Ethereum
* The chains defined within the web3-onboard config will define the
* optional chains for the WalletConnect module
*/
requiredChains?: string[] | number[]
/**
* List of Required Methods for wallets to support
*/
requiredMethods?: string[]
/**
* List of Optional Methods for wallets to support
*/
optionalMethods?: string[]
/**
* List of Required Events for wallets to support
*/
requiredEvents?: string[]
/**
* List of Optional Events for wallets to support
*/
optionalEvents?: string[]
/**
* List of Chain ID to URL mapping
*/
rpcMap?: { [chainId: number]: string }
}
```

Expand All @@ -23,7 +58,17 @@ interface LedgerOptions {
import Onboard from '@web3-onboard/core'
import ledgerModule from '@web3-onboard/ledger'

const ledger = ledgerModule()
const ledger = ledgerModule({
walletConnectVersion: 2,
/**
* Project ID associated with [WalletConnect account](https://cloud.walletconnect.com)
*/
projectId: 'abc123...',
/**
* Chains required to be supported by all wallets connecting to your DApp
*/
requiredChains: [1, 137]
})

const onboard = Onboard({
// ... other Onboard options
Expand Down
8 changes: 4 additions & 4 deletions packages/ledger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/ledger",
"version": "2.4.6",
"version": "2.5.0-alpha.1",
"description": "Ledger hardare 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 @@ -55,12 +55,12 @@
},
"license": "MIT",
"devDependencies": {
"@walletconnect/types": "^2.7.0",
"typescript": "^4.5.5"
},
"dependencies": {
"@ethersproject/providers": "^5.5.0",
"@ledgerhq/connect-kit-loader": "^1.0.2",
"@walletconnect/client": "^1.7.1",
"@ledgerhq/connect-kit-loader": "^1.1.0",
"@walletconnect/client": "^1.8.0",
"@web3-onboard/common": "^2.3.3",
"rxjs": "^7.5.2"
}
Expand Down
Loading

0 comments on commit 5846eb5

Please sign in to comment.