@account-kit/privy-integration 4.73.0 → 4.73.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/esm/Provider.d.ts +4 -61
  2. package/dist/esm/Provider.js +4 -99
  3. package/dist/esm/Provider.js.map +1 -1
  4. package/dist/esm/adapters/react-native.d.ts +6 -0
  5. package/dist/esm/adapters/react-native.js +101 -0
  6. package/dist/esm/adapters/react-native.js.map +1 -0
  7. package/dist/esm/adapters/types.d.ts +44 -0
  8. package/dist/esm/adapters/types.js +2 -0
  9. package/dist/esm/adapters/types.js.map +1 -0
  10. package/dist/esm/adapters/web.d.ts +6 -0
  11. package/dist/esm/adapters/web.js +50 -0
  12. package/dist/esm/adapters/web.js.map +1 -0
  13. package/dist/esm/context/AlchemyContext.d.ts +62 -0
  14. package/dist/esm/context/AlchemyContext.js +105 -0
  15. package/dist/esm/context/AlchemyContext.js.map +1 -0
  16. package/dist/esm/hooks/internal/useEmbeddedWallet.d.ts +3 -4
  17. package/dist/esm/hooks/internal/useEmbeddedWallet.js +5 -13
  18. package/dist/esm/hooks/internal/useEmbeddedWallet.js.map +1 -1
  19. package/dist/esm/hooks/useAlchemyClient.js +13 -20
  20. package/dist/esm/hooks/useAlchemyClient.js.map +1 -1
  21. package/dist/esm/providers/ReactNativeProvider.d.ts +33 -0
  22. package/dist/esm/providers/ReactNativeProvider.js +37 -0
  23. package/dist/esm/providers/ReactNativeProvider.js.map +1 -0
  24. package/dist/esm/providers/WebProvider.d.ts +33 -0
  25. package/dist/esm/providers/WebProvider.js +37 -0
  26. package/dist/esm/providers/WebProvider.js.map +1 -0
  27. package/dist/esm/react-native.d.ts +11 -0
  28. package/dist/esm/react-native.js +13 -0
  29. package/dist/esm/react-native.js.map +1 -0
  30. package/dist/esm/version.d.ts +1 -1
  31. package/dist/esm/version.js +1 -1
  32. package/dist/esm/version.js.map +1 -1
  33. package/dist/types/Provider.d.ts +4 -61
  34. package/dist/types/Provider.d.ts.map +1 -1
  35. package/dist/types/adapters/react-native.d.ts +7 -0
  36. package/dist/types/adapters/react-native.d.ts.map +1 -0
  37. package/dist/types/adapters/types.d.ts +45 -0
  38. package/dist/types/adapters/types.d.ts.map +1 -0
  39. package/dist/types/adapters/web.d.ts +7 -0
  40. package/dist/types/adapters/web.d.ts.map +1 -0
  41. package/dist/types/context/AlchemyContext.d.ts +63 -0
  42. package/dist/types/context/AlchemyContext.d.ts.map +1 -0
  43. package/dist/types/hooks/internal/useEmbeddedWallet.d.ts +3 -4
  44. package/dist/types/hooks/internal/useEmbeddedWallet.d.ts.map +1 -1
  45. package/dist/types/hooks/useAlchemyClient.d.ts.map +1 -1
  46. package/dist/types/providers/ReactNativeProvider.d.ts +34 -0
  47. package/dist/types/providers/ReactNativeProvider.d.ts.map +1 -0
  48. package/dist/types/providers/WebProvider.d.ts +34 -0
  49. package/dist/types/providers/WebProvider.d.ts.map +1 -0
  50. package/dist/types/react-native.d.ts +12 -0
  51. package/dist/types/react-native.d.ts.map +1 -0
  52. package/dist/types/version.d.ts +1 -1
  53. package/dist/types/version.d.ts.map +1 -1
  54. package/package.json +17 -4
  55. package/src/adapters/react-native.ts +149 -0
  56. package/src/adapters/types.ts +56 -0
  57. package/src/adapters/web.ts +73 -0
  58. package/src/hooks/internal/useEmbeddedWallet.ts +5 -20
  59. package/src/hooks/useAlchemyClient.ts +17 -32
  60. package/src/react-native.ts +29 -0
  61. package/src/version.ts +1 -1
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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,2 +1,2 @@
1
- export declare const VERSION = "4.73.0";
1
+ export declare const VERSION = "4.73.1-alpha.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/privy-integration",
3
- "version": "4.73.0",
3
+ "version": "4.73.1-alpha.1",
4
4
  "description": "Use Alchemy gas sponsorship, swaps and more with Privy",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -27,6 +27,11 @@
