diff --git a/.changeset/quick-pans-grow.md b/.changeset/quick-pans-grow.md new file mode 100644 index 0000000000..06635c60d0 --- /dev/null +++ b/.changeset/quick-pans-grow.md @@ -0,0 +1,5 @@ +--- +"@wagmi/core": patch +--- + +Added support for multiple connector `rdns` entries. diff --git a/.changeset/wild-guests-tell.md b/.changeset/wild-guests-tell.md new file mode 100644 index 0000000000..45e38d4b0f --- /dev/null +++ b/.changeset/wild-guests-tell.md @@ -0,0 +1,5 @@ +--- +"@wagmi/connectors": patch +--- + +Added additional RDNS to MetaMask Connector. diff --git a/packages/connectors/src/metaMask.ts b/packages/connectors/src/metaMask.ts index fc4e19f55a..26e07561b3 100644 --- a/packages/connectors/src/metaMask.ts +++ b/packages/connectors/src/metaMask.ts @@ -95,7 +95,7 @@ export function metaMask(parameters: MetaMaskParameters = {}) { return createConnector((config) => ({ id: 'metaMaskSDK', name: 'MetaMask', - rdns: 'io.metamask', + rdns: ['io.metamask', 'io.metamask.mobile'], type: metaMask.type, async setup() { const provider = await this.getProvider() diff --git a/packages/core/src/connectors/createConnector.ts b/packages/core/src/connectors/createConnector.ts index f5072f1add..1724e8d765 100644 --- a/packages/core/src/connectors/createConnector.ts +++ b/packages/core/src/connectors/createConnector.ts @@ -37,7 +37,7 @@ export type CreateConnectorFn< readonly icon?: string | undefined readonly id: string readonly name: string - readonly rdns?: string | undefined + readonly rdns?: string | readonly string[] | undefined readonly supportsSimulation?: boolean | undefined readonly type: string diff --git a/packages/core/src/createConfig.test.ts b/packages/core/src/createConfig.test.ts index 36f270ba22..a6ae41e280 100644 --- a/packages/core/src/createConfig.test.ts +++ b/packages/core/src/createConfig.test.ts @@ -394,7 +394,7 @@ test('behavior: eip 6963 providers', async () => { createConnector((c) => { return { ...mock({ accounts })(c), - rdns: 'com.mock', + rdns: ['com.mock', 'com.baz'], } }), ], @@ -413,9 +413,12 @@ test('behavior: eip 6963 providers', async () => { announceProvider(detail_3)() await wait(100) - expect(config.connectors.map((x) => x.rdns ?? x.id)).toMatchInlineSnapshot(` + expect( + config.connectors.flatMap((x) => x.rdns ?? x.id), + ).toMatchInlineSnapshot(` [ "com.mock", + "com.baz", "com.example", "com.foo", "com.bar", diff --git a/packages/core/src/createConfig.ts b/packages/core/src/createConfig.ts index 00d5eb6f9d..1ada1da8c0 100644 --- a/packages/core/src/createConfig.ts +++ b/packages/core/src/createConfig.ts @@ -98,7 +98,13 @@ export function createConfig< for (const connectorFns of rest.connectors ?? []) { const connector = setup(connectorFns) collection.push(connector) - if (!ssr && connector.rdns) rdnsSet.add(connector.rdns) + if (!ssr && connector.rdns) { + const rdnsValues = + typeof connector.rdns === 'string' ? [connector.rdns] : connector.rdns + for (const rdns of rdnsValues) { + rdnsSet.add(rdns) + } + } } if (!ssr && mipd) { const providers = mipd.getProviders() @@ -323,11 +329,17 @@ export function createConfig< // EIP-6963 subscribe for new wallet providers mipd?.subscribe((providerDetails) => { - const connectorIdSet = new Set() - const connectorRdnsSet = new Set() + const connectorIdSet = new Set() + const connectorRdnsSet = new Set() for (const connector of connectors.getState()) { connectorIdSet.add(connector.id) - if (connector.rdns) connectorRdnsSet.add(connector.rdns) + if (connector.rdns) { + const rdnsValues = + typeof connector.rdns === 'string' ? [connector.rdns] : connector.rdns + for (const rdns of rdnsValues) { + connectorRdnsSet.add(rdns) + } + } } const newConnectors: Connector[] = [] diff --git a/packages/core/src/hydrate.ts b/packages/core/src/hydrate.ts index 3c566ef0b2..70bc2199e6 100644 --- a/packages/core/src/hydrate.ts +++ b/packages/core/src/hydrate.ts @@ -27,7 +27,14 @@ export function hydrate(config: Config, parameters: HydrateParameters) { config._internal.connectors.setState((connectors) => { const rdnsSet = new Set() for (const connector of connectors ?? []) { - if (connector.rdns) rdnsSet.add(connector.rdns) + if (connector.rdns) { + const rdnsValues = Array.isArray(connector.rdns) + ? connector.rdns + : [connector.rdns] + for (const rdns of rdnsValues) { + rdnsSet.add(rdns) + } + } } const mipdConnectors = [] const providers = config._internal.mipd?.getProviders() ?? []