@getpara/react-core 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chains/index.d.ts +1 -0
- package/dist/chains/index.js +1 -0
- package/dist/chains/sui/index.d.ts +5 -0
- package/dist/chains/sui/index.js +15 -0
- package/dist/chains/sui/mutations.d.ts +232 -0
- package/dist/chains/sui/mutations.js +77 -0
- package/dist/chains/sui/types.d.ts +3 -0
- package/dist/chains/sui/types.js +0 -0
- package/dist/chains/sui/useParaSuiMultiSigSigner.d.ts +42 -0
- package/dist/chains/sui/useParaSuiMultiSigSigner.js +109 -0
- package/dist/chains/sui/useParaSuiSigner.d.ts +49 -0
- package/dist/chains/sui/useParaSuiSigner.js +90 -0
- package/dist/provider/hooks/mutations/useExportPrivateKey.d.ts +1 -1
- package/dist/provider/hooks/utils/useCoreWalletState.d.ts +1 -1
- package/package.json +20 -8
package/dist/chains/index.d.ts
CHANGED
package/dist/chains/index.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useParaSuiSigner, createParaSuiSignerHook, SUI_SIGNER_BASE_KEY } from './useParaSuiSigner.js';
|
|
2
|
+
export { useParaSuiMultiSigSigner, createParaSuiMultiSigSignerHook, SUI_MULTISIG_SIGNER_BASE_KEY, } from './useParaSuiMultiSigSigner.js';
|
|
3
|
+
export type { UseParaSuiMultiSigSignerReturn } from './useParaSuiMultiSigSigner.js';
|
|
4
|
+
export type { SuiEnhancement } from './types.js';
|
|
5
|
+
export * from './mutations.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useParaSuiSigner, createParaSuiSignerHook, SUI_SIGNER_BASE_KEY } from "./useParaSuiSigner.js";
|
|
2
|
+
import {
|
|
3
|
+
useParaSuiMultiSigSigner,
|
|
4
|
+
createParaSuiMultiSigSignerHook,
|
|
5
|
+
SUI_MULTISIG_SIGNER_BASE_KEY
|
|
6
|
+
} from "./useParaSuiMultiSigSigner.js";
|
|
7
|
+
export * from "./mutations.js";
|
|
8
|
+
export {
|
|
9
|
+
SUI_MULTISIG_SIGNER_BASE_KEY,
|
|
10
|
+
SUI_SIGNER_BASE_KEY,
|
|
11
|
+
createParaSuiMultiSigSignerHook,
|
|
12
|
+
createParaSuiSignerHook,
|
|
13
|
+
useParaSuiMultiSigSigner,
|
|
14
|
+
useParaSuiSigner
|
|
15
|
+
};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import type { ParaSuiSigner } from '@getpara/sui-sdk-integration';
|
|
2
|
+
export declare const SUI_SIGN_TRANSACTION_KEY = "PARA_SUI_SIGN_TRANSACTION";
|
|
3
|
+
export declare const SUI_SIGN_PERSONAL_MESSAGE_KEY = "PARA_SUI_SIGN_PERSONAL_MESSAGE";
|
|
4
|
+
/**
|
|
5
|
+
* Mutation hook for signing a Sui transaction.
|
|
6
|
+
*
|
|
7
|
+
* @param signer - The signer from {@link useParaSuiSigner}.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const { suiSigner } = useParaSuiSigner();
|
|
12
|
+
* const { signTransactionAsync, isPending } = useParaSuiSignTransaction(suiSigner);
|
|
13
|
+
* const { signature } = await signTransactionAsync(txBytes);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const useParaSuiSignTransaction: (signer: ParaSuiSigner | null | undefined) => {
|
|
17
|
+
isPending: boolean;
|
|
18
|
+
data: undefined;
|
|
19
|
+
variables: undefined;
|
|
20
|
+
error: null;
|
|
21
|
+
isError: false;
|
|
22
|
+
isIdle: true;
|
|
23
|
+
isSuccess: false;
|
|
24
|
+
status: "idle";
|
|
25
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
26
|
+
reset: () => void;
|
|
27
|
+
context: unknown;
|
|
28
|
+
failureCount: number;
|
|
29
|
+
failureReason: Error;
|
|
30
|
+
isPaused: boolean;
|
|
31
|
+
submittedAt: number;
|
|
32
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
33
|
+
signTransaction: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
34
|
+
signTransactionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
35
|
+
} | {
|
|
36
|
+
isPending: boolean;
|
|
37
|
+
data: undefined;
|
|
38
|
+
variables: Uint8Array<ArrayBufferLike>;
|
|
39
|
+
error: null;
|
|
40
|
+
isError: false;
|
|
41
|
+
isIdle: false;
|
|
42
|
+
isSuccess: false;
|
|
43
|
+
status: "pending";
|
|
44
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
45
|
+
reset: () => void;
|
|
46
|
+
context: unknown;
|
|
47
|
+
failureCount: number;
|
|
48
|
+
failureReason: Error;
|
|
49
|
+
isPaused: boolean;
|
|
50
|
+
submittedAt: number;
|
|
51
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
52
|
+
signTransaction: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
53
|
+
signTransactionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
54
|
+
} | {
|
|
55
|
+
isPending: boolean;
|
|
56
|
+
data: undefined;
|
|
57
|
+
error: Error;
|
|
58
|
+
variables: Uint8Array<ArrayBufferLike>;
|
|
59
|
+
isError: true;
|
|
60
|
+
isIdle: false;
|
|
61
|
+
isSuccess: false;
|
|
62
|
+
status: "error";
|
|
63
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
64
|
+
reset: () => void;
|
|
65
|
+
context: unknown;
|
|
66
|
+
failureCount: number;
|
|
67
|
+
failureReason: Error;
|
|
68
|
+
isPaused: boolean;
|
|
69
|
+
submittedAt: number;
|
|
70
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
71
|
+
signTransaction: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
72
|
+
signTransactionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
73
|
+
} | {
|
|
74
|
+
isPending: boolean;
|
|
75
|
+
data: import("@mysten/sui/cryptography").SignatureWithBytes;
|
|
76
|
+
error: null;
|
|
77
|
+
variables: Uint8Array<ArrayBufferLike>;
|
|
78
|
+
isError: false;
|
|
79
|
+
isIdle: false;
|
|
80
|
+
isSuccess: true;
|
|
81
|
+
status: "success";
|
|
82
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
83
|
+
reset: () => void;
|
|
84
|
+
context: unknown;
|
|
85
|
+
failureCount: number;
|
|
86
|
+
failureReason: Error;
|
|
87
|
+
isPaused: boolean;
|
|
88
|
+
submittedAt: number;
|
|
89
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
90
|
+
signTransaction: import("@tanstack/react-query").UseMutateFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
91
|
+
signTransactionAsync: import("@tanstack/react-query").UseMutateAsyncFunction<import("@mysten/sui/cryptography").SignatureWithBytes, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Mutation hook for signing a Sui personal message.
|
|
95
|
+
*
|
|
96
|
+
* @param signer - The signer from {@link useParaSuiSigner}.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* const { suiSigner } = useParaSuiSigner();
|
|
101
|
+
* const { signPersonalMessageAsync, isPending } = useParaSuiSignPersonalMessage(suiSigner);
|
|
102
|
+
* const { signature } = await signPersonalMessageAsync(new TextEncoder().encode("gm"));
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare const useParaSuiSignPersonalMessage: (signer: ParaSuiSigner | null | undefined) => {
|
|
106
|
+
isPending: boolean;
|
|
107
|
+
data: undefined;
|
|
108
|
+
variables: undefined;
|
|
109
|
+
error: null;
|
|
110
|
+
isError: false;
|
|
111
|
+
isIdle: true;
|
|
112
|
+
isSuccess: false;
|
|
113
|
+
status: "idle";
|
|
114
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
115
|
+
bytes: string;
|
|
116
|
+
signature: string;
|
|
117
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
118
|
+
reset: () => void;
|
|
119
|
+
context: unknown;
|
|
120
|
+
failureCount: number;
|
|
121
|
+
failureReason: Error;
|
|
122
|
+
isPaused: boolean;
|
|
123
|
+
submittedAt: number;
|
|
124
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
125
|
+
bytes: string;
|
|
126
|
+
signature: string;
|
|
127
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
128
|
+
signPersonalMessage: import("@tanstack/react-query").UseMutateFunction<{
|
|
129
|
+
bytes: string;
|
|
130
|
+
signature: string;
|
|
131
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
132
|
+
signPersonalMessageAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
133
|
+
bytes: string;
|
|
134
|
+
signature: string;
|
|
135
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
136
|
+
} | {
|
|
137
|
+
isPending: boolean;
|
|
138
|
+
data: undefined;
|
|
139
|
+
variables: Uint8Array<ArrayBufferLike>;
|
|
140
|
+
error: null;
|
|
141
|
+
isError: false;
|
|
142
|
+
isIdle: false;
|
|
143
|
+
isSuccess: false;
|
|
144
|
+
status: "pending";
|
|
145
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
146
|
+
bytes: string;
|
|
147
|
+
signature: string;
|
|
148
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
149
|
+
reset: () => void;
|
|
150
|
+
context: unknown;
|
|
151
|
+
failureCount: number;
|
|
152
|
+
failureReason: Error;
|
|
153
|
+
isPaused: boolean;
|
|
154
|
+
submittedAt: number;
|
|
155
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
156
|
+
bytes: string;
|
|
157
|
+
signature: string;
|
|
158
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
159
|
+
signPersonalMessage: import("@tanstack/react-query").UseMutateFunction<{
|
|
160
|
+
bytes: string;
|
|
161
|
+
signature: string;
|
|
162
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
163
|
+
signPersonalMessageAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
164
|
+
bytes: string;
|
|
165
|
+
signature: string;
|
|
166
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
167
|
+
} | {
|
|
168
|
+
isPending: boolean;
|
|
169
|
+
data: undefined;
|
|
170
|
+
error: Error;
|
|
171
|
+
variables: Uint8Array<ArrayBufferLike>;
|
|
172
|
+
isError: true;
|
|
173
|
+
isIdle: false;
|
|
174
|
+
isSuccess: false;
|
|
175
|
+
status: "error";
|
|
176
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
177
|
+
bytes: string;
|
|
178
|
+
signature: string;
|
|
179
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
180
|
+
reset: () => void;
|
|
181
|
+
context: unknown;
|
|
182
|
+
failureCount: number;
|
|
183
|
+
failureReason: Error;
|
|
184
|
+
isPaused: boolean;
|
|
185
|
+
submittedAt: number;
|
|
186
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
187
|
+
bytes: string;
|
|
188
|
+
signature: string;
|
|
189
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
190
|
+
signPersonalMessage: import("@tanstack/react-query").UseMutateFunction<{
|
|
191
|
+
bytes: string;
|
|
192
|
+
signature: string;
|
|
193
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
194
|
+
signPersonalMessageAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
195
|
+
bytes: string;
|
|
196
|
+
signature: string;
|
|
197
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
198
|
+
} | {
|
|
199
|
+
isPending: boolean;
|
|
200
|
+
data: {
|
|
201
|
+
bytes: string;
|
|
202
|
+
signature: string;
|
|
203
|
+
};
|
|
204
|
+
error: null;
|
|
205
|
+
variables: Uint8Array<ArrayBufferLike>;
|
|
206
|
+
isError: false;
|
|
207
|
+
isIdle: false;
|
|
208
|
+
isSuccess: true;
|
|
209
|
+
status: "success";
|
|
210
|
+
mutate: import("@tanstack/react-query").UseMutateFunction<{
|
|
211
|
+
bytes: string;
|
|
212
|
+
signature: string;
|
|
213
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
214
|
+
reset: () => void;
|
|
215
|
+
context: unknown;
|
|
216
|
+
failureCount: number;
|
|
217
|
+
failureReason: Error;
|
|
218
|
+
isPaused: boolean;
|
|
219
|
+
submittedAt: number;
|
|
220
|
+
mutateAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
221
|
+
bytes: string;
|
|
222
|
+
signature: string;
|
|
223
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
224
|
+
signPersonalMessage: import("@tanstack/react-query").UseMutateFunction<{
|
|
225
|
+
bytes: string;
|
|
226
|
+
signature: string;
|
|
227
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
228
|
+
signPersonalMessageAsync: import("@tanstack/react-query").UseMutateAsyncFunction<{
|
|
229
|
+
bytes: string;
|
|
230
|
+
signature: string;
|
|
231
|
+
}, Error, Uint8Array<ArrayBufferLike>, unknown>;
|
|
232
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
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 SUI_SIGN_TRANSACTION_KEY = "PARA_SUI_SIGN_TRANSACTION";
|
|
43
|
+
const SUI_SIGN_PERSONAL_MESSAGE_KEY = "PARA_SUI_SIGN_PERSONAL_MESSAGE";
|
|
44
|
+
const useParaSuiSignTransaction = (signer) => {
|
|
45
|
+
var _a;
|
|
46
|
+
const mutation = renameMutations(
|
|
47
|
+
useMutation({
|
|
48
|
+
mutationKey: [SUI_SIGN_TRANSACTION_KEY, (_a = signer == null ? void 0 : signer.address) != null ? _a : null],
|
|
49
|
+
mutationFn: (transaction) => __async(null, null, function* () {
|
|
50
|
+
if (!signer) throw new Error("Sui signer not ready. Ensure useParaSuiSigner has resolved.");
|
|
51
|
+
return signer.signTransaction(transaction);
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
54
|
+
"signTransaction"
|
|
55
|
+
);
|
|
56
|
+
return __spreadProps(__spreadValues({}, mutation), { isPending: !signer || mutation.isPending });
|
|
57
|
+
};
|
|
58
|
+
const useParaSuiSignPersonalMessage = (signer) => {
|
|
59
|
+
var _a;
|
|
60
|
+
const mutation = renameMutations(
|
|
61
|
+
useMutation({
|
|
62
|
+
mutationKey: [SUI_SIGN_PERSONAL_MESSAGE_KEY, (_a = signer == null ? void 0 : signer.address) != null ? _a : null],
|
|
63
|
+
mutationFn: (message) => __async(null, null, function* () {
|
|
64
|
+
if (!signer) throw new Error("Sui signer not ready. Ensure useParaSuiSigner has resolved.");
|
|
65
|
+
return signer.signPersonalMessage(message);
|
|
66
|
+
})
|
|
67
|
+
}),
|
|
68
|
+
"signPersonalMessage"
|
|
69
|
+
);
|
|
70
|
+
return __spreadProps(__spreadValues({}, mutation), { isPending: !signer || mutation.isPending });
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
SUI_SIGN_PERSONAL_MESSAGE_KEY,
|
|
74
|
+
SUI_SIGN_TRANSACTION_KEY,
|
|
75
|
+
useParaSuiSignPersonalMessage,
|
|
76
|
+
useParaSuiSignTransaction
|
|
77
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SuiMultiSigMember } from '@getpara/sui-sdk-integration';
|
|
3
|
+
import type { WalletSelector } from '../types.js';
|
|
4
|
+
export declare const SUI_MULTISIG_SIGNER_BASE_KEY = "PARA_SUI_MULTISIG_SIGNER";
|
|
5
|
+
type UseParaSuiMultiSigSignerParameters = WalletSelector & {
|
|
6
|
+
/** The other co-signers (public keys + weights) — everyone except the Para member. */
|
|
7
|
+
otherMembers: SuiMultiSigMember[];
|
|
8
|
+
/** k-of-n threshold: the summed weight required for a valid multisig signature. */
|
|
9
|
+
threshold: number;
|
|
10
|
+
/** Weight of the Para member (1–255). Defaults to 1. */
|
|
11
|
+
paraWeight?: number;
|
|
12
|
+
};
|
|
13
|
+
/** The signer object returned by `@getpara/sui-sdk-integration`'s `createParaSuiMultiSigSigner`. */
|
|
14
|
+
type SuiMultiSigSignerData = ReturnType<Awaited<typeof import('@getpara/sui-sdk-integration')>['createParaSuiMultiSigSigner']> | null | undefined;
|
|
15
|
+
export type UseParaSuiMultiSigSignerReturn = UseQueryResult<NonNullable<SuiMultiSigSignerData> | null, Error> & {
|
|
16
|
+
/** The Sui multisig signer, or `undefined` while loading / `null` when unavailable. */
|
|
17
|
+
multiSigSigner: SuiMultiSigSignerData;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Hook that returns a Sui multisig signer where one member is the user's embedded Para wallet. It
|
|
21
|
+
* derives the multisig address, produces the Para member's partial signature, and combines partials —
|
|
22
|
+
* see `ParaSuiMultiSigSigner`. Requires `@getpara/sui-sdk-integration` and `@mysten/sui`.
|
|
23
|
+
*
|
|
24
|
+
* Embedded-only: unlike `useParaSuiSigner`, this hook has no external-wallet enhancer path — the Para
|
|
25
|
+
* member is always the embedded MPC wallet.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const { multiSigSigner } = useParaSuiMultiSigSigner({
|
|
30
|
+
* otherMembers: [{ publicKey: coSignerPublicKey, weight: 1 }],
|
|
31
|
+
* threshold: 2,
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const { signature: paraPartial } = await multiSigSigner.signPersonalMessage(bytes);
|
|
35
|
+
* // ...collect coPartial from the other signer out of band...
|
|
36
|
+
* const combined = multiSigSigner.combine([paraPartial, coPartial]);
|
|
37
|
+
* const ok = await multiSigSigner.verifyPersonalMessage(bytes, combined);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createParaSuiMultiSigSignerHook(): ({ address, walletId, otherMembers, threshold, paraWeight, }: UseParaSuiMultiSigSignerParameters) => UseParaSuiMultiSigSignerReturn;
|
|
41
|
+
export declare const useParaSuiMultiSigSigner: (params: UseParaSuiMultiSigSignerParameters) => UseParaSuiMultiSigSignerReturn;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
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 SUI_MULTISIG_SIGNER_BASE_KEY = "PARA_SUI_MULTISIG_SIGNER";
|
|
55
|
+
function membersKey(members) {
|
|
56
|
+
if (!members) return "";
|
|
57
|
+
return members.map(({ publicKey, weight }) => {
|
|
58
|
+
const pk = publicKey;
|
|
59
|
+
const id = typeof (pk == null ? void 0 : pk.toSuiAddress) === "function" ? pk.toSuiAddress() : pk instanceof Uint8Array ? Array.from(pk).join(",") : String(pk);
|
|
60
|
+
return `${id}:${weight}`;
|
|
61
|
+
}).join("|");
|
|
62
|
+
}
|
|
63
|
+
function createParaSuiMultiSigSignerHook() {
|
|
64
|
+
return function useParaSuiMultiSigSigner2({
|
|
65
|
+
address,
|
|
66
|
+
walletId,
|
|
67
|
+
otherMembers,
|
|
68
|
+
threshold,
|
|
69
|
+
paraWeight
|
|
70
|
+
}) {
|
|
71
|
+
const para = useClient();
|
|
72
|
+
const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
|
|
73
|
+
const { data: wallet } = useWallet();
|
|
74
|
+
const isEmbeddedActive = !!isFullyLoggedIn;
|
|
75
|
+
const _a = useQuery({
|
|
76
|
+
queryKey: [
|
|
77
|
+
SUI_MULTISIG_SIGNER_BASE_KEY,
|
|
78
|
+
isEmbeddedActive,
|
|
79
|
+
walletId != null ? walletId : (wallet == null ? void 0 : wallet.type) === "SUI" ? wallet == null ? void 0 : wallet.id : null,
|
|
80
|
+
threshold,
|
|
81
|
+
paraWeight != null ? paraWeight : 1,
|
|
82
|
+
membersKey(otherMembers)
|
|
83
|
+
],
|
|
84
|
+
enabled: isEmbeddedActive && !!para && Array.isArray(otherMembers) && otherMembers.length > 0 && (threshold != null ? threshold : 0) > 0,
|
|
85
|
+
queryFn: () => __async(null, null, function* () {
|
|
86
|
+
if (!isEmbeddedActive || !para) return null;
|
|
87
|
+
const resolved = resolveWalletForChain(para, { address, walletId }, "SUI", wallet != null ? wallet : void 0);
|
|
88
|
+
const mod = yield importSui();
|
|
89
|
+
return mod.createParaSuiMultiSigSigner({ para, walletId: resolved == null ? void 0 : resolved.id, otherMembers, threshold, paraWeight });
|
|
90
|
+
})
|
|
91
|
+
}), { data, isLoading } = _a, rest = __objRest(_a, ["data", "isLoading"]);
|
|
92
|
+
return __spreadValues({ multiSigSigner: data, data, isLoading }, rest);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function importSui() {
|
|
96
|
+
return __async(this, null, function* () {
|
|
97
|
+
try {
|
|
98
|
+
return yield import("@getpara/sui-sdk-integration");
|
|
99
|
+
} catch (e) {
|
|
100
|
+
throw new Error("[@getpara/react-core] Please install @getpara/sui-sdk-integration to use useParaSuiMultiSigSigner");
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const useParaSuiMultiSigSigner = createParaSuiMultiSigSignerHook();
|
|
105
|
+
export {
|
|
106
|
+
SUI_MULTISIG_SIGNER_BASE_KEY,
|
|
107
|
+
createParaSuiMultiSigSignerHook,
|
|
108
|
+
useParaSuiMultiSigSigner
|
|
109
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { WalletSelector } from '../types.js';
|
|
3
|
+
import type { SuiEnhancement } from './types.js';
|
|
4
|
+
export declare const SUI_SIGNER_BASE_KEY = "PARA_SUI_SIGNER";
|
|
5
|
+
type UseParaSuiSignerParameters = WalletSelector;
|
|
6
|
+
/** The signer object returned by `@getpara/sui-sdk-integration`'s `createParaSuiSigner` (synchronous). */
|
|
7
|
+
type SuiSignerData = ReturnType<Awaited<typeof import('@getpara/sui-sdk-integration')>['createParaSuiSigner']> | null | undefined;
|
|
8
|
+
/** Return type for `useParaSuiSigner`. Extends the react-query result with a named `suiSigner` alias for `data`. */
|
|
9
|
+
export type UseParaSuiSignerReturn = UseQueryResult<NonNullable<SuiSignerData> | null, Error> & {
|
|
10
|
+
/** The Sui signer, or `undefined` while loading / `null` when unavailable. */
|
|
11
|
+
suiSigner: SuiSignerData;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Factory that creates a `useParaSuiSigner` hook. Accepts an optional enhancer
|
|
15
|
+
* for external wallet support.
|
|
16
|
+
*
|
|
17
|
+
* @param useEnhancer - Optional hook that provides an external Sui signer.
|
|
18
|
+
* @returns A `useParaSuiSigner` hook.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createParaSuiSignerHook(useEnhancer?: () => SuiEnhancement): ({ address, walletId }?: UseParaSuiSignerParameters) => UseParaSuiSignerReturn;
|
|
21
|
+
/**
|
|
22
|
+
* Hook that returns a Sui signer backed by the user's embedded Para wallet (Sui reuses the Solana
|
|
23
|
+
* Ed25519 key material). Requires `@getpara/sui-sdk-integration` and `@mysten/sui` as peer dependencies.
|
|
24
|
+
*
|
|
25
|
+
* If the user has multiple Ed25519 wallets, pass `address` or `walletId` to select one. When omitted,
|
|
26
|
+
* the active wallet from `useWalletState` is used automatically.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { useParaSuiSigner } from "@getpara/react-sdk";
|
|
31
|
+
*
|
|
32
|
+
* function SignMessage() {
|
|
33
|
+
* const { suiSigner, isLoading } = useParaSuiSigner();
|
|
34
|
+
*
|
|
35
|
+
* const handleSign = async () => {
|
|
36
|
+
* if (!suiSigner) return;
|
|
37
|
+
* const { signature } = await suiSigner.signPersonalMessage(new TextEncoder().encode("gm"));
|
|
38
|
+
* console.log(signature);
|
|
39
|
+
* };
|
|
40
|
+
*
|
|
41
|
+
* if (isLoading) return <p>Loading...</p>;
|
|
42
|
+
* return <button onClick={handleSign}>Sign Message</button>;
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @returns {@link UseParaSuiSignerReturn} — a react-query result with `suiSigner` as a named alias for `data`.
|
|
47
|
+
*/
|
|
48
|
+
export declare const useParaSuiSigner: (params?: UseParaSuiSignerParameters) => UseParaSuiSignerReturn;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
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 SUI_SIGNER_BASE_KEY = "PARA_SUI_SIGNER";
|
|
55
|
+
function createParaSuiSignerHook(useEnhancer) {
|
|
56
|
+
return function useParaSuiSigner2({ address, walletId } = {}) {
|
|
57
|
+
var _a;
|
|
58
|
+
const para = useClient();
|
|
59
|
+
const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
|
|
60
|
+
const { data: wallet } = useWallet();
|
|
61
|
+
const enhancement = (_a = useEnhancer == null ? void 0 : useEnhancer()) != null ? _a : {};
|
|
62
|
+
const isEmbeddedActive = !!isFullyLoggedIn;
|
|
63
|
+
const _b = useQuery({
|
|
64
|
+
queryKey: [SUI_SIGNER_BASE_KEY, isEmbeddedActive, walletId != null ? walletId : (wallet == null ? void 0 : wallet.type) === "SUI" ? wallet == null ? void 0 : wallet.id : null],
|
|
65
|
+
enabled: !enhancement.isLoading && isEmbeddedActive && !!para,
|
|
66
|
+
queryFn: () => __async(null, null, function* () {
|
|
67
|
+
if (!isEmbeddedActive || !para) return null;
|
|
68
|
+
const resolved = resolveWalletForChain(para, { address, walletId }, "SUI", wallet != null ? wallet : void 0);
|
|
69
|
+
const mod = yield importSui();
|
|
70
|
+
return mod.createParaSuiSigner({ para, walletId: resolved == null ? void 0 : resolved.id });
|
|
71
|
+
})
|
|
72
|
+
}), { data, isLoading } = _b, rest = __objRest(_b, ["data", "isLoading"]);
|
|
73
|
+
return __spreadValues({ suiSigner: data, data, isLoading }, rest);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function importSui() {
|
|
77
|
+
return __async(this, null, function* () {
|
|
78
|
+
try {
|
|
79
|
+
return yield import("@getpara/sui-sdk-integration");
|
|
80
|
+
} catch (e) {
|
|
81
|
+
throw new Error("[@getpara/react-core] Please install @getpara/sui-sdk-integration to use useParaSuiSigner");
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const useParaSuiSigner = createParaSuiSignerHook();
|
|
86
|
+
export {
|
|
87
|
+
SUI_SIGNER_BASE_KEY,
|
|
88
|
+
createParaSuiSignerHook,
|
|
89
|
+
useParaSuiSigner
|
|
90
|
+
};
|
|
@@ -7,7 +7,7 @@ export declare const EXPORT_PRIVATE_KEY_KEY = "EXPORT_PRIVATE_KEY";
|
|
|
7
7
|
* (`shouldOpenPopup: true`). On React Native, load this URL in a WebView.
|
|
8
8
|
*
|
|
9
9
|
* Supports both DKLS wallets (EVM, Cosmos — returns a `0x`-prefixed hex string)
|
|
10
|
-
* and ED25519 wallets (Solana, Stellar — returns an MPC-Ed25519 v1 base58
|
|
10
|
+
* and ED25519 wallets (Solana, Stellar, Sui — returns an MPC-Ed25519 v1 base58
|
|
11
11
|
* string starting with `MPCS`). Pregenerated and external wallets are rejected.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Platform-agnostic ParaProvider, hooks, and store for Para SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"./stellar": {
|
|
44
44
|
"types": "./dist/chains/stellar/index.d.ts",
|
|
45
45
|
"import": "./dist/chains/stellar/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./sui": {
|
|
48
|
+
"types": "./dist/chains/sui/index.d.ts",
|
|
49
|
+
"import": "./dist/chains/sui/index.js"
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
52
|
"typesVersions": {
|
|
@@ -70,6 +74,9 @@
|
|
|
70
74
|
],
|
|
71
75
|
"stellar": [
|
|
72
76
|
"./dist/chains/stellar/index.d.ts"
|
|
77
|
+
],
|
|
78
|
+
"sui": [
|
|
79
|
+
"./dist/chains/sui/index.d.ts"
|
|
73
80
|
]
|
|
74
81
|
}
|
|
75
82
|
},
|
|
@@ -82,17 +89,18 @@
|
|
|
82
89
|
"test": "vitest run"
|
|
83
90
|
},
|
|
84
91
|
"dependencies": {
|
|
85
|
-
"@getpara/core-sdk": "3.
|
|
92
|
+
"@getpara/core-sdk": "3.9.0",
|
|
86
93
|
"zustand": "^5.0.0"
|
|
87
94
|
},
|
|
88
95
|
"devDependencies": {
|
|
89
96
|
"@cosmjs/amino": "^0.32.0",
|
|
90
97
|
"@cosmjs/proto-signing": "^0.32.0",
|
|
91
|
-
"@getpara/cosmjs-v0-integration": "3.
|
|
92
|
-
"@getpara/ethers-v6-integration": "3.
|
|
93
|
-
"@getpara/solana-signers-v2-integration": "3.
|
|
94
|
-
"@getpara/stellar-sdk-v14-integration": "3.
|
|
95
|
-
"@getpara/
|
|
98
|
+
"@getpara/cosmjs-v0-integration": "3.9.0",
|
|
99
|
+
"@getpara/ethers-v6-integration": "3.9.0",
|
|
100
|
+
"@getpara/solana-signers-v2-integration": "3.9.0",
|
|
101
|
+
"@getpara/stellar-sdk-v14-integration": "3.9.0",
|
|
102
|
+
"@getpara/sui-sdk-integration": "3.9.0",
|
|
103
|
+
"@getpara/viem-v2-integration": "3.9.0",
|
|
96
104
|
"@solana/signers": "^2.0.0",
|
|
97
105
|
"@tanstack/react-query": "^5.74.0",
|
|
98
106
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -112,6 +120,7 @@
|
|
|
112
120
|
"@getpara/ethers-v6-integration": ">=2",
|
|
113
121
|
"@getpara/solana-signers-v2-integration": ">=2",
|
|
114
122
|
"@getpara/stellar-sdk-v14-integration": ">=2",
|
|
123
|
+
"@getpara/sui-sdk-integration": ">=2",
|
|
115
124
|
"@getpara/viem-v2-integration": ">=2",
|
|
116
125
|
"@tanstack/react-query": ">=5",
|
|
117
126
|
"react": ">=18",
|
|
@@ -130,9 +139,12 @@
|
|
|
130
139
|
"@getpara/stellar-sdk-v14-integration": {
|
|
131
140
|
"optional": true
|
|
132
141
|
},
|
|
142
|
+
"@getpara/sui-sdk-integration": {
|
|
143
|
+
"optional": true
|
|
144
|
+
},
|
|
133
145
|
"@getpara/viem-v2-integration": {
|
|
134
146
|
"optional": true
|
|
135
147
|
}
|
|
136
148
|
},
|
|
137
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "0ce96d513e4690451e371054e2e75bdcad379639"
|
|
138
150
|
}
|