@getpara/react-core 2.21.0 → 2.22.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 (93) hide show
  1. package/dist/chains/cosmos/index.d.ts +4 -0
  2. package/dist/chains/cosmos/index.js +19 -0
  3. package/dist/chains/cosmos/mutations.d.ts +175 -0
  4. package/dist/chains/cosmos/mutations.js +63 -0
  5. package/dist/chains/cosmos/types.d.ts +9 -0
  6. package/dist/chains/cosmos/types.js +0 -0
  7. package/dist/chains/cosmos/useParaCosmjsAminoSigner.d.ts +54 -0
  8. package/dist/chains/cosmos/useParaCosmjsAminoSigner.js +115 -0
  9. package/dist/chains/cosmos/useParaCosmjsProtoSigner.d.ts +56 -0
  10. package/dist/chains/cosmos/useParaCosmjsProtoSigner.js +115 -0
  11. package/dist/chains/evm/ethers/index.d.ts +3 -0
  12. package/dist/chains/evm/ethers/index.js +7 -0
  13. package/dist/chains/evm/ethers/mutations.d.ts +608 -0
  14. package/dist/chains/evm/ethers/mutations.js +112 -0
  15. package/dist/chains/evm/ethers/types.d.ts +8 -0
  16. package/dist/chains/evm/ethers/types.js +0 -0
  17. package/dist/chains/evm/ethers/useParaEthersSigner.d.ts +55 -0
  18. package/dist/chains/evm/ethers/useParaEthersSigner.js +115 -0
  19. package/dist/chains/evm/viem/index.d.ts +4 -0
  20. package/dist/chains/evm/viem/index.js +11 -0
  21. package/dist/chains/evm/viem/mutations.d.ts +546 -0
  22. package/dist/chains/evm/viem/mutations.js +146 -0
  23. package/dist/chains/evm/viem/types.d.ts +10 -0
  24. package/dist/chains/evm/viem/types.js +0 -0
  25. package/dist/chains/evm/viem/useParaViemAccount.d.ts +44 -0
  26. package/dist/chains/evm/viem/useParaViemAccount.js +108 -0
  27. package/dist/chains/evm/viem/useParaViemClient.d.ts +57 -0
  28. package/dist/chains/evm/viem/useParaViemClient.js +115 -0
  29. package/dist/chains/index.d.ts +6 -0
  30. package/dist/chains/index.js +5 -0
  31. package/dist/chains/resolveWallet.d.ts +20 -0
  32. package/dist/chains/resolveWallet.js +42 -0
  33. package/dist/chains/solana/index.d.ts +3 -0
  34. package/dist/chains/solana/index.js +7 -0
  35. package/dist/chains/solana/mutations.d.ts +129 -0
  36. package/dist/chains/solana/mutations.js +59 -0
  37. package/dist/chains/solana/types.d.ts +7 -0
  38. package/dist/chains/solana/types.js +0 -0
  39. package/dist/chains/solana/useParaSolanaSigner.d.ts +59 -0
  40. package/dist/chains/solana/useParaSolanaSigner.js +108 -0
  41. package/dist/chains/stellar/index.d.ts +3 -0
  42. package/dist/chains/stellar/index.js +7 -0
  43. package/dist/chains/stellar/mutations.d.ts +351 -0
  44. package/dist/chains/stellar/mutations.js +77 -0
  45. package/dist/chains/stellar/types.d.ts +3 -0
  46. package/dist/chains/stellar/types.js +0 -0
  47. package/dist/chains/stellar/useParaStellarSigner.d.ts +54 -0
  48. package/dist/chains/stellar/useParaStellarSigner.js +108 -0
  49. package/dist/chains/types.d.ts +21 -0
  50. package/dist/chains/types.js +0 -0
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.js +4 -1
  53. package/dist/provider/ParaProviderCore.d.ts +39 -47
  54. package/dist/provider/ParaProviderCore.js +11 -6
  55. package/dist/provider/actions/index.d.ts +5 -0
  56. package/dist/provider/hooks/aa/createSmartAccountHook.js +3 -2
  57. package/dist/provider/hooks/aa/thirdweb.d.ts +6 -2
  58. package/dist/provider/hooks/mutations/useAuthenticateWithEmailOrPhone.d.ts +64 -5
  59. package/dist/provider/hooks/mutations/useAuthenticateWithOAuth.d.ts +64 -5
  60. package/dist/provider/hooks/mutations/useClaimPregenWallets.d.ts +66 -5
  61. package/dist/provider/hooks/mutations/useCreateGuestWallets.d.ts +64 -5
  62. package/dist/provider/hooks/mutations/useCreatePregenWallet.d.ts +66 -5
  63. package/dist/provider/hooks/mutations/useCreatePregenWalletPerType.d.ts +66 -5
  64. package/dist/provider/hooks/mutations/useCreateWallet.d.ts +64 -5
  65. package/dist/provider/hooks/mutations/useCreateWalletPerType.d.ts +64 -5
  66. package/dist/provider/hooks/mutations/useEnable2fa.d.ts +64 -5
  67. package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +112 -5
  68. package/dist/provider/hooks/mutations/useHasPregenWallet.d.ts +66 -5
  69. package/dist/provider/hooks/mutations/useIssueJwt.d.ts +64 -5
  70. package/dist/provider/hooks/mutations/useKeepSessionAlive.d.ts +64 -5
  71. package/dist/provider/hooks/mutations/useLoginExternalWallet.d.ts +64 -5
  72. package/dist/provider/hooks/mutations/useLogout.d.ts +64 -5
  73. package/dist/provider/hooks/mutations/useResendVerificationCode.d.ts +64 -5
  74. package/dist/provider/hooks/mutations/useSetup2fa.d.ts +64 -5
  75. package/dist/provider/hooks/mutations/useSignMessage.d.ts +64 -5
  76. package/dist/provider/hooks/mutations/useSignTransaction.d.ts +64 -5
  77. package/dist/provider/hooks/mutations/useSignUpOrLogIn.d.ts +64 -5
  78. package/dist/provider/hooks/mutations/useUpdatePregenWalletIdentifier.d.ts +66 -5
  79. package/dist/provider/hooks/mutations/useVerify2fa.d.ts +64 -5
  80. package/dist/provider/hooks/mutations/useVerifyExternalWallet.d.ts +64 -5
  81. package/dist/provider/hooks/mutations/useVerifyNewAccount.d.ts +64 -5
  82. package/dist/provider/hooks/mutations/useWaitForLogin.d.ts +64 -5
  83. package/dist/provider/hooks/mutations/useWaitForSignup.d.ts +64 -5
  84. package/dist/provider/hooks/mutations/useWaitForWalletCreation.d.ts +64 -5
  85. package/dist/provider/hooks/queries/createAccountHook.js +3 -3
  86. package/dist/provider/hooks/queries/useAccount.d.ts +9 -63
  87. package/dist/provider/hooks/queries/useAccount.js +3 -61
  88. package/dist/provider/index.d.ts +1 -1
  89. package/dist/provider/stores/index.d.ts +1 -1
  90. package/dist/provider/stores/index.js +0 -1
  91. package/dist/provider/utils/renameMutations.d.ts +1 -1
  92. package/dist/provider/utils/renameMutations.js +1 -14
  93. package/package.json +68 -3
