@getpara/react-sdk 2.0.0-alpha.33 → 2.0.0-alpha.34

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,25 @@
1
+ "use client";
2
+ import {
3
+ __async,
4
+ __spreadProps,
5
+ __spreadValues
6
+ } from "../../chunk-MMUBH76A.js";
7
+ import { createParaViemClient } from "@getpara/viem-v2-integration";
8
+ import { getViemAccount } from "./getViemAccount.js";
9
+ const getViemClient = (_0) => __async(void 0, [_0], function* ({
10
+ para,
11
+ address,
12
+ walletClientConfig
13
+ }) {
14
+ const viemAccount = yield getViemAccount({
15
+ para,
16
+ address
17
+ });
18
+ if (!viemAccount || !para) {
19
+ return null;
20
+ }
21
+ return yield createParaViemClient(para, __spreadProps(__spreadValues({}, walletClientConfig), { account: viemAccount }));
22
+ });
23
+ export {
24
+ getViemClient
25
+ };
@@ -0,0 +1,2 @@
1
+ export * from './getViemAccount.js';
2
+ export * from './getViemClient.js';
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ export * from "./getViemAccount.js";
3
+ export * from "./getViemClient.js";
@@ -0,0 +1,2 @@
1
+ export * from './useViemClient.js';
2
+ export * from './useViemAccount.js';
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ export * from "./useViemClient.js";
3
+ export * from "./useViemAccount.js";
@@ -0,0 +1,26 @@
1
+ export declare const VIEM_ACCOUNT_BASE_KEY = "PARA_VIEM_ACCOUNT";
2
+ type UseViemAccountParameters = {
3
+ address?: `0x${string}`;
4
+ };
5
+ export declare const useViemAccount: ({ address }?: UseViemAccountParameters) => {
6
+ viemAccount: {
7
+ address: import("abitype").Address;
8
+ nonceManager?: import("viem").NonceManager | undefined;
9
+ sign?: ((parameters: {
10
+ hash: import("viem").Hash;
11
+ }) => Promise<import("viem").Hex>) | undefined | undefined;
12
+ signAuthorization?: ((parameters: import("viem/_types/types/authorization.js").AuthorizationRequest) => Promise<import("viem/accounts").SignAuthorizationReturnType>) | undefined | undefined;
13
+ signMessage: ({ message }: {
14
+ message: import("viem").SignableMessage;
15
+ }) => Promise<import("viem").Hex>;
16
+ signTransaction: <serializer extends import("viem").SerializeTransactionFn<import("viem").TransactionSerializable> = import("viem").SerializeTransactionFn<import("viem").TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
17
+ serializer?: serializer | undefined;
18
+ } | undefined) => Promise<import("viem").IsNarrowable<import("viem").TransactionSerialized<import("viem").GetTransactionType<transaction>>, import("viem").Hex> extends true ? import("viem").TransactionSerialized<import("viem").GetTransactionType<transaction>> : import("viem").Hex>;
19
+ signTypedData: <const typedData extends import("abitype").TypedData | Record<string, unknown>, primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(parameters: import("viem").TypedDataDefinition<typedData, primaryType>) => Promise<import("viem").Hex>;
20
+ publicKey: import("viem").Hex;
21
+ source: string;
22
+ type: "local";
23
+ } | null | undefined;
24
+ isLoading: boolean;
25
+ };
26
+ export {};
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import {
3
+ __async
4
+ } from "../../chunk-MMUBH76A.js";
5
+ import { useAccount, useClient, useWallet } from "@getpara/react-sdk-lite";
6
+ import { useQuery } from "@tanstack/react-query";
7
+ import { getViemAccount } from "../actions/index.js";
8
+ const VIEM_ACCOUNT_BASE_KEY = "PARA_VIEM_ACCOUNT";
9
+ const useViemAccount = ({ address } = {}) => {
10
+ const para = useClient();
11
+ const {
12
+ isConnected,
13
+ embedded: { userId }
14
+ } = useAccount();
15
+ const { data: wallet } = useWallet();
16
+ const { data, isLoading } = useQuery({
17
+ queryKey: [VIEM_ACCOUNT_BASE_KEY, isConnected, userId, address != null ? address : (wallet == null ? void 0 : wallet.type) === "EVM" ? wallet == null ? void 0 : wallet.address : null],
18
+ enabled: isConnected && !!para,
19
+ queryFn: () => __async(void 0, null, function* () {
20
+ if (!isConnected || !para) {
21
+ return null;
22
+ }
23
+ const _address = address != null ? address : (wallet == null ? void 0 : wallet.type) === "EVM" ? wallet == null ? void 0 : wallet.address : void 0;
24
+ return yield getViemAccount({ para, address: _address });
25
+ })
26
+ });
27
+ return { viemAccount: data, isLoading };
28
+ };
29
+ export {
30
+ VIEM_ACCOUNT_BASE_KEY,
31
+ useViemAccount
32
+ };