@account-kit/privy-integration 4.71.1 → 4.73.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 (41) hide show
  1. package/README.md +117 -9
  2. package/dist/esm/Provider.d.ts +4 -2
  3. package/dist/esm/Provider.js +4 -2
  4. package/dist/esm/Provider.js.map +1 -1
  5. package/dist/esm/hooks/useAlchemySolanaTransaction.d.ts +163 -0
  6. package/dist/esm/hooks/useAlchemySolanaTransaction.js +233 -0
  7. package/dist/esm/hooks/useAlchemySolanaTransaction.js.map +1 -0
  8. package/dist/esm/solana.d.ts +2 -0
  9. package/dist/esm/solana.js +5 -0
  10. package/dist/esm/solana.js.map +1 -0
  11. package/dist/esm/types.d.ts +5 -1
  12. package/dist/esm/types.js.map +1 -1
  13. package/dist/esm/util/createSolanaSponsoredTransaction.d.ts +12 -0
  14. package/dist/esm/util/createSolanaSponsoredTransaction.js +53 -0
  15. package/dist/esm/util/createSolanaSponsoredTransaction.js.map +1 -0
  16. package/dist/esm/util/createSolanaTransaction.d.ts +11 -0
  17. package/dist/esm/util/createSolanaTransaction.js +21 -0
  18. package/dist/esm/util/createSolanaTransaction.js.map +1 -0
  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 +4 -2
  23. package/dist/types/Provider.d.ts.map +1 -1
  24. package/dist/types/hooks/useAlchemySolanaTransaction.d.ts +164 -0
  25. package/dist/types/hooks/useAlchemySolanaTransaction.d.ts.map +1 -0
  26. package/dist/types/solana.d.ts +3 -0
  27. package/dist/types/solana.d.ts.map +1 -0
  28. package/dist/types/types.d.ts +5 -1
  29. package/dist/types/types.d.ts.map +1 -1
  30. package/dist/types/util/createSolanaSponsoredTransaction.d.ts +13 -0
  31. package/dist/types/util/createSolanaSponsoredTransaction.d.ts.map +1 -0
  32. package/dist/types/util/createSolanaTransaction.d.ts +12 -0
  33. package/dist/types/util/createSolanaTransaction.d.ts.map +1 -0
  34. package/dist/types/version.d.ts +1 -1
  35. package/package.json +15 -5
  36. package/src/hooks/useAlchemySolanaTransaction.ts +402 -0
  37. package/src/solana.ts +16 -0
  38. package/src/types.ts +7 -1
  39. package/src/util/createSolanaSponsoredTransaction.ts +75 -0
  40. package/src/util/createSolanaTransaction.ts +31 -0
  41. package/src/version.ts +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlchemySolanaTransaction.js","sourceRoot":"","sources":["../../../src/hooks/useAlchemySolanaTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAkH7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAA2C,EAAE;IAE7C,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;IACjC,MAAM,EAAE,eAAe,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAEjD,yCAAyC;IACzC,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC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ClB,OAAO,EAAE,IAAI,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC9D,QAAQ,CAAC,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,EACD;QACE,cAAc;QACd,UAAU;QACV,iBAAiB;QACjB,wBAAwB;QACxB,IAAI,CAAC,mBAAmB;QACxB,eAAe;KAChB,CACF,CAAC;IAEF,MAAM,eAAe,GAAG,WAAW,CACjC,CAAC,MAA+B,EAAE,EAAE;QAClC,2FAA2F;QAC3F,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC/C,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,UAAU;QACV,IAAI;QACJ,SAAS;QACT,KAAK;QACL,KAAK;QACL,eAAe;QACf,oBAAoB;KACrB,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,OAAe;IAC9B,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { useCallback, useMemo, useState } from \"react\";\nimport {\n Connection,\n PublicKey,\n SystemProgram,\n Transaction,\n TransactionInstruction,\n VersionedTransaction,\n} from \"@solana/web3.js\";\nimport { useAlchemyConfig } from \"../Provider.js\";\nimport { createSolanaSponsoredTransaction } from \"../util/createSolanaSponsoredTransaction.js\";\nimport { useSignTransaction, useWallets } from \"@privy-io/react-auth/solana\";\nimport { createSolanaTransaction } from \"../util/createSolanaTransaction.js\";\n\n/**\n * Type helper for values that can be synchronous or asynchronous\n *\n * @template T - The value type\n */\nexport type PromiseOrValue<T> = T | Promise<T>;\n\n/**\n * Callback to modify a transaction before it's signed\n * Useful for adding additional signatures or metadata\n *\n * @param transaction - The unsigned transaction to modify\n * @returns The modified transaction\n */\nexport type PreSend = (\n this: void,\n transaction: VersionedTransaction | Transaction,\n) => PromiseOrValue<VersionedTransaction | Transaction>;\n\n/**\n * Callback to transform instructions into a custom transaction\n * Useful for advanced transaction construction (e.g., multi-sig, custom versioning)\n *\n * @param instructions - Array of Solana transaction instructions\n * @returns Constructed transaction (legacy or versioned)\n */\nexport type TransformInstruction = (\n this: void,\n instructions: TransactionInstruction[],\n) => PromiseOrValue<Transaction | VersionedTransaction>;\n\n/**\n * Optional transaction lifecycle hooks for advanced use cases\n */\nexport type SolanaTransactionParamOptions = {\n /** Hook called before signing the transaction */\n preSend?: PreSend;\n /** Custom transaction builder from instructions */\n transformInstruction?: TransformInstruction;\n};\n\n/**\n * Parameters for sending a Solana transaction\n * Supports either a simple transfer or custom instructions\n */\nexport type SolanaTransactionParams =\n | {\n /** Simple SOL transfer parameters */\n transfer: {\n /** Amount in lamports (accepts number or bigint) */\n amount: number | bigint;\n /** Recipient's base58-encoded address */\n toAddress: string;\n };\n /** Optional transaction lifecycle hooks */\n transactionComponents?: SolanaTransactionParamOptions;\n /** Options for confirming the transaction on-chain */\n confirmationOptions?: Parameters<Connection[\"confirmTransaction\"]>[1];\n }\n | {\n /** Custom Solana transaction instructions */\n instructions: TransactionInstruction[];\n /** Optional transaction lifecycle hooks */\n transactionComponents?: SolanaTransactionParamOptions;\n /** Options for confirming the transaction on-chain */\n confirmationOptions?: Parameters<Connection[\"confirmTransaction\"]>[1];\n };\n\n/**\n * Result of a successful Solana transaction\n */\nexport interface SolanaTransactionResult {\n /** Base58-encoded transaction signature (hash) */\n hash: string;\n}\n\n/**\n * Configuration options for useAlchemySolanaTransaction hook\n */\nexport interface UseAlchemySolanaTransactionOptions {\n /** Solana RPC URL (overrides provider config) */\n rpcUrl?: string;\n /** Gas sponsorship policy ID (overrides provider config) */\n policyId?: string | void;\n /** Transaction confirmation options */\n confirmationOptions?: Parameters<Connection[\"confirmTransaction\"]>[1];\n /** Specific wallet address to use (defaults to first available wallet) */\n walletAddress?: string;\n}\n\n/**\n * Return type of useAlchemySolanaTransaction hook\n */\nexport interface UseAlchemySolanaTransactionResult {\n /** Active Solana connection instance */\n readonly connection: Connection | null;\n /** Transaction result if successful */\n readonly data: void | SolanaTransactionResult;\n /** Whether a transaction is currently being sent */\n readonly isPending: boolean;\n /** Error if transaction failed */\n readonly error: Error | null;\n /** Reset hook state (clears error, data, isPending) */\n reset(): void;\n /** Send transaction (fire-and-forget, errors caught internally) */\n sendTransaction(params: SolanaTransactionParams): void;\n /** Send transaction and await result (throws on error) */\n sendTransactionAsync(\n params: SolanaTransactionParams,\n ): Promise<SolanaTransactionResult>;\n}\n\n/**\n * Hook to send Solana transactions with optional gas sponsorship via Alchemy\n * Works with Privy's Solana wallet integration for signing transactions\n * Supports both simple transfers and custom instruction sets\n *\n * @param {UseAlchemySolanaTransactionOptions} [opts] - Configuration options\n * @param {string} [opts.rpcUrl] - Solana RPC URL (overrides provider config)\n * @param {string} [opts.policyId] - Gas sponsorship policy ID (overrides provider config)\n * @param {string} [opts.walletAddress] - Specific wallet address to use (defaults to first wallet)\n * @param {Parameters<Connection[\"confirmTransaction\"]>[1]} [opts.confirmationOptions] - Transaction confirmation options\n * @returns {UseAlchemySolanaTransactionResult} Hook result with transaction functions and state\n *\n * @example Simple SOL transfer\n * ```tsx\n * const { sendTransactionAsync, isPending, error, data } = useAlchemySolanaTransaction({\n * rpcUrl: 'https://solana-mainnet.g.alchemy.com/v2/your-api-key',\n * policyId: 'your-policy-id', // Optional: for gas sponsorship\n * });\n *\n * const handleTransfer = async () => {\n * try {\n * const result = await sendTransactionAsync({\n * transfer: {\n * amount: 1_000_000_000, // 1 SOL in lamports\n * toAddress: 'recipient-address',\n * },\n * });\n * console.log('Transaction hash:', result.hash);\n * } catch (err) {\n * console.error('Transaction failed:', err);\n * }\n * };\n * ```\n *\n * @example Custom instructions\n * ```tsx\n * import { SystemProgram, PublicKey } from '@solana/web3.js';\n *\n * const { sendTransactionAsync } = useAlchemySolanaTransaction();\n *\n * // Build your custom instructions\n * const transferIx = SystemProgram.transfer({\n * fromPubkey: new PublicKey(walletAddress),\n * toPubkey: new PublicKey(recipientAddress),\n * lamports: 1_000_000,\n * });\n *\n * // Pass instructions array to the hook\n * const result = await sendTransactionAsync({\n * instructions: [transferIx],\n * });\n * ```\n *\n * @example With provider configuration\n * ```tsx\n * // In your provider setup\n * <AlchemyProvider\n * solanaRpcUrl=\"https://solana-mainnet.g.alchemy.com/v2/...\"\n * solanaPolicyId=\"your-solana-policy-id\"\n * >\n * <YourApp />\n * </AlchemyProvider>\n *\n * // In your component - uses provider config automatically\n * const { sendTransactionAsync } = useAlchemySolanaTransaction();\n * ```\n */\nexport function useAlchemySolanaTransaction(\n opts: UseAlchemySolanaTransactionOptions = {},\n): UseAlchemySolanaTransactionResult {\n const config = useAlchemyConfig();\n const { wallets } = useWallets();\n const { signTransaction } = useSignTransaction();\n\n // Resolve the Privy Solana wallet to use\n const embeddedWallet = useMemo(() => {\n if (opts.walletAddress) {\n const w = wallets.find((w) => w.address === opts.walletAddress);\n if (!w) throw new Error(\"Specified Solana wallet not found\");\n return w;\n }\n return wallets[0];\n }, [wallets, opts.walletAddress]);\n\n // Build Solana connection from rpcUrl (hook override or provider default)\n const connection = useMemo(() => {\n const url = opts.rpcUrl || config.solanaRpcUrl;\n return url ? new Connection(url) : null;\n }, [opts.rpcUrl, config.solanaRpcUrl]);\n\n const [isPending, setIsPending] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<void | SolanaTransactionResult>(undefined);\n\n const resolvedPolicyId = useMemo(() => {\n if (opts.policyId != null) return opts.policyId || undefined;\n // Use solanaPolicyId from config, fallback to policyId for backwards compat\n const configPolicy = config.solanaPolicyId || config.policyId;\n return Array.isArray(configPolicy) ? configPolicy[0] : configPolicy;\n }, [opts.policyId, config.solanaPolicyId, config.policyId]);\n\n const mapTransformInstructions = useMemo(() => {\n const addSponsorship: TransformInstruction = async (instructions) => {\n const policyId = resolvedPolicyId;\n if (!policyId)\n throw new Error(\n \"Gas sponsorship requires a policyId (see provider or hook options).\",\n );\n const localConnection = connection || missing(\"connection\");\n const fromAddress = embeddedWallet?.address;\n if (!fromAddress) throw new Error(\"No embedded Solana wallet connected\");\n return createSolanaSponsoredTransaction(\n instructions,\n localConnection,\n policyId,\n fromAddress,\n );\n };\n const createTx: TransformInstruction = async (instructions) => {\n const localConnection = connection || missing(\"connection\");\n const fromAddress = embeddedWallet?.address;\n if (!fromAddress) throw new Error(\"No embedded Solana wallet connected\");\n return createSolanaTransaction(\n instructions,\n localConnection,\n fromAddress,\n );\n };\n const defaultTransform =\n !!resolvedPolicyId && !config.disableSponsorship\n ? addSponsorship\n : createTx;\n return {\n addSponsorship,\n createTransaction: createTx,\n default: defaultTransform,\n } as const;\n }, [\n resolvedPolicyId,\n config.disableSponsorship,\n connection,\n embeddedWallet?.address,\n ]);\n\n const buildInstructions = useCallback(\n (\n params: SolanaTransactionParams,\n fromAddress: string,\n ): TransactionInstruction[] => {\n if (\"instructions\" in params) return params.instructions;\n return [\n SystemProgram.transfer({\n fromPubkey: new PublicKey(fromAddress),\n toPubkey: new PublicKey(params.transfer.toAddress),\n lamports:\n typeof params.transfer.amount === \"bigint\"\n ? Number(params.transfer.amount) // web3.js currently expects number; callers can pass bigint safely\n : params.transfer.amount,\n }),\n ];\n },\n [],\n );\n\n function toUnsignedBytes(tx: VersionedTransaction | Transaction): Uint8Array {\n // Serialize the full transaction structure (with placeholder signatures)\n // Privy expects the complete transaction format, not just the message\n if (tx instanceof VersionedTransaction) {\n // VersionedTransaction.serialize() includes signature slots\n return tx.serialize();\n }\n // Legacy Transaction: serialize without requiring all signatures\n const buf = tx.serialize({\n requireAllSignatures: false,\n verifySignatures: false,\n });\n return buf instanceof Uint8Array ? buf : new Uint8Array(buf);\n }\n\n const sendTransactionAsync = useCallback(\n async (\n params: SolanaTransactionParams,\n ): Promise<SolanaTransactionResult> => {\n setIsPending(true);\n setError(null);\n try {\n const localConnection = connection || missing(\"connection\");\n if (!embeddedWallet?.address) {\n throw new Error(\"No Solana wallet connected via Privy\");\n }\n\n const fromAddress = embeddedWallet.address;\n const {\n transactionComponents: { preSend, transformInstruction } = {},\n confirmationOptions,\n } = params;\n\n const instructions = buildInstructions(params, fromAddress);\n\n let transaction: VersionedTransaction | Transaction;\n if (transformInstruction) {\n transaction = await transformInstruction(instructions);\n } else {\n transaction = await mapTransformInstructions.default(instructions);\n }\n\n transaction = (await preSend?.(transaction)) || transaction;\n\n // Sign the transaction using Privy's useSignTransaction hook\n const unsignedBytes = toUnsignedBytes(transaction);\n const { signedTransaction } = await signTransaction({\n transaction: unsignedBytes,\n wallet: embeddedWallet,\n });\n\n // Broadcast the signed transaction\n const hash = await localConnection.sendRawTransaction(\n signedTransaction,\n { skipPreflight: false },\n );\n\n if (confirmationOptions || opts.confirmationOptions) {\n await localConnection.confirmTransaction(\n hash,\n confirmationOptions || opts.confirmationOptions,\n );\n }\n\n setData({ hash });\n return { hash };\n } catch (err) {\n const e = err instanceof Error ? err : new Error(String(err));\n setError(e);\n throw e;\n } finally {\n setIsPending(false);\n }\n },\n [\n embeddedWallet,\n connection,\n buildInstructions,\n mapTransformInstructions,\n opts.confirmationOptions,\n signTransaction,\n ],\n );\n\n const sendTransaction = useCallback(\n (params: SolanaTransactionParams) => {\n // Prevent unhandled rejection warnings; error state is already set in sendTransactionAsync\n sendTransactionAsync(params).catch(() => {});\n },\n [sendTransactionAsync],\n );\n\n const reset = useCallback(() => {\n setIsPending(false);\n setError(null);\n setData(undefined);\n }, []);\n\n return {\n connection,\n data,\n isPending,\n error,\n reset,\n sendTransaction,\n sendTransactionAsync,\n };\n}\n\nfunction missing(message: string): never {\n throw new Error(message);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { useAlchemySolanaTransaction } from "./hooks/useAlchemySolanaTransaction.js";
