@dynamic-labs-sdk/wagmi 0.0.0 → 1.29.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/README.md +212 -0
- package/dist/createDynamicWagmiConnector/createDynamicWagmiConnector.d.ts +66 -0
- package/dist/createDynamicWagmiConnector/createDynamicWagmiConnector.d.ts.map +1 -0
- package/dist/createDynamicWagmiConnector/index.d.ts +3 -0
- package/dist/createDynamicWagmiConnector/index.d.ts.map +1 -0
- package/dist/errors/NotEvmWalletAccountError/NotEvmWalletAccountError.d.ts +23 -0
- package/dist/errors/NotEvmWalletAccountError/NotEvmWalletAccountError.d.ts.map +1 -0
- package/dist/errors/NotEvmWalletAccountError/index.d.ts +2 -0
- package/dist/errors/NotEvmWalletAccountError/index.d.ts.map +1 -0
- package/dist/exports/index.d.ts +6 -0
- package/dist/exports/index.d.ts.map +1 -0
- package/dist/exports/react.d.ts +5 -0
- package/dist/exports/react.d.ts.map +1 -0
- package/dist/index.cjs +11 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +9 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/react/SyncDynamicWagmi/SyncDynamicWagmi.d.ts +37 -0
- package/dist/react/SyncDynamicWagmi/SyncDynamicWagmi.d.ts.map +1 -0
- package/dist/react/SyncDynamicWagmi/index.d.ts +3 -0
- package/dist/react/SyncDynamicWagmi/index.d.ts.map +1 -0
- package/dist/react/useSyncDynamicWagmi/index.d.ts +3 -0
- package/dist/react/useSyncDynamicWagmi/index.d.ts.map +1 -0
- package/dist/react/useSyncDynamicWagmi/useSyncDynamicWagmi.d.ts +29 -0
- package/dist/react/useSyncDynamicWagmi/useSyncDynamicWagmi.d.ts.map +1 -0
- package/dist/react.cjs +66 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.esm.js +65 -0
- package/dist/react.esm.js.map +1 -0
- package/dist/syncDynamicWagmi/index.d.ts +3 -0
- package/dist/syncDynamicWagmi/index.d.ts.map +1 -0
- package/dist/syncDynamicWagmi/syncDynamicWagmi.d.ts +56 -0
- package/dist/syncDynamicWagmi/syncDynamicWagmi.d.ts.map +1 -0
- package/dist/syncDynamicWagmi-4t63--sw.esm.js +303 -0
- package/dist/syncDynamicWagmi-4t63--sw.esm.js.map +1 -0
- package/dist/syncDynamicWagmi-CkgWtmHt.cjs +332 -0
- package/dist/syncDynamicWagmi-CkgWtmHt.cjs.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +62 -1
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# @dynamic-labs-sdk/wagmi
|
|
2
|
+
|
|
3
|
+
Official [wagmi](https://wagmi.sh) support for the Dynamic JS SDK. Expose a
|
|
4
|
+
Dynamic-managed EVM wallet account (embedded/OTP or external) as a wagmi
|
|
5
|
+
connector so `useAccount`, `useSendTransaction`, `useReadContract`, and the rest
|
|
6
|
+
of the wagmi/viem hook ecosystem work against Dynamic wallets — with Dynamic
|
|
7
|
+
remaining the source of truth for wallet state.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @dynamic-labs-sdk/wagmi wagmi @wagmi/core viem @tanstack/react-query
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`wagmi`, `@wagmi/core` and `viem` are peer dependencies. `wagmi` and
|
|
16
|
+
`@tanstack/react-query` are only required for the React helpers.
|
|
17
|
+
|
|
18
|
+
## Which API to use
|
|
19
|
+
|
|
20
|
+
Use the automatic sync — `syncDynamicWagmi` in vanilla JS, `SyncDynamicWagmi` /
|
|
21
|
+
`useSyncDynamicWagmi` in React. Both keep wagmi pointed at Dynamic's **selected**
|
|
22
|
+
EVM wallet account, so `setSelectedWalletAccount(...)` is all you ever call to
|
|
23
|
+
move wagmi.
|
|
24
|
+
|
|
25
|
+
| | Vanilla JS | React |
|
|
26
|
+
| ---------------------------------------- | ----------------------------- | ------------------------------------------------------ |
|
|
27
|
+
| Keep wagmi on Dynamic's selected account | `syncDynamicWagmi` | `SyncDynamicWagmi` (or the `useSyncDynamicWagmi` hook) |
|
|
28
|
+
| Bridge one specific account yourself | `createDynamicWagmiConnector` | `createDynamicWagmiConnector` |
|
|
29
|
+
|
|
30
|
+
`createDynamicWagmiConnector` is the primitive both sync helpers are built on. It
|
|
31
|
+
bridges **exactly one** account — the one you pass in — and never follows
|
|
32
|
+
Dynamic's selection, so reach for it only when you deliberately want to pin wagmi
|
|
33
|
+
to a specific account.
|
|
34
|
+
|
|
35
|
+
## Vanilla JS
|
|
36
|
+
|
|
37
|
+
`syncDynamicWagmi` keeps a wagmi config on Dynamic's selected EVM wallet account,
|
|
38
|
+
with no React involved. It subscribes to Dynamic's wallet events and drives
|
|
39
|
+
wagmi's `connect` / `disconnect` whenever that selection changes — login, wallet
|
|
40
|
+
switch, or logout — and returns a function that stops the sync.
|
|
41
|
+
|
|
42
|
+
Create your wagmi config **once at startup** — you don't have a wallet account
|
|
43
|
+
yet, and you never rebuild the config. There is no Dynamic connector in
|
|
44
|
+
`createConfig`:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { createConfig, http } from '@wagmi/core';
|
|
48
|
+
import { mainnet } from 'viem/chains';
|
|
49
|
+
|
|
50
|
+
export const config = createConfig({
|
|
51
|
+
chains: [mainnet],
|
|
52
|
+
transports: { [mainnet.id]: http() },
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Then start the sync once — there is no `walletAccount` argument, and you never
|
|
57
|
+
build a connector yourself:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { setSelectedWalletAccount } from '@dynamic-labs-sdk/client';
|
|
61
|
+
import { syncDynamicWagmi } from '@dynamic-labs-sdk/wagmi';
|
|
62
|
+
|
|
63
|
+
const stopSync = syncDynamicWagmi({ config });
|
|
64
|
+
|
|
65
|
+
// When you're done (teardown / logout):
|
|
66
|
+
stopSync();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
It can start before the user has a wallet: wagmi stays disconnected until an EVM
|
|
70
|
+
wallet account is selected.
|
|
71
|
+
|
|
72
|
+
If you use multiple Dynamic clients, pass the client as the second argument:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const stopSync = syncDynamicWagmi({ config }, client);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Switching the target wallet account
|
|
79
|
+
|
|
80
|
+
Switching is a Dynamic call — no wagmi code:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { setSelectedWalletAccount } from '@dynamic-labs-sdk/client';
|
|
84
|
+
|
|
85
|
+
// wagmi re-points to nextWalletAccount automatically.
|
|
86
|
+
await setSelectedWalletAccount({ walletAccount: nextWalletAccount });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Pinning wagmi to one specific account
|
|
90
|
+
|
|
91
|
+
If you want wagmi on an account of your choosing rather than Dynamic's selected
|
|
92
|
+
one, build the connector yourself. The wallet provider is derived from the
|
|
93
|
+
account, so you only ever pass the account:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { connect, disconnect, getConnections } from '@wagmi/core';
|
|
97
|
+
import { createDynamicWagmiConnector } from '@dynamic-labs-sdk/wagmi';
|
|
98
|
+
|
|
99
|
+
await connect(config, {
|
|
100
|
+
connector: createDynamicWagmiConnector({ walletAccount }),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Dynamic-backed connectors carry `type: 'dynamic'`, so you can disconnect
|
|
104
|
+
// yours by name and leave connections your app made elsewhere untouched.
|
|
105
|
+
const dynamicConnections = getConnections(config).filter(
|
|
106
|
+
(connection) => connection.connector.type === 'dynamic'
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
for (const { connector } of dynamicConnections) {
|
|
110
|
+
await disconnect(config, { connector });
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
This connector is bound to that single account and does not react to
|
|
115
|
+
`setSelectedWalletAccount(...)`; to point it elsewhere, disconnect it and connect
|
|
116
|
+
a connector built for the other account.
|
|
117
|
+
|
|
118
|
+
If you use multiple Dynamic clients, pass the client as the second argument:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
const connector = createDynamicWagmiConnector({ walletAccount }, client);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## React
|
|
125
|
+
|
|
126
|
+
`SyncDynamicWagmi` (or the `useSyncDynamicWagmi` hook) is the React wrapper
|
|
127
|
+
around `syncDynamicWagmi` — it runs the sync for the component's lifetime. It
|
|
128
|
+
watches Dynamic's **selected** EVM wallet account and drives wagmi's `connect` /
|
|
129
|
+
`disconnect` for you whenever that selection changes — login, wallet switch, or
|
|
130
|
+
logout. You do **not** pass a `walletAccount`, and you never build a connector
|
|
131
|
+
yourself.
|
|
132
|
+
|
|
133
|
+
The payoff: call Dynamic's `setSelectedWalletAccount(...)` anywhere in your app
|
|
134
|
+
and wagmi follows automatically — `useAccount` and friends re-point to the newly
|
|
135
|
+
selected account with no extra wiring. Dynamic stays the source of truth; wagmi
|
|
136
|
+
is a read-only mirror. It renders nothing.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { DynamicProvider } from '@dynamic-labs-sdk/react-hooks';
|
|
140
|
+
import { SyncDynamicWagmi } from '@dynamic-labs-sdk/wagmi/react';
|
|
141
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
142
|
+
import { WagmiProvider, createConfig, http } from 'wagmi';
|
|
143
|
+
import { mainnet } from 'wagmi/chains';
|
|
144
|
+
|
|
145
|
+
// Your Dynamic client, created once via createDynamicClient(...).
|
|
146
|
+
import { client } from './dynamicClient';
|
|
147
|
+
|
|
148
|
+
// Dynamic handles wallet discovery, so disable wagmi's own injected discovery.
|
|
149
|
+
const config = createConfig({
|
|
150
|
+
chains: [mainnet],
|
|
151
|
+
multiInjectedProviderDiscovery: false,
|
|
152
|
+
transports: { [mainnet.id]: http() },
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const queryClient = new QueryClient();
|
|
156
|
+
|
|
157
|
+
// DynamicProvider makes the client available to the rest of Dynamic's React
|
|
158
|
+
// hooks (useUser, useGetWalletAccounts, ...). SyncDynamicWagmi uses the same
|
|
159
|
+
// client to keep wagmi in sync.
|
|
160
|
+
export const Providers = ({ children }) => (
|
|
161
|
+
<DynamicProvider client={client}>
|
|
162
|
+
<WagmiProvider config={config}>
|
|
163
|
+
<QueryClientProvider client={queryClient}>
|
|
164
|
+
<SyncDynamicWagmi config={config} />
|
|
165
|
+
{children}
|
|
166
|
+
</QueryClientProvider>
|
|
167
|
+
</WagmiProvider>
|
|
168
|
+
</DynamicProvider>
|
|
169
|
+
);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Once mounted, any wagmi hook mirrors the selected Dynamic wallet, and switching
|
|
173
|
+
accounts is just a Dynamic call — no wagmi code:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
import { setSelectedWalletAccount } from '@dynamic-labs-sdk/client';
|
|
177
|
+
import { useAccount } from 'wagmi';
|
|
178
|
+
|
|
179
|
+
const { address, isConnected } = useAccount();
|
|
180
|
+
|
|
181
|
+
// wagmi re-points to nextWalletAccount automatically.
|
|
182
|
+
await setSelectedWalletAccount({ walletAccount: nextWalletAccount });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The hook is also available directly:
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
import { useSyncDynamicWagmi } from '@dynamic-labs-sdk/wagmi/react';
|
|
189
|
+
|
|
190
|
+
useSyncDynamicWagmi({ config });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## What's supported
|
|
194
|
+
|
|
195
|
+
- `connect` / `disconnect`
|
|
196
|
+
- `getAccounts` / `getChainId` / `isAuthorized`
|
|
197
|
+
- `switchChain`
|
|
198
|
+
- Forwarding Dynamic wallet events (account change, network change, disconnect)
|
|
199
|
+
to wagmi.
|
|
200
|
+
|
|
201
|
+
## Notes & limitations
|
|
202
|
+
|
|
203
|
+
- v1 bridges a single EVM account at a time (the selected one when syncing, the
|
|
204
|
+
one you pass otherwise). Bridging multiple EVM accounts simultaneously is a
|
|
205
|
+
follow-up — let us know if you need this feature.
|
|
206
|
+
- Only EVM wallet accounts are bridged. Selecting a non-EVM wallet account (e.g.
|
|
207
|
+
Solana) leaves wagmi disconnected until an EVM wallet account is selected
|
|
208
|
+
again.
|
|
209
|
+
- Not every Dynamic wallet provider can change networks. When the underlying
|
|
210
|
+
provider cannot, `switchChain` — and `connect(config, { connector, chainId })`
|
|
211
|
+
with a chain other than the wallet's current one — rejects with wagmi's
|
|
212
|
+
`SwitchChainNotSupportedError` instead of silently staying on the old network.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { EvmWalletAccount, EvmWalletProvider } from '@dynamic-labs-sdk/evm';
|
|
2
|
+
import type { CreateConnectorFn } from '@wagmi/core';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for {@link createDynamicWagmiConnector}.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const params: CreateDynamicWagmiConnectorParams = { walletAccount };
|
|
9
|
+
* ```
|
|
10
|
+
* @see {@link createDynamicWagmiConnector}
|
|
11
|
+
* @see {@link EvmWalletAccount}
|
|
12
|
+
*/
|
|
13
|
+
export type CreateDynamicWagmiConnectorParams = {
|
|
14
|
+
/**
|
|
15
|
+
* The Dynamic EVM wallet account to expose as a wagmi connector. The
|
|
16
|
+
* underlying wallet provider (embedded/OTP or external) is derived from it,
|
|
17
|
+
* so callers never pass a provider directly.
|
|
18
|
+
*/
|
|
19
|
+
walletAccount: EvmWalletAccount;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Bridges a Dynamic EVM wallet account into a wagmi connector so it can drive
|
|
23
|
+
* the entire wagmi/viem hook ecosystem (`useAccount`, `useSendTransaction`,
|
|
24
|
+
* `useReadContract`, …) while Dynamic remains the source of truth for wallet
|
|
25
|
+
* state.
|
|
26
|
+
*
|
|
27
|
+
* The connector derives the EVM wallet provider from the account and reuses the
|
|
28
|
+
* SDK's own viem integration (`createWalletClientForWalletAccount`) so custom
|
|
29
|
+
* wallet clients (e.g. smart accounts) keep working. Wallet events emitted by
|
|
30
|
+
* the provider (account / network / disconnect) are forwarded to wagmi so its
|
|
31
|
+
* cache stays in sync.
|
|
32
|
+
*
|
|
33
|
+
* This is the low-level primitive: it bridges the one account you pass in and
|
|
34
|
+
* never follows Dynamic's selected account on its own. To have wagmi track
|
|
35
|
+
* Dynamic's selection automatically, use `syncDynamicWagmi` (vanilla JS) or
|
|
36
|
+
* `useSyncDynamicWagmi` / `SyncDynamicWagmi` (React, in
|
|
37
|
+
* `@dynamic-labs-sdk/wagmi/react`), both of which build this connector for you.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Create the wagmi config once at startup, with no Dynamic connector.
|
|
42
|
+
* const config = createConfig({ chains, transports });
|
|
43
|
+
*
|
|
44
|
+
* // Once the user has a Dynamic EVM wallet account, build the connector and
|
|
45
|
+
* // connect. `connect` accepts a connector function, so the config is untouched.
|
|
46
|
+
* const connector = createDynamicWagmiConnector({ walletAccount });
|
|
47
|
+
* await connect(config, { connector });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* Not every Dynamic wallet provider can change networks: when the underlying
|
|
51
|
+
* provider has no `switchActiveNetwork`, `switchChain` (and `connect` with a
|
|
52
|
+
* `chainId` that differs from the wallet's active network) rejects with wagmi's
|
|
53
|
+
* `SwitchChainNotSupportedError` rather than pretending the switch happened.
|
|
54
|
+
*
|
|
55
|
+
* @param params.walletAccount - The Dynamic EVM wallet account to bridge.
|
|
56
|
+
* @param [client] - The Dynamic client instance. Only required when using multiple Dynamic clients.
|
|
57
|
+
* @returns A wagmi `CreateConnectorFn` to pass to `connect(config, { connector })`.
|
|
58
|
+
* @throws {@link NotEvmWalletAccountError} when the account does not resolve to an EVM wallet provider.
|
|
59
|
+
* @throws `SwitchChainNotSupportedError` when a network switch is requested and the wallet provider cannot switch networks.
|
|
60
|
+
* @see {@link syncDynamicWagmi}
|
|
61
|
+
* @see {@link useSyncDynamicWagmi}
|
|
62
|
+
* @see {@link NotEvmWalletAccountError}
|
|
63
|
+
* @notInstrumented
|
|
64
|
+
*/
|
|
65
|
+
export declare const createDynamicWagmiConnector: ({ walletAccount }: CreateDynamicWagmiConnectorParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => CreateConnectorFn<EvmWalletProvider>;
|
|
66
|
+
//# sourceMappingURL=createDynamicWagmiConnector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDynamicWagmiConnector.d.ts","sourceRoot":"","sources":["../../src/createDynamicWagmiConnector/createDynamicWagmiConnector.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAiBrD;;;;;;;;;GASG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;;;OAIG;IACH,aAAa,EAAE,gBAAgB,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,2BAA2B,sBACnB,iCAAiC,gEAEnD,iBAAiB,CAAC,iBAAiB,CAgPlC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/createDynamicWagmiConnector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,YAAY,EAAE,iCAAiC,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseError } from '@dynamic-labs-sdk/client';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a wallet account passed to the wagmi bridge does not resolve to
|
|
4
|
+
* an EVM wallet provider. wagmi/viem only speak EVM, so non-EVM accounts
|
|
5
|
+
* (Solana, Sui, etc.) cannot be surfaced as a wagmi connector.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* try {
|
|
10
|
+
* createDynamicWagmiConnector({ walletAccount });
|
|
11
|
+
* } catch (error) {
|
|
12
|
+
* if (error instanceof NotEvmWalletAccountError) {
|
|
13
|
+
* // the account is not an EVM account
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* @see {@link createDynamicWagmiConnector}
|
|
18
|
+
* @see {@link isEvmWalletProvider}
|
|
19
|
+
*/
|
|
20
|
+
export declare class NotEvmWalletAccountError extends BaseError {
|
|
21
|
+
constructor(address: string);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=NotEvmWalletAccountError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotEvmWalletAccountError.d.ts","sourceRoot":"","sources":["../../../src/errors/NotEvmWalletAccountError/NotEvmWalletAccountError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;gBAEzC,OAAO,EAAE,MAAM;CAS5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/NotEvmWalletAccountError/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createDynamicWagmiConnector } from '../createDynamicWagmiConnector';
|
|
2
|
+
export type { CreateDynamicWagmiConnectorParams } from '../createDynamicWagmiConnector';
|
|
3
|
+
export { syncDynamicWagmi } from '../syncDynamicWagmi';
|
|
4
|
+
export type { SyncDynamicWagmiParams } from '../syncDynamicWagmi';
|
|
5
|
+
export { NotEvmWalletAccountError } from '../errors/NotEvmWalletAccountError';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,YAAY,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SyncDynamicWagmi } from '../react/SyncDynamicWagmi';
|
|
2
|
+
export type { SyncDynamicWagmiProps } from '../react/SyncDynamicWagmi';
|
|
3
|
+
export { useSyncDynamicWagmi } from '../react/useSyncDynamicWagmi';
|
|
4
|
+
export type { UseSyncDynamicWagmiParams } from '../react/useSyncDynamicWagmi';
|
|
5
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/exports/react.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,YAAY,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const require_syncDynamicWagmi = require('./syncDynamicWagmi-CkgWtmHt.cjs');
|
|
2
|
+
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
|
+
|
|
4
|
+
//#region src/exports/index.ts
|
|
5
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_syncDynamicWagmi.name, require_syncDynamicWagmi.version);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.NotEvmWalletAccountError = require_syncDynamicWagmi.NotEvmWalletAccountError;
|
|
9
|
+
exports.createDynamicWagmiConnector = require_syncDynamicWagmi.createDynamicWagmiConnector;
|
|
10
|
+
exports.syncDynamicWagmi = require_syncDynamicWagmi.syncDynamicWagmi;
|
|
11
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["packageName","packageVersion"],"sources":["../src/exports/index.ts"],"sourcesContent":["import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { createDynamicWagmiConnector } from '../createDynamicWagmiConnector';\nexport type { CreateDynamicWagmiConnectorParams } from '../createDynamicWagmiConnector';\nexport { syncDynamicWagmi } from '../syncDynamicWagmi';\nexport type { SyncDynamicWagmiParams } from '../syncDynamicWagmi';\nexport { NotEvmWalletAccountError } from '../errors/NotEvmWalletAccountError';\n"],"mappings":";;;;mEAMqBA,+BAAaC,iCAAe"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { a as version, i as name, n as createDynamicWagmiConnector, r as NotEvmWalletAccountError, t as syncDynamicWagmi } from "./syncDynamicWagmi-4t63--sw.esm.js";
|
|
2
|
+
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
|
+
|
|
4
|
+
//#region src/exports/index.ts
|
|
5
|
+
assertPackageVersion(name, version);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { NotEvmWalletAccountError, createDynamicWagmiConnector, syncDynamicWagmi };
|
|
9
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","names":["packageName","packageVersion"],"sources":["../src/exports/index.ts"],"sourcesContent":["import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { createDynamicWagmiConnector } from '../createDynamicWagmiConnector';\nexport type { CreateDynamicWagmiConnectorParams } from '../createDynamicWagmiConnector';\nexport { syncDynamicWagmi } from '../syncDynamicWagmi';\nexport type { SyncDynamicWagmiParams } from '../syncDynamicWagmi';\nexport { NotEvmWalletAccountError } from '../errors/NotEvmWalletAccountError';\n"],"mappings":";;;;AAMA,qBAAqBA,MAAaC,QAAe"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DynamicClient } from '@dynamic-labs-sdk/client';
|
|
2
|
+
import type { Config } from '@wagmi/core';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
export type SyncDynamicWagmiProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The Dynamic client instance. Only required when using multiple Dynamic
|
|
7
|
+
* clients.
|
|
8
|
+
*/
|
|
9
|
+
client?: DynamicClient;
|
|
10
|
+
/**
|
|
11
|
+
* The wagmi config to keep in sync with Dynamic's selected EVM wallet account.
|
|
12
|
+
*/
|
|
13
|
+
config: Config;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Drop-in component that keeps a wagmi `Config` in sync with Dynamic's selected
|
|
17
|
+
* EVM wallet account. Renders nothing.
|
|
18
|
+
*
|
|
19
|
+
* Place it inside your `DynamicProvider` / `WagmiProvider` /
|
|
20
|
+
* `QueryClientProvider` tree so the wagmi hooks mirror Dynamic's wallet state.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <DynamicProvider client={client}>
|
|
25
|
+
* <WagmiProvider config={config}>
|
|
26
|
+
* <QueryClientProvider client={queryClient}>
|
|
27
|
+
* <SyncDynamicWagmi config={config} />
|
|
28
|
+
* <App />
|
|
29
|
+
* </QueryClientProvider>
|
|
30
|
+
* </WagmiProvider>
|
|
31
|
+
* </DynamicProvider>
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @notInstrumented
|
|
35
|
+
*/
|
|
36
|
+
export declare const SyncDynamicWagmi: FC<SyncDynamicWagmiProps>;
|
|
37
|
+
//# sourceMappingURL=SyncDynamicWagmi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncDynamicWagmi.d.ts","sourceRoot":"","sources":["../../../src/react/SyncDynamicWagmi/SyncDynamicWagmi.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAOtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/SyncDynamicWagmi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/useSyncDynamicWagmi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Config } from '@wagmi/core';
|
|
2
|
+
export type UseSyncDynamicWagmiParams = {
|
|
3
|
+
/**
|
|
4
|
+
* The wagmi config to keep in sync with Dynamic's selected EVM wallet account.
|
|
5
|
+
*/
|
|
6
|
+
config: Config;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Keeps a wagmi `Config` in sync with Dynamic's selected EVM wallet account.
|
|
10
|
+
*
|
|
11
|
+
* Whenever the selected EVM account changes (login, wallet switch, logout),
|
|
12
|
+
* wagmi's `connect` / `disconnect` are driven so `useAccount` and the rest of
|
|
13
|
+
* the wagmi hooks mirror Dynamic. Dynamic stays the source of truth; wagmi is a
|
|
14
|
+
* read-only mirror.
|
|
15
|
+
*
|
|
16
|
+
* This is a thin React wrapper around the vanilla `syncDynamicWagmi`: the effect
|
|
17
|
+
* only starts the sync on mount and stops it (unsubscribe + disconnect) on
|
|
18
|
+
* unmount or when `config` / `client` change. All sync logic lives in
|
|
19
|
+
* `syncDynamicWagmi`. Prefer the `SyncDynamicWagmi` component if you just want to
|
|
20
|
+
* drop it into your tree.
|
|
21
|
+
*
|
|
22
|
+
* @param params.config - The wagmi config to synchronize.
|
|
23
|
+
* @param [client] - The Dynamic client instance. Only required when using
|
|
24
|
+
* multiple Dynamic clients.
|
|
25
|
+
* @see {@link syncDynamicWagmi}
|
|
26
|
+
* @notInstrumented
|
|
27
|
+
*/
|
|
28
|
+
export declare const useSyncDynamicWagmi: ({ config }: UseSyncDynamicWagmiParams, client?: import("@dynamic-labs-sdk/client").DynamicClient) => void;
|
|
29
|
+
//# sourceMappingURL=useSyncDynamicWagmi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSyncDynamicWagmi.d.ts","sourceRoot":"","sources":["../../../src/react/useSyncDynamicWagmi/useSyncDynamicWagmi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,eAClB,yBAAyB,gEAEpC,IAEF,CAAC"}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const require_syncDynamicWagmi = require('./syncDynamicWagmi-CkgWtmHt.cjs');
|
|
2
|
+
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
3
|
+
let _dynamic_labs_sdk_client = require("@dynamic-labs-sdk/client");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
|
|
6
|
+
//#region src/react/useSyncDynamicWagmi/useSyncDynamicWagmi.ts
|
|
7
|
+
/**
|
|
8
|
+
* Keeps a wagmi `Config` in sync with Dynamic's selected EVM wallet account.
|
|
9
|
+
*
|
|
10
|
+
* Whenever the selected EVM account changes (login, wallet switch, logout),
|
|
11
|
+
* wagmi's `connect` / `disconnect` are driven so `useAccount` and the rest of
|
|
12
|
+
* the wagmi hooks mirror Dynamic. Dynamic stays the source of truth; wagmi is a
|
|
13
|
+
* read-only mirror.
|
|
14
|
+
*
|
|
15
|
+
* This is a thin React wrapper around the vanilla `syncDynamicWagmi`: the effect
|
|
16
|
+
* only starts the sync on mount and stops it (unsubscribe + disconnect) on
|
|
17
|
+
* unmount or when `config` / `client` change. All sync logic lives in
|
|
18
|
+
* `syncDynamicWagmi`. Prefer the `SyncDynamicWagmi` component if you just want to
|
|
19
|
+
* drop it into your tree.
|
|
20
|
+
*
|
|
21
|
+
* @param params.config - The wagmi config to synchronize.
|
|
22
|
+
* @param [client] - The Dynamic client instance. Only required when using
|
|
23
|
+
* multiple Dynamic clients.
|
|
24
|
+
* @see {@link syncDynamicWagmi}
|
|
25
|
+
* @notInstrumented
|
|
26
|
+
*/
|
|
27
|
+
const useSyncDynamicWagmi = ({ config }, client = (0, _dynamic_labs_sdk_client.getDefaultClient)()) => {
|
|
28
|
+
(0, react.useEffect)(() => require_syncDynamicWagmi.syncDynamicWagmi({ config }, client), [config, client]);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/react/SyncDynamicWagmi/SyncDynamicWagmi.tsx
|
|
33
|
+
/**
|
|
34
|
+
* Drop-in component that keeps a wagmi `Config` in sync with Dynamic's selected
|
|
35
|
+
* EVM wallet account. Renders nothing.
|
|
36
|
+
*
|
|
37
|
+
* Place it inside your `DynamicProvider` / `WagmiProvider` /
|
|
38
|
+
* `QueryClientProvider` tree so the wagmi hooks mirror Dynamic's wallet state.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <DynamicProvider client={client}>
|
|
43
|
+
* <WagmiProvider config={config}>
|
|
44
|
+
* <QueryClientProvider client={queryClient}>
|
|
45
|
+
* <SyncDynamicWagmi config={config} />
|
|
46
|
+
* <App />
|
|
47
|
+
* </QueryClientProvider>
|
|
48
|
+
* </WagmiProvider>
|
|
49
|
+
* </DynamicProvider>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @notInstrumented
|
|
53
|
+
*/
|
|
54
|
+
const SyncDynamicWagmi = ({ config, client }) => {
|
|
55
|
+
useSyncDynamicWagmi({ config }, client);
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/exports/react.ts
|
|
61
|
+
(0, _dynamic_labs_sdk_assert_package_version.assertPackageVersion)(require_syncDynamicWagmi.name, require_syncDynamicWagmi.version);
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.SyncDynamicWagmi = SyncDynamicWagmi;
|
|
65
|
+
exports.useSyncDynamicWagmi = useSyncDynamicWagmi;
|
|
66
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.cjs","names":["syncDynamicWagmi","SyncDynamicWagmi: FC<SyncDynamicWagmiProps>","packageName","packageVersion"],"sources":["../src/react/useSyncDynamicWagmi/useSyncDynamicWagmi.ts","../src/react/SyncDynamicWagmi/SyncDynamicWagmi.tsx","../src/exports/react.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport type { Config } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { syncDynamicWagmi } from '../../syncDynamicWagmi';\n\nexport type UseSyncDynamicWagmiParams = {\n /**\n * The wagmi config to keep in sync with Dynamic's selected EVM wallet account.\n */\n config: Config;\n};\n\n/**\n * Keeps a wagmi `Config` in sync with Dynamic's selected EVM wallet account.\n *\n * Whenever the selected EVM account changes (login, wallet switch, logout),\n * wagmi's `connect` / `disconnect` are driven so `useAccount` and the rest of\n * the wagmi hooks mirror Dynamic. Dynamic stays the source of truth; wagmi is a\n * read-only mirror.\n *\n * This is a thin React wrapper around the vanilla `syncDynamicWagmi`: the effect\n * only starts the sync on mount and stops it (unsubscribe + disconnect) on\n * unmount or when `config` / `client` change. All sync logic lives in\n * `syncDynamicWagmi`. Prefer the `SyncDynamicWagmi` component if you just want to\n * drop it into your tree.\n *\n * @param params.config - The wagmi config to synchronize.\n * @param [client] - The Dynamic client instance. Only required when using\n * multiple Dynamic clients.\n * @see {@link syncDynamicWagmi}\n * @notInstrumented\n */\nexport const useSyncDynamicWagmi = (\n { config }: UseSyncDynamicWagmiParams,\n client = getDefaultClient()\n): void => {\n useEffect(() => syncDynamicWagmi({ config }, client), [config, client]);\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport type { Config } from '@wagmi/core';\nimport type { FC } from 'react';\n\nimport { useSyncDynamicWagmi } from '../useSyncDynamicWagmi';\n\nexport type SyncDynamicWagmiProps = {\n /**\n * The Dynamic client instance. Only required when using multiple Dynamic\n * clients.\n */\n client?: DynamicClient;\n /**\n * The wagmi config to keep in sync with Dynamic's selected EVM wallet account.\n */\n config: Config;\n};\n\n/**\n * Drop-in component that keeps a wagmi `Config` in sync with Dynamic's selected\n * EVM wallet account. Renders nothing.\n *\n * Place it inside your `DynamicProvider` / `WagmiProvider` /\n * `QueryClientProvider` tree so the wagmi hooks mirror Dynamic's wallet state.\n *\n * @example\n * ```tsx\n * <DynamicProvider client={client}>\n * <WagmiProvider config={config}>\n * <QueryClientProvider client={queryClient}>\n * <SyncDynamicWagmi config={config} />\n * <App />\n * </QueryClientProvider>\n * </WagmiProvider>\n * </DynamicProvider>\n * ```\n *\n * @notInstrumented\n */\nexport const SyncDynamicWagmi: FC<SyncDynamicWagmiProps> = ({\n config,\n client,\n}) => {\n useSyncDynamicWagmi({ config }, client);\n\n return null;\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { SyncDynamicWagmi } from '../react/SyncDynamicWagmi';\nexport type { SyncDynamicWagmiProps } from '../react/SyncDynamicWagmi';\nexport { useSyncDynamicWagmi } from '../react/useSyncDynamicWagmi';\nexport type { UseSyncDynamicWagmiParams } from '../react/useSyncDynamicWagmi';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBACX,EAAE,UACF,yDAA2B,KAClB;AACT,4BAAgBA,0CAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;ACEzE,MAAaC,oBAA+C,EAC1D,QACA,aACI;AACJ,qBAAoB,EAAE,QAAQ,EAAE,OAAO;AAEvC,QAAO;;;;;mECvCYC,+BAAaC,iCAAe"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { a as version, i as name, t as syncDynamicWagmi } from "./syncDynamicWagmi-4t63--sw.esm.js";
|
|
2
|
+
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
3
|
+
import { getDefaultClient } from "@dynamic-labs-sdk/client";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/react/useSyncDynamicWagmi/useSyncDynamicWagmi.ts
|
|
7
|
+
/**
|
|
8
|
+
* Keeps a wagmi `Config` in sync with Dynamic's selected EVM wallet account.
|
|
9
|
+
*
|
|
10
|
+
* Whenever the selected EVM account changes (login, wallet switch, logout),
|
|
11
|
+
* wagmi's `connect` / `disconnect` are driven so `useAccount` and the rest of
|
|
12
|
+
* the wagmi hooks mirror Dynamic. Dynamic stays the source of truth; wagmi is a
|
|
13
|
+
* read-only mirror.
|
|
14
|
+
*
|
|
15
|
+
* This is a thin React wrapper around the vanilla `syncDynamicWagmi`: the effect
|
|
16
|
+
* only starts the sync on mount and stops it (unsubscribe + disconnect) on
|
|
17
|
+
* unmount or when `config` / `client` change. All sync logic lives in
|
|
18
|
+
* `syncDynamicWagmi`. Prefer the `SyncDynamicWagmi` component if you just want to
|
|
19
|
+
* drop it into your tree.
|
|
20
|
+
*
|
|
21
|
+
* @param params.config - The wagmi config to synchronize.
|
|
22
|
+
* @param [client] - The Dynamic client instance. Only required when using
|
|
23
|
+
* multiple Dynamic clients.
|
|
24
|
+
* @see {@link syncDynamicWagmi}
|
|
25
|
+
* @notInstrumented
|
|
26
|
+
*/
|
|
27
|
+
const useSyncDynamicWagmi = ({ config }, client = getDefaultClient()) => {
|
|
28
|
+
useEffect(() => syncDynamicWagmi({ config }, client), [config, client]);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/react/SyncDynamicWagmi/SyncDynamicWagmi.tsx
|
|
33
|
+
/**
|
|
34
|
+
* Drop-in component that keeps a wagmi `Config` in sync with Dynamic's selected
|
|
35
|
+
* EVM wallet account. Renders nothing.
|
|
36
|
+
*
|
|
37
|
+
* Place it inside your `DynamicProvider` / `WagmiProvider` /
|
|
38
|
+
* `QueryClientProvider` tree so the wagmi hooks mirror Dynamic's wallet state.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <DynamicProvider client={client}>
|
|
43
|
+
* <WagmiProvider config={config}>
|
|
44
|
+
* <QueryClientProvider client={queryClient}>
|
|
45
|
+
* <SyncDynamicWagmi config={config} />
|
|
46
|
+
* <App />
|
|
47
|
+
* </QueryClientProvider>
|
|
48
|
+
* </WagmiProvider>
|
|
49
|
+
* </DynamicProvider>
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @notInstrumented
|
|
53
|
+
*/
|
|
54
|
+
const SyncDynamicWagmi = ({ config, client }) => {
|
|
55
|
+
useSyncDynamicWagmi({ config }, client);
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/exports/react.ts
|
|
61
|
+
assertPackageVersion(name, version);
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { SyncDynamicWagmi, useSyncDynamicWagmi };
|
|
65
|
+
//# sourceMappingURL=react.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.esm.js","names":["SyncDynamicWagmi: FC<SyncDynamicWagmiProps>","packageName","packageVersion"],"sources":["../src/react/useSyncDynamicWagmi/useSyncDynamicWagmi.ts","../src/react/SyncDynamicWagmi/SyncDynamicWagmi.tsx","../src/exports/react.ts"],"sourcesContent":["import { getDefaultClient } from '@dynamic-labs-sdk/client';\nimport type { Config } from '@wagmi/core';\nimport { useEffect } from 'react';\n\nimport { syncDynamicWagmi } from '../../syncDynamicWagmi';\n\nexport type UseSyncDynamicWagmiParams = {\n /**\n * The wagmi config to keep in sync with Dynamic's selected EVM wallet account.\n */\n config: Config;\n};\n\n/**\n * Keeps a wagmi `Config` in sync with Dynamic's selected EVM wallet account.\n *\n * Whenever the selected EVM account changes (login, wallet switch, logout),\n * wagmi's `connect` / `disconnect` are driven so `useAccount` and the rest of\n * the wagmi hooks mirror Dynamic. Dynamic stays the source of truth; wagmi is a\n * read-only mirror.\n *\n * This is a thin React wrapper around the vanilla `syncDynamicWagmi`: the effect\n * only starts the sync on mount and stops it (unsubscribe + disconnect) on\n * unmount or when `config` / `client` change. All sync logic lives in\n * `syncDynamicWagmi`. Prefer the `SyncDynamicWagmi` component if you just want to\n * drop it into your tree.\n *\n * @param params.config - The wagmi config to synchronize.\n * @param [client] - The Dynamic client instance. Only required when using\n * multiple Dynamic clients.\n * @see {@link syncDynamicWagmi}\n * @notInstrumented\n */\nexport const useSyncDynamicWagmi = (\n { config }: UseSyncDynamicWagmiParams,\n client = getDefaultClient()\n): void => {\n useEffect(() => syncDynamicWagmi({ config }, client), [config, client]);\n};\n","import type { DynamicClient } from '@dynamic-labs-sdk/client';\nimport type { Config } from '@wagmi/core';\nimport type { FC } from 'react';\n\nimport { useSyncDynamicWagmi } from '../useSyncDynamicWagmi';\n\nexport type SyncDynamicWagmiProps = {\n /**\n * The Dynamic client instance. Only required when using multiple Dynamic\n * clients.\n */\n client?: DynamicClient;\n /**\n * The wagmi config to keep in sync with Dynamic's selected EVM wallet account.\n */\n config: Config;\n};\n\n/**\n * Drop-in component that keeps a wagmi `Config` in sync with Dynamic's selected\n * EVM wallet account. Renders nothing.\n *\n * Place it inside your `DynamicProvider` / `WagmiProvider` /\n * `QueryClientProvider` tree so the wagmi hooks mirror Dynamic's wallet state.\n *\n * @example\n * ```tsx\n * <DynamicProvider client={client}>\n * <WagmiProvider config={config}>\n * <QueryClientProvider client={queryClient}>\n * <SyncDynamicWagmi config={config} />\n * <App />\n * </QueryClientProvider>\n * </WagmiProvider>\n * </DynamicProvider>\n * ```\n *\n * @notInstrumented\n */\nexport const SyncDynamicWagmi: FC<SyncDynamicWagmiProps> = ({\n config,\n client,\n}) => {\n useSyncDynamicWagmi({ config }, client);\n\n return null;\n};\n","import { assertPackageVersion } from '@dynamic-labs-sdk/assert-package-version';\n\nimport {\n name as packageName,\n version as packageVersion,\n} from '../../package.json';\nassertPackageVersion(packageName, packageVersion);\n\nexport { SyncDynamicWagmi } from '../react/SyncDynamicWagmi';\nexport type { SyncDynamicWagmiProps } from '../react/SyncDynamicWagmi';\nexport { useSyncDynamicWagmi } from '../react/useSyncDynamicWagmi';\nexport type { UseSyncDynamicWagmiParams } from '../react/useSyncDynamicWagmi';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,uBACX,EAAE,UACF,SAAS,kBAAkB,KAClB;AACT,iBAAgB,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,QAAQ,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;ACEzE,MAAaA,oBAA+C,EAC1D,QACA,aACI;AACJ,qBAAoB,EAAE,QAAQ,EAAE,OAAO;AAEvC,QAAO;;;;;ACvCT,qBAAqBC,MAAaC,QAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/syncDynamicWagmi/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
|