27
27
  "import": "./dist/esm/index.js",
28
28
  "default": "./dist/esm/index.js"
29
29
  },
30
+ "./react-native": {
31
+ "types": "./dist/types/react-native.d.ts",
32
+ "import": "./dist/esm/react-native.js",
33
+ "default": "./dist/esm/react-native.js"
34
+ },
30
35
  "./solana": {
31
36
  "types": "./dist/types/solana.d.ts",
32
37
  "import": "./dist/esm/solana.js",
@@ -44,18 +49,26 @@
44
49
  "test:run": "vitest run --passWithNoTests"
45
50
  },
46
51
  "devDependencies": {
52
+ "@privy-io/expo": "0.58.1",
47
53
  "@privy-io/react-auth": "3.3.0",
48
54
  "typescript-template": "*"
49
55
  },
50
56
  "dependencies": {
51
- "@account-kit/infra": "^4.73.0",
52
- "@account-kit/wallet-client": "^4.73.0"
57
+ "@account-kit/infra": "^4.73.1-alpha.1",
58
+ "@account-kit/wallet-client": "^4.73.1-alpha.1"
53
59
  },
54
60
  "peerDependencies": {
61
+ "@privy-io/expo": "^0.58.0",
55
62
  "@privy-io/react-auth": "^2.3.1 || ^3.0.0",
56
63
  "viem": "^2.29.2"
57
64
  },
58
65
  "peerDependenciesMeta": {
66
+ "@privy-io/react-auth": {
67
+ "optional": true
68
+ },
69
+ "@privy-io/expo": {
70
+ "optional": true
71
+ },
59
72
  "@solana/web3.js": {
60
73
  "optional": true
61
74
  }
@@ -72,5 +85,5 @@
72
85
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
73
86
  },
74
87
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
75
- "gitHead": "1471537aa2b9e8cac4661b7162aa9c702efac7f1"
88
+ "gitHead": "03b2f5bff3d97e39f0be09eeaa6eb1f5a51631c6"
76
89
  }
