solid-wagmi 0.2.3 → 0.3.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.
@@ -5,10 +5,11 @@ export { useBalance } from "../hooks/useBalance.js";
5
5
  export { useChainId } from "../hooks/useChainId.js";
6
6
  export { useConfig } from "../hooks/useConfig.js";
7
7
  export { useConnect } from "../hooks/useConnect.js";
8
+ export { useConnection } from "../hooks/useConnection.js";
8
9
  export { useConnections } from "../hooks/useConnections.js";
9
10
  export { useDisconnect } from "../hooks/useDisconnect.js";
10
11
  export { useReadContract } from "../hooks/useReadContract.js";
11
12
  export { useReadContracts } from "../hooks/useReadContracts.js";
12
13
  export { useWriteContract } from "../hooks/useWriteContract.js";
13
- export { ChainNotConfiguredError, ConnectorAccountNotFoundError, ConnectorAlreadyConnectedError, ConnectorChainMismatchError, ConnectorNotFoundError, ConnectorUnavailableReconnectingError, cookieStorage, cookieToInitialState, createConfig, createConnector, createStorage, custom, deepEqual, deserialize, fallback, http, injected, mock, noopStorage, normalizeChainId, parseCookie, ProviderNotFoundError, serialize, SwitchChainNotSupportedError, unstable_connector, webSocket, type ChainNotConfiguredErrorType, type Config, type Connection, type Connector, type ConnectorAccountNotFoundErrorType, type ConnectorAlreadyConnectedErrorType, type ConnectorChainMismatchErrorType, type ConnectorEventMap, type ConnectorNotFoundErrorType, type ConnectorUnavailableReconnectingErrorType, type CreateConfigParameters, type CreateConnectorFn, type CreateStorageParameters, type PartializedState, type ProviderNotFoundErrorType, type Register, type ResolvedRegister, type State, type Storage, type SwitchChainNotSupportedErrorType, type Transport, } from "@wagmi/core";
14
+ export { ChainNotConfiguredError, ConnectorAccountNotFoundError, ConnectorAlreadyConnectedError, ConnectorChainMismatchError, ConnectorNotFoundError, ConnectorUnavailableReconnectingError, ProviderNotFoundError, SwitchChainNotSupportedError, cookieStorage, cookieToInitialState, createConfig, createConnector, createStorage, custom, deepEqual, deserialize, fallback, http, injected, mock, noopStorage, parseCookie, serialize, unstable_connector, webSocket, type ChainNotConfiguredErrorType, type Config, type Connection, type Connector, type ConnectorAccountNotFoundErrorType, type ConnectorAlreadyConnectedErrorType, type ConnectorChainMismatchErrorType, type ConnectorEventMap, type ConnectorNotFoundErrorType, type ConnectorUnavailableReconnectingErrorType, type CreateConfigParameters, type CreateConnectorFn, type CreateStorageParameters, type PartializedState, type ProviderNotFoundErrorType, type Register, type ResolvedRegister, type State, type Storage, type SwitchChainNotSupportedErrorType, type Transport, } from "@wagmi/core";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAKlE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,sBAAsB,EACtB,qCAAqC,EAErC,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,aAAa,EAEb,MAAM,EACN,SAAS,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AC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAMhE,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,sBAAsB,EACtB,qCAAqC,EACrC,qBAAqB,EACrB,4BAA4B,EAE5B,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,aAAa,EAEb,MAAM,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,SAAS,EAET,KAAK,2BAA2B,EAChC,KAAK,MAAM,EAEX,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,iCAAiC,EACtC,KAAK,kCAAkC,EACvC,KAAK,+BAA+B,EAEpC,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,yCAAyC,EAC9C,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAEtB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAE9B,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,gCAAgC,EACrC,KAAK,SAAS,GACf,MAAM,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type Config, type GetConnectionReturnType, type ResolvedRegister } from "@wagmi/core";
2
+ import { type Accessor } from "solid-js";
3
+ import type { ConfigParameter } from "../types/index.js";
4
+ export type SolidConnectionParameters<config extends Config = Config> = ConfigParameter<config>;
5
+ export type UseConnectionParameters<config extends Config = Config> = Accessor<SolidConnectionParameters<config>>;
6
+ export type SolidConnectionReturnType<config extends Config = Config> = GetConnectionReturnType<config>;
7
+ export type UseConnectionReturnType<config extends Config = Config> = Accessor<SolidConnectionReturnType<config>>;
8
+ /** https://wagmi.sh/solid/api/primitives/useConnection */
9
+ export declare function useConnection<config extends Config = ResolvedRegister["config"]>(parameters?: UseConnectionParameters<config>): UseConnectionReturnType<config>;
10
+ //# sourceMappingURL=useConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConnection.d.ts","sourceRoot":"","sources":["../../../src/hooks/useConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAyC,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,MAAM,MAAM,yBAAyB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAClE,eAAe,CAAC,MAAM,CAAC,CAAC;AAE1B,MAAM,MAAM,uBAAuB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CAC5E,yBAAyB,CAAC,MAAM,CAAC,CAClC,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAClE,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAElC,MAAM,MAAM,uBAAuB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CAC5E,yBAAyB,CAAC,MAAM,CAAC,CAClC,CAAC;AAEF,0DAA0D;AAC1D,wBAAgB,aAAa,CAC3B,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAElD,UAAU,GAAE,uBAAuB,CAAC,MAAM,CAAc,GACvD,uBAAuB,CAAC,MAAM,CAAC,CAkBjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-wagmi",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "Solid.js Hooks for Ethereum",
5
5
  "type": "module",