2
+ export type { PromiseOrValue, PreSend, TransformInstruction, SolanaTransactionParamOptions, SolanaTransactionParams, SolanaTransactionResult, UseAlchemySolanaTransactionOptions, UseAlchemySolanaTransactionResult, } from "./hooks/useAlchemySolanaTransaction.js";
@@ -0,0 +1,5 @@
1
+ // Solana-specific exports
2
+ // Import from '@account-kit/privy-integration/solana' to use Solana functionality
3
+ // This ensures @solana/web3.js is only loaded when explicitly needed
4
+ export { useAlchemySolanaTransaction } from "./hooks/useAlchemySolanaTransaction.js";
5
+ //# sourceMappingURL=solana.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana.js","sourceRoot":"","sources":["../../src/solana.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,kFAAkF;AAClF,qEAAqE;AAErE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["// Solana-specific exports\n// Import from '@account-kit/privy-integration/solana' to use Solana functionality\n// This ensures @solana/web3.js is only loaded when explicitly needed\n\nexport { useAlchemySolanaTransaction } from \"./hooks/useAlchemySolanaTransaction.js\";\n\nexport type {\n PromiseOrValue,\n PreSend,\n TransformInstruction,\n SolanaTransactionParamOptions,\n SolanaTransactionParams,\n SolanaTransactionResult,\n UseAlchemySolanaTransactionOptions,\n UseAlchemySolanaTransactionResult,\n} from \"./hooks/useAlchemySolanaTransaction.js\";\n"]}
@@ -7,8 +7,12 @@ import type { z } from "zod";
7
7
  * Uses ConnectionConfigSchema to ensure valid transport configuration
