@account-kit/privy-integration 4.73.1-alpha.0 → 4.74.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.
Files changed (80) hide show
  1. package/README.md +61 -21
  2. package/dist/esm/Provider.d.ts +71 -4
  3. package/dist/esm/Provider.js +109 -4
  4. package/dist/esm/Provider.js.map +1 -1
  5. package/dist/esm/hooks/internal/useEmbeddedWallet.d.ts +4 -3
  6. package/dist/esm/hooks/internal/useEmbeddedWallet.js +13 -5
  7. package/dist/esm/hooks/internal/useEmbeddedWallet.js.map +1 -1
  8. package/dist/esm/hooks/useAlchemyClient.d.ts +10 -5
  9. package/dist/esm/hooks/useAlchemyClient.js +36 -17
  10. package/dist/esm/hooks/useAlchemyClient.js.map +1 -1
  11. package/dist/esm/hooks/useAlchemyPrepareSwap.js +3 -6
  12. package/dist/esm/hooks/useAlchemyPrepareSwap.js.map +1 -1
  13. package/dist/esm/hooks/useAlchemySendTransaction.js +11 -9
  14. package/dist/esm/hooks/useAlchemySendTransaction.js.map +1 -1
  15. package/dist/esm/hooks/useAlchemySubmitSwap.js +1 -1
  16. package/dist/esm/hooks/useAlchemySubmitSwap.js.map +1 -1
  17. package/dist/esm/types.d.ts +6 -0
  18. package/dist/esm/types.js.map +1 -1
  19. package/dist/esm/version.d.ts +1 -1
  20. package/dist/esm/version.js +1 -1
  21. package/dist/esm/version.js.map +1 -1
  22. package/dist/types/Provider.d.ts +71 -4
  23. package/dist/types/Provider.d.ts.map +1 -1
  24. package/dist/types/hooks/internal/useEmbeddedWallet.d.ts +4 -3
  25. package/dist/types/hooks/internal/useEmbeddedWallet.d.ts.map +1 -1
  26. package/dist/types/hooks/useAlchemyClient.d.ts +10 -5
  27. package/dist/types/hooks/useAlchemyClient.d.ts.map +1 -1
  28. package/dist/types/hooks/useAlchemyPrepareSwap.d.ts.map +1 -1
  29. package/dist/types/hooks/useAlchemySendTransaction.d.ts.map +1 -1
  30. package/dist/types/types.d.ts +6 -0
  31. package/dist/types/types.d.ts.map +1 -1
  32. package/dist/types/version.d.ts +1 -1
  33. package/dist/types/version.d.ts.map +1 -1
  34. package/package.json +4 -17
  35. package/src/hooks/internal/useEmbeddedWallet.ts +20 -5
  36. package/src/hooks/useAlchemyClient.ts +61 -26
  37. package/src/hooks/useAlchemyPrepareSwap.ts +3 -6
  38. package/src/hooks/useAlchemySendTransaction.ts +16 -13
  39. package/src/hooks/useAlchemySubmitSwap.ts +1 -1
  40. package/src/types.ts +7 -0
  41. package/src/version.ts +1 -1
  42. package/dist/esm/adapters/react-native.d.ts +0 -6
  43. package/dist/esm/adapters/react-native.js +0 -46
  44. package/dist/esm/adapters/react-native.js.map +0 -1
  45. package/dist/esm/adapters/types.d.ts +0 -44
  46. package/dist/esm/adapters/types.js +0 -2
  47. package/dist/esm/adapters/types.js.map +0 -1
  48. package/dist/esm/adapters/web.d.ts +0 -6
  49. package/dist/esm/adapters/web.js +0 -50
  50. package/dist/esm/adapters/web.js.map +0 -1
  51. package/dist/esm/context/AlchemyContext.d.ts +0 -62
  52. package/dist/esm/context/AlchemyContext.js +0 -105
  53. package/dist/esm/context/AlchemyContext.js.map +0 -1
  54. package/dist/esm/providers/ReactNativeProvider.d.ts +0 -33
  55. package/dist/esm/providers/ReactNativeProvider.js +0 -37
  56. package/dist/esm/providers/ReactNativeProvider.js.map +0 -1
  57. package/dist/esm/providers/WebProvider.d.ts +0 -33
  58. package/dist/esm/providers/WebProvider.js +0 -37
  59. package/dist/esm/providers/WebProvider.js.map +0 -1
  60. package/dist/esm/react-native.d.ts +0 -11
  61. package/dist/esm/react-native.js +0 -13
  62. package/dist/esm/react-native.js.map +0 -1
  63. package/dist/types/adapters/react-native.d.ts +0 -7
  64. package/dist/types/adapters/react-native.d.ts.map +0 -1
  65. package/dist/types/adapters/types.d.ts +0 -45
  66. package/dist/types/adapters/types.d.ts.map +0 -1
  67. package/dist/types/adapters/web.d.ts +0 -7
  68. package/dist/types/adapters/web.d.ts.map +0 -1
  69. package/dist/types/context/AlchemyContext.d.ts +0 -63
  70. package/dist/types/context/AlchemyContext.d.ts.map +0 -1
  71. package/dist/types/providers/ReactNativeProvider.d.ts +0 -34
  72. package/dist/types/providers/ReactNativeProvider.d.ts.map +0 -1
  73. package/dist/types/providers/WebProvider.d.ts +0 -34
  74. package/dist/types/providers/WebProvider.d.ts.map +0 -1
  75. package/dist/types/react-native.d.ts +0 -12
  76. package/dist/types/react-native.d.ts.map +0 -1
  77. package/src/adapters/react-native.ts +0 -71
  78. package/src/adapters/types.ts +0 -56
  79. package/src/adapters/web.ts +0 -73
  80. package/src/react-native.ts +0 -29
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlchemyContext.js","sourceRoot":"","sources":["../../../src/context/AlchemyContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,aAAa,EACb,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,OAAO,CAAC;AAKf;;GAEG;AACH,MAAM,oBAAoB,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,cAAc,GAAG,aAAa,CAAsB,IAAI,CAAC,CAAC;AAYhE,MAAM,kBAAkB,GAAG,aAAa,CAAqB,IAAI,CAAC,CAAC;AAUnE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,EACR,MAAM,EACN,OAAO,GACqB;IAC5B,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAEvD,uFAAuF;IACvF,qFAAqF;IACrF,MAAM,KAAK,GAAG,MAAM,CAAc;QAChC,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IAEH,2DAA2D;IAC3D,MAAM,oBAAoB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE3D,mEAAmE;IACnE,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;QACtD,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC;QACvD,MAAM,oBAAoB,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;QAEnD,wBAAwB;QACxB,IAAI,gBAAgB,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAC5B,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;QAChC,CAAC;QAED,2DAA2D;QAC3D,IACE,aAAa;YACb,iBAAiB;YACjB,oBAAoB;YACpB,iBAAiB,KAAK,oBAAoB,EAC1C,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAC5B,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;QAChC,CAAC;QAED,8BAA8B;QAC9B,oBAAoB,CAAC,OAAO,GAAG,aAAa,CAAC;QAC7C,oBAAoB,CAAC,OAAO,GAAG,oBAAoB,CAAC;IACtD,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3C,OAAO,CACL,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAC1C,KAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACrC,KAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,OAAO,YAC9C,QAAQ,GACmB,GACN,GACI,CACjC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,mHAAmH,CACpH,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type PropsWithChildren,\n createContext,\n useContext,\n useRef,\n useEffect,\n} from \"react\";\nimport type { SmartWalletClient } from \"@account-kit/wallet-client\";\nimport type { AlchemyProviderConfig } from \"../types.js\";\nimport type { PrivyAdapter } from \"../adapters/types.js\";\n\n/**\n * Context for Alchemy configuration\n */\nconst AlchemyConfigContext = createContext<AlchemyProviderConfig | null>(null);\n\n/**\n * Context for the platform adapter\n */\nconst AdapterContext = createContext<PrivyAdapter | null>(null);\n\n/**\n * Client cache stored in React tree (similar to QueryClient in React Query)\n *\n * @internal\n */\ninterface ClientCache {\n client: SmartWalletClient | null;\n cacheKey: string | null;\n}\n\nconst ClientCacheContext = createContext<ClientCache | null>(null);\n\n/**\n * Props for AlchemyContextProvider\n */\ninterface AlchemyContextProviderProps extends PropsWithChildren {\n config: AlchemyProviderConfig;\n adapter: PrivyAdapter;\n}\n\n/**\n * Internal provider component that manages Alchemy context\n * Used by both web and React Native providers\n *\n * @internal\n * @param {AlchemyContextProviderProps} props - Component props\n * @param {React.ReactNode} props.children - React children to wrap with context\n * @param {AlchemyProviderConfig} props.config - Alchemy configuration\n * @param {PrivyAdapter} props.adapter - Platform adapter\n * @returns {JSX.Element} Context provider component\n */\nexport function AlchemyContextProvider({\n children,\n config,\n adapter,\n}: AlchemyContextProviderProps) {\n const { authenticated, user } = adapter.usePrivyAuth();\n\n // Store cache in a ref - persists across renders but scoped to this component instance\n // This makes it SSR-safe (each request gets its own cache) and React StrictMode-safe\n const cache = useRef<ClientCache>({\n client: null,\n cacheKey: null,\n });\n\n // Track previous state to detect logout and wallet changes\n const prevAuthenticatedRef = useRef(authenticated);\n const prevWalletAddressRef = useRef(user?.wallet?.address);\n\n // Automatically reset cache when user logs out or switches wallets\n useEffect(() => {\n const wasAuthenticated = prevAuthenticatedRef.current;\n const prevWalletAddress = prevWalletAddressRef.current;\n const currentWalletAddress = user?.wallet?.address;\n\n // Reset cache on logout\n if (wasAuthenticated && !authenticated) {\n cache.current.client = null;\n cache.current.cacheKey = null;\n }\n\n // Reset cache on wallet address change (account switching)\n if (\n authenticated &&\n prevWalletAddress &&\n currentWalletAddress &&\n prevWalletAddress !== currentWalletAddress\n ) {\n cache.current.client = null;\n cache.current.cacheKey = null;\n }\n\n // Update refs for next render\n prevAuthenticatedRef.current = authenticated;\n prevWalletAddressRef.current = currentWalletAddress;\n }, [authenticated, user?.wallet?.address]);\n\n return (\n <AlchemyConfigContext.Provider value={config}>\n <AdapterContext.Provider value={adapter}>\n <ClientCacheContext.Provider value={cache.current}>\n {children}\n </ClientCacheContext.Provider>\n </AdapterContext.Provider>\n </AlchemyConfigContext.Provider>\n );\n}\n\n/**\n * Hook to access Alchemy provider configuration\n * Must be used within an <AlchemyProvider> component\n *\n * @returns {AlchemyProviderConfig} The current Alchemy configuration\n * @throws {Error} If used outside of AlchemyProvider\n *\n * @example\n * ```tsx\n * const config = useAlchemyConfig();\n * console.log('Policy ID:', config.policyId);\n * ```\n */\nexport function useAlchemyConfig(): AlchemyProviderConfig {\n const context = useContext(AlchemyConfigContext);\n if (!context) {\n throw new Error(\"useAlchemyConfig must be used within <AlchemyProvider />\");\n }\n return context;\n}\n\n/**\n * Hook to access the platform adapter\n * Must be used within an <AlchemyProvider> component\n *\n * @internal\n * @returns {PrivyAdapter} The platform adapter\n */\nexport function useAdapter(): PrivyAdapter {\n const context = useContext(AdapterContext);\n if (!context) {\n throw new Error(\n \"useAdapter must be used within <AlchemyProvider />. Make sure AlchemyProvider is nested inside PrivyProvider.\",\n );\n }\n return context;\n}\n\n/**\n * Hook to access the client cache (internal use only)\n *\n * @internal\n * @returns {ClientCache} The client cache object\n */\nexport function useClientCache(): ClientCache {\n const context = useContext(ClientCacheContext);\n if (!context) {\n throw new Error(\n \"useClientCache must be used within <AlchemyProvider />. Make sure AlchemyProvider is nested inside PrivyProvider.\",\n );\n }\n return context;\n}\n"]}
@@ -1,33 +0,0 @@
1
- import type { PropsWithChildren } from "react";
2
- import type { AlchemyProviderConfig } from "../types.js";
3
- /**
4
- * Provider component for React Native (Expo) applications
5
- * Must be nested INSIDE PrivyProvider from @privy-io/expo
6
- *
7
- * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
8
- * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
9
- * @param {string} [props.apiKey] - Your Alchemy API key
10
- * @param {string} [props.jwt] - JWT token for authentication
11
- * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
12
- * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
13
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
14
- * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
15
- * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
16
- * @returns {JSX.Element} Provider component
17
- *
18
- * @example
19
- * ```tsx
20
- * import { PrivyProvider } from '@privy-io/expo';
21
- * import { AlchemyProvider } from '@account-kit/privy-integration/react-native';
22
- *
23
- * <PrivyProvider appId="..." clientId="...">
24
- * <AlchemyProvider
25
- * apiKey="your-alchemy-api-key"
26
- * policyId="your-gas-policy-id"
27
- * >
28
- * <YourApp />
29
- * </AlchemyProvider>
30
- * </PrivyProvider>
31
- * ```
32
- */
33
- export declare function AlchemyProvider({ children, ...config }: PropsWithChildren<AlchemyProviderConfig>): import("react/jsx-runtime").JSX.Element;
@@ -1,37 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AlchemyContextProvider } from "../context/AlchemyContext.js";
3
- import { reactNativeAdapter } from "../adapters/react-native.js";
4
- /**
5
- * Provider component for React Native (Expo) applications
6
- * Must be nested INSIDE PrivyProvider from @privy-io/expo
7
- *
8
- * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
9
- * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
10
- * @param {string} [props.apiKey] - Your Alchemy API key
11
- * @param {string} [props.jwt] - JWT token for authentication
12
- * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
13
- * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
14
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
15
- * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
16
- * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
17
- * @returns {JSX.Element} Provider component
18
- *
19
- * @example
20
- * ```tsx
21
- * import { PrivyProvider } from '@privy-io/expo';
22
- * import { AlchemyProvider } from '@account-kit/privy-integration/react-native';
23
- *
24
- * <PrivyProvider appId="..." clientId="...">
25
- * <AlchemyProvider
26
- * apiKey="your-alchemy-api-key"
27
- * policyId="your-gas-policy-id"
28
- * >
29
- * <YourApp />
30
- * </AlchemyProvider>
31
- * </PrivyProvider>
32
- * ```
33
- */
34
- export function AlchemyProvider({ children, ...config }) {
35
- return (_jsx(AlchemyContextProvider, { config: config, adapter: reactNativeAdapter, children: children }));
36
- }
37
- //# sourceMappingURL=ReactNativeProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReactNativeProvider.js","sourceRoot":"","sources":["../../../src/providers/ReactNativeProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACgC;IACzC,OAAO,CACL,KAAC,sBAAsB,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,YAChE,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport { AlchemyContextProvider } from \"../context/AlchemyContext.js\";\nimport { reactNativeAdapter } from \"../adapters/react-native.js\";\nimport type { AlchemyProviderConfig } from \"../types.js\";\n\n/**\n * Provider component for React Native (Expo) applications\n * Must be nested INSIDE PrivyProvider from @privy-io/expo\n *\n * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props\n * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration\n * @param {string} [props.apiKey] - Your Alchemy API key\n * @param {string} [props.jwt] - JWT token for authentication\n * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains\n * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana\n * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains\n * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana\n * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)\n * @returns {JSX.Element} Provider component\n *\n * @example\n * ```tsx\n * import { PrivyProvider } from '@privy-io/expo';\n * import { AlchemyProvider } from '@account-kit/privy-integration/react-native';\n *\n * <PrivyProvider appId=\"...\" clientId=\"...\">\n * <AlchemyProvider\n * apiKey=\"your-alchemy-api-key\"\n * policyId=\"your-gas-policy-id\"\n * >\n * <YourApp />\n * </AlchemyProvider>\n * </PrivyProvider>\n * ```\n */\nexport function AlchemyProvider({\n children,\n ...config\n}: PropsWithChildren<AlchemyProviderConfig>) {\n return (\n <AlchemyContextProvider config={config} adapter={reactNativeAdapter}>\n {children}\n </AlchemyContextProvider>\n );\n}\n"]}
@@ -1,33 +0,0 @@
1
- import type { PropsWithChildren } from "react";
2
- import type { AlchemyProviderConfig } from "../types.js";
3
- /**
4
- * Provider component for React web applications
5
- * Must be nested INSIDE PrivyProvider from @privy-io/react-auth
6
- *
7
- * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
8
- * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
9
- * @param {string} [props.apiKey] - Your Alchemy API key
10
- * @param {string} [props.jwt] - JWT token for authentication
11
- * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
12
- * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
13
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
14
- * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
15
- * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
16
- * @returns {JSX.Element} Provider component
17
- *
18
- * @example
19
- * ```tsx
20
- * import { PrivyProvider } from '@privy-io/react-auth';
21
- * import { AlchemyProvider } from '@account-kit/privy-integration';
22
- *
23
- * <PrivyProvider appId="...">
24
- * <AlchemyProvider
25
- * apiKey="your-alchemy-api-key"
26
- * policyId="your-gas-policy-id"
27
- * >
28
- * <YourApp />
29
- * </AlchemyProvider>
30
- * </PrivyProvider>
31
- * ```
32
- */
33
- export declare function AlchemyProvider({ children, ...config }: PropsWithChildren<AlchemyProviderConfig>): import("react/jsx-runtime").JSX.Element;
@@ -1,37 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AlchemyContextProvider } from "../context/AlchemyContext.js";
3
- import { webAdapter } from "../adapters/web.js";
4
- /**
5
- * Provider component for React web applications
6
- * Must be nested INSIDE PrivyProvider from @privy-io/react-auth
7
- *
8
- * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
9
- * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
10
- * @param {string} [props.apiKey] - Your Alchemy API key
11
- * @param {string} [props.jwt] - JWT token for authentication
12
- * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
13
- * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
14
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
15
- * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
16
- * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
17
- * @returns {JSX.Element} Provider component
18
- *
19
- * @example
20
- * ```tsx
21
- * import { PrivyProvider } from '@privy-io/react-auth';
22
- * import { AlchemyProvider } from '@account-kit/privy-integration';
23
- *
24
- * <PrivyProvider appId="...">
25
- * <AlchemyProvider
26
- * apiKey="your-alchemy-api-key"
27
- * policyId="your-gas-policy-id"
28
- * >
29
- * <YourApp />
30
- * </AlchemyProvider>
31
- * </PrivyProvider>
32
- * ```
33
- */
34
- export function AlchemyProvider({ children, ...config }) {
35
- return (_jsx(AlchemyContextProvider, { config: config, adapter: webAdapter, children: children }));
36
- }
37
- //# sourceMappingURL=WebProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebProvider.js","sourceRoot":"","sources":["../../../src/providers/WebProvider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACgC;IACzC,OAAO,CACL,KAAC,sBAAsB,IAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,YACxD,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport { AlchemyContextProvider } from \"../context/AlchemyContext.js\";\nimport { webAdapter } from \"../adapters/web.js\";\nimport type { AlchemyProviderConfig } from \"../types.js\";\n\n/**\n * Provider component for React web applications\n * Must be nested INSIDE PrivyProvider from @privy-io/react-auth\n *\n * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props\n * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration\n * @param {string} [props.apiKey] - Your Alchemy API key\n * @param {string} [props.jwt] - JWT token for authentication\n * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains\n * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana\n * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains\n * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana\n * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)\n * @returns {JSX.Element} Provider component\n *\n * @example\n * ```tsx\n * import { PrivyProvider } from '@privy-io/react-auth';\n * import { AlchemyProvider } from '@account-kit/privy-integration';\n *\n * <PrivyProvider appId=\"...\">\n * <AlchemyProvider\n * apiKey=\"your-alchemy-api-key\"\n * policyId=\"your-gas-policy-id\"\n * >\n * <YourApp />\n * </AlchemyProvider>\n * </PrivyProvider>\n * ```\n */\nexport function AlchemyProvider({\n children,\n ...config\n}: PropsWithChildren<AlchemyProviderConfig>) {\n return (\n <AlchemyContextProvider config={config} adapter={webAdapter}>\n {children}\n </AlchemyContextProvider>\n );\n}\n"]}
@@ -1,11 +0,0 @@
1
- /**
2
- * React Native (Expo) entry point
3
- * Import from '@account-kit/privy-integration/react-native' in Expo apps
4
- */
5
- export { AlchemyProvider } from "./providers/ReactNativeProvider.js";
6
- export { useAlchemyConfig } from "./context/AlchemyContext.js";
7
- export { useAlchemyClient } from "./hooks/useAlchemyClient.js";
8
- export { useAlchemySendTransaction } from "./hooks/useAlchemySendTransaction.js";
9
- export { useAlchemyPrepareSwap } from "./hooks/useAlchemyPrepareSwap.js";
10
- export { useAlchemySubmitSwap } from "./hooks/useAlchemySubmitSwap.js";
11
- export type { AlchemyProviderConfig, UnsignedTransactionRequest, SendTransactionOptions, SendTransactionResult, UseSendTransactionResult, PrepareSwapRequest, PrepareSwapResult, UsePrepareSwapResult, SubmitSwapResult, UseSubmitSwapResult, SwapQuote, } from "./types.js";
@@ -1,13 +0,0 @@
1
- /**
2
- * React Native (Expo) entry point
3
- * Import from '@account-kit/privy-integration/react-native' in Expo apps
4
- */
5
- // Provider
6
- export { AlchemyProvider } from "./providers/ReactNativeProvider.js";
7
- export { useAlchemyConfig } from "./context/AlchemyContext.js";
8
- // Hooks
9
- export { useAlchemyClient } from "./hooks/useAlchemyClient.js";
10
- export { useAlchemySendTransaction } from "./hooks/useAlchemySendTransaction.js";
11
- export { useAlchemyPrepareSwap } from "./hooks/useAlchemyPrepareSwap.js";
12
- export { useAlchemySubmitSwap } from "./hooks/useAlchemySubmitSwap.js";
13
- //# sourceMappingURL=react-native.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../src/react-native.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,WAAW;AACX,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ;AACR,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["/**\n * React Native (Expo) entry point\n * Import from '@account-kit/privy-integration/react-native' in Expo apps\n */\n\n// Provider\nexport { AlchemyProvider } from \"./providers/ReactNativeProvider.js\";\nexport { useAlchemyConfig } from \"./context/AlchemyContext.js\";\n\n// Hooks\nexport { useAlchemyClient } from \"./hooks/useAlchemyClient.js\";\nexport { useAlchemySendTransaction } from \"./hooks/useAlchemySendTransaction.js\";\nexport { useAlchemyPrepareSwap } from \"./hooks/useAlchemyPrepareSwap.js\";\nexport { useAlchemySubmitSwap } from \"./hooks/useAlchemySubmitSwap.js\";\n\n// Types\nexport type {\n AlchemyProviderConfig,\n UnsignedTransactionRequest,\n SendTransactionOptions,\n SendTransactionResult,\n UseSendTransactionResult,\n PrepareSwapRequest,\n PrepareSwapResult,\n UsePrepareSwapResult,\n SubmitSwapResult,\n UseSubmitSwapResult,\n SwapQuote,\n} from \"./types.js\";\n"]}
@@ -1,7 +0,0 @@
1
- import type { PrivyAdapter } from "./types.js";
2
- /**
3
- * React Native (Expo) adapter for @privy-io/expo
4
- * Implements platform-specific hooks for React Native applications
5
- */
6
- export declare const reactNativeAdapter: PrivyAdapter;
7
- //# sourceMappingURL=react-native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../../src/adapters/react-native.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,YAAY,CAAC;AAY/E;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,YA2BhC,CAAC"}
@@ -1,45 +0,0 @@
1
- import type { Address, Authorization } from "viem";
2
- import type { AuthorizationRequest } from "@aa-sdk/core";
3
- /**
4
- * Platform-agnostic embedded wallet interface
5
- * Abstracts differences between @privy-io/react-auth and @privy-io/expo
6
- */
7
- export interface EmbeddedWallet {
8
- /** Wallet address */
9
- address: Address;
10
- /** Chain ID (may be CAIP-2 format like "eip155:1" or numeric) */
11
- chainId: string | number;
12
- /** Get EVM provider for the wallet */
13
- getEthereumProvider(): Promise<any>;
14
- }
15
- /**
16
- * Platform-agnostic Privy auth state
17
- */
18
- export interface PrivyAuthState {
19
- /** Whether user is authenticated */
20
- authenticated: boolean;
21
- /** User object (platform-specific, used for cache invalidation) */
22
- user: any;
23
- }
24
- /**
25
- * Adapter interface that each platform must implement
26
- * Provides platform-specific Privy functionality
27
- */
28
- export interface PrivyAdapter {
29
- /**
30
- * Hook to get embedded wallet
31
- * Must be called as a React hook (follows rules of hooks)
32
- */
33
- useEmbeddedWallet(): () => EmbeddedWallet;
34
- /**
35
- * Hook to get Privy authentication state
36
- * Must be called as a React hook (follows rules of hooks)
37
- */
38
- usePrivyAuth(): PrivyAuthState;
39
- /**
40
- * Hook to get EIP-7702 authorization signer (optional, web only)
41
- * Must be called as a React hook (follows rules of hooks)
42
- */
43
- useAuthorizationSigner?(): ((auth: AuthorizationRequest<number>) => Promise<Authorization<number, true>>) | null;
44
- }
45
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,OAAO,EAAE,OAAO,CAAC;IAEjB,iEAAiE;IACjE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB,sCAAsC;IACtC,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,aAAa,EAAE,OAAO,CAAC;IAEvB,mEAAmE;IACnE,IAAI,EAAE,GAAG,CAAC;CACX;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,iBAAiB,IAAI,MAAM,cAAc,CAAC;IAE1C;;;OAGG;IACH,YAAY,IAAI,cAAc,CAAC;IAE/B;;;OAGG;IACH,sBAAsB,CAAC,IACnB,CAAC,CACC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAC/B,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,GAC1C,IAAI,CAAC;CACV"}
@@ -1,7 +0,0 @@
1
- import type { PrivyAdapter } from "./types.js";
2
- /**
3
- * Web adapter for @privy-io/react-auth
4
- * Implements platform-specific hooks for React web applications
5
- */
6
- export declare const webAdapter: PrivyAdapter;
7
- //# sourceMappingURL=web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../../src/adapters/web.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,YAAY,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,YA2CxB,CAAC"}
@@ -1,63 +0,0 @@
1
- import { type PropsWithChildren } from "react";
2
- import type { SmartWalletClient } from "@account-kit/wallet-client";
3
- import type { AlchemyProviderConfig } from "../types.js";
4
- import type { PrivyAdapter } from "../adapters/types.js";
5
- /**
6
- * Client cache stored in React tree (similar to QueryClient in React Query)
7
- *
8
- * @internal
9
- */
10
- interface ClientCache {
11
- client: SmartWalletClient | null;
12
- cacheKey: string | null;
13
- }
14
- /**
15
- * Props for AlchemyContextProvider
16
- */
17
- interface AlchemyContextProviderProps extends PropsWithChildren {
18
- config: AlchemyProviderConfig;
19
- adapter: PrivyAdapter;
20
- }
21
- /**
22
- * Internal provider component that manages Alchemy context
23
- * Used by both web and React Native providers
24
- *
25
- * @internal
26
- * @param {AlchemyContextProviderProps} props - Component props
27
- * @param {React.ReactNode} props.children - React children to wrap with context
28
- * @param {AlchemyProviderConfig} props.config - Alchemy configuration
29
- * @param {PrivyAdapter} props.adapter - Platform adapter
30
- * @returns {JSX.Element} Context provider component
31
- */
32
- export declare function AlchemyContextProvider({ children, config, adapter, }: AlchemyContextProviderProps): import("react/jsx-runtime").JSX.Element;
33
- /**
34
- * Hook to access Alchemy provider configuration
35
- * Must be used within an <AlchemyProvider> component
36
- *
37
- * @returns {AlchemyProviderConfig} The current Alchemy configuration
38
- * @throws {Error} If used outside of AlchemyProvider
39
- *
40
- * @example
41
- * ```tsx
42
- * const config = useAlchemyConfig();
43
- * console.log('Policy ID:', config.policyId);
44
- * ```
45
- */
46
- export declare function useAlchemyConfig(): AlchemyProviderConfig;
47
- /**
48
- * Hook to access the platform adapter
49
- * Must be used within an <AlchemyProvider> component
50
- *
51
- * @internal
52
- * @returns {PrivyAdapter} The platform adapter
53
- */
54
- export declare function useAdapter(): PrivyAdapter;
55
- /**
56
- * Hook to access the client cache (internal use only)
57
- *
58
- * @internal
59
- * @returns {ClientCache} The client cache object
60
- */
61
- export declare function useClientCache(): ClientCache;
62
- export {};
63
- //# sourceMappingURL=AlchemyContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AlchemyContext.d.ts","sourceRoot":"","sources":["../../../src/context/AlchemyContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAKvB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAYzD;;;;GAIG;AACH,UAAU,WAAW;IACnB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAID;;GAEG;AACH,UAAU,2BAA4B,SAAQ,iBAAiB;IAC7D,MAAM,EAAE,qBAAqB,CAAC;IAC9B,OAAO,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,MAAM,EACN,OAAO,GACR,EAAE,2BAA2B,2CAmD7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAMxD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,IAAI,YAAY,CAQzC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C"}
@@ -1,34 +0,0 @@
1
- import type { PropsWithChildren } from "react";
2
- import type { AlchemyProviderConfig } from "../types.js";
3
- /**
4
- * Provider component for React Native (Expo) applications
5
- * Must be nested INSIDE PrivyProvider from @privy-io/expo
6
- *
7
- * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
8
- * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
9
- * @param {string} [props.apiKey] - Your Alchemy API key
10
- * @param {string} [props.jwt] - JWT token for authentication
11
- * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
12
- * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
13
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
14
- * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
15
- * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
16
- * @returns {JSX.Element} Provider component
17
- *
18
- * @example
19
- * ```tsx
20
- * import { PrivyProvider } from '@privy-io/expo';
21
- * import { AlchemyProvider } from '@account-kit/privy-integration/react-native';
22
- *
23
- * <PrivyProvider appId="..." clientId="...">
24
- * <AlchemyProvider
25
- * apiKey="your-alchemy-api-key"
26
- * policyId="your-gas-policy-id"
27
- * >
28
- * <YourApp />
29
- * </AlchemyProvider>
30
- * </PrivyProvider>
31
- * ```
32
- */
33
- export declare function AlchemyProvider({ children, ...config }: PropsWithChildren<AlchemyProviderConfig>): import("react/jsx-runtime").JSX.Element;
34
- //# sourceMappingURL=ReactNativeProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReactNativeProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/ReactNativeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,2CAM1C"}
@@ -1,34 +0,0 @@
1
- import type { PropsWithChildren } from "react";
2
- import type { AlchemyProviderConfig } from "../types.js";
3
- /**
4
- * Provider component for React web applications
5
- * Must be nested INSIDE PrivyProvider from @privy-io/react-auth
6
- *
7
- * @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
8
- * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
9
- * @param {string} [props.apiKey] - Your Alchemy API key
10
- * @param {string} [props.jwt] - JWT token for authentication
11
- * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
12
- * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
13
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
14
- * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
15
- * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
16
- * @returns {JSX.Element} Provider component
17
- *
18
- * @example
19
- * ```tsx
20
- * import { PrivyProvider } from '@privy-io/react-auth';
21
- * import { AlchemyProvider } from '@account-kit/privy-integration';
22
- *
23
- * <PrivyProvider appId="...">
24
- * <AlchemyProvider
25
- * apiKey="your-alchemy-api-key"
26
- * policyId="your-gas-policy-id"
27
- * >
28
- * <YourApp />
29
- * </AlchemyProvider>
30
- * </PrivyProvider>
31
- * ```
32
- */
33
- export declare function AlchemyProvider({ children, ...config }: PropsWithChildren<AlchemyProviderConfig>): import("react/jsx-runtime").JSX.Element;
34
- //# sourceMappingURL=WebProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/WebProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,2CAM1C"}
@@ -1,12 +0,0 @@
1
- /**
2
- * React Native (Expo) entry point
3
- * Import from '@account-kit/privy-integration/react-native' in Expo apps
4
- */
5
- export { AlchemyProvider } from "./providers/ReactNativeProvider.js";
6
- export { useAlchemyConfig } from "./context/AlchemyContext.js";
7
- export { useAlchemyClient } from "./hooks/useAlchemyClient.js";
8
- export { useAlchemySendTransaction } from "./hooks/useAlchemySendTransaction.js";
9
- export { useAlchemyPrepareSwap } from "./hooks/useAlchemyPrepareSwap.js";
10
- export { useAlchemySubmitSwap } from "./hooks/useAlchemySubmitSwap.js";
11
- export type { AlchemyProviderConfig, UnsignedTransactionRequest, SendTransactionOptions, SendTransactionResult, UseSendTransactionResult, PrepareSwapRequest, PrepareSwapResult, UsePrepareSwapResult, SubmitSwapResult, UseSubmitSwapResult, SwapQuote, } from "./types.js";
12
- //# sourceMappingURL=react-native.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-native.d.ts","sourceRoot":"","sources":["../../src/react-native.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGvE,YAAY,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,GACV,MAAM,YAAY,CAAC"}
@@ -1,71 +0,0 @@
1
- import { useCallback } from "react";
2
- import {
3
- usePrivy,
4
- useEmbeddedEthereumWallet,
5
- type PrivyEmbeddedWalletProvider,
6
- } from "@privy-io/expo";
7
- import type { PrivyAdapter, EmbeddedWallet, PrivyAuthState } from "./types.js";
8
-
9
- /**
10
- * Wallet type from @privy-io/expo
11
- * Based on the example app structure
12
- */
13
- interface ExpoEmbeddedWallet {
14
- address: string;
15
- chainId?: string;
16
- getProvider?: () => Promise<PrivyEmbeddedWalletProvider>;
17
- }
18
-
19
- /**
20
- * React Native (Expo) adapter for @privy-io/expo
21
- * Implements platform-specific hooks for React Native applications
22
- */
23
- export const reactNativeAdapter: PrivyAdapter = {
24
- useEmbeddedWallet() {
25
- const { wallets } = useEmbeddedEthereumWallet();
26
-
27
- const getEmbeddedWallet = useCallback((): EmbeddedWallet => {
28
- const wallet = wallets?.[0];
29
- if (!wallet) {
30
- throw new Error(
31
- "Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.",
32
- );
33
- }
34
-
35
- return adaptExpoWallet(wallet);
36
- }, [wallets]);
37
-
38
- return getEmbeddedWallet;
39
- },
40
-
41
- usePrivyAuth(): PrivyAuthState {
42
- const { user } = usePrivy();
43
- return { authenticated: !!user, user };
44
- },
45
-
46
- // EIP-7702 authorization not available on React Native
47
- useAuthorizationSigner() {
48
- return null;
49
- },
50
- };
51
-
52
- /**
53
- * Adapts an Expo wallet to the common EmbeddedWallet interface
54
- *
55
- * @param {ExpoEmbeddedWallet} wallet - The Expo embedded wallet to adapt
56
- * @returns {EmbeddedWallet} The adapted wallet following the common interface
57
- */
58
- function adaptExpoWallet(wallet: ExpoEmbeddedWallet): EmbeddedWallet {
59
- return {
60
- address: wallet.address as `0x${string}`,
61
- chainId: wallet.chainId || "1",
62
- getEthereumProvider: async () => {
63
- if (!wallet.getProvider) {
64
- throw new Error(
65
- "getProvider is not available on this wallet. Ensure you're using the embedded Ethereum wallet.",
66
- );
67
- }
68
- return await wallet.getProvider();
69
- },
70
- };
71
- }
@@ -1,56 +0,0 @@
1
- import type { Address, Authorization } from "viem";
2
- import type { AuthorizationRequest } from "@aa-sdk/core";
3
-
4
- /**
5
- * Platform-agnostic embedded wallet interface
6
- * Abstracts differences between @privy-io/react-auth and @privy-io/expo
7
- */
8
- export interface EmbeddedWallet {
9
- /** Wallet address */
10
- address: Address;
11
-
12
- /** Chain ID (may be CAIP-2 format like "eip155:1" or numeric) */
13
- chainId: string | number;
14
-
15
- /** Get EVM provider for the wallet */
16
- getEthereumProvider(): Promise<any>;
17
- }
18
-
19
- /**
20
- * Platform-agnostic Privy auth state
21
- */
22
- export interface PrivyAuthState {
23
- /** Whether user is authenticated */
24
- authenticated: boolean;
25
-
26
- /** User object (platform-specific, used for cache invalidation) */
27
- user: any;
28
- }
29
-
30
- /**
31
- * Adapter interface that each platform must implement
32
- * Provides platform-specific Privy functionality
33
- */
34
- export interface PrivyAdapter {
35
- /**
36
- * Hook to get embedded wallet
37
- * Must be called as a React hook (follows rules of hooks)
38
- */
39
- useEmbeddedWallet(): () => EmbeddedWallet;
40
-
41
- /**
42
- * Hook to get Privy authentication state
43
- * Must be called as a React hook (follows rules of hooks)
44
- */
45
- usePrivyAuth(): PrivyAuthState;
46
-
47
- /**
48
- * Hook to get EIP-7702 authorization signer (optional, web only)
49
- * Must be called as a React hook (follows rules of hooks)
50
- */
51
- useAuthorizationSigner?():
52
- | ((
53
- auth: AuthorizationRequest<number>,
54
- ) => Promise<Authorization<number, true>>)
55
- | null;
56
- }