@@ -0,0 +1,149 @@
1
+ import { useCallback } from "react";
2
+ import {
3
+ usePrivy,
4
+ useEmbeddedEthereumWallet,
5
+ type PrivyEmbeddedWalletProvider,
6
+ } from "@privy-io/expo";
7
+ import type { Authorization } from "viem";
8
+ import type { AuthorizationRequest } from "@aa-sdk/core";
9
+ import type { PrivyAdapter, EmbeddedWallet, PrivyAuthState } from "./types.js";
10
+
11
+ /**
12
+ * Wallet type from @privy-io/expo
13
+ * Based on the example app structure
14
+ */
15
+ interface ExpoEmbeddedWallet {
16
+ address: string;
17
+ chainId?: string;
18
+ getProvider?: () => Promise<PrivyEmbeddedWalletProvider>;
19
+ }
20
+
21
+ /**
22
+ * React Native (Expo) adapter for @privy-io/expo
23
+ * Implements platform-specific hooks for React Native applications
24
+ */
25
+ export const reactNativeAdapter: PrivyAdapter = {
26
+ useEmbeddedWallet() {
27
+ const { wallets } = useEmbeddedEthereumWallet();
28
+
29
+ const getEmbeddedWallet = useCallback((): EmbeddedWallet => {
30
+ const wallet = wallets?.[0];
31
+ if (!wallet) {
32
+ throw new Error(
33
+ "Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.",
34
+ );
35
+ }
36
+
37
+ return adaptExpoWallet(wallet);
38
+ }, [wallets]);
39
+
40
+ return getEmbeddedWallet;
41
+ },
42
+
43
+ usePrivyAuth(): PrivyAuthState {
44
+ const { user } = usePrivy();
45
+ return { authenticated: !!user, user };
46
+ },
47
+
48
+ useAuthorizationSigner() {
49
+ const { wallets } = useEmbeddedEthereumWallet();
50
+
51
+ return useCallback(
52
+ async (
53
+ unsignedAuth: AuthorizationRequest<number>,
54
+ ): Promise<Authorization<number, true>> => {
55
+ const wallet = wallets?.[0];
56
+ if (!wallet) {
57
+ throw new Error(
58
+ "Privy embedded wallet not found. Please ensure the user is authenticated and has created a wallet.",
59
+ );
60
+ }
61
+
62
+ const provider = await wallet.getProvider?.();
63
+ if (!provider) {
64
+ throw new Error(
65
+ "Provider not available on this wallet. Ensure you're using the embedded Ethereum wallet.",
66
+ );
67
+ }
68
+
69
+ // Extract the implementation address (handle both 'address' and 'contractAddress' fields)
70
+ const implementationAddress =
71
+ unsignedAuth.address ?? unsignedAuth.contractAddress;
72
+
73
+ if (!implementationAddress) {
74
+ throw new Error(
75
+ "Implementation address is required for EIP-7702 authorization",
76
+ );
77
+ }
78
+
79
+ // EIP-7702 Authorization structure
80
+ const authorization = {
81
+ domain: {
82
+ name: "EIP-7702",
83
+ version: "1",
84
+ chainId: unsignedAuth.chainId,
85
+ },
86
+ types: {
87
+ Authorization: [
88
+ { name: "chainId", type: "uint256" },
89
+ { name: "address", type: "address" },
90
+ { name: "nonce", type: "uint256" },
91
+ ],
92
+ },
93
+ primaryType: "Authorization" as const,
94
+ message: {
95
+ chainId: unsignedAuth.chainId,
96
+ address: implementationAddress,
97
+ nonce: unsignedAuth.nonce,
98
+ },
99
+ };
100
+
101
+ const signature = (await provider.request({
102
+ method: "eth_signTypedData_v4",
103
+ params: [wallet.address, JSON.stringify(authorization)],
104
+ })) as `0x${string}`;
105
+
106
+ // Parse the signature into r, s, v components
107
+ // Signature format: 0x[r(64)][s(64)][v(2)]
108
+ const r = `0x${signature.slice(2, 66)}` as `0x${string}`;
109
+ const s = `0x${signature.slice(66, 130)}` as `0x${string}`;
110
+ const v = parseInt(signature.slice(130, 132), 16);
111
+
112
+ // Convert v to yParity (0 or 1)
113
+ // v can be 27/28 (legacy) or 0/1 (EIP-155)
114
+ const yParity = v >= 27 ? v - 27 : v;
115
+
116
+ return {
117
+ chainId: unsignedAuth.chainId,
118
+ address: implementationAddress,
119
+ nonce: unsignedAuth.nonce,
120
+ r,
121
+ s,
122
+ yParity,
123
+ };
124
+ },
125
+ [wallets],
126
+ );
127
+ },
128
+ };
129
+
130
+ /**
131
+ * Adapts an Expo wallet to the common EmbeddedWallet interface
132
+ *
133
+ * @param {ExpoEmbeddedWallet} wallet - The Expo embedded wallet to adapt
134
+ * @returns {EmbeddedWallet} The adapted wallet following the common interface
135
+ */
136
+ function adaptExpoWallet(wallet: ExpoEmbeddedWallet): EmbeddedWallet {
137
+ return {
138
+ address: wallet.address as `0x${string}`,
139
+ chainId: wallet.chainId || "1",
140
+ getEthereumProvider: async () => {
141
+ if (!wallet.getProvider) {
142
+ throw new Error(
143
+ "getProvider is not available on this wallet. Ensure you're using the embedded Ethereum wallet.",
144
+ );
145
+ }
146
+ return await wallet.getProvider();
147
+ },
148
+ };
149
+ }
@@ -0,0 +1,56 @@
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
+ }
@@ -0,0 +1,73 @@
1
+ import { useCallback } from "react";
2
+ import {
3
+ useWallets,
4
+ usePrivy,
5
+ useSign7702Authorization,
6
+ type ConnectedWallet as PrivyWallet,
7
+ } from "@privy-io/react-auth";
8
+ import type { Authorization } from "viem";
9
+ import type { AuthorizationRequest } from "@aa-sdk/core";
10
+ import type { PrivyAdapter, EmbeddedWallet, PrivyAuthState } from "./types.js";
11
+
12
+ /**
13
+ * Web adapter for @privy-io/react-auth
14
+ * Implements platform-specific hooks for React web applications
15
+ */
16
+ export const webAdapter: PrivyAdapter = {
17
+ useEmbeddedWallet() {
18
+ const { wallets } = useWallets();
19
+
20
+ const getEmbeddedWallet = useCallback((): EmbeddedWallet => {
21
+ const embedded = wallets.find((w) => w.walletClientType === "privy");
22
+ if (!embedded) {
23
+ throw new Error(
24
+ "Privy embedded wallet not found. Please ensure the user is authenticated.",
25
+ );
26
+ }
27
+
28
+ return adaptWebWallet(embedded);
29
+ }, [wallets]);
30
+
31
+ return getEmbeddedWallet;
32
+ },
33
+
34
+ usePrivyAuth(): PrivyAuthState {
35
+ const { user } = usePrivy();
36
+ return { authenticated: !!user, user };
37
+ },
38
+
39
+ useAuthorizationSigner() {
40
+ const { signAuthorization } = useSign7702Authorization();
41
+
42
+ return useCallback(
43
+ async (
44
+ unsignedAuth: AuthorizationRequest<number>,
45
+ ): Promise<Authorization<number, true>> => {
46
+ const signature = await signAuthorization({
47
+ ...unsignedAuth,
48
+ contractAddress: unsignedAuth.address ?? unsignedAuth.contractAddress,
49
+ });
50
+
51
+ return {
52
+ ...unsignedAuth,
53
+ ...signature,
54
+ };
55
+ },
56
+ [signAuthorization],
57
+ );
58
+ },
59
+ };
60
+
61
+ /**
62
+ * Adapts a Privy web wallet to the common EmbeddedWallet interface
63
+ *
64
+ * @param {PrivyWallet} wallet - The Privy web wallet to adapt
65
+ * @returns {EmbeddedWallet} The adapted wallet following the common interface
66
+ */
67
+ function adaptWebWallet(wallet: PrivyWallet): EmbeddedWallet {
68
+ return {
69
+ address: wallet.address as `0x${string}`,
70
+ chainId: wallet.chainId || "1",
71
+ getEthereumProvider: () => wallet.getEthereumProvider(),
72
+ };
73
+ }
@@ -1,29 +1,14 @@
1
- import { useCallback } from "react";
2
- import {
3
- useWallets,
4
- type ConnectedWallet as PrivyWallet,
5
- } from "@privy-io/react-auth";
1
+ import { useAdapter } from "../../context/AlchemyContext.js";
6
2
 
7
3
  /**
8
4
  * Internal hook to get the Privy embedded wallet
9
- * Shared across multiple hooks to avoid duplication
5
+ * Uses the platform adapter to abstract differences between web and React Native
10
6
  *
11
7
  * @internal
12
- * @returns {() => PrivyWallet} Function that returns the embedded wallet
8
+ * @returns {() => EmbeddedWallet} Function that returns the embedded wallet
13
9
  * @throws {Error} If embedded wallet is not found
14
10
  */
15
11
  export function useEmbeddedWallet() {
16
- const { wallets } = useWallets();
17
-
18
- const getEmbeddedWallet = useCallback((): PrivyWallet => {
19
- const embedded = wallets.find((w) => w.walletClientType === "privy");
20
- if (!embedded) {
21
- throw new Error(
22
- "Privy embedded wallet not found. Please ensure the user is authenticated.",
23
- );
24
- }
25
- return embedded;
26
- }, [wallets]);
27
-
28
- return getEmbeddedWallet;
12
+ const adapter = useAdapter();
13
+ return adapter.useEmbeddedWallet();
29
14
  }
@@ -1,22 +1,16 @@
1
1
  import { useCallback } from "react";
2
- import {
3
- WalletClientSigner,
4
- type AuthorizationRequest,
5
- ConnectionConfigSchema,
6
- } from "@aa-sdk/core";
7
- import {
8
- createWalletClient,
9
- custom,
10
- type Address,
11
- type Authorization,
12
- } from "viem";
13
- import { useSign7702Authorization } from "@privy-io/react-auth";
2
+ import { WalletClientSigner, ConnectionConfigSchema } from "@aa-sdk/core";
3
+ import { createWalletClient, custom, type Address } from "viem";
14
4
  import {
15
5
  createSmartWalletClient,
16
6
  type SmartWalletClient,
17
7
  } from "@account-kit/wallet-client";