6
6
  "repository": {
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@wagmi/connectors": "^6.1.3",
58
- "@wagmi/core": "^2.22.1"
58
+ "@wagmi/core": "^3.0.0"
59
59
  },
60
60
  "keywords": [
61
61
  "solidjs",
@@ -17,6 +17,7 @@ export { useBalance } from "../hooks/useBalance.js";
17
17
  export { useChainId } from "../hooks/useChainId.js";
18
18
  export { useConfig } from "../hooks/useConfig.js";
19
19
  export { useConnect } from "../hooks/useConnect.js";
20
+ export { useConnection } from "../hooks/useConnection.js";
20
21
  export { useConnections } from "../hooks/useConnections.js";
21
22
  export { useDisconnect } from "../hooks/useDisconnect.js";
22
23
  export { useReadContract } from "../hooks/useReadContract.js";
@@ -34,6 +35,8 @@ export {
34
35
  ConnectorChainMismatchError,
35
36
  ConnectorNotFoundError,
36
37
  ConnectorUnavailableReconnectingError,
38
+ ProviderNotFoundError,
39
+ SwitchChainNotSupportedError,
37
40
  // Utilities
38
41
  cookieStorage,
39
42
  cookieToInitialState,
@@ -49,11 +52,8 @@ export {
49
52
  injected,
50
53
  mock,
51
54
  noopStorage,
52
- normalizeChainId,
53
55
  parseCookie,
54
- ProviderNotFoundError,
55
56
  serialize,
56
- SwitchChainNotSupportedError,
57
57
  unstable_connector,
58
58
  webSocket,
59
59
  // Errors
@@ -0,0 +1,50 @@
1
+ import {
2
+ getConnection,
3
+ watchConnection,
4
+ type Config,
5
+ type GetConnectionReturnType,
6
+ type ResolvedRegister,
7
+ } from "@wagmi/core";
8
+ import { createEffect, createSignal, onCleanup, type Accessor } from "solid-js";
9
+
10
+ import type { ConfigParameter } from "../types/index.js";
11
+ import { useConfig } from "./useConfig.js";
12
+
13
+ export type SolidConnectionParameters<config extends Config = Config> =
14
+ ConfigParameter<config>;
15
+
16
+ export type UseConnectionParameters<config extends Config = Config> = Accessor<
17
+ SolidConnectionParameters<config>
18
+ >;
19
+
20
+ export type SolidConnectionReturnType<config extends Config = Config> =
21
+ GetConnectionReturnType<config>;
22
+
23
+ export type UseConnectionReturnType<config extends Config = Config> = Accessor<
24
+ SolidConnectionReturnType<config>
25
+ >;
26
+
27
+ /** https://wagmi.sh/solid/api/primitives/useConnection */
28
+ export function useConnection<
29
+ config extends Config = ResolvedRegister["config"]
30
+ >(
31
+ parameters: UseConnectionParameters<config> = () => ({})
32
+ ): UseConnectionReturnType<config> {
33
+ const config = useConfig(parameters);
34
+
35
+ const [connection, setConnection] = createSignal(getConnection(config()));
36
+
37
+ createEffect(() => {
38
+ const _config = config();
39
+ setConnection(() => getConnection(_config));
40
+
41
+ const unsubscribe = watchConnection(_config, {
42
+ onChange(data) {
43
+ setConnection(() => data);
44
+ },
45
+ });
46
+ onCleanup(() => unsubscribe());
47
+ });
48
+
49
+ return connection;
50
+ }