@sodax/dapp-kit 2.0.0-rc.1 → 2.0.0-rc.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sodax/dapp-kit",
3
3
  "license": "MIT",
4
- "version": "2.0.0-rc.1",
4
+ "version": "2.0.0-rc.3",
5
5
  "description": "dapp-kit of New World",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "viem": "2.29.2",
21
- "@sodax/sdk": "2.0.0-rc.1"
21
+ "@sodax/sdk": "2.0.0-rc.3"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@tanstack/react-query": "5.87.4",
@@ -33,7 +33,7 @@
33
33
  "react": ">=18"
34
34
  },
35
35
  "engines": {
36
- "node": ">=18.0.0"
36
+ "node": ">=20.0.0"
37
37
  },
38
38
  "exports": {
39
39
  "./package.json": "./package.json",
@@ -58,6 +58,7 @@
58
58
  "check:ai-imports": "bash ./scripts/check-ai-imports.sh",
59
59
  "check:ai-snippets": "bash ./scripts/check-ai-snippets.sh",
60
60
  "check:ai-keys": "bash ./scripts/check-ai-keys.sh",
61
- "check:ai-consistency": "bash ./scripts/check-ai-consistency.sh"
61
+ "check:ai-consistency": "bash ./scripts/check-ai-consistency.sh",
62
+ "check:ai": "pnpm run check:ai-exported && pnpm run check:ai-scope && pnpm run check:ai-links && pnpm run check:ai-imports && pnpm run check:ai-snippets && pnpm run check:ai-keys && pnpm run check:ai-consistency"
62
63
  }
63
64
  }
@@ -1,4 +1,4 @@
1
- import { useMemo, useRef, type ReactNode, type ReactElement } from 'react';
1
+ import { useMemo, type ReactNode, type ReactElement } from 'react';
2
2
  import { Sodax, type SodaxConfig } from '@sodax/sdk';
3
3
  import { SodaxContext } from '@/contexts/index.js';
4
4
  import type { DeepPartial } from '@sodax/sdk';
@@ -6,20 +6,24 @@ import type { DeepPartial } from '@sodax/sdk';
6
6
  interface SodaxProviderProps {
7
7
  children: ReactNode;
8
8
  /**
9
- * Sodax config (overrides defaults including rpcUrls). **Read-once at mount**
10
- * changes after first render are ignored to prevent re-instantiating the SDK
11
- * from unstable parent references. To switch config (e.g. testnet mainnet),
12
- * unmount/remount the provider.
9
+ * Sodax SDK config. Tracked by **reference** - a new identity re-instantiates the
10
+ * SDK. Hoist to a module constant or wrap in `useMemo`; include any value the SDK
11
+ * should react to (e.g. solver env) in the deps. Inline `{...}` re-creates the SDK
12
+ * every parent render and resets every `useSodaxContext` consumer.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const config = useMemo(() => ({ solver: solverMap[env] }), [env]);
17
+ * <SodaxProvider config={config}>...</SodaxProvider>
18
+ * ```
13
19
  */
14
20
  config?: DeepPartial<SodaxConfig>;
15
21
  }
16
22
 
23
+ /** Root provider for `@sodax/dapp-kit`. Must be paired with `QueryClientProvider`. */
17
24
  export const SodaxProvider = ({ children, config }: SodaxProviderProps): ReactElement => {
18
- // Freeze config on first render so the SDK instance and consumers share one
19
- // snapshot (matches SodaxWalletProvider semantic).
20
- const configRef = useRef<DeepPartial<SodaxConfig> | undefined>(config);
21
- const frozen = configRef.current;
22
- const sodax = useMemo(() => new Sodax(frozen), [frozen]);
25
+ const sodax = useMemo(() => new Sodax(config), [config]);
26
+ const contextValue = useMemo(() => ({ sodax }), [sodax]);
23
27
 
24
- return <SodaxContext.Provider value={{ sodax }}>{children}</SodaxContext.Provider>;
28
+ return <SodaxContext.Provider value={contextValue}>{children}</SodaxContext.Provider>;
25
29
  };