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

Fix/make wc connector more caip compliant #401

Merged
merged 8 commits into from
Jul 5, 2023

Conversation

xzilja
Copy link
Contributor

@xzilja xzilja commented Jul 5, 2023

Description

  • Fix optionalNamespaces returning invalid empty []

  • Better CAIP compliance

Up until now WalletConnectConnector was set up to handle namespaces that included all data under global eip155 key i.e.

{
  "namespaces": {
    "eip155": {
      "chains": ["eip155:14", "eip155:19"],
      "methods": ["eth_sendTransaction", "eth_signTransaction", "personal_sign"],
      "events": ["accountsChanged", "chainChanged"],
      "accounts": ["eip155:14:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb", "eip155:19:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb"]
    },
  }
}

This worked as that's how majority of wallets implement the spec, however with v1 sunset we saw few wallets that return namespaces in another format (also valid)

{
  "namespaces": {
    "eip155:14": {
      "methods": ["eth_sendTransaction", "eth_signTransaction", "personal_sign"],
      "events": ["accountsChanged", "chainChanged"],
      "accounts": ["eip155:14:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb"]
    },
    "eip155:19": {
      "methods": ["eth_sendTransaction", "eth_signTransaction", "personal_sign"],
      "events": ["accountsChanged", "chainChanged"],
      "accounts": ["eip155:19:0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb"]
    },
  }
}

Plus, there can be a combination of both formats returned. I updated connector to handle both when checking namespace chainId's and methods for validation.

Additional Information

Your ENS/address: asimetriq.eth

@changeset-bot
Copy link

changeset-bot bot commented Jul 5, 2023

🦋 Changeset detected

Latest commit: 096798a

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

@xzilja xzilja requested review from jxom and tmm July 5, 2023 05:44
@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2023

Size Change: +44 B (0%)

Total Size: 52.1 kB

Filename Size Change
packages/connectors/dist/safe.js 2.72 kB +44 B (+2%)
ℹ️ View Unchanged
Filename Size Change
packages/chains/dist 8.94 kB 0 B
packages/chains/dist/index.d.ts 9.3 kB 0 B
packages/chains/dist/index.js 8.9 kB 0 B
packages/chains/dist/index.mjs 1.34 kB 0 B
packages/connectors/dist 198 B 0 B
packages/connectors/dist/base-2dd7facf.d.ts 2.69 kB 0 B
packages/connectors/dist/chunk-OQILYQDO.js 784 B 0 B
packages/connectors/dist/chunk-QRUHVNWK.js 292 B 0 B
packages/connectors/dist/chunk-QYMCVNHT.js 727 B 0 B
packages/connectors/dist/chunk-ZCAPXGBX.js 1.8 kB 0 B
packages/connectors/dist/coinbaseWallet.d.ts 311 B 0 B
packages/connectors/dist/coinbaseWallet.js 165 B 0 B
packages/connectors/dist/index.d.ts 968 B 0 B
packages/connectors/dist/index.js 119 B 0 B
packages/connectors/dist/injected.d.ts 758 B 0 B
packages/connectors/dist/injected.js 1.99 kB 0 B
packages/connectors/dist/ledger.d.ts 516 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 806 B 0 B
packages/connectors/dist/mock 1.62 kB 0 B
packages/connectors/dist/mock/index.d.ts 737 B 0 B
packages/connectors/dist/mock/index.js 1.17 kB 0 B
packages/connectors/dist/safe.d.ts 1.65 kB 0 B
packages/connectors/dist/walletConnect.d.ts 506 B 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

@jxom jxom merged commit 51e346e into main Jul 5, 2023
6 checks passed
@jxom jxom deleted the fix/make-wc-connector-more-caip-compliant branch July 5, 2023 06:33
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