8
8
  */
9
9
  export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
10
- /** Policy ID(s) for gas sponsorship */
10
+ /** Policy ID(s) for EVM gas sponsorship */
11
11
  policyId?: string | string[];
12
+ /** Policy ID(s) for Solana gas sponsorship */
13
+ solanaPolicyId?: string | string[];
14
+ /** Solana RPC URL (separate from EVM rpcUrl) */
15
+ solanaRpcUrl?: string;
12
16
  /**
13
17
  * Set to true to disable gas sponsorship by default
14
18
  * Default: false (sponsorship enabled when policyId is provided)
@@ -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 gas sponsorship */\n policyId?: string | 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 * 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"]}
@@ -0,0 +1,12 @@
1
+ import type { TransactionInstruction } from "@solana/web3.js";
2
+ import { Connection, VersionedTransaction } from "@solana/web3.js";
3
+ /**
4
+ * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service
5
+ *
6
+ * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to
7
+ * @param {Connection} connection - The connection to use
8
+ * @param {string} policyId - The policy id to use
9
+ * @param {string} address - The address to use
10
+ * @returns {Promise<VersionedTransaction>} - The sponsored transaction
11
+ */
12
+ export declare function createSolanaSponsoredTransaction(instructions: TransactionInstruction[], connection: Connection, policyId: string, address: string): Promise<VersionedTransaction>;
@@ -0,0 +1,53 @@
1
+ import { Connection, PublicKey, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
2
+ /**
3
+ * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service
4
+ *
5
+ * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to
6
+ * @param {Connection} connection - The connection to use
7
+ * @param {string} policyId - The policy id to use
8
+ * @param {string} address - The address to use
9
+ * @returns {Promise<VersionedTransaction>} - The sponsored transaction
10
+ */
11
+ export async function createSolanaSponsoredTransaction(instructions, connection, policyId, address) {
12
+ const { blockhash } = await connection.getLatestBlockhash({
13
+ commitment: "finalized",
14
+ });
15
+ const message = new TransactionMessage({
16
+ // Right now the backend will rewrite this payer Key to the server's address
17
+ payerKey: new PublicKey(address),
18
+ recentBlockhash: blockhash,
19
+ instructions,
20
+ }).compileToV0Message();
21
+ const versionedTransaction = new VersionedTransaction(message);
22
+ const serializedTransaction = Buffer.from(versionedTransaction.serialize()).toString("base64");
23
+ const body = JSON.stringify({
24
+ id: crypto?.randomUUID() ??
25
+ `${Date.now()}-${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`,
26
+ jsonrpc: "2.0",
27
+ method: "alchemy_requestFeePayer",
28
+ params: [
29
+ {
30
+ policyId,
31
+ serializedTransaction,
32
+ },
33
+ ],
34
+ });
35
+ const options = {
36
+ method: "POST",
37
+ headers: {
38
+ accept: "application/json",
39
+ "content-type": "application/json",
40
+ "X-Alchemy-Client-Breadcrumb": "privyIntegrationSdk",
41
+ },
42
+ body,
43
+ };
44
+ const response = await fetch(connection.rpcEndpoint, options);
45
+ const jsonResponse = await response.json();
46
+ if (!jsonResponse?.result?.serializedTransaction)
47
+ throw new Error(`Response doesn't include the serializedTransaction ${JSON.stringify(jsonResponse)}`);
48
+ return VersionedTransaction.deserialize(decodeBase64(jsonResponse.result.serializedTransaction));
49
+ }
50
+ function decodeBase64(serializedTransaction) {
51
+ return Buffer.from(serializedTransaction, "base64");
52
+ }
53
+ //# sourceMappingURL=createSolanaSponsoredTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSolanaSponsoredTransaction.js","sourceRoot":"","sources":["../../../src/util/createSolanaSponsoredTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,YAAsC,EACtC,UAAsB,EACtB,QAAgB,EAChB,OAAe;IAEf,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;QACxD,UAAU,EAAE,WAAW;KACxB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC;QACrC,4EAA4E;QAC5E,QAAQ,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC;QAChC,eAAe,EAAE,SAAS;QAC1B,YAAY;KACb,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACxB,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CACvC,oBAAoB,CAAC,SAAS,EAAE,CACjC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,EAAE,EACA,MAAM,EAAE,UAAU,EAAE;YACpB,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE;QACxE,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,yBAAyB;QACjC,MAAM,EAAE;YACN;gBACE,QAAQ;gBACR,qBAAqB;aACtB;SACF;KACF,CAAC,CAAC;IACH,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;YAClC,6BAA6B,EAAE,qBAAqB;SACrD;QACD,IAAI;KACL,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,qBAAqB;QAC9C,MAAM,IAAI,KAAK,CACb,sDAAsD,IAAI,CAAC,SAAS,CAClE,YAAY,CACb,EAAE,CACJ,CAAC;IACJ,OAAO,oBAAoB,CAAC,WAAW,CACrC,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,qBAAqB,CAAC,CACxD,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,qBAA6B;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import type { TransactionInstruction } from \"@solana/web3.js\";\nimport {\n Connection,\n PublicKey,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\n\n/**\n * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service\n *\n * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to\n * @param {Connection} connection - The connection to use\n * @param {string} policyId - The policy id to use\n * @param {string} address - The address to use\n * @returns {Promise<VersionedTransaction>} - The sponsored transaction\n */\nexport async function createSolanaSponsoredTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n policyId: string,\n address: string,\n): Promise<VersionedTransaction> {\n const { blockhash } = await connection.getLatestBlockhash({\n commitment: \"finalized\",\n });\n const message = new TransactionMessage({\n // Right now the backend will rewrite this payer Key to the server's address\n payerKey: new PublicKey(address),\n recentBlockhash: blockhash,\n instructions,\n }).compileToV0Message();\n const versionedTransaction = new VersionedTransaction(message);\n const serializedTransaction = Buffer.from(\n versionedTransaction.serialize(),\n ).toString(\"base64\");\n const body = JSON.stringify({\n id:\n crypto?.randomUUID() ??\n `${Date.now()}-${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`,\n jsonrpc: \"2.0\",\n method: \"alchemy_requestFeePayer\",\n params: [\n {\n policyId,\n serializedTransaction,\n },\n ],\n });\n const options = {\n method: \"POST\",\n headers: {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n \"X-Alchemy-Client-Breadcrumb\": \"privyIntegrationSdk\",\n },\n body,\n };\n\n const response = await fetch(connection.rpcEndpoint, options);\n const jsonResponse = await response.json();\n if (!jsonResponse?.result?.serializedTransaction)\n throw new Error(\n `Response doesn't include the serializedTransaction ${JSON.stringify(\n jsonResponse,\n )}`,\n );\n return VersionedTransaction.deserialize(\n decodeBase64(jsonResponse.result.serializedTransaction),\n );\n}\n\nfunction decodeBase64(serializedTransaction: string): Uint8Array {\n return Buffer.from(serializedTransaction, \"base64\");\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { TransactionInstruction } from "@solana/web3.js";
2
+ import { Connection, VersionedTransaction } from "@solana/web3.js";
3
+ /**
4
+ * Creates a regular (non-sponsored) Solana transaction from instructions
5
+ *
6
+ * @param {TransactionInstruction[]} instructions - The instructions to create transaction from
7
+ * @param {Connection} connection - The connection to use
8
+ * @param {string} address - The payer address
9
+ * @returns {Promise<VersionedTransaction>} - The transaction
10
+ */
11
+ export declare function createSolanaTransaction(instructions: TransactionInstruction[], connection: Connection, address: string): Promise<VersionedTransaction>;
@@ -0,0 +1,21 @@
1
+ import { Connection, PublicKey, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
2
+ /**
3
+ * Creates a regular (non-sponsored) Solana transaction from instructions
4
+ *
5
+ * @param {TransactionInstruction[]} instructions - The instructions to create transaction from
6
+ * @param {Connection} connection - The connection to use
7
+ * @param {string} address - The payer address
8
+ * @returns {Promise<VersionedTransaction>} - The transaction
9
+ */
10
+ export async function createSolanaTransaction(instructions, connection, address) {
11
+ const { blockhash } = await connection.getLatestBlockhash({
12
+ commitment: "finalized",
13
+ });
14
+ const message = new TransactionMessage({
15
+ payerKey: new PublicKey(address),
16
+ recentBlockhash: blockhash,
17
+ instructions,
18
+ }).compileToV0Message();
19
+ return new VersionedTransaction(message);
20
+ }
21
+ //# sourceMappingURL=createSolanaTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSolanaTransaction.js","sourceRoot":"","sources":["../../../src/util/createSolanaTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,YAAsC,EACtC,UAAsB,EACtB,OAAe;IAEf,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC;QACxD,UAAU,EAAE,WAAW;KACxB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC;QACrC,QAAQ,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC;QAChC,eAAe,EAAE,SAAS;QAC1B,YAAY;KACb,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACxB,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import type { TransactionInstruction } from \"@solana/web3.js\";\nimport {\n Connection,\n PublicKey,\n TransactionMessage,\n VersionedTransaction,\n} from \"@solana/web3.js\";\n\n/**\n * Creates a regular (non-sponsored) Solana transaction from instructions\n *\n * @param {TransactionInstruction[]} instructions - The instructions to create transaction from\n * @param {Connection} connection - The connection to use\n * @param {string} address - The payer address\n * @returns {Promise<VersionedTransaction>} - The transaction\n */\nexport async function createSolanaTransaction(\n instructions: TransactionInstruction[],\n connection: Connection,\n address: string,\n): Promise<VersionedTransaction> {\n const { blockhash } = await connection.getLatestBlockhash({\n commitment: \"finalized\",\n });\n const message = new TransactionMessage({\n payerKey: new PublicKey(address),\n recentBlockhash: blockhash,\n instructions,\n }).compileToV0Message();\n return new VersionedTransaction(message);\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.71.1";
1
+ export declare const VERSION = "4.73.0";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.71.1";
3
+ export const VERSION = "4.73.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -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,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.71.1\";\n"]}
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.73.0\";\n"]}
@@ -19,8 +19,10 @@ interface ClientCache {
19
19
  * @param {React.ReactNode} props.children - React children to wrap with Alchemy configuration
20
20
  * @param {string} [props.apiKey] - Your Alchemy API key
21
21
  * @param {string} [props.jwt] - JWT token for authentication
22
- * @param {string} [props.rpcUrl] - Custom RPC URL
23
- * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s)
22
+ * @param {string} [props.rpcUrl] - Custom RPC URL for EVM chains
23
+ * @param {string} [props.solanaRpcUrl] - Custom RPC URL for Solana
24
+ * @param {string | string[]} [props.policyId] - Gas Manager policy ID(s) for EVM chains
25
+ * @param {string | string[]} [props.solanaPolicyId] - Gas Manager policy ID(s) for Solana
24
26
  * @param {boolean} [props.disableSponsorship] - Set to true to disable sponsorship by default (default: false)
