@wagmi/solid 0.0.0-alpha → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -0
  3. package/actions/package.json +5 -0
  4. package/chains/package.json +5 -0
  5. package/connectors/package.json +5 -0
  6. package/dist/esm/context.js +28 -0
  7. package/dist/esm/context.js.map +1 -0
  8. package/dist/esm/errors/base.js +20 -0
  9. package/dist/esm/errors/base.js.map +1 -0
  10. package/dist/esm/errors/context.js +15 -0
  11. package/dist/esm/errors/context.js.map +1 -0
  12. package/dist/esm/exports/actions.js +7 -0
  13. package/dist/esm/exports/actions.js.map +1 -0
  14. package/dist/esm/exports/chains.js +7 -0
  15. package/dist/esm/exports/chains.js.map +1 -0
  16. package/dist/esm/exports/connectors.js +7 -0
  17. package/dist/esm/exports/connectors.js.map +1 -0
  18. package/dist/esm/exports/index.js +47 -0
  19. package/dist/esm/exports/index.js.map +1 -0
  20. package/dist/esm/exports/query.js +8 -0
  21. package/dist/esm/exports/query.js.map +1 -0
  22. package/dist/esm/hydrate.js +19 -0
  23. package/dist/esm/hydrate.js.map +1 -0
  24. package/dist/esm/primitives/useBalance.js +16 -0
  25. package/dist/esm/primitives/useBalance.js.map +1 -0
  26. package/dist/esm/primitives/useBlockNumber.js +36 -0
  27. package/dist/esm/primitives/useBlockNumber.js.map +1 -0
  28. package/dist/esm/primitives/useChainId.js +20 -0
  29. package/dist/esm/primitives/useChainId.js.map +1 -0
  30. package/dist/esm/primitives/useChains.js +19 -0
  31. package/dist/esm/primitives/useChains.js.map +1 -0
  32. package/dist/esm/primitives/useClient.js +22 -0
  33. package/dist/esm/primitives/useClient.js.map +1 -0
  34. package/dist/esm/primitives/useConfig.js +12 -0
  35. package/dist/esm/primitives/useConfig.js.map +1 -0
  36. package/dist/esm/primitives/useConnect.js +20 -0
  37. package/dist/esm/primitives/useConnect.js.map +1 -0
  38. package/dist/esm/primitives/useConnection.js +20 -0
  39. package/dist/esm/primitives/useConnection.js.map +1 -0
  40. package/dist/esm/primitives/useConnectionEffect.js +36 -0
  41. package/dist/esm/primitives/useConnectionEffect.js.map +1 -0
  42. package/dist/esm/primitives/useConnections.js +20 -0
  43. package/dist/esm/primitives/useConnections.js.map +1 -0
  44. package/dist/esm/primitives/useConnectorClient.js +31 -0
  45. package/dist/esm/primitives/useConnectorClient.js.map +1 -0
  46. package/dist/esm/primitives/useConnectors.js +20 -0
  47. package/dist/esm/primitives/useConnectors.js.map +1 -0
  48. package/dist/esm/primitives/useDisconnect.js +10 -0
  49. package/dist/esm/primitives/useDisconnect.js.map +1 -0
  50. package/dist/esm/primitives/useReconnect.js +10 -0
  51. package/dist/esm/primitives/useReconnect.js.map +1 -0
  52. package/dist/esm/primitives/useSwitchChain.js +10 -0
  53. package/dist/esm/primitives/useSwitchChain.js.map +1 -0
  54. package/dist/esm/primitives/useSwitchConnection.js +10 -0
  55. package/dist/esm/primitives/useSwitchConnection.js.map +1 -0
  56. package/dist/esm/primitives/useWatchBlockNumber.js +23 -0
  57. package/dist/esm/primitives/useWatchBlockNumber.js.map +1 -0
  58. package/dist/esm/tsconfig.build.tsbuildinfo +1 -0
  59. package/dist/esm/utils/getVersion.js +3 -0
  60. package/dist/esm/utils/getVersion.js.map +1 -0
  61. package/dist/esm/utils/query.js +29 -0
  62. package/dist/esm/utils/query.js.map +1 -0
  63. package/dist/esm/version.js +2 -0
  64. package/dist/esm/version.js.map +1 -0
  65. package/dist/types/context.d.ts +10 -0
  66. package/dist/types/context.d.ts.map +1 -0
  67. package/dist/types/errors/base.d.ts +10 -0
  68. package/dist/types/errors/base.d.ts.map +1 -0
  69. package/dist/types/errors/context.d.ts +9 -0
  70. package/dist/types/errors/context.d.ts.map +1 -0
  71. package/dist/types/exports/actions.d.ts +2 -0
  72. package/dist/types/exports/actions.d.ts.map +1 -0
  73. package/dist/types/exports/chains.d.ts +2 -0
  74. package/dist/types/exports/chains.d.ts.map +1 -0
  75. package/dist/types/exports/connectors.d.ts +2 -0
  76. package/dist/types/exports/connectors.d.ts.map +1 -0
  77. package/dist/types/exports/index.d.ts +24 -0
  78. package/dist/types/exports/index.d.ts.map +1 -0
  79. package/dist/types/exports/query.d.ts +3 -0
  80. package/dist/types/exports/query.d.ts.map +1 -0
  81. package/dist/types/hydrate.d.ts +9 -0
  82. package/dist/types/hydrate.d.ts.map +1 -0
  83. package/dist/types/primitives/useBalance.d.ts +13 -0
  84. package/dist/types/primitives/useBalance.d.ts.map +1 -0
  85. package/dist/types/primitives/useBlockNumber.d.ts +16 -0
  86. package/dist/types/primitives/useBlockNumber.d.ts.map +1 -0
  87. package/dist/types/primitives/useChainId.d.ts +12 -0
  88. package/dist/types/primitives/useChainId.d.ts.map +1 -0
  89. package/dist/types/primitives/useChains.d.ts +12 -0
  90. package/dist/types/primitives/useChains.d.ts.map +1 -0
  91. package/dist/types/primitives/useClient.d.ts +12 -0
  92. package/dist/types/primitives/useClient.d.ts.map +1 -0
  93. package/dist/types/primitives/useConfig.d.ts +11 -0
  94. package/dist/types/primitives/useConfig.d.ts.map +1 -0
  95. package/dist/types/primitives/useConnect.d.ts +13 -0
  96. package/dist/types/primitives/useConnect.d.ts.map +1 -0
  97. package/dist/types/primitives/useConnection.d.ts +12 -0
  98. package/dist/types/primitives/useConnection.d.ts.map +1 -0
  99. package/dist/types/primitives/useConnectionEffect.d.ts +17 -0
  100. package/dist/types/primitives/useConnectionEffect.d.ts.map +1 -0
  101. package/dist/types/primitives/useConnections.d.ts +12 -0
  102. package/dist/types/primitives/useConnections.d.ts.map +1 -0
  103. package/dist/types/primitives/useConnectorClient.d.ts +13 -0
  104. package/dist/types/primitives/useConnectorClient.d.ts.map +1 -0
  105. package/dist/types/primitives/useConnectors.d.ts +12 -0
  106. package/dist/types/primitives/useConnectors.d.ts.map +1 -0
  107. package/dist/types/primitives/useDisconnect.d.ts +13 -0
  108. package/dist/types/primitives/useDisconnect.d.ts.map +1 -0
  109. package/dist/types/primitives/useReconnect.d.ts +13 -0
  110. package/dist/types/primitives/useReconnect.d.ts.map +1 -0
  111. package/dist/types/primitives/useSwitchChain.d.ts +13 -0
  112. package/dist/types/primitives/useSwitchChain.d.ts.map +1 -0
  113. package/dist/types/primitives/useSwitchConnection.d.ts +13 -0
  114. package/dist/types/primitives/useSwitchConnection.d.ts.map +1 -0
  115. package/dist/types/primitives/useWatchBlockNumber.d.ts +11 -0
  116. package/dist/types/primitives/useWatchBlockNumber.d.ts.map +1 -0
  117. package/dist/types/utils/getVersion.d.ts +2 -0
  118. package/dist/types/utils/getVersion.d.ts.map +1 -0
  119. package/dist/types/utils/query.d.ts +28 -0
  120. package/dist/types/utils/query.d.ts.map +1 -0
  121. package/dist/types/version.d.ts +2 -0
  122. package/dist/types/version.d.ts.map +1 -0
  123. package/package.json +95 -7
  124. package/query/package.json +5 -0
  125. package/src/context.ts +43 -0
  126. package/src/errors/base.ts +14 -0
  127. package/src/errors/context.ts +13 -0
  128. package/src/exports/actions.ts +7 -0
  129. package/src/exports/chains.ts +7 -0
  130. package/src/exports/connectors.ts +7 -0
  131. package/src/exports/index.ts +134 -0
  132. package/src/exports/query.ts +19 -0
  133. package/src/hydrate.ts +27 -0
  134. package/src/primitives/useBalance.ts +46 -0
  135. package/src/primitives/useBlockNumber.ts +99 -0
  136. package/src/primitives/useChainId.ts +42 -0
  137. package/src/primitives/useChains.ts +42 -0
  138. package/src/primitives/useClient.ts +67 -0
  139. package/src/primitives/useConfig.ts +27 -0
  140. package/src/primitives/useConnect.ts +63 -0
  141. package/src/primitives/useConnection.ts +44 -0
  142. package/src/primitives/useConnectionEffect.ts +66 -0
  143. package/src/primitives/useConnections.ts +34 -0
  144. package/src/primitives/useConnectorClient.ts +86 -0
  145. package/src/primitives/useConnectors.ts +47 -0
  146. package/src/primitives/useDisconnect.ts +44 -0
  147. package/src/primitives/useReconnect.ts +44 -0
  148. package/src/primitives/useSwitchChain.ts +58 -0
  149. package/src/primitives/useSwitchConnection.ts +60 -0
  150. package/src/primitives/useWatchBlockNumber.ts +65 -0
  151. package/src/utils/getVersion.ts +3 -0
  152. package/src/utils/query.ts +171 -0
  153. package/src/version.ts +1 -0
