solid-wagmi 0.2.2 → 0.3.0
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.
- package/dist/esm/context.js +3 -3
- package/dist/esm/context.js.map +1 -1
- package/dist/esm/exports/index.js +2 -2
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/hooks/useAccount.js +2 -2
- package/dist/esm/hooks/useAccount.js.map +1 -1
- package/dist/esm/hooks/useBalance.js +1 -1
- package/dist/esm/hooks/useBalance.js.map +1 -1
- package/dist/esm/hooks/useChainId.js +3 -3
- package/dist/esm/hooks/useChainId.js.map +1 -1
- package/dist/esm/hooks/useConfig.js +8 -6
- package/dist/esm/hooks/useConfig.js.map +1 -1
- package/dist/esm/hooks/useConnect.js +2 -2
- package/dist/esm/hooks/useConnect.js.map +1 -1
- package/dist/esm/hooks/useConnection.js +20 -0
- package/dist/esm/hooks/useConnection.js.map +1 -0
- package/dist/esm/hooks/useConnections.js +2 -2
- package/dist/esm/hooks/useConnections.js.map +1 -1
- package/dist/esm/hooks/useDisconnect.js +1 -1
- package/dist/esm/hooks/useDisconnect.js.map +1 -1
- package/dist/esm/hooks/useReadContract.js +1 -1
- package/dist/esm/hooks/useReadContract.js.map +1 -1
- package/dist/esm/hooks/useReadContracts.js +1 -1
- package/dist/esm/hooks/useReadContracts.js.map +1 -1
- package/dist/esm/hooks/useWriteContract.js +9 -6
- package/dist/esm/hooks/useWriteContract.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +1 -5
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +1 -1
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/hooks/useConfig.d.ts +1 -1
- package/dist/types/hooks/useConfig.d.ts.map +1 -1
- package/dist/types/hooks/useConnection.d.ts +10 -0
- package/dist/types/hooks/useConnection.d.ts.map +1 -0
- package/dist/types/hooks/useWriteContract.d.ts +3 -2
- package/dist/types/hooks/useWriteContract.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/context.ts +11 -9
- package/src/exports/index.ts +2 -3
- package/src/hooks/useAccount.ts +2 -2
- package/src/hooks/useBalance.ts +1 -1
- package/src/hooks/useChainId.ts +3 -3
- package/src/hooks/useConfig.ts +9 -7
- package/src/hooks/useConnect.ts +2 -2
- package/src/hooks/useConnection.ts +50 -0
- package/src/hooks/useConnections.ts +2 -2
- package/src/hooks/useDisconnect.ts +1 -1
- package/src/hooks/useReadContract.ts +1 -1
- package/src/hooks/useReadContracts.ts +1 -1
- package/src/hooks/useWriteContract.ts +17 -9
- package/src/types/index.ts +2 -2
package/dist/types/context.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { type Config, type State } from "@wagmi/core";
|
|
2
2
|
import { type JSX } from "solid-js";
|
|
3
|
-
export
|
|
4
|
-
config: Config;
|
|
5
|
-
initialState?: State;
|
|
6
|
-
};
|
|
7
|
-
export declare const WagmiContext: import("solid-js").Context<WagmiCtx | undefined>;
|
|
3
|
+
export declare const WagmiContext: import("solid-js").Context<Config | undefined>;
|
|
8
4
|
export declare function WagmiProvider(props: {
|
|
9
5
|
config: Config;
|
|
10
6
|
initialState?: State;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EAEX,KAAK,KAAK,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAKL,KAAK,GAAG,EACT,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,YAAY,gDAEb,CAAC;AAEb,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB,eAqBA"}
|
|
@@ -10,5 +10,5 @@ export { useDisconnect } from "../hooks/useDisconnect.js";
|
|
|
10
10
|
export { useReadContract } from "../hooks/useReadContract.js";
|
|
11
11
|
export { useReadContracts } from "../hooks/useReadContracts.js";
|
|
12
12
|
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,
|
|
13
|
+
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
14
|
//# 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,e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,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,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"}
|
|
@@ -2,6 +2,6 @@ import type { Config, ResolvedRegister } from "@wagmi/core";
|
|
|
2
2
|
import { type Accessor } from "solid-js";
|
|
3
3
|
import type { ConfigParameter } from "../types/index.js";
|
|
4
4
|
export type UseConfigParameters<config extends Config = Config> = Accessor<ConfigParameter<config>>;
|
|
5
|
-
export type UseConfigReturnType<config extends Config = Config> = config
|
|
5
|
+
export type UseConfigReturnType<config extends Config = Config> = Accessor<config>;
|
|
6
6
|
export declare function useConfig<config extends Config = ResolvedRegister["config"]>(parameters?: UseConfigParameters<config>): UseConfigReturnType<config>;
|
|
7
7
|
//# sourceMappingURL=useConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"useConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,QAAQ,CACxE,eAAe,CAAC,MAAM,CAAC,CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAC5D,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnB,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAC1E,UAAU,GAAE,mBAAmB,CAAC,MAAM,CAAc,GACnD,mBAAmB,CAAC,MAAM,CAAC,CAO7B"}
|
|
@@ -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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Config, WriteContractErrorType } from "@wagmi/core";
|
|
1
|
+
import type { Config, ResolvedRegister, WriteContractErrorType } from "@wagmi/core";
|
|
2
2
|
import { type WriteContractData, type WriteContractMutate, type WriteContractMutateAsync, type WriteContractVariables } from "@wagmi/core/query";
|
|
3
|
+
import type { Accessor } from "solid-js";
|
|
3
4
|
import type { Abi } from "viem";
|
|
4
5
|
import type { ConfigParameter, UseMutationParameters, UseMutationReturnType } from "../types/index.js";
|
|
5
6
|
export type UseWriteContractParameters<config extends Config = Config, context = unknown> = ConfigParameter<config> & {
|
|
@@ -9,5 +10,5 @@ export type UseWriteContractReturnType<config extends Config = Config, context =
|
|
|
9
10
|
writeContract: WriteContractMutate<config, context>;
|
|
10
11
|
writeContractAsync: WriteContractMutateAsync<config, context>;
|
|
11
12
|
};
|
|
12
|
-
export declare function useWriteContract<config extends Config =
|
|
13
|
+
export declare function useWriteContract<config extends Config = ResolvedRegister["config"], context = unknown>(params?: Accessor<UseWriteContractParameters<config, context>>): UseWriteContractReturnType<config, context>;
|
|
13
14
|
//# sourceMappingURL=useWriteContract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWriteContract.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWriteContract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useWriteContract.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWriteContract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EACN,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAA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,
|
|
1
|
+
import type { DefaultError, QueryKey, SolidMutationOptions, SolidQueryOptions, UseInfiniteQueryOptions, UseMutationResult, UseQueryResult } from "@tanstack/solid-query";
|
|
2
2
|
import type { Config } from "@wagmi/core";
|
|
3
3
|
import type { Compute, ExactPartial, Omit, UnionStrictOmit } from "@wagmi/core/internal";
|
|
4
4
|
export type EnabledParameter = {
|
|
@@ -12,7 +12,7 @@ export type UseInfiniteQueryParameters<queryFnData = unknown, error = DefaultErr
|
|
|
12
12
|
initialData?: ReturnType<UseInfiniteQueryOptions<queryFnData, error, data, queryKey>>["initialData"] | undefined;
|
|
13
13
|
}>;
|
|
14
14
|
export type UseMutationReturnType<data = unknown, error = Error, variables = void, context = unknown> = Compute<UnionStrictOmit<UseMutationResult<data, error, variables, context>, "mutate" | "mutateAsync">>;
|
|
15
|
-
export type UseMutationParameters<data = unknown, error = Error, variables = void, context = unknown> = Compute<Omit<
|
|
15
|
+
export type UseMutationParameters<data = unknown, error = Error, variables = void, context = unknown> = Compute<Omit<SolidMutationOptions<data, error, Compute<variables>, context>, "mutationFn" | "mutationKey" | "throwOnError">>;
|
|
16
16
|
export type UseQueryParameters<queryFnData = unknown, error = DefaultError, data = queryFnData, queryKey extends QueryKey = QueryKey> = Compute<ExactPartial<Omit<SolidQueryOptions<queryFnData, error, data, queryKey>, "initialData">> & {
|
|
17
17
|
initialData?: SolidQueryOptions<queryFnData, error, data, queryKey>["initialData"] | undefined;
|
|
18
18
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,iBAAiB,EACjB,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,iBAAi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AAG,QAAQ,EACpC,SAAS,GAAG,OAAO,IACjB;IACF,KAAK,EAAE,IAAI,CACT,0BAA0B,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,EACzE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,gBAAgB,GAAG,cAAc,CACzE,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-wagmi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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": "^
|
|
58
|
+
"@wagmi/core": "^3.0.0"
|
|
59
59
|
},
|
|
60
60
|
"keywords": [
|
|
61
61
|
"solidjs",
|
package/src/context.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
hydrate,
|
|
3
|
+
type Config,
|
|
4
|
+
type ResolvedRegister,
|
|
5
|
+
type State,
|
|
6
|
+
} from "@wagmi/core";
|
|
2
7
|
import {
|
|
3
8
|
createComponent,
|
|
4
9
|
createContext,
|
|
5
|
-
type JSX,
|
|
6
10
|
onMount,
|
|
7
11
|
splitProps,
|
|
12
|
+
type JSX,
|
|
8
13
|
} from "solid-js";
|
|
9
14
|
|
|
10
|
-
export
|
|
11
|
-
config
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const WagmiContext = createContext<WagmiCtx>();
|
|
15
|
+
export const WagmiContext = createContext<
|
|
16
|
+
ResolvedRegister["config"] | undefined
|
|
17
|
+
>(undefined);
|
|
16
18
|
|
|
17
19
|
export function WagmiProvider(props: {
|
|
18
20
|
config: Config;
|
|
@@ -35,7 +37,7 @@ export function WagmiProvider(props: {
|
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
return createComponent(WagmiContext.Provider, {
|
|
38
|
-
value:
|
|
40
|
+
value: config,
|
|
39
41
|
get children() {
|
|
40
42
|
return rest.children;
|
|
41
43
|
},
|
package/src/exports/index.ts
CHANGED
|
@@ -34,6 +34,8 @@ export {
|
|
|
34
34
|
ConnectorChainMismatchError,
|
|
35
35
|
ConnectorNotFoundError,
|
|
36
36
|
ConnectorUnavailableReconnectingError,
|
|
37
|
+
ProviderNotFoundError,
|
|
38
|
+
SwitchChainNotSupportedError,
|
|
37
39
|
// Utilities
|
|
38
40
|
cookieStorage,
|
|
39
41
|
cookieToInitialState,
|
|
@@ -49,11 +51,8 @@ export {
|
|
|
49
51
|
injected,
|
|
50
52
|
mock,
|
|
51
53
|
noopStorage,
|
|
52
|
-
normalizeChainId,
|
|
53
54
|
parseCookie,
|
|
54
|
-
ProviderNotFoundError,
|
|
55
55
|
serialize,
|
|
56
|
-
SwitchChainNotSupportedError,
|
|
57
56
|
unstable_connector,
|
|
58
57
|
webSocket,
|
|
59
58
|
// Errors
|
package/src/hooks/useAccount.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { useConfig } from "./useConfig.js";
|
|
|
4
4
|
|
|
5
5
|
export function useAccount() {
|
|
6
6
|
const config = useConfig();
|
|
7
|
-
const [account, setAccount] = createSignal(getAccount(config));
|
|
7
|
+
const [account, setAccount] = createSignal(getAccount(config()));
|
|
8
8
|
|
|
9
9
|
// Watch account
|
|
10
10
|
let cleanup: VoidFunction;
|
|
11
11
|
onMount(() => {
|
|
12
|
-
cleanup = watchAccount(config, { onChange: setAccount });
|
|
12
|
+
cleanup = watchAccount(config(), { onChange: setAccount });
|
|
13
13
|
});
|
|
14
14
|
onCleanup(() => cleanup?.());
|
|
15
15
|
|
package/src/hooks/useBalance.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function useBalance(params: () => UseBalanceParameters) {
|
|
|
34
34
|
const chain = useChainId();
|
|
35
35
|
|
|
36
36
|
const options = () =>
|
|
37
|
-
getBalanceQueryOptions(config, { chainId: chain().id, ...params() });
|
|
37
|
+
getBalanceQueryOptions(config(), { chainId: chain().id, ...params() });
|
|
38
38
|
const enabled = () =>
|
|
39
39
|
Boolean(params().address && (params().query?.enabled ?? true));
|
|
40
40
|
|
package/src/hooks/useChainId.ts
CHANGED
|
@@ -6,17 +6,17 @@ import { useConfig } from "./useConfig.js";
|
|
|
6
6
|
|
|
7
7
|
export function useChainId() {
|
|
8
8
|
const config = useConfig();
|
|
9
|
-
const [chainId, setChainID] = createSignal(getChainId(config));
|
|
9
|
+
const [chainId, setChainID] = createSignal(getChainId(config()));
|
|
10
10
|
|
|
11
11
|
// Watch chain id
|
|
12
12
|
let cleanup: VoidFunction;
|
|
13
13
|
onMount(() => {
|
|
14
|
-
cleanup = watchChainId(config, { onChange: setChainID });
|
|
14
|
+
cleanup = watchChainId(config(), { onChange: setChainID });
|
|
15
15
|
});
|
|
16
16
|
onCleanup(() => cleanup?.());
|
|
17
17
|
|
|
18
18
|
const chain = createMemo(() =>
|
|
19
|
-
extractChain({ chains: config.chains, id: chainId() })
|
|
19
|
+
extractChain({ chains: config().chains, id: chainId() })
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
return chain;
|
package/src/hooks/useConfig.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Config, ResolvedRegister } from "@wagmi/core";
|
|
2
|
-
import { useContext, type Accessor } from "solid-js";
|
|
2
|
+
import { createMemo, useContext, type Accessor } from "solid-js";
|
|
3
3
|
import { WagmiContext } from "../context.js";
|
|
4
4
|
import { WagmiProviderNotFoundError } from "../errors/context.js";
|
|
5
5
|
import type { ConfigParameter } from "../types/index.js";
|
|
@@ -8,14 +8,16 @@ export type UseConfigParameters<config extends Config = Config> = Accessor<
|
|
|
8
8
|
ConfigParameter<config>
|
|
9
9
|
>;
|
|
10
10
|
|
|
11
|
-
export type UseConfigReturnType<config extends Config = Config> =
|
|
11
|
+
export type UseConfigReturnType<config extends Config = Config> =
|
|
12
|
+
Accessor<config>;
|
|
12
13
|
|
|
13
14
|
export function useConfig<config extends Config = ResolvedRegister["config"]>(
|
|
14
|
-
parameters
|
|
15
|
+
parameters: UseConfigParameters<config> = () => ({})
|
|
15
16
|
): UseConfigReturnType<config> {
|
|
16
|
-
|
|
17
|
+
return createMemo(() => {
|
|
18
|
+
const config = parameters().config ?? useContext(WagmiContext);
|
|
19
|
+
if (!config) throw new WagmiProviderNotFoundError();
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return config as UseConfigReturnType<config>;
|
|
21
|
+
return config as config;
|
|
22
|
+
});
|
|
21
23
|
}
|
package/src/hooks/useConnect.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { useConfig } from "./useConfig.js";
|
|
|
6
6
|
export function useConnect() {
|
|
7
7
|
const config = useConfig();
|
|
8
8
|
|
|
9
|
-
const mutationOptions = connectMutationOptions(config);
|
|
9
|
+
const mutationOptions = connectMutationOptions(config());
|
|
10
10
|
const { mutate, mutateAsync, ...result } = useMutation(() => ({
|
|
11
11
|
...mutationOptions,
|
|
12
12
|
}));
|
|
13
13
|
|
|
14
14
|
// Reset mutation back to an idle state when the connector disconnects.
|
|
15
15
|
createEffect(() => {
|
|
16
|
-
const unsub = config.subscribe(
|
|
16
|
+
const unsub = config().subscribe(
|
|
17
17
|
({ status }) => status,
|
|
18
18
|
(status, previousStatus) => {
|
|
19
19
|
if (previousStatus === "connected" && status === "disconnected")
|
|
@@ -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
|
+
}
|
|
@@ -4,11 +4,11 @@ import { useConfig } from "./useConfig.js";
|
|
|
4
4
|
|
|
5
5
|
export function useConnections() {
|
|
6
6
|
const config = useConfig();
|
|
7
|
-
const [connections, setConnections] = createSignal(getConnections(config));
|
|
7
|
+
const [connections, setConnections] = createSignal(getConnections(config()));
|
|
8
8
|
|
|
9
9
|
let cleanup: VoidFunction | undefined;
|
|
10
10
|
onMount(() => {
|
|
11
|
-
cleanup = watchConnections(config, { onChange: setConnections });
|
|
11
|
+
cleanup = watchConnections(config(), { onChange: setConnections });
|
|
12
12
|
});
|
|
13
13
|
onCleanup(() => cleanup?.());
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ export function useDisconnect() {
|
|
|
8
8
|
const config = useConfig();
|
|
9
9
|
|
|
10
10
|
const connections = useConnections();
|
|
11
|
-
const mutationOptions = disconnectMutationOptions(config);
|
|
11
|
+
const mutationOptions = disconnectMutationOptions(config());
|
|
12
12
|
const { mutate, mutateAsync, ...result } = useMutation(() => ({
|
|
13
13
|
...mutationOptions,
|
|
14
14
|
}));
|
|
@@ -91,7 +91,7 @@ export function useReadContracts<
|
|
|
91
91
|
const code = params().code as Hex | undefined;
|
|
92
92
|
|
|
93
93
|
const options = readContractsQueryOptions<Config, contracts, allowFailure>(
|
|
94
|
-
config,
|
|
94
|
+
config(),
|
|
95
95
|
{ ...params(), chainId: contractsChainId() ?? chainId().id }
|
|
96
96
|
);
|
|
97
97
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useMutation } from "@tanstack/solid-query";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
Config,
|
|
4
|
+
ResolvedRegister,
|
|
5
|
+
WriteContractErrorType,
|
|
6
|
+
} from "@wagmi/core";
|
|
3
7
|
import {
|
|
4
8
|
writeContractMutationOptions,
|
|
5
9
|
type WriteContractData,
|
|
@@ -7,7 +11,7 @@ import {
|
|
|
7
11
|
type WriteContractMutateAsync,
|
|
8
12
|
type WriteContractVariables,
|
|
9
13
|
} from "@wagmi/core/query";
|
|
10
|
-
|
|
14
|
+
import type { Accessor } from "solid-js";
|
|
11
15
|
import type { Abi } from "viem";
|
|
12
16
|
import type {
|
|
13
17
|
ConfigParameter,
|
|
@@ -56,18 +60,22 @@ export type UseWriteContractReturnType<
|
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
export function useWriteContract<
|
|
59
|
-
config extends Config =
|
|
63
|
+
config extends Config = ResolvedRegister["config"],
|
|
60
64
|
context = unknown
|
|
61
65
|
>(
|
|
62
|
-
params
|
|
66
|
+
params: Accessor<UseWriteContractParameters<config, context>> = () => ({})
|
|
63
67
|
): UseWriteContractReturnType<config, context> {
|
|
64
68
|
const config = useConfig();
|
|
65
69
|
|
|
66
|
-
const mutationOptions = writeContractMutationOptions(config);
|
|
67
|
-
const { mutate, mutateAsync, ...result } = useMutation(() =>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
const mutationOptions = writeContractMutationOptions(config());
|
|
71
|
+
const { mutate, mutateAsync, ...result } = useMutation(() => {
|
|
72
|
+
const mutation = params?.().mutation;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
...(mutation ?? {}),
|
|
76
|
+
...mutationOptions,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
71
79
|
|
|
72
80
|
type Return = UseWriteContractReturnType<config, context>;
|
|
73
81
|
return {
|
package/src/types/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
DefaultError,
|
|
3
3
|
QueryKey,
|
|
4
|
+
SolidMutationOptions,
|
|
4
5
|
SolidQueryOptions,
|
|
5
6
|
UseInfiniteQueryOptions,
|
|
6
|
-
UseMutationOptions,
|
|
7
7
|
UseMutationResult,
|
|
8
8
|
UseQueryResult,
|
|
9
9
|
} from "@tanstack/solid-query";
|
|
@@ -67,7 +67,7 @@ export type UseMutationParameters<
|
|
|
67
67
|
context = unknown
|
|
68
68
|
> = Compute<
|
|
69
69
|
Omit<
|
|
70
|
-
|
|
70
|
+
SolidMutationOptions<data, error, Compute<variables>, context>,
|
|
71
71
|
"mutationFn" | "mutationKey" | "throwOnError"
|
|
72
72
|
>
|
|
73
73
|
>;
|