25
27
  * @returns {JSX.Element} Provider component
26
28
  *
@@ -1 +1 @@
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,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIxD;;;;GAIG;AACH,UAAU,WAAW;IACnB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,2CAiD1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C"}
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,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIxD;;;;GAIG;AACH,UAAU,WAAW;IACnB,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,2CAiD1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAMxD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAQ5C"}
@@ -0,0 +1,164 @@
1
+ import { Connection, Transaction, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
2
+ /**
3
+ * Type helper for values that can be synchronous or asynchronous
4
+ *
5
+ * @template T - The value type
6
+ */
7
+ export type PromiseOrValue<T> = T | Promise<T>;
8
+ /**
9
+ * Callback to modify a transaction before it's signed
10
+ * Useful for adding additional signatures or metadata
11
+ *
12
+ * @param transaction - The unsigned transaction to modify
13
+ * @returns The modified transaction
14
+ */
15
+ export type PreSend = (this: void, transaction: VersionedTransaction | Transaction) => PromiseOrValue<VersionedTransaction | Transaction>;
16
+ /**
17
+ * Callback to transform instructions into a custom transaction
18
+ * Useful for advanced transaction construction (e.g., multi-sig, custom versioning)
19
+ *
20
+ * @param instructions - Array of Solana transaction instructions
21
+ * @returns Constructed transaction (legacy or versioned)
22
+ */
23
+ export type TransformInstruction = (this: void, instructions: TransactionInstruction[]) => PromiseOrValue<Transaction | VersionedTransaction>;
24
+ /**
25
+ * Optional transaction lifecycle hooks for advanced use cases
26
+ */
27
+ export type SolanaTransactionParamOptions = {
28
+ /** Hook called before signing the transaction */
29
+ preSend?: PreSend;
30
+ /** Custom transaction builder from instructions */
31
+ transformInstruction?: TransformInstruction;
32
+ };
33
+ /**
34
+ * Parameters for sending a Solana transaction
35
+ * Supports either a simple transfer or custom instructions
36
+ */
37
+ export type SolanaTransactionParams = {
38
+ /** Simple SOL transfer parameters */
39
+ transfer: {
40
+ /** Amount in lamports (accepts number or bigint) */
41
+ amount: number | bigint;
42
+ /** Recipient's base58-encoded address */
43
+ toAddress: string;
44
+ };
45
+ /** Optional transaction lifecycle hooks */
46
+ transactionComponents?: SolanaTransactionParamOptions;
47
+ /** Options for confirming the transaction on-chain */
48
+ confirmationOptions?: Parameters<Connection["confirmTransaction"]>[1];
49
+ } | {
50
+ /** Custom Solana transaction instructions */
51
+ instructions: TransactionInstruction[];
52
+ /** Optional transaction lifecycle hooks */
53
+ transactionComponents?: SolanaTransactionParamOptions;
54
+ /** Options for confirming the transaction on-chain */
55
+ confirmationOptions?: Parameters<Connection["confirmTransaction"]>[1];
56
+ };
57
+ /**
58
+ * Result of a successful Solana transaction
59
+ */
60
+ export interface SolanaTransactionResult {
61
+ /** Base58-encoded transaction signature (hash) */
62
+ hash: string;
63
+ }
64
+ /**
65
+ * Configuration options for useAlchemySolanaTransaction hook
66
+ */
67
+ export interface UseAlchemySolanaTransactionOptions {
68
+ /** Solana RPC URL (overrides provider config) */
69
+ rpcUrl?: string;
70
+ /** Gas sponsorship policy ID (overrides provider config) */
71
+ policyId?: string | void;
72
+ /** Transaction confirmation options */
73
+ confirmationOptions?: Parameters<Connection["confirmTransaction"]>[1];
74
+ /** Specific wallet address to use (defaults to first available wallet) */
75
+ walletAddress?: string;
76
+ }
77
+ /**
78
+ * Return type of useAlchemySolanaTransaction hook
79
+ */
80
+ export interface UseAlchemySolanaTransactionResult {
81
+ /** Active Solana connection instance */
82
+ readonly connection: Connection | null;
83
+ /** Transaction result if successful */
84
+ readonly data: void | SolanaTransactionResult;
85
+ /** Whether a transaction is currently being sent */
86
+ readonly isPending: boolean;
87
+ /** Error if transaction failed */
88
+ readonly error: Error | null;
89
+ /** Reset hook state (clears error, data, isPending) */
90
+ reset(): void;
91
+ /** Send transaction (fire-and-forget, errors caught internally) */
92
+ sendTransaction(params: SolanaTransactionParams): void;
93
+ /** Send transaction and await result (throws on error) */
94
+ sendTransactionAsync(params: SolanaTransactionParams): Promise<SolanaTransactionResult>;
95
+ }
96
+ /**
97
+ * Hook to send Solana transactions with optional gas sponsorship via Alchemy
98
+ * Works with Privy's Solana wallet integration for signing transactions
99
+ * Supports both simple transfers and custom instruction sets
100
+ *
101
+ * @param {UseAlchemySolanaTransactionOptions} [opts] - Configuration options
102
+ * @param {string} [opts.rpcUrl] - Solana RPC URL (overrides provider config)
103
+ * @param {string} [opts.policyId] - Gas sponsorship policy ID (overrides provider config)
104
+ * @param {string} [opts.walletAddress] - Specific wallet address to use (defaults to first wallet)
105
+ * @param {Parameters<Connection["confirmTransaction"]>[1]} [opts.confirmationOptions] - Transaction confirmation options
106
+ * @returns {UseAlchemySolanaTransactionResult} Hook result with transaction functions and state
107
+ *
108
+ * @example Simple SOL transfer
109
+ * ```tsx
110
+ * const { sendTransactionAsync, isPending, error, data } = useAlchemySolanaTransaction({
111
+ * rpcUrl: 'https://solana-mainnet.g.alchemy.com/v2/your-api-key',
112
+ * policyId: 'your-policy-id', // Optional: for gas sponsorship
113
+ * });
114
+ *
115
+ * const handleTransfer = async () => {
116
+ * try {
117
+ * const result = await sendTransactionAsync({
118
+ * transfer: {
119
+ * amount: 1_000_000_000, // 1 SOL in lamports
120
+ * toAddress: 'recipient-address',
121
+ * },
122
+ * });
123
+ * console.log('Transaction hash:', result.hash);
124
+ * } catch (err) {
125
+ * console.error('Transaction failed:', err);
126
+ * }
127
+ * };
128
+ * ```
129
+ *
130
+ * @example Custom instructions
131
+ * ```tsx
132
+ * import { SystemProgram, PublicKey } from '@solana/web3.js';
133
+ *
134
+ * const { sendTransactionAsync } = useAlchemySolanaTransaction();
135
+ *
136
+ * // Build your custom instructions
137
+ * const transferIx = SystemProgram.transfer({
138
+ * fromPubkey: new PublicKey(walletAddress),
139
+ * toPubkey: new PublicKey(recipientAddress),
140
+ * lamports: 1_000_000,
141
+ * });
142
+ *
143
+ * // Pass instructions array to the hook
144
+ * const result = await sendTransactionAsync({
145
+ * instructions: [transferIx],
146
+ * });
147
+ * ```
148
+ *
149
+ * @example With provider configuration
150
+ * ```tsx
151
+ * // In your provider setup
152
+ * <AlchemyProvider
153
+ * solanaRpcUrl="https://solana-mainnet.g.alchemy.com/v2/..."
154
+ * solanaPolicyId="your-solana-policy-id"
155
+ * >
156
+ * <YourApp />
157
+ * </AlchemyProvider>
158
+ *
159
+ * // In your component - uses provider config automatically
160
+ * const { sendTransactionAsync } = useAlchemySolanaTransaction();
161
+ * ```
162
+ */
163
+ export declare function useAlchemySolanaTransaction(opts?: UseAlchemySolanaTransactionOptions): UseAlchemySolanaTransactionResult;
164
+ //# sourceMappingURL=useAlchemySolanaTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlchemySolanaTransaction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAlchemySolanaTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAMzB;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,oBAAoB,GAAG,WAAW,KAC5C,cAAc,CAAC,oBAAoB,GAAG,WAAW,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,sBAAsB,EAAE,KACnC,cAAc,CAAC,WAAW,GAAG,oBAAoB,CAAC,C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,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IACvC,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,uBAAuB,CAAC;IAC9C,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,uDAAuD;IACvD,KAAK,IAAI,IAAI,CAAC;IACd,mEAAmE;IACnE,eAAe,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACvD,0DAA0D;IAC1D,oBAAoB,CAClB,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE,kCAAuC,GAC5C,iCAAiC,CA0MnC"}
@@ -0,0 +1,3 @@
1
+ export { useAlchemySolanaTransaction } from "./hooks/useAlchemySolanaTransaction.js";
2
+ export type { PromiseOrValue, PreSend, TransformInstruction, SolanaTransactionParamOptions, SolanaTransactionParams, SolanaTransactionResult, UseAlchemySolanaTransactionOptions, UseAlchemySolanaTransactionResult, } from "./hooks/useAlchemySolanaTransaction.js";
3
+ //# sourceMappingURL=solana.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/solana.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAErF,YAAY,EACV,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,EACvB,kCAAkC,EAClC,iCAAiC,GAClC,MAAM,wCAAwC,CAAC"}
@@ -7,8 +7,12 @@ import type { z } from "zod";
7
7
  * Uses ConnectionConfigSchema to ensure valid transport configuration
8
8
  */
9
9
  export type AlchemyProviderConfig = z.infer<typeof ConnectionConfigSchema> & {
10
- /** Policy ID(s) for gas sponsorship */
10
+ /** Policy ID(s) for EVM gas sponsorship */
11
11
  policyId?: string | string[];
12
+ /** Policy ID(s) for Solana gas sponsorship */
13
+ solanaPolicyId?: string | string[];
14
+ /** Solana RPC URL (separate from EVM rpcUrl) */
15
+ solanaRpcUrl?: string;
12
16
  /**
13
17
  * Set to true to disable gas sponsorship by default
14
18
  * 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,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,wBAAwB;IACxB,EAAE,EAAE,OAAO,CAAC;IAEZ,kCAAkC;IAClC,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WA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,KAAK,GAAG,SAAS,CAAA;CAAE,CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,SAAS,EAAE,OAAO,CAAC;IAEnB,kCAAkC;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,uCAAuC;IACvC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE/B,2BAA2B;IAC3B,KAAK,IAAI,IAAI,CAAC;IAEd,6CAA6C;IAC7C,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACtE;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IAEnB,iCAAiC;IACjC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEpB,2CAA2C;IAC3C,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE9B,2BAA2B;IAC3B,KAAK,IAAI,IAAI,CAAC;IAEd,0CAA0C;IAC1C,UAAU,CAAC,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACxE"}
@@ -0,0 +1,13 @@
1
+ import type { TransactionInstruction } from "@solana/web3.js";
2
+ import { Connection, VersionedTransaction } from "@solana/web3.js";
3
+ /**
4
+ * This function wraps instructions in a sponsored transaction using Alchemy's fee payer service
5
+ *
6
+ * @param {TransactionInstruction[]} instructions - The instructions to add sponsorship to
7
+ * @param {Connection} connection - The connection to use
8
+ * @param {string} policyId - The policy id to use
9
+ * @param {string} address - The address to use
10
+ * @returns {Promise<VersionedTransaction>} - The sponsored transaction
11
+ */
12
+ export declare function createSolanaSponsoredTransaction(instructions: TransactionInstruction[], connection: Connection, policyId: string, address: string): Promise<VersionedTransaction>;
13
+ //# sourceMappingURL=createSolanaSponsoredTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSolanaSponsoredTransaction.d.ts","sourceRoot":"","sources":["../../../src/util/createSolanaSponsoredTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,UAAU,EAGV,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;GAQG;AACH,wBAAsB,gCAAgC,CACpD,YAAY,EAAE,sBAAsB,EAAE,EACtC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAgD/B"}
@@ -0,0 +1,12 @@
1
+ import type { TransactionInstruction } from "@solana/web3.js";
2
+ import { Connection, VersionedTransaction } from "@solana/web3.js";
3
+ /**
4
+ * Creates a regular (non-sponsored) Solana transaction from instructions
5
+ *
6
+ * @param {TransactionInstruction[]} instructions - The instructions to create transaction from
7
+ * @param {Connection} connection - The connection to use
8
+ * @param {string} address - The payer address
9
+ * @returns {Promise<VersionedTransaction>} - The transaction
10
+ */
11
+ export declare function createSolanaTransaction(instructions: TransactionInstruction[], connection: Connection, address: string): Promise<VersionedTransaction>;
12
+ //# sourceMappingURL=createSolanaTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSolanaTransaction.d.ts","sourceRoot":"","sources":["../../../src/util/createSolanaTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,UAAU,EAGV,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,YAAY,EAAE,sBAAsB,EAAE,EACtC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAU/B"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.71.1";
1
+ export declare const VERSION = "4.73.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/privy-integration",
3
- "version": "4.71.1",
3
+ "version": "4.73.0",
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
+ "./solana": {
31
+ "types": "./dist/types/solana.d.ts",
32
+ "import": "./dist/esm/solana.js",
33
+ "default": "./dist/esm/solana.js"
34
+ },
30
35
  "./package.json": "./package.json"
31
36
  },
32
37
  "scripts": {
@@ -39,17 +44,22 @@
39
44
  "test:run": "vitest run --passWithNoTests"
40
45
  },
41
46
  "devDependencies": {
42
- "@privy-io/react-auth": "^2.3.1",
47
+ "@privy-io/react-auth": "3.3.0",
43
48
  "typescript-template": "*"
44
49
  },
45
50
  "dependencies": {
46
- "@account-kit/infra": "^4.71.1",
47
- "@account-kit/wallet-client": "^4.71.1"
51
+ "@account-kit/infra": "^4.73.0",
52
+ "@account-kit/wallet-client": "^4.73.0"
48
53
  },
49
54
  "peerDependencies": {
50
55
  "@privy-io/react-auth": "^2.3.1 || ^3.0.0",
51
56
  "viem": "^2.29.2"
52
57
  },
58
+ "peerDependenciesMeta": {
59
+ "@solana/web3.js": {
60
+ "optional": true
61
+ }
62
+ },
53
63
  "publishConfig": {
54
64
  "access": "public",
55
65
  "registry": "https://registry.npmjs.org/"
@@ -62,5 +72,5 @@
62
72
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
63
73
  },
64
74
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
65
- "gitHead": "5d0007b85f6594847cbafbc2326cb6ce17239bf7"
75
+ "gitHead": "1471537aa2b9e8cac4661b7162aa9c702efac7f1"
66
76
  }