@@ -0,0 +1,67 @@
1
+ import {
2
+ type Config,
3
+ type GetClientParameters,
4
+ type GetClientReturnType,
5
+ getClient,
6
+ type ResolvedRegister,
7
+ watchClient,
8
+ } from '@wagmi/core'
9
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
10
+ import type { Accessor } from 'solid-js'
11
+ import { createEffect, createSignal, onCleanup } from 'solid-js'
12
+ import { useConfig } from './useConfig.js'
13
+
14
+ /** https://wagmi.sh/solid/api/primitives/useClient */
15
+ export function useClient<
16
+ config extends Config = ResolvedRegister['config'],
17
+ chainId extends config['chains'][number]['id'] | number | undefined =
18
+ | config['chains'][number]['id']
19
+ | undefined,
20
+ >(
21
+ parameters: useClient.Parameters<config, chainId> = () => ({}),
22
+ ): useClient.ReturnType<config, chainId> {
23
+ const config = useConfig(parameters)
24
+ const [client, setClient] = createSignal(getClient(config(), parameters()))
25
+ createEffect(() => {
26
+ const _config = config()
27
+ setClient(() => getClient(_config, parameters()))
28
+ const unsubscribe = watchClient(_config, {
29
+ onChange(data) {
30
+ if (client()?.uid === data?.uid) return
31
+ setClient(() => data)
32
+ },
33
+ })
34
+ onCleanup(() => unsubscribe())
35
+ })
36
+ return client as unknown as useClient.ReturnType<config, chainId>
37
+ }
38
+
39
+ export namespace useClient {
40
+ export type Parameters<
41
+ config extends Config = Config,
42
+ chainId extends config['chains'][number]['id'] | number | undefined =
43
+ | config['chains'][number]['id']
44
+ | undefined,
45
+ > = Accessor<SolidParameters<config, chainId>>
46
+
47
+ export type ReturnType<
48
+ config extends Config = Config,
49
+ chainId extends config['chains'][number]['id'] | number | undefined =
50
+ | config['chains'][number]['id']
51
+ | undefined,
52
+ > = Accessor<SolidReturnType<config, chainId>>
53
+
54
+ export type SolidParameters<
55
+ config extends Config = Config,
56
+ chainId extends config['chains'][number]['id'] | number | undefined =
57
+ | config['chains'][number]['id']
58
+ | undefined,
59
+ > = Compute<GetClientParameters<config, chainId> & ConfigParameter<config>>
60
+
61
+ export type SolidReturnType<
62
+ config extends Config = Config,
63
+ chainId extends config['chains'][number]['id'] | number | undefined =
64
+ | config['chains'][number]['id']
65
+ | undefined,
66
+ > = GetClientReturnType<config, chainId>
67
+ }
@@ -0,0 +1,27 @@
1
+ import type { Config, ResolvedRegister } from '@wagmi/core'
2
+ import type { ConfigParameter } from '@wagmi/core/internal'
3
+ import { type Accessor, createMemo, useContext } from 'solid-js'
4
+ import { WagmiContext } from '../context.js'
5
+ import { WagmiProviderNotFoundError } from '../errors/context.js'
6
+
7
+ export function useConfig<config extends Config = ResolvedRegister['config']>(
8
+ parameters: useConfig.Parameters<config> = () => ({}),
9
+ ): useConfig.ReturnType<config> {
10
+ return createMemo(() => {
11
+ const config = parameters().config ?? useContext(WagmiContext)
12
+ if (!config) throw new WagmiProviderNotFoundError()
13
+ return config as config
14
+ })
15
+ }
16
+
17
+ export namespace useConfig {
18
+ export type Parameters<config extends Config = Config> = Accessor<
19
+ SolidParameters<config>
20
+ >
21
+ export type ReturnType<config extends Config = Config> = Accessor<
22
+ SolidReturnType<config>
23
+ >
24
+ export type SolidParameters<config extends Config = Config> =
25
+ ConfigParameter<config>
26
+ export type SolidReturnType<config extends Config = Config> = config
27
+ }
@@ -0,0 +1,63 @@
1
+ import type { Config, ConnectErrorType } from '@wagmi/core'
2
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
3
+ import {
4
+ type ConnectData,
5
+ type ConnectMutate,
6
+ type ConnectMutateAsync,
7
+ type ConnectOptions,
8
+ type ConnectVariables,
9
+ connectMutationOptions,
10
+ } from '@wagmi/core/query'
11
+ import { type Accessor, createEffect, onCleanup } from 'solid-js'
12
+ import type { UseMutationReturnType } from '../utils/query.js'
13
+ import { useMutation } from '../utils/query.js'
14
+ import { useConfig } from './useConfig.js'
15
+
16
+ /** https://wagmi.sh/solid/api/hooks/useConnect */
17
+ export function useConnect<config extends Config = Config, context = unknown>(
18
+ parameters: useConnect.Parameters<config, context> = () => ({}),
19
+ ): useConnect.ReturnType<config, context> {
20
+ const config = useConfig(parameters)
21
+ const mutation = useMutation(() =>
22
+ connectMutationOptions(config(), parameters()),
23
+ )
24
+ // Reset mutation back to an idle state when the connector disconnects.
25
+ createEffect(() => {
26
+ const unsubscribe = config().subscribe(
27
+ ({ status }) => status,
28
+ (status, previousStatus) => {
29
+ if (previousStatus === 'connected' && status === 'disconnected') {
30
+ mutation.reset()
31
+ }
32
+ },
33
+ )
34
+ onCleanup(() => unsubscribe())
35
+ })
36
+ return mutation as unknown as useConnect.ReturnType<config, context>
37
+ }
38
+
39
+ export namespace useConnect {
40
+ export type Parameters<
41
+ config extends Config = Config,
42
+ context = unknown,
43
+ > = Accessor<SolidParameters<config, context>>
44
+
45
+ export type ReturnType<
46
+ config extends Config = Config,
47
+ context = unknown,
48
+ > = Compute<
49
+ UseMutationReturnType<
50
+ ConnectData<config, config['connectors'][number], boolean>,
51
+ ConnectErrorType,
52
+ ConnectVariables<config, config['connectors'][number], boolean>,
53
+ context,
54
+ ConnectMutate<config, context>,
55
+ ConnectMutateAsync<config, context>
56
+ >
57
+ >
58
+
59
+ export type SolidParameters<
60
+ config extends Config = Config,
61
+ context = unknown,
62
+ > = Compute<ConfigParameter<config> & ConnectOptions<config, context>>
63
+ }
@@ -0,0 +1,44 @@
1
+ import {
2
+ type Config,
3
+ type GetConnectionReturnType,
4
+ getConnection,
5
+ type ResolvedRegister,
6
+ watchConnection,
7
+ } from '@wagmi/core'
8
+ import type { ConfigParameter } from '@wagmi/core/internal'
9
+ import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js'
10
+ import { useConfig } from './useConfig.js'
11
+
12
+ /** https://wagmi.sh/solid/api/primitives/useConnection */
13
+ export function useConnection<
14
+ config extends Config = ResolvedRegister['config'],
15
+ >(
16
+ parameters: useConnection.Parameters<config> = () => ({}),
17
+ ): useConnection.ReturnType<config> {
18
+ const config = useConfig(parameters)
19
+ const [connection, setConnection] = createSignal(getConnection(config()))
20
+ createEffect(() => {
21
+ const _config = config()
22
+ setConnection(() => getConnection(_config))
23
+ const unsubscribe = watchConnection(_config, {
24
+ onChange(data) {
25
+ setConnection(() => data)
26
+ },
27
+ })
28
+ onCleanup(() => unsubscribe())
29
+ })
30
+ return connection
31
+ }
32
+
33
+ export namespace useConnection {
34
+ export type Parameters<config extends Config = Config> = Accessor<
35
+ SolidParameters<config>
36
+ >
37
+ export type ReturnType<config extends Config = Config> = Accessor<
38
+ SolidReturnType<config>
39
+ >
40
+ export type SolidParameters<config extends Config = Config> =
41
+ ConfigParameter<config>
42
+ export type SolidReturnType<config extends Config = Config> =
43
+ GetConnectionReturnType<config>
44
+ }
@@ -0,0 +1,66 @@
1
+ import { type GetConnectionReturnType, watchConnection } from '@wagmi/core'
2
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
3
+ import type { Accessor } from 'solid-js'
4
+ import { createEffect, onCleanup } from 'solid-js'
5
+ import { useConfig } from './useConfig.js'
6
+
7
+ /** https://wagmi.sh/solid/api/primitives/useConnectionEffect */
8
+ export function useConnectionEffect(
9
+ parameters: useConnectionEffect.Parameters = () => ({}),
10
+ ) {
11
+ const config = useConfig(parameters)
12
+
13
+ createEffect(() => {
14
+ const { onConnect, onDisconnect } = parameters()
15
+
16
+ const unsubscribe = watchConnection(config(), {
17
+ onChange(data, prevData) {
18
+ if (
19
+ (prevData.status === 'reconnecting' ||
20
+ (prevData.status === 'connecting' &&
21
+ prevData.address === undefined)) &&
22
+ data.status === 'connected'
23
+ ) {
24
+ const { address, addresses, chain, chainId, connector } = data
25
+ const isReconnected =
26
+ prevData.status === 'reconnecting' ||
27
+ // if `previousAccount.status` is `undefined`, the connector connected immediately.
28
+ prevData.status === undefined
29
+ onConnect?.({
30
+ address,
31
+ addresses,
32
+ chain,
33
+ chainId,
34
+ connector,
35
+ isReconnected,
36
+ })
37
+ } else if (
38
+ prevData.status === 'connected' &&
39
+ data.status === 'disconnected'
40
+ )
41
+ onDisconnect?.()
42
+ },
43
+ })
44
+ onCleanup(() => unsubscribe())
45
+ })
46
+ }
47
+
48
+ export namespace useConnectionEffect {
49
+ export type Parameters = Accessor<SolidParameters>
50
+
51
+ export type SolidParameters = Compute<
52
+ {
53
+ onConnect?(
54
+ data: Compute<
55
+ Pick<
56
+ Extract<GetConnectionReturnType, { status: 'connected' }>,
57
+ 'address' | 'addresses' | 'chain' | 'chainId' | 'connector'
58
+ > & {
59
+ isReconnected: boolean
60
+ }
61
+ >,
62
+ ): void
63
+ onDisconnect?(): void
64
+ } & ConfigParameter
65
+ >
66
+ }
@@ -0,0 +1,34 @@
1
+ import {
2
+ type GetConnectionsReturnType,
3
+ getConnections,
4
+ watchConnections,
5
+ } from '@wagmi/core'
6
+ import type { ConfigParameter } from '@wagmi/core/internal'
7
+ import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js'
8
+ import { useConfig } from './useConfig.js'
9
+
10
+ /** https://wagmi.sh/solid/api/primitives/useConnections */
11
+ export function useConnections(
12
+ parameters: useConnections.Parameters = () => ({}),
13
+ ): useConnections.ReturnType {
14
+ const config = useConfig(parameters)
15
+ const [connections, setConnections] = createSignal(getConnections(config()))
16
+ createEffect(() => {
17
+ const _config = config()
18
+ setConnections(() => getConnections(_config))
19
+ const unsubscribe = watchConnections(_config, {
20
+ onChange(data) {
21
+ setConnections(() => data)
22
+ },
23
+ })
24
+ onCleanup(() => unsubscribe())
25
+ })
26
+ return connections
27
+ }
28
+
29
+ export namespace useConnections {
30
+ export type Parameters = Accessor<SolidParameters>
31
+ export type ReturnType = Accessor<SolidReturnType>
32
+ export type SolidParameters = ConfigParameter
33
+ export type SolidReturnType = GetConnectionsReturnType
34
+ }
@@ -0,0 +1,86 @@
1
+ import { useQueryClient } from '@tanstack/solid-query'
2
+ import type {
3
+ Config,
4
+ GetConnectorClientErrorType,
5
+ ResolvedRegister,
6
+ } from '@wagmi/core'
7
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
8
+ import {
9
+ type GetConnectorClientData,
10
+ type GetConnectorClientOptions,
11
+ getConnectorClientQueryOptions,
12
+ } from '@wagmi/core/query'
13
+ import type { Accessor } from 'solid-js'
14
+ import { createEffect, createMemo, on } from 'solid-js'
15
+ import { type UseQueryReturnType, useQuery } from '../utils/query.js'
16
+ import { useChainId } from './useChainId.js'
17
+ import { useConfig } from './useConfig.js'
18
+ import { useConnection } from './useConnection.js'
19
+
20
+ /** https://wagmi.sh/solid/api/primitives/useConnectorClient */
21
+ export function useConnectorClient<
22
+ config extends Config = ResolvedRegister['config'],
23
+ chainId extends
24
+ config['chains'][number]['id'] = config['chains'][number]['id'],
25
+ selectData = GetConnectorClientData<config, chainId>,
26
+ >(
27
+ parameters: useConnectorClient.Parameters<
28
+ config,
29
+ chainId,
30
+ selectData
31
+ > = () => ({}),
32
+ ): useConnectorClient.ReturnType<config, chainId, selectData> {
33
+ const config = useConfig(parameters)
34
+ const chainId = useChainId(() => ({ config: config() }))
35
+ const connection = useConnection(() => ({ config: config() }))
36
+ const options = createMemo(() =>
37
+ getConnectorClientQueryOptions<config, chainId>(config(), {
38
+ ...(parameters() as any),
39
+ chainId: parameters().chainId ?? chainId(),
40
+ connector: parameters().connector ?? connection().connector,
41
+ }),
42
+ )
43
+ const queryClient = useQueryClient()
44
+ createEffect(
45
+ on(
46
+ () => connection().address,
47
+ (currentAddress, previousAddress) => {
48
+ if (!currentAddress && previousAddress) {
49
+ // remove when account is disconnected
50
+ queryClient.removeQueries({ queryKey: options().queryKey })
51
+ } else if (currentAddress !== previousAddress) {
52
+ // invalidate when address changes
53
+ queryClient.invalidateQueries({ queryKey: options().queryKey })
54
+ }
55
+ },
56
+ { defer: true },
57
+ ),
58
+ )
59
+ return useQuery(options) as any
60
+ }
61
+
62
+ export namespace useConnectorClient {
63
+ export type Parameters<
64
+ config extends Config = Config,
65
+ chainId extends
66
+ config['chains'][number]['id'] = config['chains'][number]['id'],
67
+ selectData = GetConnectorClientData<config, chainId>,
68
+ > = Accessor<SolidParameters<config, chainId, selectData>>
69
+
70
+ export type ReturnType<
71
+ config extends Config = Config,
72
+ chainId extends
73
+ config['chains'][number]['id'] = config['chains'][number]['id'],
74
+ selectData = GetConnectorClientData<config, chainId>,
75
+ > = UseQueryReturnType<selectData, GetConnectorClientErrorType>
76
+
77
+ export type SolidParameters<
78
+ config extends Config = Config,
79
+ chainId extends
80
+ config['chains'][number]['id'] = config['chains'][number]['id'],
81
+ selectData = GetConnectorClientData<config, chainId>,
82
+ > = Compute<
83
+ GetConnectorClientOptions<config, chainId, selectData> &
84
+ ConfigParameter<config>
85
+ >
86
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ type Config,
3
+ type GetConnectorsReturnType,
4
+ getConnectors,
5
+ type ResolvedRegister,
6
+ watchConnectors,
7
+ } from '@wagmi/core'
8
+ import { type Accessor, createEffect, createSignal, onCleanup } from 'solid-js'
9
+ import { useConfig } from './useConfig.js'
10
+
11
+ /** https://wagmi.sh/solid/api/primitives/useConnectors */
12
+ export function useConnectors<
13
+ config extends Config = ResolvedRegister['config'],
14
+ >(
15
+ parameters: useConnectors.Parameters<config> = () => ({}),
16
+ ): useConnectors.ReturnType<config> {
17
+ const config = useConfig(parameters)
18
+ const [connectors, setConnectors] = createSignal(getConnectors(config()))
19
+ createEffect(() => {
20
+ const _config = config()
21
+ setConnectors(() => getConnectors(_config))
22
+
23
+ const unsubscribe = watchConnectors(_config, {
24
+ onChange(data) {
25
+ setConnectors(() => data)
26
+ },
27
+ })
28
+ onCleanup(() => unsubscribe())
29
+ })
30
+ return connectors
31
+ }
32
+
33
+ export namespace useConnectors {
34
+ export type Parameters<config extends Config = Config> = Accessor<
35
+ SolidParameters<config>
36
+ >
37
+
38
+ export type ReturnType<config extends Config = Config> = Accessor<
39
+ SolidReturnType<config>
40
+ >
41
+
42
+ export type SolidParameters<config extends Config = Config> =
43
+ useConfig.SolidParameters<config>
44
+
45
+ export type SolidReturnType<config extends Config = Config> =
46
+ GetConnectorsReturnType<config>
47
+ }
@@ -0,0 +1,44 @@
1
+ import { createMutation as useMutation } from '@tanstack/solid-query'
2
+ import type { DisconnectErrorType } from '@wagmi/core'
3
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
4
+ import {
5
+ type DisconnectData,
6
+ type DisconnectMutate,
7
+ type DisconnectMutateAsync,
8
+ type DisconnectOptions,
9
+ type DisconnectVariables,
10
+ disconnectMutationOptions,
11
+ } from '@wagmi/core/query'
12
+ import type { Accessor } from 'solid-js'
13
+ import type { UseMutationReturnType } from '../utils/query.js'
14
+ import { useConfig } from './useConfig.js'
15
+
16
+ /** https://wagmi.sh/solid/api/primitives/useDisconnect */
17
+ export function useDisconnect<context = unknown>(
18
+ parameters: useDisconnect.Parameters<context> = () => ({}),
19
+ ): useDisconnect.ReturnType<context> {
20
+ const config = useConfig(parameters)
21
+ const mutation = useMutation(() =>
22
+ disconnectMutationOptions(config(), parameters()),
23
+ )
24
+ return mutation as useDisconnect.ReturnType<context>
25
+ }
26
+
27
+ export namespace useDisconnect {
28
+ export type Parameters<context = unknown> = Accessor<SolidParameters<context>>
29
+
30
+ export type ReturnType<context = unknown> = Compute<
31
+ UseMutationReturnType<
32
+ DisconnectData,
33
+ DisconnectErrorType,
34
+ DisconnectVariables,
35
+ context,
36
+ DisconnectMutate<context>,
37
+ DisconnectMutateAsync<context>
38
+ >
39
+ >
40
+
41
+ export type SolidParameters<context = unknown> = Compute<
42
+ ConfigParameter & DisconnectOptions<context>
43
+ >
44
+ }
@@ -0,0 +1,44 @@
1
+ import { createMutation as useMutation } from '@tanstack/solid-query'
2
+ import type { ReconnectErrorType } from '@wagmi/core'
3
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
4
+ import {
5
+ type ReconnectData,
6
+ type ReconnectMutate,
7
+ type ReconnectMutateAsync,
8
+ type ReconnectOptions,
9
+ type ReconnectVariables,
10
+ reconnectMutationOptions,
11
+ } from '@wagmi/core/query'
12
+ import type { Accessor } from 'solid-js'
13
+ import type { UseMutationReturnType } from '../utils/query.js'
14
+ import { useConfig } from './useConfig.js'
15
+
16
+ /** https://wagmi.sh/solid/api/primitives/useReconnect */
17
+ export function useReconnect<context = unknown>(
18
+ parameters: useReconnect.Parameters<context> = () => ({}),
19
+ ): useReconnect.ReturnType<context> {
20
+ const config = useConfig(parameters)
21
+ const mutation = useMutation(() =>
22
+ reconnectMutationOptions(config(), parameters()),
23
+ )
24
+ return mutation as useReconnect.ReturnType<context>
25
+ }
26
+
27
+ export namespace useReconnect {
28
+ export type Parameters<context = unknown> = Accessor<SolidParameters<context>>
29
+
30
+ export type ReturnType<context = unknown> = Compute<
31
+ UseMutationReturnType<
32
+ ReconnectData,
33
+ ReconnectErrorType,
34
+ ReconnectVariables,
35
+ context,
36
+ ReconnectMutate<context>,
37
+ ReconnectMutateAsync<context>
38
+ >
39
+ >
40
+
41
+ export type SolidParameters<context = unknown> = Compute<
42
+ ConfigParameter & ReconnectOptions<context>
43
+ >
44
+ }
@@ -0,0 +1,58 @@
1
+ import { createMutation as useMutation } from '@tanstack/solid-query'
2
+ import type {
3
+ Config,
4
+ ResolvedRegister,
5
+ SwitchChainErrorType,
6
+ } from '@wagmi/core'
7
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
8
+ import {
9
+ type SwitchChainData,
10
+ type SwitchChainMutate,
11
+ type SwitchChainMutateAsync,
12
+ type SwitchChainOptions,
13
+ type SwitchChainVariables,
14
+ switchChainMutationOptions,
15
+ } from '@wagmi/core/query'
16
+ import type { Accessor } from 'solid-js'
17
+ import type { UseMutationReturnType } from '../utils/query.js'
18
+ import { useConfig } from './useConfig.js'
19
+
20
+ /** https://wagmi.sh/solid/api/primitives/useSwitchChain */
21
+ export function useSwitchChain<
22
+ config extends Config = ResolvedRegister['config'],
23
+ context = unknown,
24
+ >(
25
+ parameters: useSwitchChain.Parameters<config, context> = () => ({}),
26
+ ): useSwitchChain.ReturnType<config, context> {
27
+ const config = useConfig(parameters)
28
+ const mutation = useMutation(() =>
29
+ switchChainMutationOptions(config(), parameters()),
30
+ )
31
+ return mutation as useSwitchChain.ReturnType<config, context>
32
+ }
33
+
34
+ export namespace useSwitchChain {
35
+ export type Parameters<
36
+ config extends Config = Config,
37
+ context = unknown,
38
+ > = Accessor<SolidParameters<config, context>>
39
+
40
+ export type ReturnType<
41
+ config extends Config = Config,
42
+ context = unknown,
43
+ > = Compute<
44
+ UseMutationReturnType<
45
+ SwitchChainData<config, config['chains'][number]['id']>,
46
+ SwitchChainErrorType,
47
+ SwitchChainVariables<config, config['chains'][number]['id']>,
48
+ context,
49
+ SwitchChainMutate<config, context>,
50
+ SwitchChainMutateAsync<config, context>
51
+ >
52
+ >
53
+
54
+ export type SolidParameters<
55
+ config extends Config = Config,
56
+ context = unknown,
57
+ > = Compute<ConfigParameter<config> & SwitchChainOptions<config, context>>
58
+ }
@@ -0,0 +1,60 @@
1
+ import { createMutation as useMutation } from '@tanstack/solid-query'
2
+ import type {
3
+ Config,
4
+ ResolvedRegister,
5
+ SwitchConnectionErrorType,
6
+ } from '@wagmi/core'
7
+ import type { Compute, ConfigParameter } from '@wagmi/core/internal'
8
+ import {
9
+ type SwitchConnectionData,
10
+ type SwitchConnectionMutate,
11
+ type SwitchConnectionMutateAsync,
12
+ type SwitchConnectionOptions,
13
+ type SwitchConnectionVariables,
14
+ switchConnectionMutationOptions,
15
+ } from '@wagmi/core/query'
16
+ import type { Accessor } from 'solid-js'
17
+ import type { UseMutationReturnType } from '../utils/query.js'
18
+ import { useConfig } from './useConfig.js'
19
+
20
+ /** https://wagmi.sh/solid/api/primitives/useSwitchConnection */
21
+ export function useSwitchConnection<
22
+ config extends Config = ResolvedRegister['config'],
23
+ context = unknown,
24
+ >(
25
+ parameters: useSwitchConnection.Parameters<config, context> = () => ({}),
26
+ ): useSwitchConnection.ReturnType<config, context> {
27
+ const config = useConfig<config>(parameters)
28
+ const mutation = useMutation(() =>
29
+ switchConnectionMutationOptions(config(), parameters()),
30
+ )
31
+ return mutation as useSwitchConnection.ReturnType<config, context>
32
+ }
33
+
34
+ export namespace useSwitchConnection {
35
+ export type Parameters<
36
+ config extends Config = Config,
37
+ context = unknown,
38
+ > = Accessor<SolidParameters<config, context>>
39
+
40
+ export type ReturnType<
41
+ config extends Config = Config,
42
+ context = unknown,
43
+ > = Compute<
44
+ UseMutationReturnType<
45
+ SwitchConnectionData<config>,
46
+ SwitchConnectionErrorType,
47
+ SwitchConnectionVariables,
48
+ context,
49
+ SwitchConnectionMutate<config, context>,
50
+ SwitchConnectionMutateAsync<config, context>
51
+ >
52
+ >
53
+
54
+ export type SolidParameters<
55
+ config extends Config = Config,
56
+ context = unknown,
57
+ > = Compute<
58
+ ConfigParameter<config> & SwitchConnectionOptions<config, context>
59
+ >
60
+ }