@getpara/react-sdk-lite 2.15.0 → 2.17.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.
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { createSmartAccountHook } from "../createSmartAccountHook.js";
6
+ const ALCHEMY_SMART_ACCOUNT_BASE_KEY = "PARA_ALCHEMY_SMART_ACCOUNT";
7
+ const useAlchemySmartAccount = createSmartAccountHook({
8
+ queryKeyBase: ALCHEMY_SMART_ACCOUNT_BASE_KEY,
9
+ getQueryKey: (p) => {
10
+ var _a;
11
+ return [p.apiKey, (_a = p.chain) == null ? void 0 : _a.id, p.rpcUrl, p.gasPolicyId, p.mode];
12
+ },
13
+ createClient: (params) => __async(void 0, null, function* () {
14
+ let mod;
15
+ try {
16
+ mod = yield import("@getpara/aa-alchemy");
17
+ } catch (e) {
18
+ throw new Error("[@getpara/react-sdk-lite] Please install @getpara/aa-alchemy to use useAlchemySmartAccount");
19
+ }
20
+ return mod.createAlchemySmartAccount(params);
21
+ })
22
+ });
23
+ export {
24
+ ALCHEMY_SMART_ACCOUNT_BASE_KEY,
25
+ useAlchemySmartAccount
26
+ };
@@ -0,0 +1,44 @@
1
+ export declare const BICONOMY_SMART_ACCOUNT_BASE_KEY = "PARA_BICONOMY_SMART_ACCOUNT";
2
+ /**
3
+ * React hook to create and manage a Biconomy smart account.
4
+ *
5
+ * Supports both EIP-4337 and EIP-7702 modes. Transactions are executed via
6
+ * Biconomy's MEE (Multi-chain Execution Environment).
7
+ *
8
+ * Requires `@getpara/aa-biconomy` to be installed.
9
+ */
10
+ export declare const useBiconomySmartAccount: (params?: import("@getpara/aa-biconomy").BiconomySmartAccountConfig & {
11
+ enabled?: boolean;
12
+ }) => import("../types.js").UseSmartAccountResult<NonNullable<import("@getpara/viem-v2-integration/aa").SmartAccount4337<import("@biconomy/abstractjs").MeeActions & {
13
+ request: <T>(params: {
14
+ path: string;
15
+ method?: "GET" | "POST";
16
+ body?: object;
17
+ params?: Record<string, string>;
18
+ headers?: Record<string, string>;
19
+ }) => Promise<T>;
20
+ extend: <const client extends {
21
+ [x: string]: unknown;
22
+ request?: undefined;
23
+ extend?: undefined;
24
+ }, const extendedHttpClient extends import("@biconomy/abstractjs").HttpClient>(fn: (base: extendedHttpClient) => client) => client & extendedHttpClient;
25
+ pollingInterval: number;
26
+ account: import("@biconomy/abstractjs").MultichainSmartAccount;
27
+ info: import("@biconomy/abstractjs").GetInfoPayload;
28
+ }> | import("@getpara/viem-v2-integration/aa").SmartAccount7702<import("@biconomy/abstractjs").MeeActions & {
29
+ request: <T>(params: {
30
+ path: string;
31
+ method?: "GET" | "POST";
32
+ body?: object;
33
+ params?: Record<string, string>;
34
+ headers?: Record<string, string>;
35
+ }) => Promise<T>;
36
+ extend: <const client extends {
37
+ [x: string]: unknown;
38
+ request?: undefined;
39
+ extend?: undefined;
40
+ }, const extendedHttpClient extends import("@biconomy/abstractjs").HttpClient>(fn: (base: extendedHttpClient) => client) => client & extendedHttpClient;
41
+ pollingInterval: number;
42
+ account: import("@biconomy/abstractjs").MultichainSmartAccount;
43
+ info: import("@biconomy/abstractjs").GetInfoPayload;
44
+ }> | null>>;
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { createSmartAccountHook } from "../createSmartAccountHook.js";
6
+ const BICONOMY_SMART_ACCOUNT_BASE_KEY = "PARA_BICONOMY_SMART_ACCOUNT";
7
+ const useBiconomySmartAccount = createSmartAccountHook({
8
+ queryKeyBase: BICONOMY_SMART_ACCOUNT_BASE_KEY,
9
+ getQueryKey: (p) => {
10
+ var _a;
11
+ return [(_a = p.chain) == null ? void 0 : _a.id, p.rpcUrl, p.meeUrl, p.apiKey, p.mode];
12
+ },
13
+ createClient: (params) => __async(void 0, null, function* () {
14
+ let mod;
15
+ try {
16
+ mod = yield import("@getpara/aa-biconomy");
17
+ } catch (e) {
18
+ throw new Error("[@getpara/react-sdk-lite] Please install @getpara/aa-biconomy to use useBiconomySmartAccount");
19
+ }
20
+ return mod.createBiconomySmartAccount(params);
21
+ })
22
+ });
23
+ export {
24
+ BICONOMY_SMART_ACCOUNT_BASE_KEY,
25
+ useBiconomySmartAccount
26
+ };
@@ -0,0 +1,11 @@
1
+ export declare const CDP_SMART_ACCOUNT_BASE_KEY = "PARA_CDP_SMART_ACCOUNT";
2
+ /**
3
+ * React hook to create and manage a Coinbase Developer Platform smart account.
4
+ *
5
+ * CDP operates in EIP-4337 mode only. Only supports Base and Base Sepolia.
6
+ *
7
+ * Requires `@getpara/aa-cdp` to be installed.
8
+ */
9
+ export declare const useCDPSmartAccount: (params?: import("@getpara/aa-cdp").CDPSmartAccountConfig & {
10
+ enabled?: boolean;
11
+ }) => import("../types.js").UseSmartAccountResult<import("@getpara/viem-v2-integration/aa").SmartAccount4337<import("viem/_types/account-abstraction/index.js").BundlerClient>>;
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { createSmartAccountHook } from "../createSmartAccountHook.js";
6
+ const CDP_SMART_ACCOUNT_BASE_KEY = "PARA_CDP_SMART_ACCOUNT";
7
+ const useCDPSmartAccount = createSmartAccountHook({
8
+ queryKeyBase: CDP_SMART_ACCOUNT_BASE_KEY,
9
+ getQueryKey: (p) => {
10
+ var _a;
11
+ return [(_a = p.chain) == null ? void 0 : _a.id, p.rpcUrl, p.rpcToken];
12
+ },
13
+ createClient: (params) => __async(void 0, null, function* () {
14
+ let mod;
15
+ try {
16
+ mod = yield import("@getpara/aa-cdp");
17
+ } catch (e) {
18
+ throw new Error("[@getpara/react-sdk-lite] Please install @getpara/aa-cdp to use useCDPSmartAccount");
19
+ }
20
+ return mod.createCDPSmartAccount(params);
21
+ })
22
+ });
23
+ export {
24
+ CDP_SMART_ACCOUNT_BASE_KEY,
25
+ useCDPSmartAccount
26
+ };
@@ -0,0 +1,13 @@
1
+ import type { Hex, LocalAccount, WalletClient } from 'viem';
2
+ import type { SmartAccountHookConfig, UseSmartAccountResult } from './types.js';
3
+ /**
4
+ * Factory that creates a React hook for a specific smart account provider.
5
+ * Each provider hook uses React Query to manage async account creation.
6
+ */
7
+ export declare function createSmartAccountHook<TParams extends {
8
+ address?: Hex;
9
+ walletId?: string;
10
+ signer?: LocalAccount | WalletClient;
11
+ }, TResult>(config: SmartAccountHookConfig<TParams, TResult>): (params?: TParams & {
12
+ enabled?: boolean;
13
+ }) => UseSmartAccountResult<TResult>;
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __objRest,
5
+ __spreadProps,
6
+ __spreadValues
7
+ } from "../chunk-MMUBH76A.js";
8
+ import { useAccount, useClient, useWallet } from "../provider/index.js";
9
+ import { useStore } from "../provider/stores/useStore.js";
10
+ import { useQuery } from "@tanstack/react-query";
11
+ import { useContext } from "react";
12
+ function createSmartAccountHook(config) {
13
+ return function useSmartAccount(params = {}) {
14
+ var _a, _b, _d, _e, _f, _g, _h, _i, _j;
15
+ const para = useClient();
16
+ const {
17
+ isConnected,
18
+ embedded: { userId }
19
+ } = useAccount();
20
+ const { data: wallet } = useWallet();
21
+ const evmContext = useStore((state) => state.evmContext);
22
+ const evmCtxValue = useContext(evmContext);
23
+ const noopUseAccount = () => void 0;
24
+ const noopUseWalletClient = () => ({
25
+ data: void 0,
26
+ isLoading: false
27
+ });
28
+ const useEvmAccount = (_a = evmCtxValue == null ? void 0 : evmCtxValue.useAccount) != null ? _a : noopUseAccount;
29
+ const useEvmWalletClient = (_b = evmCtxValue == null ? void 0 : evmCtxValue.useWalletClient) != null ? _b : noopUseWalletClient;
30
+ const evmAccount = useEvmAccount();
31
+ const { data: evmWalletClient, isLoading: isEvmWalletClientLoading } = useEvmWalletClient();
32
+ const _c = params != null ? params : {}, { enabled = true } = _c, rest = __objRest(_c, ["enabled"]);
33
+ const configParams = rest;
34
+ const contextAddress = (wallet == null ? void 0 : wallet.type) === "EVM" && !(wallet == null ? void 0 : wallet.isExternal) ? wallet == null ? void 0 : wallet.address : void 0;
35
+ const addressParamIsExternal = (() => {
36
+ if (!para || !(configParams == null ? void 0 : configParams.address)) return false;
37
+ try {
38
+ const w = para.findWalletByAddress(configParams.address, { type: ["EVM"] });
39
+ return !!(w == null ? void 0 : w.isExternal);
40
+ } catch (e) {
41
+ return false;
42
+ }
43
+ })();
44
+ const hasEmbeddedWallet = !!contextAddress;
45
+ const externalEvmAddress = evmAccount == null ? void 0 : evmAccount.address;
46
+ const isPotentiallyExternal = !hasEmbeddedWallet && !!externalEvmAddress || addressParamIsExternal;
47
+ const autoExternalSigner = !(configParams == null ? void 0 : configParams.signer) && isPotentiallyExternal && evmWalletClient ? !addressParamIsExternal || (externalEvmAddress == null ? void 0 : externalEvmAddress.toLowerCase()) === ((_d = configParams == null ? void 0 : configParams.address) == null ? void 0 : _d.toLowerCase()) ? (
48
+ // wagmi's WalletClient type diverges from viem's — cast through unknown to bridge them
49
+ evmWalletClient
50
+ ) : void 0 : void 0;
51
+ const effectiveSigner = (_e = configParams == null ? void 0 : configParams.signer) != null ? _e : autoExternalSigner;
52
+ const signerAddress = effectiveSigner ? "address" in effectiveSigner ? effectiveSigner.address : (_f = effectiveSigner.account) == null ? void 0 : _f.address : void 0;
53
+ const hasSigner = !!effectiveSigner;
54
+ const isAwaitingExternalSigner = isPotentiallyExternal && !(configParams == null ? void 0 : configParams.signer) && isEvmWalletClientLoading;
55
+ const queryResult = useQuery({
56
+ queryKey: [
57
+ config.queryKeyBase,
58
+ isConnected,
59
+ userId,
60
+ (_j = (_i = (_h = (_g = configParams == null ? void 0 : configParams.address) != null ? _g : configParams == null ? void 0 : configParams.walletId) != null ? _h : contextAddress) != null ? _i : signerAddress) != null ? _j : null,
61
+ ...config.getQueryKey(configParams != null ? configParams : {})
62
+ ],
63
+ // Allow the query to run if: Para embedded session is active, OR an external signer is available.
64
+ // Block while waiting for the external wallet client to load.
65
+ enabled: !isAwaitingExternalSigner && (isConnected || hasSigner) && !!para && enabled,
66
+ queryFn: () => __async(this, null, function* () {
67
+ var _a2;
68
+ if (!isConnected && !hasSigner) return null;
69
+ if (!para) return null;
70
+ const address = hasSigner ? configParams == null ? void 0 : configParams.address : (configParams == null ? void 0 : configParams.walletId) ? void 0 : (_a2 = configParams == null ? void 0 : configParams.address) != null ? _a2 : contextAddress;
71
+ return config.createClient(__spreadProps(__spreadValues({}, configParams), { para, address, signer: effectiveSigner }));
72
+ })
73
+ });
74
+ return __spreadProps(__spreadValues({}, queryResult), {
75
+ smartAccount: queryResult.data
76
+ });
77
+ };
78
+ }
79
+ export {
80
+ createSmartAccountHook
81
+ };
@@ -0,0 +1,11 @@
1
+ export declare const GELATO_SMART_ACCOUNT_BASE_KEY = "PARA_GELATO_SMART_ACCOUNT";
2
+ /**
3
+ * React hook to create and manage a Gelato smart account.
4
+ *
5
+ * Gelato operates in EIP-7702 mode only. Uses Gelato's relay for gas-sponsored transactions.
6
+ *
7
+ * Requires `@getpara/aa-gelato` to be installed.
8
+ */
9
+ export declare const useGelatoSmartAccount: (params?: import("@getpara/aa-gelato").GelatoSmartAccountConfig & {
10
+ enabled?: boolean;
11
+ }) => import("../types.js").UseSmartAccountResult<import("@getpara/viem-v2-integration/aa").SmartAccount7702<import("@gelatocloud/gasless").GelatoBundlerClient>>;
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { createSmartAccountHook } from "../createSmartAccountHook.js";
6
+ const GELATO_SMART_ACCOUNT_BASE_KEY = "PARA_GELATO_SMART_ACCOUNT";
7
+ const useGelatoSmartAccount = createSmartAccountHook({
8
+ queryKeyBase: GELATO_SMART_ACCOUNT_BASE_KEY,
9
+ getQueryKey: (p) => {
10
+ var _a;
11
+ return [p.apiKey, (_a = p.chain) == null ? void 0 : _a.id, p.rpcUrl];
12
+ },
13
+ createClient: (params) => __async(void 0, null, function* () {
14
+ let mod;
15
+ try {
16
+ mod = yield import("@getpara/aa-gelato");
17
+ } catch (e) {
18
+ throw new Error("[@getpara/react-sdk-lite] Please install @getpara/aa-gelato to use useGelatoSmartAccount");
19
+ }
20
+ return mod.createGelatoSmartAccount(params);
21
+ })
22
+ });
23
+ export {
24
+ GELATO_SMART_ACCOUNT_BASE_KEY,
25
+ useGelatoSmartAccount
26
+ };