Skip to content

Commit

Permalink
fix: remove unneeded uniqueBy check
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Mar 29, 2024
1 parent d2c8c32 commit b80236d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .changeset/smart-dots-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wagmi/core": patch
"wagmi": patch
---

Removed unneeded `uniqueBy` check on connectors state.
3 changes: 1 addition & 2 deletions packages/core/src/createConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { type Storage, createStorage, noopStorage } from './createStorage.js'
import { ChainNotConfiguredError } from './errors/config.js'
import type { Evaluate, ExactPartial, LooseOmit, OneOf } from './types/utils.js'
import { uid } from './utils/uid.js'
import { uniqueBy } from './utils/uniqueBy.js'
import { version } from './version.js'

export type CreateConfigParameters<
Expand Down Expand Up @@ -286,7 +285,7 @@ export function createConfig<
}

if (parameters.storage && !store.persist.hasHydrated()) return
connectors.setState((x) => uniqueBy([...x, ...newConnectors], 'id'), true)
connectors.setState((x) => [...x, ...newConnectors], true)
})

/////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/hydrate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { reconnect } from './actions/reconnect.js'
import type { Config, State } from './createConfig.js'
import { uniqueBy } from './utils/uniqueBy.js'

type HydrateParameters = {
initialState?: State | undefined
Expand All @@ -25,9 +24,10 @@ export function hydrate(config: Config, parameters: HydrateParameters) {
?.getProviders()
.map(config._internal.connectors.providerDetailToConnector)
.map(config._internal.connectors.setup)
config._internal.connectors.setState((connectors) =>
uniqueBy([...connectors, ...(mipdConnectors ?? [])], 'id'),
)
config._internal.connectors.setState((connectors) => [
...connectors,
...(mipdConnectors ?? []),
])
}

if (reconnectOnMount) reconnect(config)
Expand Down
11 changes: 0 additions & 11 deletions packages/core/src/utils/uniqueBy.ts

This file was deleted.

0 comments on commit b80236d

Please sign in to comment.