@@ -0,0 +1,4 @@
1
+ export { useParaCosmjsProtoSigner, createParaCosmjsProtoSignerHook, COSMJS_PROTO_SIGNER_BASE_KEY, } from './useParaCosmjsProtoSigner.js';
2
+ export { useParaCosmjsAminoSigner, createParaCosmjsAminoSignerHook, COSMJS_AMINO_SIGNER_BASE_KEY, } from './useParaCosmjsAminoSigner.js';
3
+ export type { CosmosEnhancement } from './types.js';
4
+ export * from './mutations.js';
@@ -0,0 +1,19 @@
1
+ import {
2
+ useParaCosmjsProtoSigner,
3
+ createParaCosmjsProtoSignerHook,
4
+ COSMJS_PROTO_SIGNER_BASE_KEY
5
+ } from "./useParaCosmjsProtoSigner.js";
6
+ import {
7
+ useParaCosmjsAminoSigner,
8
+ createParaCosmjsAminoSignerHook,
9
+ COSMJS_AMINO_SIGNER_BASE_KEY
10
+ } from "./useParaCosmjsAminoSigner.js";
11
+ export * from "./mutations.js";
12
+ export {
13
+ COSMJS_AMINO_SIGNER_BASE_KEY,
14
+ COSMJS_PROTO_SIGNER_BASE_KEY,
15
+ createParaCosmjsAminoSignerHook,
16
+ createParaCosmjsProtoSignerHook,
17
+ useParaCosmjsAminoSigner,
18
+ useParaCosmjsProtoSigner
19
+ };
@@ -0,0 +1,175 @@
1
+ import type { ParaProtoSigner, ParaAminoSigner } from '@getpara/cosmjs-v0-integration';
2
+ import type { EncodeObject } from '@cosmjs/proto-signing';
3
+ import type { StdFee } from '@cosmjs/amino';
4
+ /** Minimal signing client shape (SigningStargateClient or SigningCosmWasmClient). */
5
+ interface CosmosSigningClient {
6
+ signAndBroadcast: (address: string, messages: EncodeObject[], fee: StdFee, memo?: string) => Promise<unknown>;
7
+ }
8
+ export declare const COSMJS_SIGN_AND_BROADCAST_KEY = "PARA_COSMJS_SIGN_AND_BROADCAST";
9
+ /**
10
+ * Mutation hook for signing and broadcasting a Cosmos transaction.
11
+ *
12
+ * @param signer - The signer from {@link useParaCosmjsProtoSigner} or {@link useParaCosmjsAminoSigner}.
13
+ * @param client - A `SigningStargateClient` or `SigningCosmWasmClient` connected with the signer.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const { protoSigner } = useParaCosmjsProtoSigner();
18
+ * const { signAndBroadcastAsync, isPending } = useParaCosmjsSignAndBroadcast(protoSigner, signingClient);
19
+ * const result = await signAndBroadcastAsync({ messages: [sendMsg], fee });
20
+ * ```
21
+ */
22
+ export declare const useParaCosmjsSignAndBroadcast: (signer: ParaProtoSigner | ParaAminoSigner | null | undefined, client: CosmosSigningClient | null | undefined) => {
23
+ isPending: boolean;
24
+ data: undefined;
25
+ variables: undefined;
26
+ error: null;
27
+ isError: false;
28
+ isIdle: true;
29
+ isSuccess: false;
30
+ status: "idle";
31
+ mutate: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
32
+ messages: EncodeObject[];
33
+ fee: StdFee;
34
+ memo?: string;
35
+ }, unknown>;
36
+ reset: () => void;
37
+ context: unknown;
38
+ failureCount: number;
39
+ failureReason: Error;
40
+ isPaused: boolean;
41
+ submittedAt: number;
42
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
43
+ messages: EncodeObject[];
44
+ fee: StdFee;
45
+ memo?: string;
46
+ }, unknown>;
47
+ signAndBroadcast: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
48
+ messages: EncodeObject[];
49
+ fee: StdFee;
50
+ memo?: string;
51
+ }, unknown>;
52
+ signAndBroadcastAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
53
+ messages: EncodeObject[];
54
+ fee: StdFee;
55
+ memo?: string;
56
+ }, unknown>;
57
+ } | {
58
+ isPending: boolean;
59
+ data: undefined;
60
+ variables: {
61
+ messages: EncodeObject[];
62
+ fee: StdFee;
63
+ memo?: string;
64
+ };
65
+ error: null;
66
+ isError: false;
67
+ isIdle: false;
68
+ isSuccess: false;
69
+ status: "pending";
70
+ mutate: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
71
+ messages: EncodeObject[];
72
+ fee: StdFee;
73
+ memo?: string;
74
+ }, unknown>;
75
+ reset: () => void;
76
+ context: unknown;
77
+ failureCount: number;
78
+ failureReason: Error;
79
+ isPaused: boolean;
80
+ submittedAt: number;
81
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
82
+ messages: EncodeObject[];
83
+ fee: StdFee;
84
+ memo?: string;
85
+ }, unknown>;
86
+ signAndBroadcast: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
87
+ messages: EncodeObject[];
88
+ fee: StdFee;
89
+ memo?: string;
90
+ }, unknown>;
91
+ signAndBroadcastAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
92
+ messages: EncodeObject[];
93
+ fee: StdFee;
94
+ memo?: string;
95
+ }, unknown>;
96
+ } | {
97
+ isPending: boolean;
98
+ data: undefined;
99
+ error: Error;
100
+ variables: {
101
+ messages: EncodeObject[];
102
+ fee: StdFee;
103
+ memo?: string;
104
+ };
105
+ isError: true;
106
+ isIdle: false;
107
+ isSuccess: false;
108
+ status: "error";
109
+ mutate: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
110
+ messages: EncodeObject[];
111
+ fee: StdFee;
112
+ memo?: string;
113
+ }, unknown>;
114
+ reset: () => void;
115
+ context: unknown;
116
+ failureCount: number;
117
+ failureReason: Error;
118
+ isPaused: boolean;
119
+ submittedAt: number;
120
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
121
+ messages: EncodeObject[];
122
+ fee: StdFee;
123
+ memo?: string;
124
+ }, unknown>;
125
+ signAndBroadcast: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
126
+ messages: EncodeObject[];
127
+ fee: StdFee;
128
+ memo?: string;
129
+ }, unknown>;
130
+ signAndBroadcastAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
131
+ messages: EncodeObject[];
132
+ fee: StdFee;
133
+ memo?: string;
134
+ }, unknown>;
135
+ } | {
136
+ isPending: boolean;
137
+ data: unknown;
138
+ error: null;
139
+ variables: {
140
+ messages: EncodeObject[];
141
+ fee: StdFee;
142
+ memo?: string;
143
+ };
144
+ isError: false;
145
+ isIdle: false;
146
+ isSuccess: true;
147
+ status: "success";
148
+ mutate: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
149
+ messages: EncodeObject[];
150
+ fee: StdFee;
151
+ memo?: string;
152
+ }, unknown>;
153
+ reset: () => void;
154
+ context: unknown;
155
+ failureCount: number;
156
+ failureReason: Error;
157
+ isPaused: boolean;
158
+ submittedAt: number;
159
+ mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
160
+ messages: EncodeObject[];
161
+ fee: StdFee;
162
+ memo?: string;
163
+ }, unknown>;
164
+ signAndBroadcast: import("@tanstack/react-query").UseMutateFunction<unknown, Error, {
165
+ messages: EncodeObject[];
166
+ fee: StdFee;
167
+ memo?: string;
168
+ }, unknown>;
169
+ signAndBroadcastAsync: import("@tanstack/react-query").UseMutateAsyncFunction<unknown, Error, {
170
+ messages: EncodeObject[];
171
+ fee: StdFee;
172
+ memo?: string;
173
+ }, unknown>;
174
+ };
175
+ export {};
@@ -0,0 +1,63 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+ import { useMutation } from "@tanstack/react-query";
41
+ import { renameMutations } from "../../provider/utils/renameMutations.js";
42
+ const COSMJS_SIGN_AND_BROADCAST_KEY = "PARA_COSMJS_SIGN_AND_BROADCAST";
43
+ const useParaCosmjsSignAndBroadcast = (signer, client) => {
44
+ const mutation = renameMutations(
45
+ useMutation({
46
+ mutationKey: [COSMJS_SIGN_AND_BROADCAST_KEY],
47
+ mutationFn: (params) => __async(void 0, null, function* () {
48
+ var _a;
49
+ if (!signer || !client) throw new Error("Cosmos signer or client not ready.");
50
+ const accounts = yield signer.getAccounts();
51
+ const address = (_a = accounts[0]) == null ? void 0 : _a.address;
52
+ if (!address) throw new Error("No Cosmos account found.");
53
+ return client.signAndBroadcast(address, params.messages, params.fee, params.memo);
54
+ })
55
+ }),
56
+ "signAndBroadcast"
57
+ );
58
+ return __spreadProps(__spreadValues({}, mutation), { isPending: !signer || !client || mutation.isPending });
59
+ };
60
+ export {
61
+ COSMJS_SIGN_AND_BROADCAST_KEY,
62
+ useParaCosmjsSignAndBroadcast
63
+ };
@@ -0,0 +1,9 @@
1
+ import type { ChainEnhancement } from '../types.js';
2
+ import type { OfflineDirectSigner } from '@cosmjs/proto-signing';
3
+ import type { OfflineAminoSigner } from '@cosmjs/amino';
4
+ export interface CosmosEnhancement extends ChainEnhancement {
5
+ /** External proto signer (e.g. from graz's getOfflineSignerDirect). */
6
+ protoSigner?: OfflineDirectSigner | null;
7
+ /** External amino signer (e.g. from graz's getOfflineSignerAmino). */
8
+ aminoSigner?: OfflineAminoSigner | null;
9
+ }
File without changes
@@ -0,0 +1,54 @@
1
+ import { type UseQueryResult } from '@tanstack/react-query';
2
+ import type { WalletSelector } from '../types.js';
3
+ import type { CosmosEnhancement } from './types.js';
4
+ import type { OfflineAminoSigner } from '@cosmjs/amino';
5
+ export declare const COSMJS_AMINO_SIGNER_BASE_KEY = "PARA_COSMJS_AMINO_SIGNER";
6
+ type UseParaCosmjsAminoSignerParameters = WalletSelector & {
7
+ prefix?: string;
8
+ messageSigningTimeoutMs?: number;
9
+ };
10
+ type AminoSignerData = OfflineAminoSigner | null | undefined;
11
+ /** Return type for `useParaCosmjsAminoSigner`. Extends the react-query result with a named `aminoSigner` alias for `data`. */
12
+ export type UseParaCosmjsAminoSignerReturn = UseQueryResult<OfflineAminoSigner | null, Error> & {
13
+ /** The CosmJS OfflineAminoSigner, or `undefined` while loading / `null` when unavailable. */
14
+ aminoSigner: AminoSignerData;
15
+ };
16
+ /**
17
+ * Factory that creates a `useParaCosmjsAminoSigner` hook. Accepts an optional enhancer
18
+ * for external wallet support (e.g. graz/Keplr on web).
19
+ *
20
+ * @param useEnhancer - Optional hook that provides an external `OfflineAminoSigner`.
21
+ * When the enhancer's `aminoSigner` is set, it is returned as a fallback when
22
+ * no embedded wallet is available.
23
+ * @returns A `useParaCosmjsAminoSigner` hook.
24
+ */
25
+ export declare function createParaCosmjsAminoSignerHook(useEnhancer?: () => CosmosEnhancement): ({ address, prefix, walletId, messageSigningTimeoutMs, }?: UseParaCosmjsAminoSignerParameters) => UseParaCosmjsAminoSignerReturn;
26
+ /**
27
+ * Hook that returns a CosmJS `OfflineAminoSigner` backed by the user's embedded
28
+ * Para Cosmos wallet. Requires `@getpara/cosmjs-v0-integration` as a peer dependency.
29
+ *
30
+ * If the user has multiple Cosmos wallets, pass `address` or `walletId` to select one.
31
+ * When omitted, the active wallet from `useWalletState` is used automatically.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * import { useParaCosmjsAminoSigner } from "@getpara/react-sdk";
36
+ *
37
+ * function SignAmino() {
38
+ * const { aminoSigner, isLoading } = useParaCosmjsAminoSigner();
39
+ *
40
+ * const handleSign = async () => {
41
+ * if (!aminoSigner) return;
42
+ * const result = await aminoSigner.signAmino(aminoSigner.address, signDoc);
43
+ * console.log(result);
44
+ * };
45
+ *
46
+ * if (isLoading) return <p>Loading...</p>;
47
+ * return <button onClick={handleSign}>Sign</button>;
48
+ * }
49
+ * ```
50
+ *
51
+ * @returns {@link UseParaCosmjsAminoSignerReturn} — a react-query result with `aminoSigner` as a named alias for `data`.
52
+ */
53
+ export declare const useParaCosmjsAminoSigner: (params?: UseParaCosmjsAminoSignerParameters) => UseParaCosmjsAminoSignerReturn;
54
+ export {};
@@ -0,0 +1,115 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
49
+ import { useQuery } from "@tanstack/react-query";
50
+ import { useClient } from "../../provider/hooks/utils/useClient.js";
51
+ import { useIsFullyLoggedIn } from "../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
+ import { useWallet } from "../../provider/hooks/queries/useWallet.js";
53
+ import { resolveWalletForChain } from "../resolveWallet.js";
54
+ const COSMJS_AMINO_SIGNER_BASE_KEY = "PARA_COSMJS_AMINO_SIGNER";
55
+ function createParaCosmjsAminoSignerHook(useEnhancer) {
56
+ return function useParaCosmjsAminoSigner2({
57
+ address,
58
+ prefix,
59
+ walletId,
60
+ messageSigningTimeoutMs
61
+ } = {}) {
62
+ var _a, _b;
63
+ const para = useClient();
64
+ const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
65
+ const { data: wallet } = useWallet();
66
+ const enhancement = (_a = useEnhancer == null ? void 0 : useEnhancer()) != null ? _a : {};
67
+ const hasExternalSigner = !!enhancement.aminoSigner;
68
+ const isEmbeddedActive = !!isFullyLoggedIn;
69
+ const _c = useQuery({
70
+ queryKey: [
71
+ COSMJS_AMINO_SIGNER_BASE_KEY,
72
+ isEmbeddedActive,
73
+ (_b = walletId != null ? walletId : address) != null ? _b : (wallet == null ? void 0 : wallet.type) === "COSMOS" ? wallet == null ? void 0 : wallet.id : null,
74
+ hasExternalSigner ? "external-available" : "embedded-only"
75
+ ],
76
+ enabled: !enhancement.isLoading && !!para && (isEmbeddedActive || hasExternalSigner),
77
+ queryFn: () => __async(this, null, function* () {
78
+ if (isEmbeddedActive) {
79
+ const resolved = resolveWalletForChain(para, { address, walletId }, "COSMOS", wallet != null ? wallet : void 0);
80
+ if ((resolved == null ? void 0 : resolved.isExternal) && hasExternalSigner) {
81
+ return enhancement.aminoSigner;
82
+ }
83
+ if ((resolved == null ? void 0 : resolved.id) && !resolved.isExternal) {
84
+ const mod = yield importCosmjs();
85
+ return mod.createParaAminoSigner({ para, prefix, walletId: resolved.id, messageSigningTimeoutMs });
86
+ }
87
+ }
88
+ if (hasExternalSigner) {
89
+ return enhancement.aminoSigner;
90
+ }
91
+ return null;
92
+ })
93
+ }), { data, isLoading } = _c, rest = __objRest(_c, ["data", "isLoading"]);
94
+ return __spreadValues({
95
+ aminoSigner: data,
96
+ data,
97
+ isLoading: enhancement.isLoading || isLoading
98
+ }, rest);
99
+ };
100
+ }
101
+ function importCosmjs() {
102
+ return __async(this, null, function* () {
103
+ try {
104
+ return yield import("@getpara/cosmjs-v0-integration");
105
+ } catch (e) {
106
+ throw new Error("[@getpara/react-core] Please install @getpara/cosmjs-v0-integration to use useParaCosmjsAminoSigner");
107
+ }
108
+ });
109
+ }
110
+ const useParaCosmjsAminoSigner = createParaCosmjsAminoSignerHook();
111
+ export {
112
+ COSMJS_AMINO_SIGNER_BASE_KEY,
113
+ createParaCosmjsAminoSignerHook,
114
+ useParaCosmjsAminoSigner
115
+ };
@@ -0,0 +1,56 @@
1
+ import { type UseQueryResult } from '@tanstack/react-query';
2
+ import type { WalletSelector } from '../types.js';
3
+ import type { CosmosEnhancement } from './types.js';
4
+ import type { OfflineDirectSigner } from '@cosmjs/proto-signing';
5
+ export declare const COSMJS_PROTO_SIGNER_BASE_KEY = "PARA_COSMJS_PROTO_SIGNER";
6
+ type UseParaCosmjsProtoSignerParameters = WalletSelector & {
7
+ prefix?: string;
8
+ messageSigningTimeoutMs?: number;
9
+ };
10
+ type ProtoSignerData = OfflineDirectSigner | null | undefined;
11
+ /** Return type for `useParaCosmjsProtoSigner`. Extends the react-query result with a named `protoSigner` alias for `data`. */
12
+ export type UseParaCosmjsProtoSignerReturn = UseQueryResult<OfflineDirectSigner | null, Error> & {
13
+ /** The CosmJS OfflineDirectSigner, or `undefined` while loading / `null` when unavailable. */
14
+ protoSigner: ProtoSignerData;
15
+ };
16
+ /**
17
+ * Factory that creates a `useParaCosmjsProtoSigner` hook. Accepts an optional enhancer
18
+ * for external wallet support (e.g. graz/Keplr on web).
19
+ *
20
+ * @param useEnhancer - Optional hook that provides an external `OfflineDirectSigner`.
21
+ * When the enhancer's `protoSigner` is set, it is returned as a fallback when
22
+ * no embedded wallet is available.
23
+ * @returns A `useParaCosmjsProtoSigner` hook.
24
+ */
25
+ export declare function createParaCosmjsProtoSignerHook(useEnhancer?: () => CosmosEnhancement): ({ address, prefix, walletId, messageSigningTimeoutMs, }?: UseParaCosmjsProtoSignerParameters) => UseParaCosmjsProtoSignerReturn;
26
+ /**
27
+ * Hook that returns a CosmJS `OfflineDirectSigner` (protobuf) backed by the user's
28
+ * embedded Para Cosmos wallet. Requires `@getpara/cosmjs-v0-integration` as a peer dependency.
29
+ *
30
+ * If the user has multiple Cosmos wallets, pass `address` or `walletId` to select one.
31
+ * When omitted, the active wallet from `useWalletState` is used automatically.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * import { useParaCosmjsProtoSigner } from "@getpara/react-sdk";
36
+ * import { SigningStargateClient } from "@cosmjs/stargate";
37
+ *
38
+ * function SignDirect() {
39
+ * const { protoSigner, isLoading } = useParaCosmjsProtoSigner();
40
+ *
41
+ * const handleSign = async () => {
42
+ * if (!protoSigner) return;
43
+ * const client = await SigningStargateClient.connectWithSigner(rpcUrl, protoSigner);
44
+ * const result = await protoSigner.signDirect(protoSigner.address, signDoc);
45
+ * console.log(result);
46
+ * };
47
+ *
48
+ * if (isLoading) return <p>Loading...</p>;
49
+ * return <button onClick={handleSign}>Sign</button>;
50
+ * }
51
+ * ```
52
+ *
53
+ * @returns {@link UseParaCosmjsProtoSignerReturn} — a react-query result with `protoSigner` as a named alias for `data`.
54
+ */
55
+ export declare const useParaCosmjsProtoSigner: (params?: UseParaCosmjsProtoSignerParameters) => UseParaCosmjsProtoSignerReturn;
56
+ export {};
@@ -0,0 +1,115 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ var __async = (__this, __arguments, generator) => {
30
+ return new Promise((resolve, reject) => {
31
+ var fulfilled = (value) => {
32
+ try {
33
+ step(generator.next(value));
34
+ } catch (e) {
35
+ reject(e);
36
+ }
37
+ };
38
+ var rejected = (value) => {
39
+ try {
40
+ step(generator.throw(value));
41
+ } catch (e) {
42
+ reject(e);
43
+ }
44
+ };
45
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
46
+ step((generator = generator.apply(__this, __arguments)).next());
47
+ });
48
+ };
49
+ import { useQuery } from "@tanstack/react-query";
50
+ import { useClient } from "../../provider/hooks/utils/useClient.js";
51
+ import { useIsFullyLoggedIn } from "../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
+ import { useWallet } from "../../provider/hooks/queries/useWallet.js";
53
+ import { resolveWalletForChain } from "../resolveWallet.js";
54
+ const COSMJS_PROTO_SIGNER_BASE_KEY = "PARA_COSMJS_PROTO_SIGNER";
55
+ function createParaCosmjsProtoSignerHook(useEnhancer) {
56
+ return function useParaCosmjsProtoSigner2({
57
+ address,
58
+ prefix,
59
+ walletId,
60
+ messageSigningTimeoutMs
61
+ } = {}) {
62
+ var _a, _b;
63
+ const para = useClient();
64
+ const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
65
+ const { data: wallet } = useWallet();
66
+ const enhancement = (_a = useEnhancer == null ? void 0 : useEnhancer()) != null ? _a : {};
67
+ const hasExternalSigner = !!enhancement.protoSigner;
68
+ const isEmbeddedActive = !!isFullyLoggedIn;
69
+ const _c = useQuery({
70
+ queryKey: [
71
+ COSMJS_PROTO_SIGNER_BASE_KEY,
72
+ isEmbeddedActive,
73
+ (_b = walletId != null ? walletId : address) != null ? _b : (wallet == null ? void 0 : wallet.type) === "COSMOS" ? wallet == null ? void 0 : wallet.id : null,
74
+ hasExternalSigner ? "external-available" : "embedded-only"
75
+ ],
76
+ enabled: !enhancement.isLoading && !!para && (isEmbeddedActive || hasExternalSigner),
77
+ queryFn: () => __async(this, null, function* () {
78
+ if (isEmbeddedActive) {
79
+ const resolved = resolveWalletForChain(para, { address, walletId }, "COSMOS", wallet != null ? wallet : void 0);
80
+ if ((resolved == null ? void 0 : resolved.isExternal) && hasExternalSigner) {
81
+ return enhancement.protoSigner;
82
+ }
83
+ if ((resolved == null ? void 0 : resolved.id) && !resolved.isExternal) {
84
+ const mod = yield importCosmjs();
85
+ return mod.createParaProtoSigner({ para, prefix, walletId: resolved.id, messageSigningTimeoutMs });
86
+ }
87
+ }
88
+ if (hasExternalSigner) {
89
+ return enhancement.protoSigner;
90
+ }
91
+ return null;
92
+ })
93
+ }), { data, isLoading } = _c, rest = __objRest(_c, ["data", "isLoading"]);
94
+ return __spreadValues({
95
+ protoSigner: data,
96
+ data,
97
+ isLoading: enhancement.isLoading || isLoading
98
+ }, rest);
99
+ };
100
+ }
101
+ function importCosmjs() {
102
+ return __async(this, null, function* () {
103
+ try {
104
+ return yield import("@getpara/cosmjs-v0-integration");
105
+ } catch (e) {
106
+ throw new Error("[@getpara/react-core] Please install @getpara/cosmjs-v0-integration to use useParaCosmjsProtoSigner");
107
+ }
108
+ });
109
+ }
110
+ const useParaCosmjsProtoSigner = createParaCosmjsProtoSignerHook();
111
+ export {
112
+ COSMJS_PROTO_SIGNER_BASE_KEY,
113
+ createParaCosmjsProtoSignerHook,
114
+ useParaCosmjsProtoSigner
115
+ };
@@ -0,0 +1,3 @@
1
+ export { useParaEthersSigner, createParaEthersSignerHook, ETHERS_SIGNER_BASE_KEY } from './useParaEthersSigner.js';
2
+ export type { EthersEnhancement } from './types.js';
3
+ export * from './mutations.js';
@@ -0,0 +1,7 @@
1
+ import { useParaEthersSigner, createParaEthersSignerHook, ETHERS_SIGNER_BASE_KEY } from "./useParaEthersSigner.js";
2
+ export * from "./mutations.js";
3
+ export {
4
+ ETHERS_SIGNER_BASE_KEY,
5
+ createParaEthersSignerHook,
6
+ useParaEthersSigner
7
+ };