diff --git a/.changeset/angry-geckos-thank.md b/.changeset/angry-geckos-thank.md new file mode 100644 index 0000000000..777ad190ac --- /dev/null +++ b/.changeset/angry-geckos-thank.md @@ -0,0 +1,5 @@ +--- +"@wagmi/core": patch +--- + +Added `defaultConnected` feature to `mock` connector. diff --git a/package.json b/package.json index 76dd108f70..af16a285c3 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@arethetypeswrong/cli": "^0.16.4", - "@biomejs/biome": "^1.9.2", + "@biomejs/biome": "^1.9.4", "@changesets/changelog-github": "0.4.6", "@changesets/cli": "^2.27.8", "@types/bun": "^1.1.10", diff --git a/packages/core/src/connectors/mock.test.ts b/packages/core/src/connectors/mock.test.ts index 3e1f756753..6b7122f45c 100644 --- a/packages/core/src/connectors/mock.test.ts +++ b/packages/core/src/connectors/mock.test.ts @@ -1,7 +1,6 @@ import { accounts, config } from '@wagmi/test' import { expect, test } from 'vitest' -import { connect } from '../actions/connect.js' import { mock } from './mock.js' test('setup', () => { @@ -86,9 +85,14 @@ test('behavior: connector.getProvider request errors', async () => { }) test('behavior: reconnect', async () => { - const connectorFn = mock({ accounts, features: { reconnect: true } }) + const connectorFn = mock({ + accounts, + features: { + defaultConnected: true, + reconnect: true, + }, + }) const connector = config._internal.connectors.setup(connectorFn) - await connect(config, { connector }) await expect(connector.isAuthorized()).resolves.toBeTruthy() }) diff --git a/packages/core/src/connectors/mock.ts b/packages/core/src/connectors/mock.ts index 8c6fa4d57b..2598c72b62 100644 --- a/packages/core/src/connectors/mock.ts +++ b/packages/core/src/connectors/mock.ts @@ -27,6 +27,7 @@ export type MockParameters = { accounts: readonly [Address, ...Address[]] features?: | { + defaultConnected?: boolean | undefined connectError?: boolean | Error | undefined switchChainError?: boolean | Error | undefined signMessageError?: boolean | Error | undefined @@ -40,12 +41,14 @@ export type MockParameters = { mock.type = 'mock' as const export function mock(parameters: MockParameters) { const transactionCache = new Map() - const features = parameters.features ?? {} + const features = + parameters.features ?? + ({ defaultConnected: false } satisfies MockParameters['features']) type Provider = ReturnType< Transport<'custom', unknown, EIP1193RequestFn> > - let connected = false + let connected = features.defaultConnected let connectedChainId: number return createConnector((config) => ({ diff --git a/packages/core/src/exports/index.ts b/packages/core/src/exports/index.ts index 69dae7cc17..af78c71c9b 100644 --- a/packages/core/src/exports/index.ts +++ b/packages/core/src/exports/index.ts @@ -528,9 +528,9 @@ export { fallback } from '../transports/fallback.js' // Types //////////////////////////////////////////////////////////////////////////////// -export { type SelectChains } from '../types/chain.js' +export type { SelectChains } from '../types/chain.js' -export { type Register, type ResolvedRegister } from '../types/register.js' +export type { Register, ResolvedRegister } from '../types/register.js' //////////////////////////////////////////////////////////////////////////////// // Utilities diff --git a/packages/core/src/exports/internal.ts b/packages/core/src/exports/internal.ts index cd0c78935d..670420d89a 100644 --- a/packages/core/src/exports/internal.ts +++ b/packages/core/src/exports/internal.ts @@ -23,24 +23,24 @@ export { // Types //////////////////////////////////////////////////////////////////////////////// -export { type SelectChains } from '../types/chain.js' +export type { SelectChains } from '../types/chain.js' -export { - type ChainIdParameter, - type ConnectorParameter, - type ScopeKeyParameter, +export type { + ChainIdParameter, + ConnectorParameter, + ScopeKeyParameter, } from '../types/properties.js' -export { - type Compute, - type ExactPartial, - type Mutable, - type StrictOmit as Omit, - type OneOf, - type RemoveUndefined, - type UnionCompute, - type UnionStrictOmit, - type UnionExactPartial, +export type { + Compute, + ExactPartial, + Mutable, + StrictOmit as Omit, + OneOf, + RemoveUndefined, + UnionCompute, + UnionStrictOmit, + UnionExactPartial, } from '../types/utils.js' //////////////////////////////////////////////////////////////////////////////// diff --git a/packages/vue/src/exports/nuxt.ts b/packages/vue/src/exports/nuxt.ts index 4d99bc73dd..e3e2e184a3 100644 --- a/packages/vue/src/exports/nuxt.ts +++ b/packages/vue/src/exports/nuxt.ts @@ -1,4 +1,4 @@ import { wagmiModule } from '../nuxt/module.js' -export { type WagmiModuleOptions } from '../nuxt/module.js' +export type { WagmiModuleOptions } from '../nuxt/module.js' export default wagmiModule diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a81a052e4..c77c2d8f3e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^0.16.4 version: 0.16.4 '@biomejs/biome': - specifier: ^1.9.2 - version: 1.9.2 + specifier: ^1.9.4 + version: 1.9.4 '@changesets/changelog-github': specifier: 0.4.6 version: 0.4.6(encoding@0.1.13) @@ -894,55 +894,55 @@ packages: '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} - '@biomejs/biome@1.9.2': - resolution: {integrity: sha512-4j2Gfwft8Jqp1X0qLYvK4TEy4xhTo4o6rlvJPsjPeEame8gsmbGQfOPBkw7ur+7/Z/f0HZmCZKqbMvR7vTXQYQ==} + '@biomejs/biome@1.9.4': + resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==} engines: {node: '>=14.21.3'} hasBin: true - '@biomejs/cli-darwin-arm64@1.9.2': - resolution: {integrity: sha512-rbs9uJHFmhqB3Td0Ro+1wmeZOHhAPTL3WHr8NtaVczUmDhXkRDWScaxicG9+vhSLj1iLrW47itiK6xiIJy6vaA==} + '@biomejs/cli-darwin-arm64@1.9.4': + resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [darwin] - '@biomejs/cli-darwin-x64@1.9.2': - resolution: {integrity: sha512-BlfULKijNaMigQ9GH9fqJVt+3JTDOSiZeWOQtG/1S1sa8Lp046JHG3wRJVOvekTPL9q/CNFW1NVG8J0JN+L1OA==} + '@biomejs/cli-darwin-x64@1.9.4': + resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [darwin] - '@biomejs/cli-linux-arm64-musl@1.9.2': - resolution: {integrity: sha512-ZATvbUWhNxegSALUnCKWqetTZqrK72r2RsFD19OK5jXDj/7o1hzI1KzDNG78LloZxftrwr3uI9SqCLh06shSZw==} + '@biomejs/cli-linux-arm64-musl@1.9.4': + resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-arm64@1.9.2': - resolution: {integrity: sha512-T8TJuSxuBDeQCQzxZu2o3OU4eyLumTofhCxxFd3+aH2AEWVMnH7Z/c3QP1lHI5RRMBP9xIJeMORqDQ5j+gVZzw==} + '@biomejs/cli-linux-arm64@1.9.4': + resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] - '@biomejs/cli-linux-x64-musl@1.9.2': - resolution: {integrity: sha512-CjPM6jT1miV5pry9C7qv8YJk0FIZvZd86QRD3atvDgfgeh9WQU0k2Aoo0xUcPdTnoz0WNwRtDicHxwik63MmSg==} + '@biomejs/cli-linux-x64-musl@1.9.4': + resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-linux-x64@1.9.2': - resolution: {integrity: sha512-T0cPk3C3Jr2pVlsuQVTBqk2qPjTm8cYcTD9p/wmR9MeVqui1C/xTVfOIwd3miRODFMrJaVQ8MYSXnVIhV9jTjg==} + '@biomejs/cli-linux-x64@1.9.4': + resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] - '@biomejs/cli-win32-arm64@1.9.2': - resolution: {integrity: sha512-2x7gSty75bNIeD23ZRPXyox6Z/V0M71ObeJtvQBhi1fgrvPdtkEuw7/0wEHg6buNCubzOFuN9WYJm6FKoUHfhg==} + '@biomejs/cli-win32-arm64@1.9.4': + resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [win32] - '@biomejs/cli-win32-x64@1.9.2': - resolution: {integrity: sha512-JC3XvdYcjmu1FmAehVwVV0SebLpeNTnO2ZaMdGCSOdS7f8O9Fq14T2P1gTG1Q29Q8Dt1S03hh0IdVpIZykOL8g==} + '@biomejs/cli-win32-x64@1.9.4': + resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==} engines: {node: '>=14.21.3'} cpu: [x64] os: [win32] @@ -8277,39 +8277,39 @@ snapshots: '@bcoe/v8-coverage@0.2.3': {} - '@biomejs/biome@1.9.2': + '@biomejs/biome@1.9.4': optionalDependencies: - '@biomejs/cli-darwin-arm64': 1.9.2 - '@biomejs/cli-darwin-x64': 1.9.2 - '@biomejs/cli-linux-arm64': 1.9.2 - '@biomejs/cli-linux-arm64-musl': 1.9.2 - '@biomejs/cli-linux-x64': 1.9.2 - '@biomejs/cli-linux-x64-musl': 1.9.2 - '@biomejs/cli-win32-arm64': 1.9.2 - '@biomejs/cli-win32-x64': 1.9.2 - - '@biomejs/cli-darwin-arm64@1.9.2': + '@biomejs/cli-darwin-arm64': 1.9.4 + '@biomejs/cli-darwin-x64': 1.9.4 + '@biomejs/cli-linux-arm64': 1.9.4 + '@biomejs/cli-linux-arm64-musl': 1.9.4 + '@biomejs/cli-linux-x64': 1.9.4 + '@biomejs/cli-linux-x64-musl': 1.9.4 + '@biomejs/cli-win32-arm64': 1.9.4 + '@biomejs/cli-win32-x64': 1.9.4 + + '@biomejs/cli-darwin-arm64@1.9.4': optional: true - '@biomejs/cli-darwin-x64@1.9.2': + '@biomejs/cli-darwin-x64@1.9.4': optional: true - '@biomejs/cli-linux-arm64-musl@1.9.2': + '@biomejs/cli-linux-arm64-musl@1.9.4': optional: true - '@biomejs/cli-linux-arm64@1.9.2': + '@biomejs/cli-linux-arm64@1.9.4': optional: true - '@biomejs/cli-linux-x64-musl@1.9.2': + '@biomejs/cli-linux-x64-musl@1.9.4': optional: true - '@biomejs/cli-linux-x64@1.9.2': + '@biomejs/cli-linux-x64@1.9.4': optional: true - '@biomejs/cli-win32-arm64@1.9.2': + '@biomejs/cli-win32-arm64@1.9.4': optional: true - '@biomejs/cli-win32-x64@1.9.2': + '@biomejs/cli-win32-x64@1.9.4': optional: true '@bundled-es-modules/cookie@2.0.0': diff --git a/site/shared/connectors/mock.md b/site/shared/connectors/mock.md index 3e42be18e3..90d87b0b3e 100644 --- a/site/shared/connectors/mock.md +++ b/site/shared/connectors/mock.md @@ -91,6 +91,11 @@ const connector = mock({ }, // [!code focus] }) ``` +#### defaultConnected + +`boolean | undefined` + +Whether the connector is connected by default. #### connectError @@ -120,4 +125,4 @@ Whether to throw an error when `'eth_signTypedData_v4'` is called. `boolean | Error | undefined` -Whether to throw an error when `connector.switchChain` is called. \ No newline at end of file +Whether to throw an error when `connector.switchChain` is called.