Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

feat: add WalletConnect v2 support to Ledger connector #351

Merged
merged 4 commits into from
Jun 25, 2023

Conversation

hlopes-ledger
Copy link
Collaborator

@hlopes-ledger hlopes-ledger commented Jun 20, 2023

Description

Adds support for WalletConnect v2 to the Ledger connector.

The Ledger Connect Kit is currently in beta, will update package.json to the final one when released. No changes expected to the connector until the final CK release.

The update enables new options for WalletConnect v2

  • walletConnectVersion?: 1 | 2
  • projectId?: EthereumProviderOptions['projectId']
  • requiredChains?: number[]
  • requiredMethods?: string[]
  • optionalMethods?: string[]
  • requiredEvents?: string[]
  • optionalEvents?: string[]

Support for WalletConnect v1 is still kept as it can be used by specifying a custom bridge URL.

To test it

  • update the connector instance on the demo with the new options

      walletConnectVersion: 2,
      requiredChains: [1],
      projectId: 'a test id',
    
  • Ledger Extension on Safari

    • Open the example application on Safari iOS or macOS
    • follow instructions to install and enable the extension
    • connect using the Extension
  • WalletConnect and Ledger Live

    • Open the example application on Chrome iOS or macOS
    • install Ledger Live if not installed yet using the install link
    • connect with Ledger Live using the QR code or the button

Additional Information

@changeset-bot
Copy link

changeset-bot bot commented Jun 20, 2023

🦋 Changeset detected

Latest commit: 0ebfacc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wagmi/connectors Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jun 20, 2023

Size Change: +502 B (+1%)

Total Size: 59.7 kB

Filename Size Change
packages/connectors/dist/injected.d.ts 1.97 kB +198 B (+11%) ⚠️
packages/connectors/dist/injected.js 1.99 kB +304 B (+18%) ⚠️
ℹ️ View Unchanged
Filename Size Change
packages/chains/dist 8.68 kB 0 B
packages/chains/dist/index.d.ts 9.02 kB 0 B
packages/chains/dist/index.js 8.64 kB 0 B
packages/chains/dist/index.mjs 1.33 kB 0 B
packages/connectors/dist 2.68 kB 0 B
packages/connectors/dist/base-0473abd3.d.ts 198 B 0 B
packages/connectors/dist/chunk-4BSCIAHY.js 784 B 0 B
packages/connectors/dist/chunk-OQILYQDO.js 292 B 0 B
packages/connectors/dist/chunk-QYMCVNHT.js 1.94 kB 0 B
packages/connectors/dist/chunk-ZCAPXGBX.js 1.79 kB 0 B
packages/connectors/dist/coinbaseWallet.d.ts 275 B 0 B
packages/connectors/dist/coinbaseWallet.js 136 B 0 B
packages/connectors/dist/index.d.ts 2.17 kB 0 B
packages/connectors/dist/index.js 119 B 0 B
packages/connectors/dist/ledger.d.ts 518 B 0 B
packages/connectors/dist/ledger.js 1.28 kB 0 B
packages/connectors/dist/metaMask.d.ts 0 B 0 B 🆕
packages/connectors/dist/metaMask.js 2.11 kB 0 B
packages/connectors/dist/mock 1.62 kB 0 B
packages/connectors/dist/mock/index.d.ts 1.97 kB 0 B
packages/connectors/dist/mock/index.js 1.17 kB 0 B
packages/connectors/dist/safe.d.ts 2.86 kB 0 B
packages/connectors/dist/safe.js 2.66 kB 0 B
packages/connectors/dist/walletConnect.d.ts 1.72 kB 0 B
packages/connectors/dist/walletConnect.js 1.76 kB 0 B
packages/connectors/dist/walletConnectLegacy.d.ts 0 B 0 B 🆕
packages/connectors/dist/walletConnectLegacy.js 0 B 0 B 🆕

compressed-size-action

@socket-security
Copy link

socket-security bot commented Jun 20, 2023

New and updated dependency changes detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives1 Size Publisher
@ledgerhq/connect-kit-loader ⬆️ 1.0.1...1.1.0 None +0/-0 17.6 kB

Footnotes

  1. https://docs.socket.dev

@hlopes-ledger hlopes-ledger changed the title feat: add WalletConnect v2 sipport to Ledger connector feat: add WalletConnect v2 support to Ledger connector Jun 20, 2023
@hlopes-ledger hlopes-ledger requested review from tmm and jxom June 20, 2023 10:37
@hlopes-ledger hlopes-ledger force-pushed the feat/add-wc-v2-to-ledger branch 3 times, most recently from 7cf0fb3 to 9cc8d64 Compare June 21, 2023 12:01
Comment on lines +26 to +31
projectId?: EthereumProviderOptions['projectId']
requiredChains?: number[]
requiredMethods?: string[]
optionalMethods?: string[]
requiredEvents?: string[]
optionalEvents?: string[]
Copy link
Member

@jxom jxom Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a discrimitive union for these? ie:

type LedgerConnectorOptions = {
  walletConnectVersion: 1,
  ... // v1 opts
} | {
  walletConnectVersion: 2,
  ... // v2 opts
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, should we even support v1 in this PR at all if it's being turned off next week?

Copy link
Collaborator Author

@hlopes-ledger hlopes-ledger Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update it.

From what I've seen on the community you'll still be able to use v1 with a custom bridge URL, by specifying it in the bridge parameter. We intend to keep it for now and move to v2 only at a later stage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@hlopes-ledger
Copy link
Collaborator Author

We've released Connect Kit 1.1.0 and I've updated the package dependency.

@jxom jxom merged commit f21c8e0 into main Jun 25, 2023
6 checks passed
@jxom jxom deleted the feat/add-wc-v2-to-ledger branch June 25, 2023 05:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants