@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.
- package/README.md +61 -21
- package/dist/esm/Provider.d.ts +71 -4
- package/dist/esm/Provider.js +109 -4
- package/dist/esm/Provider.js.map +1 -1
- package/dist/esm/hooks/internal/useEmbeddedWallet.d.ts +4 -3
- package/dist/esm/hooks/internal/useEmbeddedWallet.js +13 -5
- package/dist/esm/hooks/internal/useEmbeddedWallet.js.map +1 -1
- package/dist/esm/hooks/useAlchemyClient.d.ts +10 -5
- package/dist/esm/hooks/useAlchemyClient.js +36 -17
- package/dist/esm/hooks/useAlchemyClient.js.map +1 -1
- package/dist/esm/hooks/useAlchemyPrepareSwap.js +3 -6
- package/dist/esm/hooks/useAlchemyPrepareSwap.js.map +1 -1
- package/dist/esm/hooks/useAlchemySendTransaction.js +11 -9
- package/dist/esm/hooks/useAlchemySendTransaction.js.map +1 -1
- package/dist/esm/hooks/useAlchemySubmitSwap.js +1 -1
- package/dist/esm/hooks/useAlchemySubmitSwap.js.map +1 -1
- package/dist/esm/types.d.ts +6 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/Provider.d.ts +71 -4
- package/dist/types/Provider.d.ts.map +1 -1
- package/dist/types/hooks/internal/useEmbeddedWallet.d.ts +4 -3
- package/dist/types/hooks/internal/useEmbeddedWallet.d.ts.map +1 -1
- package/dist/types/hooks/useAlchemyClient.d.ts +10 -5
- package/dist/types/hooks/useAlchemyClient.d.ts.map +1 -1
- package/dist/types/hooks/useAlchemyPrepareSwap.d.ts.map +1 -1
- package/dist/types/hooks/useAlchemySendTransaction.d.ts.map +1 -1
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +4 -17
- package/src/hooks/internal/useEmbeddedWallet.ts +20 -5
- package/src/hooks/useAlchemyClient.ts +61 -26
- package/src/hooks/useAlchemyPrepareSwap.ts +3 -6
- package/src/hooks/useAlchemySendTransaction.ts +16 -13
- package/src/hooks/useAlchemySubmitSwap.ts +1 -1
- package/src/types.ts +7 -0
- package/src/version.ts +1 -1
- package/dist/esm/adapters/react-native.d.ts +0 -6
- package/dist/esm/adapters/react-native.js +0 -46
- package/dist/esm/adapters/react-native.js.map +0 -1
- package/dist/esm/adapters/types.d.ts +0 -44
- package/dist/esm/adapters/types.js +0 -2
- package/dist/esm/adapters/types.js.map +0 -1
- package/dist/esm/adapters/web.d.ts +0 -6
- package/dist/esm/adapters/web.js +0 -50
- package/dist/esm/adapters/web.js.map +0 -1
- package/dist/esm/context/AlchemyContext.d.ts +0 -62
- package/dist/esm/context/AlchemyContext.js +0 -105
- package/dist/esm/context/AlchemyContext.js.map +0 -1
- package/dist/esm/providers/ReactNativeProvider.d.ts +0 -33
- package/dist/esm/providers/ReactNativeProvider.js +0 -37
- package/dist/esm/providers/ReactNativeProvider.js.map +0 -1
- package/dist/esm/providers/WebProvider.d.ts +0 -33
- package/dist/esm/providers/WebProvider.js +0 -37
- package/dist/esm/providers/WebProvider.js.map +0 -1
- package/dist/esm/react-native.d.ts +0 -11
- package/dist/esm/react-native.js +0 -13
- package/dist/esm/react-native.js.map +0 -1
- package/dist/types/adapters/react-native.d.ts +0 -7
- package/dist/types/adapters/react-native.d.ts.map +0 -1
- package/dist/types/adapters/types.d.ts +0 -45
- package/dist/types/adapters/types.d.ts.map +0 -1
- package/dist/types/adapters/web.d.ts +0 -7
- package/dist/types/adapters/web.d.ts.map +0 -1
- package/dist/types/context/AlchemyContext.d.ts +0 -63
- package/dist/types/context/AlchemyContext.d.ts.map +0 -1
- package/dist/types/providers/ReactNativeProvider.d.ts +0 -34
- package/dist/types/providers/ReactNativeProvider.d.ts.map +0 -1
- package/dist/types/providers/WebProvider.d.ts +0 -34
- package/dist/types/providers/WebProvider.d.ts.map +0 -1
- package/dist/types/react-native.d.ts +0 -12
- package/dist/types/react-native.d.ts.map +0 -1
- package/src/adapters/react-native.ts +0 -71
- package/src/adapters/types.ts +0 -56
- package/src/adapters/web.ts +0 -73
- package/src/react-native.ts +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlchemyPrepareSwap.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemyPrepareSwap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAgB,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"useAlchemyPrepareSwap.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemyPrepareSwap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAgB,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEzC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC,CAAC;IAEjE,MAAM,WAAW,GAA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S;QACT,KAAK;QACL,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\nimport { type Address } from \"viem\";\nimport { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { useAlchemyClient } from \"./useAlchemyClient.js\";\nimport type {\n PrepareSwapRequest,\n PrepareSwapResult,\n UsePrepareSwapResult,\n} from \"../types\";\n\n/**\n * Hook to request swap quotes and prepare swap calls\n * Part of the two-step swap process: prepare → submit\n * Use with `useAlchemySubmitSwap()` to execute the prepared swap\n *\n * Supports two modes:\n * 1. Specify exact amount to swap FROM (`fromAmount`)\n * 2. Specify minimum amount to receive TO (`minimumToAmount`)\n *\n * @returns {UsePrepareSwapResult} Hook result with prepareSwap function and state\n *\n * @example Complete swap flow\n * ```tsx\n * const { prepareSwap } = useAlchemyPrepareSwap();\n * const { submitSwap } = useAlchemySubmitSwap();\n *\n * // Step 1: Prepare the swap (get quote)\n * const preparedSwap = await prepareSwap({\n * fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',\n * toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n * fromAmount: '0xde0b6b3a7640000', // 1 ETH in hex\n * });\n *\n * // Step 2: Execute the swap\n * const result = await submitSwap(preparedSwap);\n * ```\n *\n * @example Swap for minimum amount TO\n * ```tsx\n * const { prepareSwap } = useAlchemyPrepareSwap();\n *\n * // Swap ETH to get at least 100 USDC\n * const result = await prepareSwap({\n * fromToken: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',\n * toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n * minimumToAmount: '0x5f5e100', // 100 USDC (6 decimals) in hex\n * });\n * console.log('Quote expiry:', new Date(parseInt(result.quote.expiry, 16) * 1000));\n * ```\n */\nexport function useAlchemyPrepareSwap(): UsePrepareSwapResult {\n const { getClient } = useAlchemyClient();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<PrepareSwapResult | null>(null);\n\n const prepareSwap = useCallback(\n async (request: PrepareSwapRequest): Promise<PrepareSwapResult> => {\n setIsLoading(true);\n setError(null);\n\n try {\n const { client, account } = await getClient();\n\n // Extend client with swap actions\n const swapClient = client.extend(swapActions);\n\n // Request the swap quote\n // Note: Gas sponsorship capabilities are configured on the client itself\n const response = await swapClient.requestQuoteV0({\n ...request,\n from: request.from || (account.address as Address),\n });\n\n // Validate that we got prepared calls, not raw calls\n if (response.rawCalls) {\n throw new Error(\n \"Received raw calls instead of prepared calls. Ensure returnRawCalls is not set to true.\",\n );\n }\n\n setData(response);\n return response;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error(\"Failed to prepare swap\");\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n },\n [getClient],\n );\n\n const reset = useCallback(() => {\n setError(null);\n setData(null);\n setIsLoading(false);\n }, []);\n\n return {\n prepareSwap,\n isLoading,\n error,\n data,\n reset,\n };\n}\n"]}
|
|
@@ -2,7 +2,6 @@ import { useCallback, useState } from "react";
|
|
|
2
2
|
import { isHex } from "viem";
|
|
3
3
|
import { useAlchemyClient } from "./useAlchemyClient.js";
|
|
4
4
|
import { useAlchemyConfig } from "../Provider.js";
|
|
5
|
-
import { useEmbeddedWallet } from "./internal/useEmbeddedWallet.js";
|
|
6
5
|
/**
|
|
7
6
|
* Normalize value to hex format
|
|
8
7
|
* Accepts bigint, number, decimal string, or hex string
|
|
@@ -61,7 +60,6 @@ function normalizeValue(value) {
|
|
|
61
60
|
export function useAlchemySendTransaction() {
|
|
62
61
|
const { getClient } = useAlchemyClient();
|
|
63
62
|
const config = useAlchemyConfig();
|
|
64
|
-
const getEmbeddedWallet = useEmbeddedWallet();
|
|
65
63
|
const [isLoading, setIsLoading] = useState(false);
|
|
66
64
|
const [error, setError] = useState(null);
|
|
67
65
|
const [data, setData] = useState(null);
|
|
@@ -69,8 +67,7 @@ export function useAlchemySendTransaction() {
|
|
|
69
67
|
setIsLoading(true);
|
|
70
68
|
setError(null);
|
|
71
69
|
try {
|
|
72
|
-
const client = await getClient();
|
|
73
|
-
const embeddedWallet = getEmbeddedWallet();
|
|
70
|
+
const { client, account } = await getClient();
|
|
74
71
|
// Determine if transaction should be sponsored
|
|
75
72
|
const hasPolicyId = !!config.policyId;
|
|
76
73
|
const enableSponsorship = !config.disableSponsorship;
|
|
@@ -84,17 +81,17 @@ export function useAlchemySendTransaction() {
|
|
|
84
81
|
data: txn.data,
|
|
85
82
|
value: txn.value ? normalizeValue(txn.value) : undefined,
|
|
86
83
|
}));
|
|
87
|
-
// Build capabilities based on sponsorship
|
|
84
|
+
// Build capabilities based on sponsorship and auth mode
|
|
88
85
|
const policyId = Array.isArray(config.policyId)
|
|
89
86
|
? config.policyId[0]
|
|
90
87
|
: config.policyId;
|
|
91
|
-
const capabilities = { eip7702Auth: true };
|
|
88
|
+
const capabilities = config.accountAuthMode === "eip7702" ? { eip7702Auth: true } : {};
|
|
92
89
|
if (shouldSponsor && policyId) {
|
|
93
90
|
capabilities.paymasterService = { policyId };
|
|
94
91
|
}
|
|
95
|
-
// Send the transaction(s)
|
|
92
|
+
// Send the transaction(s) from the smart account address
|
|
96
93
|
const result = await client.sendCalls({
|
|
97
|
-
from:
|
|
94
|
+
from: account.address,
|
|
98
95
|
calls: formattedCalls,
|
|
99
96
|
capabilities,
|
|
100
97
|
});
|
|
@@ -122,7 +119,12 @@ export function useAlchemySendTransaction() {
|
|
|
122
119
|
finally {
|
|
123
120
|
setIsLoading(false);
|
|
124
121
|
}
|
|
125
|
-
}, [
|
|
122
|
+
}, [
|
|
123
|
+
getClient,
|
|
124
|
+
config.policyId,
|
|
125
|
+
config.disableSponsorship,
|
|
126
|
+
config.accountAuthMode,
|
|
127
|
+
]);
|
|
126
128
|
const reset = useCallback(() => {
|
|
127
129
|
setError(null);
|
|
128
130
|
setData(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlchemySendTransaction.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"useAlchemySendTransaction.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAY,KAAK,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQlD;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,KAA+B;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wBAAwB;IACxB,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAElC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,Q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,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;YAC/D,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,MAAM,QAAQ,CAAC;QACjB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD;QACE,SAAS;QACT,MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,kBAAkB;QACzB,MAAM,CAAC,eAAe;KACvB,CACF,CAAC;IAEF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,eAAe;QACf,SAAS;QACT,KAAK;QACL,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\nimport { type Hex, isHex } from \"viem\";\nimport { useAlchemyClient } from \"./useAlchemyClient.js\";\nimport { useAlchemyConfig } from \"../Provider.js\";\nimport type {\n UnsignedTransactionRequest,\n SendTransactionOptions,\n SendTransactionResult,\n UseSendTransactionResult,\n} from \"../types\";\n\n/**\n * Normalize value to hex format\n * Accepts bigint, number, decimal string, or hex string\n *\n * @param {string | number | bigint} value - Value to normalize\n * @returns {Hex} Hex string representation of the value\n */\nfunction normalizeValue(value: string | number | bigint): Hex {\n if (typeof value === \"bigint\") {\n return `0x${value.toString(16)}`;\n }\n if (typeof value === \"number\") {\n return `0x${BigInt(value).toString(16)}`;\n }\n if (isHex(value)) {\n return value;\n }\n // Assume decimal string\n return `0x${BigInt(value).toString(16)}`;\n}\n\n/**\n * Hook to send transactions with optional gas sponsorship via Alchemy\n * Supports both single transactions and batch transactions\n * Drop-in alternative to Privy's useSendTransaction hook\n *\n * @returns {UseSendTransactionResult} Hook result with sendTransaction function and state\n *\n * @example Single transaction\n * ```tsx\n * const { sendTransaction, isLoading, error, data } = useAlchemySendTransaction();\n *\n * const handleSend = async () => {\n * try {\n * const result = await sendTransaction({\n * to: '0x...',\n * data: '0x...',\n * value: '1000000000000000000', // 1 ETH\n * });\n * console.log('Transaction hash:', result.txnHash);\n * } catch (err) {\n * console.error('Transaction failed:', err);\n * }\n * };\n * ```\n *\n * @example Batch transactions\n * ```tsx\n * const { sendTransaction } = useAlchemySendTransaction();\n *\n * const result = await sendTransaction([\n * { to: '0x...', data: '0x...', value: '1000000000000000000' },\n * { to: '0x...', data: '0x...' },\n * ]);\n * ```\n */\nexport function useAlchemySendTransaction(): UseSendTransactionResult {\n const { getClient } = useAlchemyClient();\n const config = useAlchemyConfig();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<SendTransactionResult | null>(null);\n\n const sendTransaction = useCallback(\n async (\n input: UnsignedTransactionRequest | UnsignedTransactionRequest[],\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult> => {\n setIsLoading(true);\n setError(null);\n\n try {\n const { client, account } = await getClient();\n\n // Determine if transaction should be sponsored\n const hasPolicyId = !!config.policyId;\n const enableSponsorship = !config.disableSponsorship;\n const shouldSponsor =\n options?.disableSponsorship !== undefined\n ? !options.disableSponsorship\n : hasPolicyId && enableSponsorship;\n\n // Format the transaction call(s)\n const inputs = Array.isArray(input) ? input : [input];\n const formattedCalls = inputs.map((txn) => ({\n to: txn.to,\n data: txn.data,\n value: txn.value ? normalizeValue(txn.value) : undefined,\n }));\n\n // Build capabilities based on sponsorship and auth mode\n const policyId = Array.isArray(config.policyId)\n ? config.policyId[0]\n : config.policyId;\n\n type Capabilities =\n | { eip7702Auth: true; paymasterService?: { policyId: string } }\n | { paymasterService?: { policyId: string } };\n const capabilities: Capabilities =\n config.accountAuthMode === \"eip7702\" ? { eip7702Auth: true } : {};\n\n if (shouldSponsor && policyId) {\n capabilities.paymasterService = { policyId };\n }\n\n // Send the transaction(s) from the smart account address\n const result = await client.sendCalls({\n from: account.address,\n calls: formattedCalls,\n capabilities,\n });\n\n if (!result.preparedCallIds || result.preparedCallIds.length === 0) {\n throw new Error(\n \"No prepared call IDs returned from transaction submission\",\n );\n }\n\n // Wait for the transaction to be confirmed\n const txStatus = await client.waitForCallsStatus({\n id: result.preparedCallIds[0],\n timeout: 60_000,\n });\n\n const txnHash = txStatus.receipts?.[0]?.transactionHash;\n if (!txnHash) {\n throw new Error(\"Transaction hash not found in receipt\");\n }\n\n const txResult: SendTransactionResult = { txnHash };\n setData(txResult);\n return txResult;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error(\"Transaction failed\");\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n },\n [\n getClient,\n config.policyId,\n config.disableSponsorship,\n config.accountAuthMode,\n ],\n );\n\n const reset = useCallback(() => {\n setError(null);\n setData(null);\n setIsLoading(false);\n }, []);\n\n return {\n sendTransaction,\n isLoading,\n error,\n data,\n reset,\n };\n}\n"]}
|
|
@@ -39,7 +39,7 @@ export function useAlchemySubmitSwap() {
|
|
|
39
39
|
setIsLoading(true);
|
|
40
40
|
setError(null);
|
|
41
41
|
try {
|
|
42
|
-
const client = await getClient();
|
|
42
|
+
const { client } = await getClient();
|
|
43
43
|
// Extend client with swap actions
|
|
44
44
|
const swapClient = client.extend(swapActions);
|
|
45
45
|
// Sign the prepared calls
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlchemySubmitSwap.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemySubmitSwap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAOzD;;;;;;;;;;;;;;;;;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CAAC;YAC3D,CAAC;YAED,MAAM,MAAM,GAAqB,EAAE,OAAO,EAAE,CAAC;YAC7C,OAAO,CAAC,MAAM,CAAC,CAAC;YAChB,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,QAAQ,GACZ,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAClE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,MAAM,QAAQ,CAAC;QACjB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,UAAU;QACV,SAAS;QACT,KAAK;QACL,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useState } from \"react\";\nimport { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { useAlchemyClient } from \"./useAlchemyClient.js\";\nimport type {\n PrepareSwapResult,\n SubmitSwapResult,\n UseSubmitSwapResult,\n} from \"../types.js\";\n\n/**\n * Hook to sign and submit prepared swap calls\n * Part of the two-step swap process: prepare → submit\n *\n * @returns {UseSubmitSwapResult} Hook result with submitSwap function and state\n *\n * @example\n * ```tsx\n * const { prepareSwap } = useAlchemyPrepareSwap();\n * const { submitSwap, isLoading, error, data } = useAlchemySubmitSwap();\n *\n * const handleSwap = async () => {\n * try {\n * // Step 1: Prepare the swap\n * const preparedSwap = await prepareSwap({\n * fromToken: '0x...',\n * toToken: '0x...',\n * fromAmount: '0x...',\n * });\n *\n * // Step 2: Submit the swap\n * const result = await submitSwap(preparedSwap);\n * console.log('Swap confirmed:', result.txnHash);\n * } catch (err) {\n * console.error('Swap failed:', err);\n * }\n * };\n * ```\n */\nexport function useAlchemySubmitSwap(): UseSubmitSwapResult {\n const { getClient } = useAlchemyClient();\n\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<SubmitSwapResult | null>(null);\n\n const submitSwap = useCallback(\n async (preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult> => {\n setIsLoading(true);\n setError(null);\n\n try {\n const { client } = await getClient();\n\n // Extend client with swap actions\n const swapClient = client.extend(swapActions);\n\n // Sign the prepared calls\n const signedCalls = await swapClient.signPreparedCalls(preparedSwap);\n\n // Send the signed calls\n const { preparedCallIds } =\n await swapClient.sendPreparedCalls(signedCalls);\n\n if (!preparedCallIds || preparedCallIds.length === 0) {\n throw new Error(\"No prepared call IDs returned from swap submission\");\n }\n\n // Wait for the swap to be confirmed\n const callStatusResult = await swapClient.waitForCallsStatus({\n id: preparedCallIds[0],\n timeout: 60_000,\n });\n\n // Validate the transaction was successful\n if (\n callStatusResult.status !== \"success\" ||\n !callStatusResult.receipts ||\n !callStatusResult.receipts[0]\n ) {\n throw new Error(\n `Swap failed with status ${\n callStatusResult.status\n }. Full receipt:\\n${JSON.stringify(callStatusResult, null, 2)}`,\n );\n }\n\n const txnHash = callStatusResult.receipts[0].transactionHash;\n if (!txnHash) {\n throw new Error(\"Transaction hash not found in receipt\");\n }\n\n const result: SubmitSwapResult = { txnHash };\n setData(result);\n return result;\n } catch (err) {\n const errorObj =\n err instanceof Error ? err : new Error(\"Failed to submit swap\");\n setError(errorObj);\n throw errorObj;\n } finally {\n setIsLoading(false);\n }\n },\n [getClient],\n );\n\n const reset = useCallback(() => {\n setError(null);\n setData(null);\n setIsLoading(false);\n }, []);\n\n return {\n submitSwap,\n isLoading,\n error,\n data,\n reset,\n };\n}\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
|
|
|
13
13
|
solanaPolicyId?: string | string[];
|
|
14
14
|
/** Solana RPC URL (separate from EVM rpcUrl) */
|
|
15
15
|
solanaRpcUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* How EVM smart account calls should be authorized.
|
|
18
|
+
* - 'eip7702' (default): delegated authorization via EIP-7702.
|
|
19
|
+
* - 'owner': sign as the account owner (Privy embedded wallet), no 7702.
|
|
20
|
+
*/
|
|
21
|
+
accountAuthMode?: "eip7702" | "owner";
|
|
16
22
|
/**
|
|
17
23
|
* Set to true to disable gas sponsorship by default
|
|
18
24
|
* Default: false (sponsorship enabled when policyId is provided)
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import type { Address, Hash, Hex } from \"viem\";\nimport type { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport type { z } from \"zod\";\n\n/**\n * Configuration for the Alchemy provider\n * Uses ConnectionConfigSchema to ensure valid transport configuration\n */\nexport type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {\n /** Policy ID(s) for EVM gas sponsorship */\n policyId?: string | string[];\n\n /** Policy ID(s) for Solana gas sponsorship */\n solanaPolicyId?: string | string[];\n\n /** Solana RPC URL (separate from EVM rpcUrl) */\n solanaRpcUrl?: string;\n\n /**\n * Set to true to disable gas sponsorship by default\n * Default: false (sponsorship enabled when policyId is provided)\n */\n disableSponsorship?: boolean;\n};\n\n/**\n * Unsigned transaction request\n */\nexport interface UnsignedTransactionRequest {\n /** Recipient address */\n to: Address;\n\n /** Transaction data (calldata) */\n data?: Hex;\n\n /** Transaction value - accepts string | number | bigint */\n value?: string | number | bigint;\n}\n\n/**\n * Options for sending a transaction\n */\nexport interface SendTransactionOptions {\n /**\n * Set to true to disable sponsorship for this specific transaction\n * Default: false (follows provider's disableSponsorship setting)\n */\n disableSponsorship?: boolean;\n}\n\n/**\n * Result of a successful transaction\n */\nexport interface SendTransactionResult {\n /** EVM transaction hash (first receipt hash) */\n txnHash: Hash;\n}\n\n/**\n * Hook result for sending transactions\n */\nexport interface UseSendTransactionResult {\n /** Whether the transaction is currently being sent */\n isLoading: boolean;\n\n /** Error if transaction failed */\n error: Error | null;\n\n /** Transaction result if successful */\n data: SendTransactionResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Send a single transaction or batch of transactions */\n sendTransaction(\n input: UnsignedTransactionRequest | UnsignedTransactionRequest[],\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult>;\n}\n\n/**\n * Request parameters for preparing a swap\n * Derived directly from the SDK to ensure type safety\n *\n * Note: Provide either `fromAmount` OR `minimumToAmount`, not both.\n * - Use `fromAmount` to specify exact amount to swap FROM\n * - Use `minimumToAmount` to specify minimum amount to receive TO\n */\nexport type PrepareSwapRequest = Parameters<\n ReturnType<typeof swapActions>[\"requestQuoteV0\"]\n>[0];\n\n/**\n * Response from requestQuoteV0\n * Derived directly from the SDK to ensure type safety\n */\nexport type RequestQuoteV0Result = Awaited<\n ReturnType<ReturnType<typeof swapActions>[\"requestQuoteV0\"]>\n>;\n\n/**\n * Swap quote information extracted from prepared swap calls\n * Derived directly from the SDK response\n */\nexport type SwapQuote = NonNullable<RequestQuoteV0Result[\"quote\"]>;\n\n/**\n * Result of preparing a swap (full response from requestQuoteV0)\n * Contains quote and prepared calls ready for signing\n */\nexport type PrepareSwapResult = Extract<\n RequestQuoteV0Result,\n { rawCalls?: false | undefined }\n>;\n\n/**\n * Hook result for preparing swaps\n */\nexport interface UsePrepareSwapResult {\n /** Whether the swap is being prepared */\n isLoading: boolean;\n\n /** Error if preparation failed */\n error: Error | null;\n\n /** Prepared swap data if successful */\n data: PrepareSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Request a swap quote and prepare calls */\n prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;\n}\n\n/**\n * Result of submitting a swap\n * Simplified wrapper that extracts the transaction hash\n */\nexport interface SubmitSwapResult {\n /** Transaction hash of the swap */\n txnHash: Hash;\n}\n\n/**\n * Hook result for submitting swaps\n */\nexport interface UseSubmitSwapResult {\n /** Whether the swap is being submitted */\n isLoading: boolean;\n\n /** Error if submission failed */\n error: Error | null;\n\n /** Swap submission result if successful */\n data: SubmitSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Sign and submit prepared swap calls */\n submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import type { Address, Hash, Hex } from \"viem\";\nimport type { swapActions } from \"@account-kit/wallet-client/experimental\";\nimport { ConnectionConfigSchema } from \"@aa-sdk/core\";\nimport type { z } from \"zod\";\n\n/**\n * Configuration for the Alchemy provider\n * Uses ConnectionConfigSchema to ensure valid transport configuration\n */\nexport type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {\n /** Policy ID(s) for EVM gas sponsorship */\n policyId?: string | string[];\n\n /** Policy ID(s) for Solana gas sponsorship */\n solanaPolicyId?: string | string[];\n\n /** Solana RPC URL (separate from EVM rpcUrl) */\n solanaRpcUrl?: string;\n\n /**\n * How EVM smart account calls should be authorized.\n * - 'eip7702' (default): delegated authorization via EIP-7702.\n * - 'owner': sign as the account owner (Privy embedded wallet), no 7702.\n */\n accountAuthMode?: \"eip7702\" | \"owner\";\n\n /**\n * Set to true to disable gas sponsorship by default\n * Default: false (sponsorship enabled when policyId is provided)\n */\n disableSponsorship?: boolean;\n};\n\n/**\n * Unsigned transaction request\n */\nexport interface UnsignedTransactionRequest {\n /** Recipient address */\n to: Address;\n\n /** Transaction data (calldata) */\n data?: Hex;\n\n /** Transaction value - accepts string | number | bigint */\n value?: string | number | bigint;\n}\n\n/**\n * Options for sending a transaction\n */\nexport interface SendTransactionOptions {\n /**\n * Set to true to disable sponsorship for this specific transaction\n * Default: false (follows provider's disableSponsorship setting)\n */\n disableSponsorship?: boolean;\n}\n\n/**\n * Result of a successful transaction\n */\nexport interface SendTransactionResult {\n /** EVM transaction hash (first receipt hash) */\n txnHash: Hash;\n}\n\n/**\n * Hook result for sending transactions\n */\nexport interface UseSendTransactionResult {\n /** Whether the transaction is currently being sent */\n isLoading: boolean;\n\n /** Error if transaction failed */\n error: Error | null;\n\n /** Transaction result if successful */\n data: SendTransactionResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Send a single transaction or batch of transactions */\n sendTransaction(\n input: UnsignedTransactionRequest | UnsignedTransactionRequest[],\n options?: SendTransactionOptions,\n ): Promise<SendTransactionResult>;\n}\n\n/**\n * Request parameters for preparing a swap\n * Derived directly from the SDK to ensure type safety\n *\n * Note: Provide either `fromAmount` OR `minimumToAmount`, not both.\n * - Use `fromAmount` to specify exact amount to swap FROM\n * - Use `minimumToAmount` to specify minimum amount to receive TO\n */\nexport type PrepareSwapRequest = Parameters<\n ReturnType<typeof swapActions>[\"requestQuoteV0\"]\n>[0];\n\n/**\n * Response from requestQuoteV0\n * Derived directly from the SDK to ensure type safety\n */\nexport type RequestQuoteV0Result = Awaited<\n ReturnType<ReturnType<typeof swapActions>[\"requestQuoteV0\"]>\n>;\n\n/**\n * Swap quote information extracted from prepared swap calls\n * Derived directly from the SDK response\n */\nexport type SwapQuote = NonNullable<RequestQuoteV0Result[\"quote\"]>;\n\n/**\n * Result of preparing a swap (full response from requestQuoteV0)\n * Contains quote and prepared calls ready for signing\n */\nexport type PrepareSwapResult = Extract<\n RequestQuoteV0Result,\n { rawCalls?: false | undefined }\n>;\n\n/**\n * Hook result for preparing swaps\n */\nexport interface UsePrepareSwapResult {\n /** Whether the swap is being prepared */\n isLoading: boolean;\n\n /** Error if preparation failed */\n error: Error | null;\n\n /** Prepared swap data if successful */\n data: PrepareSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Request a swap quote and prepare calls */\n prepareSwap(request: PrepareSwapRequest): Promise<PrepareSwapResult>;\n}\n\n/**\n * Result of submitting a swap\n * Simplified wrapper that extracts the transaction hash\n */\nexport interface SubmitSwapResult {\n /** Transaction hash of the swap */\n txnHash: Hash;\n}\n\n/**\n * Hook result for submitting swaps\n */\nexport interface UseSubmitSwapResult {\n /** Whether the swap is being submitted */\n isLoading: boolean;\n\n /** Error if submission failed */\n error: Error | null;\n\n /** Swap submission result if successful */\n data: SubmitSwapResult | null;\n\n /** Reset the hook state */\n reset(): void;\n\n /** Sign and submit prepared swap calls */\n submitSwap(preparedSwap: PrepareSwapResult): Promise<SubmitSwapResult>;\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.74.0";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.74.0\";\n"]}
|
package/dist/types/Provider.d.ts
CHANGED
|
@@ -1,7 +1,74 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
import type { SmartWalletClient } from "@account-kit/wallet-client";
|
|
3
|
+
import type { SmartContractAccount } from "@aa-sdk/core";
|
|
4
|
+
import type { AlchemyProviderConfig } from "./types.js";
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
6
|
+
* Normalized config with defaults applied
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
4
9
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
10
|
+
export type NormalizedAlchemyConfig = AlchemyProviderConfig & Required<Pick<AlchemyProviderConfig, "accountAuthMode">>;
|
|
11
|
+
/**
|
|
12
|
+
* Client cache stored in React tree (similar to QueryClient in React Query)
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
interface ClientCache {
|
|
17
|
+
client: SmartWalletClient | null;
|
|
18
|
+
account: SmartContractAccount | null;
|
|
19
|
+
cacheKey: string | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Provider component that configures Alchemy infrastructure for transaction handling
|
|
23
|
+
* Must be nested INSIDE PrivyProvider to access authentication state
|
|
24
|
+
* Automatically manages client cache lifecycle and resets on logout
|
|
25
|
+
*
|
|
26
|
+
* @param {PropsWithChildren<AlchemyProviderConfig>} props - Component props
|
|
27
|
+
* @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
|
|
28
|
+
* @param {string} [props.apiKey] - Your Alchemy API key
|
|
29
|
+
* @param {string} [props.jwt] - JWT token for authentication
|
|
30
|
+
* @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
|
|
31
|
+
* @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
|
|
32
|
+
* @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
|
|
33
|
+
* @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
|
|
34
|
+
* @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
|
|
35
|
+
* @param {'eip7702' | 'owner'} [props.accountAuthMode] - Authorization mode for EVM smart accounts (default: 'eip7702')
|
|
36
|
+
* @returns {JSX.Element} Provider component
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <PrivyProvider appId="...">
|
|
41
|
+
* <AlchemyProvider
|
|
42
|
+
* apiKey="your-alchemy-api-key"
|
|
43
|
+
* policyId="your-gas-policy-id"
|
|
44
|
+
* >
|
|
45
|
+
* <YourApp />
|
|
46
|
+
* </AlchemyProvider>
|
|
47
|
+
* </PrivyProvider>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function AlchemyProvider({ children, accountAuthMode, ...config }: PropsWithChildren<AlchemyProviderConfig>): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* Hook to access Alchemy provider configuration
|
|
53
|
+
* Must be used within an <AlchemyProvider> component
|
|
54
|
+
*
|
|
55
|
+
* @returns {NormalizedAlchemyConfig} The current Alchemy configuration with defaults applied
|
|
56
|
+
* @throws {Error} If used outside of AlchemyProvider
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* const config = useAlchemyConfig();
|
|
61
|
+
* console.log('Policy ID:', config.policyId);
|
|
62
|
+
* console.log('Auth Mode:', config.accountAuthMode); // Always defined
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function useAlchemyConfig(): NormalizedAlchemyConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Hook to access the client cache (internal use only)
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
* @returns {ClientCache} The client cache object
|
|
71
|
+
*/
|
|
72
|
+
export declare function useClientCache(): ClientCache;
|
|
73
|
+
export {};
|
|
7
74
|
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EAKvB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,GACzD,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAI3D;;;;GAIG;AACH,UAAU,WAAW;IACnB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,eAA2B,EAC3B,GAAG,MAAM,EACV,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,2CA0D1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,IAAI,uBAAuB,CAM1D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type ConnectedWallet as PrivyWallet } from "@privy-io/react-auth";
|
|
1
2
|
/**
|
|
2
3
|
* Internal hook to get the Privy embedded wallet
|
|
3
|
-
*
|
|
4
|
+
* Shared across multiple hooks to avoid duplication
|
|
4
5
|
*
|
|
5
6
|
* @internal
|
|
6
|
-
* @returns {() =>
|
|
7
|
+
* @returns {() => PrivyWallet} Function that returns the embedded wallet
|
|
7
8
|
* @throws {Error} If embedded wallet is not found
|
|
8
9
|
*/
|
|
9
|
-
export declare function useEmbeddedWallet(): () =>
|
|
10
|
+
export declare function useEmbeddedWallet(): () => PrivyWallet;
|
|
10
11
|
//# sourceMappingURL=useEmbeddedWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmbeddedWallet.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/useEmbeddedWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEmbeddedWallet.d.ts","sourceRoot":"","sources":["../../../../src/hooks/internal/useEmbeddedWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,eAAe,IAAI,WAAW,EACpC,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,UAGW,WAAW,CAWtD"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
+
import { type SmartContractAccount } from "@aa-sdk/core";
|
|
1
2
|
import { type SmartWalletClient } from "@account-kit/wallet-client";
|
|
3
|
+
export type AlchemyClientResult = {
|
|
4
|
+
client: SmartWalletClient;
|
|
5
|
+
account: SmartContractAccount;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
|
-
* Hook to get and memoize a SmartWalletClient instance
|
|
4
|
-
* The client
|
|
8
|
+
* Hook to get and memoize a SmartWalletClient instance with its associated account
|
|
9
|
+
* The client and account are cached in the AlchemyProvider context (React tree scoped)
|
|
5
10
|
* Automatically clears cache on logout via the provider
|
|
6
11
|
*
|
|
7
|
-
* @returns {{ getClient: () => Promise<
|
|
12
|
+
* @returns {{ getClient: () => Promise<AlchemyClientResult> }} Object containing the smart wallet client and account getter
|
|
8
13
|
*
|
|
9
14
|
* @example
|
|
10
15
|
* ```tsx
|
|
11
16
|
* const { getClient } = useAlchemyClient();
|
|
12
|
-
* const
|
|
17
|
+
* const { client, account } = await getClient();
|
|
13
18
|
* ```
|
|
14
19
|
*/
|
|
15
20
|
export declare function useAlchemyClient(): {
|
|
16
|
-
getClient: () => Promise<
|
|
21
|
+
getClient: () => Promise<AlchemyClientResult>;
|
|
17
22
|
};
|
|
18
23
|
//# sourceMappingURL=useAlchemyClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlchemyClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemyClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAlchemyClient.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAQtB,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAMpC,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,oBAAoB,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB;qBAgCU,OAAO,CAAC,mBAAmB,CAAC;EA0GrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlchemyPrepareSwap.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemyPrepareSwap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAlchemyPrepareSwap.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemyPrepareSwap.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,qBAAqB,IAAI,oBAAoB,CA2D5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlchemySendTransaction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAlchemySendTransaction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySendTransaction.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAIV,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAuBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,yBAAyB,IAAI,wBAAwB,CA2GpE"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
|
|
|
13
13
|
solanaPolicyId?: string | string[];
|
|
14
14
|
/** Solana RPC URL (separate from EVM rpcUrl) */
|
|
15
15
|
solanaRpcUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* How EVM smart account calls should be authorized.
|
|
18
|
+
* - 'eip7702' (default): delegated authorization via EIP-7702.
|
|
19
|
+
* - 'owner': sign as the account owner (Privy embedded wallet), no 7702.
|
|
20
|
+
*/
|
|
21
|
+
accountAuthMode?: "eip7702" | "owner";
|
|
16
22
|
/**
|
|
17
23
|
* Set to true to disable gas sponsorship by default
|
|
18
24
|
* Default: false (sponsorship enabled when policyId is provided)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,GAAG;IAC3E,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,C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3B,KAAK,IAAI,IAAI,CAAC;IAEd,0CAA0C;IAC1C,UAAU,CAAC,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACxE"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.74.0";
|
|
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,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/privy-integration",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.74.0",
|
|
4
4
|
"description": "Use Alchemy gas sponsorship, swaps and more with Privy",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,11 +27,6 @@
|
|
|
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
|
-
},
|
|
35
30
|
"./solana": {
|
|
36
31
|
"types": "./dist/types/solana.d.ts",
|
|
37
32
|
"import": "./dist/esm/solana.js",
|
|
@@ -49,26 +44,18 @@
|
|
|
49
44
|
"test:run": "vitest run --passWithNoTests"
|
|
50
45
|
},
|
|
51
46
|
"devDependencies": {
|
|
52
|
-
"@privy-io/expo": "0.58.1",
|
|
53
47
|
"@privy-io/react-auth": "3.3.0",
|
|
54
48
|
"typescript-template": "*"
|
|
55
49
|
},
|
|
56
50
|
"dependencies": {
|
|
57
|
-
"@account-kit/infra": "^4.
|
|
58
|
-
"@account-kit/wallet-client": "^4.
|
|
51
|
+
"@account-kit/infra": "^4.74.0",
|
|
52
|
+
"@account-kit/wallet-client": "^4.74.0"
|
|
59
53
|
},
|
|
60
54
|
"peerDependencies": {
|
|
61
|
-
"@privy-io/expo": "^0.58.0",
|
|
62
55
|
"@privy-io/react-auth": "^2.3.1 || ^3.0.0",
|
|
63
56
|
"viem": "^2.29.2"
|
|
64
57
|
},
|
|
65
58
|
"peerDependenciesMeta": {
|
|
66
|
-
"@privy-io/react-auth": {
|
|
67
|
-
"optional": true
|
|
68
|
-
},
|
|
69
|
-
"@privy-io/expo": {
|
|
70
|
-
"optional": true
|
|
71
|
-
},
|
|
72
59
|
"@solana/web3.js": {
|
|
73
60
|
"optional": true
|
|
74
61
|
}
|
|
@@ -85,5 +72,5 @@
|
|
|
85
72
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
86
73
|
},
|
|
87
74
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
88
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "4e77fc8eef6262c294f325d4acad720c15a5cbe2"
|
|
89
76
|
}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import {
|
|
3
|
+
useWallets,
|
|
4
|
+
type ConnectedWallet as PrivyWallet,
|
|
5
|
+
} from "@privy-io/react-auth";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Internal hook to get the Privy embedded wallet
|
|
5
|
-
*
|
|
9
|
+
* Shared across multiple hooks to avoid duplication
|
|
6
10
|
*
|
|
7
11
|
* @internal
|
|
8
|
-
* @returns {() =>
|
|
12
|
+
* @returns {() => PrivyWallet} Function that returns the embedded wallet
|
|
9
13
|
* @throws {Error} If embedded wallet is not found
|
|
10
14
|
*/
|
|
11
15
|
export function useEmbeddedWallet() {
|
|
12
|
-
const
|
|
13
|
-
|
|
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;
|
|
14
29
|
}
|