18
8
  import { alchemy } from "@account-kit/infra";
19
- import { useAlchemyConfig, useClientCache } from "../Provider.js";
9
+ import {
10
+ useAlchemyConfig,
11
+ useClientCache,
12
+ useAdapter,
13
+ } from "../context/AlchemyContext.js";
20
14
  import { getChain } from "../util/getChain.js";
21
15
  import { useEmbeddedWallet } from "./internal/useEmbeddedWallet.js";
22
16
 
@@ -34,7 +28,8 @@ import { useEmbeddedWallet } from "./internal/useEmbeddedWallet.js";
34
28
  * ```
35
29
  */
36
30
  export function useAlchemyClient() {
37
- const { signAuthorization } = useSign7702Authorization();
31
+ const adapter = useAdapter();
32
+ const signAuthorizationFn = adapter.useAuthorizationSigner?.() || null;
38
33
  const config = useAlchemyConfig();
39
34
  const cache = useClientCache();
40
35
  const getEmbeddedWallet = useEmbeddedWallet();
@@ -97,23 +92,13 @@ export function useAlchemyClient() {
97
92
  "privy",
98
93
  );
99
94
 
100
- // Extend signer with EIP-7702 authorization support
101
- const signer = {
102
- ...baseSigner,
103
- signAuthorization: async (
104
- unsignedAuth: AuthorizationRequest<number>,
105
- ): Promise<Authorization<number, true>> => {
106
- const signature = await signAuthorization({
107
- ...unsignedAuth,
108
- contractAddress: unsignedAuth.address ?? unsignedAuth.contractAddress,
109
- });
110
-
111
- return {
112
- ...unsignedAuth,
113
- ...signature,
114
- };
115
- },
116
- };
95
+ // Extend signer with EIP-7702 authorization support (if available)
96
+ const signer = signAuthorizationFn
97
+ ? {
98
+ ...baseSigner,
99
+ signAuthorization: signAuthorizationFn,
100
+ }
101
+ : baseSigner;
117
102
 
118
103
  // Determine transport configuration using schema validation
119
104
  // This properly handles combinations like rpcUrl + jwt together
@@ -148,7 +133,7 @@ export function useAlchemyClient() {
148
133
  }, [
149
134
  getEmbeddedWallet,
150
135
  getEmbeddedWalletChain,
151
- signAuthorization,
136
+ signAuthorizationFn,
152
137
  config.apiKey,
153
138
  config.jwt,
154
139
  config.rpcUrl,
@@ -0,0 +1,29 @@
1
+ /**
2
+ * React Native (Expo) entry point
3
+ * Import from '@account-kit/privy-integration/react-native' in Expo apps
4
+ */
5
+
6
+ // Provider
7
+ export { AlchemyProvider } from "./providers/ReactNativeProvider.js";
8
+ export { useAlchemyConfig } from "./context/AlchemyContext.js";
9
+
10
+ // Hooks
11
+ export { useAlchemyClient } from "./hooks/useAlchemyClient.js";
12
+ export { useAlchemySendTransaction } from "./hooks/useAlchemySendTransaction.js";
13
+ export { useAlchemyPrepareSwap } from "./hooks/useAlchemyPrepareSwap.js";
14
+ export { useAlchemySubmitSwap } from "./hooks/useAlchemySubmitSwap.js";
15
+
16
+ // Types
17
+ export type {
18
+ AlchemyProviderConfig,
19
+ UnsignedTransactionRequest,
20
+ SendTransactionOptions,
21
+ SendTransactionResult,
22
+ UseSendTransactionResult,
23
+ PrepareSwapRequest,
24
+ PrepareSwapResult,
25
+ UsePrepareSwapResult,
26
+ SubmitSwapResult,
27
+ UseSubmitSwapResult,
28
+ SwapQuote,
29
+ } from "./types.js";
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.73.0";
3
+ export const VERSION = "4.73.1-alpha.1";