cilantro-react 0.1.0 → 0.1.2
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/README.md +155 -2
- package/dist/index.d.mts +177 -27
- package/dist/index.d.ts +177 -27
- package/dist/index.js +732 -379
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +684 -337
- package/dist/index.mjs.map +1 -1
- package/dist/themes/default.css +43 -0
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -43,6 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
SIGNER_TYPES: () => SIGNER_TYPES,
|
|
44
44
|
SignerList: () => SignerList,
|
|
45
45
|
SignerSelector: () => SignerSelector,
|
|
46
|
+
Skeleton: () => Skeleton,
|
|
47
|
+
ThemeProvider: () => ThemeProvider,
|
|
46
48
|
TransactionSigningForm: () => TransactionSigningForm,
|
|
47
49
|
WalletProvider: () => WalletProvider,
|
|
48
50
|
WalletSelector: () => WalletSelector,
|
|
@@ -53,11 +55,17 @@ __export(index_exports, {
|
|
|
53
55
|
signAndSendTransactionWithSigner: () => signAndSendTransactionWithSigner,
|
|
54
56
|
signMessageWithSigner: () => signMessageWithSigner,
|
|
55
57
|
signTransactionWithSigner: () => signTransactionWithSigner,
|
|
58
|
+
useCanSign: () => useCanSign,
|
|
56
59
|
useCilantroAuth: () => useCilantroAuth,
|
|
60
|
+
useDelegatedKeys: () => useDelegatedKeys,
|
|
57
61
|
useMessageSigning: () => useMessageSigning,
|
|
62
|
+
useSelectedWallet: () => useSelectedWallet,
|
|
58
63
|
useSignerSelection: () => useSignerSelection,
|
|
59
64
|
useSigners: () => useSigners,
|
|
65
|
+
useSignersForSelectedWallet: () => useSignersForSelectedWallet,
|
|
66
|
+
useSignersRaw: () => useSignersRaw,
|
|
60
67
|
useTransactionSigning: () => useTransactionSigning,
|
|
68
|
+
useWalletAddress: () => useWalletAddress,
|
|
61
69
|
useWallets: () => useWallets
|
|
62
70
|
});
|
|
63
71
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -256,25 +264,34 @@ function CilantroAuthProvider({
|
|
|
256
264
|
const login = async (usernameOrEmail, password) => {
|
|
257
265
|
try {
|
|
258
266
|
const result = await (0, import_auth.login)({ usernameOrEmail, password });
|
|
259
|
-
const
|
|
260
|
-
if (!
|
|
261
|
-
const jwt =
|
|
262
|
-
const userType =
|
|
267
|
+
const data = result && typeof result === "object" && "data" in result ? result.data : void 0;
|
|
268
|
+
if (!data?.jwt) throw new Error("No JWT token received from server");
|
|
269
|
+
const jwt = data.jwt;
|
|
270
|
+
const userType = data.userType;
|
|
263
271
|
setToken(jwt);
|
|
264
272
|
setSdkAuth(jwt);
|
|
265
273
|
if (typeof window !== "undefined") {
|
|
266
274
|
localStorage.setItem(jwtStorageKey, jwt);
|
|
267
275
|
document.cookie = `cilantro_jwt=${jwt}; path=/; max-age=${60 * 60 * 24 * 7}`;
|
|
268
276
|
}
|
|
269
|
-
|
|
270
|
-
const
|
|
277
|
+
if (data.user && typeof data.user === "object") {
|
|
278
|
+
const u = data.user;
|
|
271
279
|
setUser({
|
|
272
|
-
username:
|
|
273
|
-
email:
|
|
274
|
-
userType: userType ??
|
|
280
|
+
username: u.username,
|
|
281
|
+
email: u.email,
|
|
282
|
+
userType: userType ?? u.userType
|
|
275
283
|
});
|
|
276
|
-
}
|
|
277
|
-
|
|
284
|
+
} else {
|
|
285
|
+
try {
|
|
286
|
+
const payload = JSON.parse(atob(jwt.split(".")[1]));
|
|
287
|
+
setUser({
|
|
288
|
+
username: payload.username,
|
|
289
|
+
email: payload.email,
|
|
290
|
+
userType: userType ?? payload.userType
|
|
291
|
+
});
|
|
292
|
+
} catch {
|
|
293
|
+
setUser({ userType });
|
|
294
|
+
}
|
|
278
295
|
}
|
|
279
296
|
onLoginSuccess?.();
|
|
280
297
|
} catch (error) {
|
|
@@ -357,12 +374,12 @@ function WalletProvider({ children, storageKey = DEFAULT_STORAGE_KEY }) {
|
|
|
357
374
|
setSelectedWallet(wallet);
|
|
358
375
|
} else {
|
|
359
376
|
setSelectedWallet(wallets[0]);
|
|
360
|
-
if (typeof window !== "undefined") localStorage.setItem(storageKey, wallets[0].id);
|
|
377
|
+
if (typeof window !== "undefined") localStorage.setItem(storageKey, wallets[0].id ?? wallets[0].walletId);
|
|
361
378
|
}
|
|
362
379
|
} else {
|
|
363
380
|
if (wallets.length > 0) {
|
|
364
381
|
setSelectedWallet(wallets[0]);
|
|
365
|
-
if (typeof window !== "undefined") localStorage.setItem(storageKey, wallets[0].id);
|
|
382
|
+
if (typeof window !== "undefined") localStorage.setItem(storageKey, wallets[0].id ?? wallets[0].walletId);
|
|
366
383
|
}
|
|
367
384
|
}
|
|
368
385
|
} else if (wallets.length === 0) {
|
|
@@ -376,19 +393,13 @@ function WalletProvider({ children, storageKey = DEFAULT_STORAGE_KEY }) {
|
|
|
376
393
|
if (token) setSdkAuth(token);
|
|
377
394
|
const result = await (0, import_wallet.findAll)();
|
|
378
395
|
const walletsList = extractResponseData(result) ?? [];
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
walletAddress: w.walletAddress ?? w.address ?? "",
|
|
387
|
-
chain: w.chain ?? "solana",
|
|
388
|
-
active: w.active !== false,
|
|
389
|
-
...w
|
|
390
|
-
};
|
|
391
|
-
}) : [];
|
|
396
|
+
const list = Array.isArray(walletsList) ? walletsList : [];
|
|
397
|
+
const formattedWallets = list.map((w) => ({
|
|
398
|
+
...w,
|
|
399
|
+
id: w.walletId,
|
|
400
|
+
address: w.walletAddress,
|
|
401
|
+
active: w.isActive
|
|
402
|
+
}));
|
|
392
403
|
setWallets(formattedWallets);
|
|
393
404
|
} catch (error) {
|
|
394
405
|
console.error("Failed to load wallets:", error);
|
|
@@ -401,7 +412,7 @@ function WalletProvider({ children, storageKey = DEFAULT_STORAGE_KEY }) {
|
|
|
401
412
|
const wallet = wallets.find((w) => w.id === walletId || w.walletId === walletId);
|
|
402
413
|
if (wallet) {
|
|
403
414
|
setSelectedWallet(wallet);
|
|
404
|
-
if (typeof window !== "undefined") localStorage.setItem(storageKey, wallet.id);
|
|
415
|
+
if (typeof window !== "undefined") localStorage.setItem(storageKey, wallet.id ?? wallet.walletId);
|
|
405
416
|
}
|
|
406
417
|
};
|
|
407
418
|
const refreshWallets = async () => {
|
|
@@ -485,6 +496,18 @@ function CilantroProvider({
|
|
|
485
496
|
);
|
|
486
497
|
}
|
|
487
498
|
|
|
499
|
+
// src/hooks/useSelectedWallet.ts
|
|
500
|
+
function useSelectedWallet() {
|
|
501
|
+
const { selectedWallet, isLoading, refreshWallets } = useWallets();
|
|
502
|
+
return { selectedWallet, isLoading, refreshWallets };
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// src/hooks/useWalletAddress.ts
|
|
506
|
+
function useWalletAddress() {
|
|
507
|
+
const { selectedWallet } = useWallets();
|
|
508
|
+
return selectedWallet?.address ?? selectedWallet?.walletAddress ?? null;
|
|
509
|
+
}
|
|
510
|
+
|
|
488
511
|
// src/hooks/useSigners.ts
|
|
489
512
|
var import_react4 = require("react");
|
|
490
513
|
|
|
@@ -632,8 +655,119 @@ function useSigners(options = {}) {
|
|
|
632
655
|
return { signers, isLoading, error, refresh };
|
|
633
656
|
}
|
|
634
657
|
|
|
635
|
-
// src/hooks/
|
|
658
|
+
// src/hooks/useSignersRaw.ts
|
|
636
659
|
var import_react5 = require("react");
|
|
660
|
+
var import_wallet3 = require("cilantro-sdk/wallet");
|
|
661
|
+
function useSignersRaw(options = {}) {
|
|
662
|
+
const { walletId } = options;
|
|
663
|
+
const { token } = useCilantroAuth();
|
|
664
|
+
const [signersRaw, setSignersRaw] = (0, import_react5.useState)(null);
|
|
665
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
666
|
+
const [error, setError] = (0, import_react5.useState)(null);
|
|
667
|
+
const load = (0, import_react5.useCallback)(async () => {
|
|
668
|
+
if (!walletId) {
|
|
669
|
+
setSignersRaw(null);
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
setIsLoading(true);
|
|
673
|
+
setError(null);
|
|
674
|
+
try {
|
|
675
|
+
if (token) setSdkAuth(token);
|
|
676
|
+
const result = await (0, import_wallet3.listSigners)(walletId);
|
|
677
|
+
setSignersRaw(result);
|
|
678
|
+
} catch (err) {
|
|
679
|
+
setSignersRaw(null);
|
|
680
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
681
|
+
} finally {
|
|
682
|
+
setIsLoading(false);
|
|
683
|
+
}
|
|
684
|
+
}, [walletId, token]);
|
|
685
|
+
(0, import_react5.useEffect)(() => {
|
|
686
|
+
if (!walletId) {
|
|
687
|
+
setSignersRaw(null);
|
|
688
|
+
setError(null);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
load();
|
|
692
|
+
}, [walletId, load]);
|
|
693
|
+
const refresh = (0, import_react5.useCallback)(async () => {
|
|
694
|
+
if (walletId) await load();
|
|
695
|
+
}, [walletId, load]);
|
|
696
|
+
return {
|
|
697
|
+
signersRaw: walletId ? signersRaw : null,
|
|
698
|
+
isLoading,
|
|
699
|
+
error,
|
|
700
|
+
refresh
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/hooks/useSignersForSelectedWallet.ts
|
|
705
|
+
function useSignersForSelectedWallet(options = {}) {
|
|
706
|
+
const { walletId: walletIdOverride } = options;
|
|
707
|
+
const { selectedWallet } = useWallets();
|
|
708
|
+
const effectiveWalletId = walletIdOverride ?? selectedWallet?.id ?? selectedWallet?.walletId ?? null;
|
|
709
|
+
return useSigners({ walletId: effectiveWalletId });
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/hooks/useDelegatedKeys.ts
|
|
713
|
+
var import_react6 = require("react");
|
|
714
|
+
var import_delegated_keys = require("cilantro-sdk/delegated-keys");
|
|
715
|
+
function normalizeKeys(list) {
|
|
716
|
+
return list.map((k) => ({
|
|
717
|
+
...k,
|
|
718
|
+
id: k.delegatedKeyId
|
|
719
|
+
}));
|
|
720
|
+
}
|
|
721
|
+
function useDelegatedKeys(options = {}) {
|
|
722
|
+
const { walletId, filterActive = true } = options;
|
|
723
|
+
const { token } = useCilantroAuth();
|
|
724
|
+
const [keys, setKeys] = (0, import_react6.useState)([]);
|
|
725
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
|
|
726
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
727
|
+
const loadKeys = (0, import_react6.useCallback)(async () => {
|
|
728
|
+
if (!walletId) {
|
|
729
|
+
setKeys([]);
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
setIsLoading(true);
|
|
733
|
+
setError(null);
|
|
734
|
+
try {
|
|
735
|
+
if (token) setSdkAuth(token);
|
|
736
|
+
const result = await (0, import_delegated_keys.findAll)(walletId);
|
|
737
|
+
const keysData = extractResponseData(result) ?? [];
|
|
738
|
+
const list = Array.isArray(keysData) ? keysData : [];
|
|
739
|
+
const valid = list.filter(
|
|
740
|
+
(k) => k != null && typeof k === "object" && "delegatedKeyId" in k
|
|
741
|
+
);
|
|
742
|
+
let loaded = normalizeKeys(valid);
|
|
743
|
+
if (filterActive) {
|
|
744
|
+
const now = Date.now();
|
|
745
|
+
loaded = loaded.filter((key) => {
|
|
746
|
+
if (!key.isActive) return false;
|
|
747
|
+
const raw = key.expiresAt;
|
|
748
|
+
const exp = raw != null && (typeof raw === "string" || typeof raw === "number") ? new Date(raw).getTime() : null;
|
|
749
|
+
return exp === null || exp > now;
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
setKeys(loaded);
|
|
753
|
+
} catch (err) {
|
|
754
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
755
|
+
setKeys([]);
|
|
756
|
+
} finally {
|
|
757
|
+
setIsLoading(false);
|
|
758
|
+
}
|
|
759
|
+
}, [walletId, token, filterActive]);
|
|
760
|
+
(0, import_react6.useEffect)(() => {
|
|
761
|
+
loadKeys();
|
|
762
|
+
}, [loadKeys]);
|
|
763
|
+
const refresh = (0, import_react6.useCallback)(async () => {
|
|
764
|
+
if (walletId) await loadKeys();
|
|
765
|
+
}, [walletId, loadKeys]);
|
|
766
|
+
return { keys, isLoading, error, refresh };
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// src/hooks/useSignerSelection.ts
|
|
770
|
+
var import_react7 = require("react");
|
|
637
771
|
function useSignerSelection(options = {}) {
|
|
638
772
|
const { walletId: walletIdOverride, signingMethod = "sdk-signer" } = options;
|
|
639
773
|
const { selectedWallet } = useWallets();
|
|
@@ -641,17 +775,17 @@ function useSignerSelection(options = {}) {
|
|
|
641
775
|
const { signers: availableSigners, isLoading: isLoadingSigners } = useSigners({
|
|
642
776
|
walletId: effectiveWalletId || null
|
|
643
777
|
});
|
|
644
|
-
const [selectedWalletId, setSelectedWalletId] = (0,
|
|
645
|
-
const [selectedSigner, setSelectedSigner] = (0,
|
|
646
|
-
(0,
|
|
778
|
+
const [selectedWalletId, setSelectedWalletId] = (0, import_react7.useState)(effectiveWalletId);
|
|
779
|
+
const [selectedSigner, setSelectedSigner] = (0, import_react7.useState)(null);
|
|
780
|
+
(0, import_react7.useEffect)(() => {
|
|
647
781
|
setSelectedWalletId(effectiveWalletId);
|
|
648
782
|
}, [effectiveWalletId]);
|
|
649
|
-
(0,
|
|
783
|
+
(0, import_react7.useEffect)(() => {
|
|
650
784
|
if (signingMethod !== "sdk-signer") {
|
|
651
785
|
setSelectedSigner(null);
|
|
652
786
|
}
|
|
653
787
|
}, [signingMethod]);
|
|
654
|
-
const reset = (0,
|
|
788
|
+
const reset = (0, import_react7.useCallback)(() => {
|
|
655
789
|
setSelectedWalletId("");
|
|
656
790
|
setSelectedSigner(null);
|
|
657
791
|
}, []);
|
|
@@ -666,8 +800,43 @@ function useSignerSelection(options = {}) {
|
|
|
666
800
|
};
|
|
667
801
|
}
|
|
668
802
|
|
|
803
|
+
// src/hooks/useCanSign.ts
|
|
804
|
+
var import_react8 = require("react");
|
|
805
|
+
function useCanSign(options = {}) {
|
|
806
|
+
const {
|
|
807
|
+
signingMethod = "sdk-signer",
|
|
808
|
+
requireSigner = true,
|
|
809
|
+
walletAdapterConnected
|
|
810
|
+
} = options;
|
|
811
|
+
const { token } = useCilantroAuth();
|
|
812
|
+
const { selectedWallet } = useWallets();
|
|
813
|
+
const { selectedSigner } = useSignerSelection({ signingMethod });
|
|
814
|
+
return (0, import_react8.useMemo)(() => {
|
|
815
|
+
const hasToken = !!token;
|
|
816
|
+
const hasWallet = !!selectedWallet?.id || !!selectedWallet?.walletId;
|
|
817
|
+
const isSdkSigner = signingMethod === "sdk-signer";
|
|
818
|
+
const hasSigner = isSdkSigner ? !!selectedSigner : walletAdapterConnected !== void 0 ? walletAdapterConnected : hasWallet;
|
|
819
|
+
const canSign = hasToken && hasWallet && (requireSigner ? hasSigner : true);
|
|
820
|
+
return {
|
|
821
|
+
hasToken,
|
|
822
|
+
hasWallet,
|
|
823
|
+
hasSigner,
|
|
824
|
+
canSignMessage: canSign,
|
|
825
|
+
canSignTransaction: canSign
|
|
826
|
+
};
|
|
827
|
+
}, [
|
|
828
|
+
token,
|
|
829
|
+
selectedWallet?.id,
|
|
830
|
+
selectedWallet?.walletId,
|
|
831
|
+
selectedSigner,
|
|
832
|
+
signingMethod,
|
|
833
|
+
requireSigner,
|
|
834
|
+
walletAdapterConnected
|
|
835
|
+
]);
|
|
836
|
+
}
|
|
837
|
+
|
|
669
838
|
// src/hooks/useMessageSigning.ts
|
|
670
|
-
var
|
|
839
|
+
var import_react9 = require("react");
|
|
671
840
|
|
|
672
841
|
// src/core/signer-signing/core.ts
|
|
673
842
|
var import_web3 = require("@solana/web3.js");
|
|
@@ -726,7 +895,7 @@ var import_helpers6 = require("cilantro-sdk/helpers");
|
|
|
726
895
|
var import_web32 = require("@solana/web3.js");
|
|
727
896
|
var import_helpers4 = require("cilantro-sdk/helpers");
|
|
728
897
|
var import_transactions = require("cilantro-sdk/transactions");
|
|
729
|
-
var
|
|
898
|
+
var import_wallet4 = require("cilantro-sdk/wallet");
|
|
730
899
|
async function createEmailSignerHelper(walletId, email) {
|
|
731
900
|
const trimmedEmail = email.trim();
|
|
732
901
|
if (!trimmedEmail) throw new Error("Email address is required");
|
|
@@ -743,7 +912,7 @@ async function createPhoneSignerHelper(walletId, phone) {
|
|
|
743
912
|
}
|
|
744
913
|
async function createExternalSignerHelper(walletId, address) {
|
|
745
914
|
if (!address.trim()) throw new Error("Wallet address is required");
|
|
746
|
-
return await (0,
|
|
915
|
+
return await (0, import_wallet4.createExternalWalletSigner)(walletId, { address: address.trim(), chain: "solana" });
|
|
747
916
|
}
|
|
748
917
|
async function registerPasskeySigner(walletId) {
|
|
749
918
|
if (!(0, import_helpers4.isWebAuthnSupported)()) throw new Error("WebAuthn is not supported in this browser");
|
|
@@ -787,9 +956,10 @@ async function signAndSendPasskeyTransaction(walletId, signerId, transaction, op
|
|
|
787
956
|
});
|
|
788
957
|
}
|
|
789
958
|
const unsignedTransaction = transaction.serialize({ verifySignatures: false }).toString("base64");
|
|
790
|
-
const authOptions = await (0,
|
|
791
|
-
|
|
792
|
-
|
|
959
|
+
const authOptions = await (0, import_wallet4.startPasskeyAuthentication)(
|
|
960
|
+
walletId,
|
|
961
|
+
{ credentialId: options?.credentialId }
|
|
962
|
+
);
|
|
793
963
|
const authData = extractResponseData(authOptions);
|
|
794
964
|
if (!authData) throw new Error("Failed to get authentication options");
|
|
795
965
|
const authDataValue = authData && typeof authData === "object" && "data" in authData ? authData.data : authData;
|
|
@@ -808,7 +978,10 @@ async function signAndSendPasskeyTransaction(walletId, signerId, transaction, op
|
|
|
808
978
|
};
|
|
809
979
|
const result = await (0, import_transactions.sendRawPasskeyTransaction)(dto);
|
|
810
980
|
const resultData = extractResponseData(result);
|
|
811
|
-
return {
|
|
981
|
+
return {
|
|
982
|
+
signature: resultData?.signature ?? "",
|
|
983
|
+
status: resultData?.status
|
|
984
|
+
};
|
|
812
985
|
}
|
|
813
986
|
|
|
814
987
|
// src/core/signer-signing/errors.ts
|
|
@@ -874,10 +1047,11 @@ async function signMessageWithSigner(walletId, signer, messageText) {
|
|
|
874
1047
|
validateSignerActive(signer, signerType);
|
|
875
1048
|
const storageOptions = getStorageOptions();
|
|
876
1049
|
try {
|
|
877
|
-
const
|
|
1050
|
+
const signatureBytes = await (0, import_helpers6.signWithEmailSigner)(walletId, signerId, message, storageOptions);
|
|
878
1051
|
const keypair = await (0, import_helpers6.getEmailSignerKeypair)(walletId, signerId, storageOptions);
|
|
879
1052
|
return {
|
|
880
|
-
signature: Buffer.from(
|
|
1053
|
+
signature: Buffer.from(signatureBytes).toString("base64"),
|
|
1054
|
+
message: messageText,
|
|
881
1055
|
publicKey: Buffer.from(keypair.publicKey).toString("hex"),
|
|
882
1056
|
signerType: SIGNER_TYPES.EMAIL
|
|
883
1057
|
};
|
|
@@ -889,10 +1063,11 @@ async function signMessageWithSigner(walletId, signer, messageText) {
|
|
|
889
1063
|
validateSignerActive(signer, signerType);
|
|
890
1064
|
const storageOptions = getStorageOptions();
|
|
891
1065
|
try {
|
|
892
|
-
const
|
|
1066
|
+
const signatureBytes = await (0, import_helpers6.signWithPhoneSigner)(walletId, signerId, message, storageOptions);
|
|
893
1067
|
const keypair = await (0, import_helpers6.getPhoneSignerKeypair)(walletId, signerId, storageOptions);
|
|
894
1068
|
return {
|
|
895
|
-
signature: Buffer.from(
|
|
1069
|
+
signature: Buffer.from(signatureBytes).toString("base64"),
|
|
1070
|
+
message: messageText,
|
|
896
1071
|
publicKey: Buffer.from(keypair.publicKey).toString("hex"),
|
|
897
1072
|
signerType: SIGNER_TYPES.PHONE
|
|
898
1073
|
};
|
|
@@ -902,8 +1077,10 @@ async function signMessageWithSigner(walletId, signer, messageText) {
|
|
|
902
1077
|
}
|
|
903
1078
|
if (signerType === SIGNER_TYPES.PASSKEY) {
|
|
904
1079
|
const signResult = await signWithPasskey(walletId, signerId, messageText, { useBrowserAutofill: false });
|
|
1080
|
+
const signatureBase64 = Buffer.from(signResult.signature, "hex").toString("base64");
|
|
905
1081
|
return {
|
|
906
|
-
signature:
|
|
1082
|
+
signature: signatureBase64,
|
|
1083
|
+
message: messageText,
|
|
907
1084
|
signerType: SIGNER_TYPES.PASSKEY,
|
|
908
1085
|
signer: signResult.signer
|
|
909
1086
|
};
|
|
@@ -911,10 +1088,11 @@ async function signMessageWithSigner(walletId, signer, messageText) {
|
|
|
911
1088
|
if (signerType === SIGNER_TYPES.EXTERNAL || signerType === SIGNER_TYPES.API_KEY) {
|
|
912
1089
|
validateSignerActive(signer, signerType);
|
|
913
1090
|
const storageOptions = getStorageOptions();
|
|
914
|
-
const
|
|
1091
|
+
const signatureBytes = await (0, import_helpers6.signWithSigner)(walletId, signerId, signerType, message, storageOptions);
|
|
915
1092
|
const keypair = await (0, import_helpers6.deriveSignerKeypair)(walletId, signerId, signerType, storageOptions);
|
|
916
1093
|
return {
|
|
917
|
-
signature: Buffer.from(
|
|
1094
|
+
signature: Buffer.from(signatureBytes).toString("base64"),
|
|
1095
|
+
message: messageText,
|
|
918
1096
|
publicKey: Buffer.from(keypair.publicKey).toString("base64"),
|
|
919
1097
|
signerType
|
|
920
1098
|
};
|
|
@@ -924,7 +1102,7 @@ async function signMessageWithSigner(walletId, signer, messageText) {
|
|
|
924
1102
|
|
|
925
1103
|
// src/core/signer-signing/transaction-signing.ts
|
|
926
1104
|
var import_helpers7 = require("cilantro-sdk/helpers");
|
|
927
|
-
var
|
|
1105
|
+
var import_wallet5 = require("cilantro-sdk/wallet");
|
|
928
1106
|
|
|
929
1107
|
// src/core/signer-signing/validation.ts
|
|
930
1108
|
var import_web33 = require("@solana/web3.js");
|
|
@@ -1030,14 +1208,16 @@ async function signTransactionWithEmailOrPhone(walletId, signerId, signerType, u
|
|
|
1030
1208
|
);
|
|
1031
1209
|
}
|
|
1032
1210
|
async function submitSignedTransaction(walletId, signedTransactionBase64) {
|
|
1033
|
-
const submitResult = await (0,
|
|
1211
|
+
const submitResult = await (0, import_wallet5.submitTransaction)(walletId, {
|
|
1034
1212
|
signedTransaction: signedTransactionBase64
|
|
1035
1213
|
});
|
|
1036
1214
|
const resultData = extractResponseData(submitResult);
|
|
1037
1215
|
if (!resultData?.signature) throw new Error("Server did not return a transaction signature");
|
|
1216
|
+
const status = resultData.status ?? "pending";
|
|
1038
1217
|
return {
|
|
1039
1218
|
signature: resultData.signature,
|
|
1040
|
-
|
|
1219
|
+
status,
|
|
1220
|
+
confirmationStatus: status
|
|
1041
1221
|
};
|
|
1042
1222
|
}
|
|
1043
1223
|
async function handlePasskeyTransaction(walletId, signerId, transaction, connection) {
|
|
@@ -1050,7 +1230,7 @@ async function handlePasskeyTransaction(walletId, signerId, transaction, connect
|
|
|
1050
1230
|
const result = await signAndSendPasskeyTransaction(walletId, signerId, transaction, {
|
|
1051
1231
|
useBrowserAutofill: false
|
|
1052
1232
|
});
|
|
1053
|
-
let
|
|
1233
|
+
let status = "confirmed";
|
|
1054
1234
|
try {
|
|
1055
1235
|
await connection.confirmTransaction({
|
|
1056
1236
|
signature: result.signature,
|
|
@@ -1060,12 +1240,12 @@ async function handlePasskeyTransaction(walletId, signerId, transaction, connect
|
|
|
1060
1240
|
} catch (error) {
|
|
1061
1241
|
const errorMsg = extractErrorMessage(error);
|
|
1062
1242
|
if (errorMsg.includes("block height exceeded") || errorMsg.includes("expired") || errorMsg.includes("timeout")) {
|
|
1063
|
-
|
|
1243
|
+
status = "pending";
|
|
1064
1244
|
} else {
|
|
1065
1245
|
throw new Error(`Transaction confirmation failed: ${errorMsg}. Signature: ${result.signature}`);
|
|
1066
1246
|
}
|
|
1067
1247
|
}
|
|
1068
|
-
return { signature: result.signature, confirmationStatus };
|
|
1248
|
+
return { signature: result.signature, status, confirmationStatus: status };
|
|
1069
1249
|
}
|
|
1070
1250
|
async function handleEmailOrPhoneTransaction(walletId, signer, signerType, signerId, transaction) {
|
|
1071
1251
|
validateSignerActive(signer, signerType);
|
|
@@ -1177,24 +1357,17 @@ async function signAndSendTransactionWithSigner(walletId, signer, transaction, c
|
|
|
1177
1357
|
|
|
1178
1358
|
// src/core/signer-signing/wallet-data.ts
|
|
1179
1359
|
var import_web34 = require("@solana/web3.js");
|
|
1180
|
-
var
|
|
1360
|
+
var import_wallet6 = require("cilantro-sdk/wallet");
|
|
1181
1361
|
async function getWalletData(walletId) {
|
|
1182
|
-
const walletDataResponse = await (0,
|
|
1362
|
+
const walletDataResponse = await (0, import_wallet6.findOne)(walletId);
|
|
1183
1363
|
const walletData = extractResponseData(walletDataResponse);
|
|
1184
1364
|
if (!walletData) throw new Error("Wallet data is empty");
|
|
1185
|
-
const address = String(
|
|
1186
|
-
|
|
1187
|
-
).trim();
|
|
1188
|
-
if (!address) throw new Error(`No wallet address found. Available fields: ${Object.keys(walletData).join(", ")}`);
|
|
1365
|
+
const address = String(walletData.walletAddress ?? "").trim();
|
|
1366
|
+
if (!address) throw new Error("No wallet address found (walletAddress is empty).");
|
|
1189
1367
|
const walletPublicKey = new import_web34.PublicKey(address);
|
|
1190
|
-
const
|
|
1191
|
-
const adminPubkey = String(
|
|
1192
|
-
walletData.adminSignerPubkey ?? walletData.adminSigner ?? adminData?.publicKey ?? ""
|
|
1193
|
-
).trim();
|
|
1368
|
+
const adminPubkey = String(walletData.adminSignerPubkey ?? "").trim();
|
|
1194
1369
|
if (!adminPubkey) {
|
|
1195
|
-
throw new Error(
|
|
1196
|
-
`adminSignerPubkey not found in wallet data. Available fields: ${Object.keys(walletData).join(", ")}`
|
|
1197
|
-
);
|
|
1370
|
+
throw new Error("adminSignerPubkey not found in wallet data.");
|
|
1198
1371
|
}
|
|
1199
1372
|
const adminSignerPubkey = new import_web34.PublicKey(adminPubkey);
|
|
1200
1373
|
return { walletPublicKey, adminSignerPubkey };
|
|
@@ -1210,9 +1383,9 @@ function useMessageSigning(options) {
|
|
|
1210
1383
|
walletAdapterSignMessage,
|
|
1211
1384
|
walletAdapterPublicKey
|
|
1212
1385
|
} = options;
|
|
1213
|
-
const [messageText, setMessageText] = (0,
|
|
1214
|
-
const [signResultState, setSignResultState] = (0,
|
|
1215
|
-
const [isSigning, setIsSigning] = (0,
|
|
1386
|
+
const [messageText, setMessageText] = (0, import_react9.useState)("Hello, Solana!");
|
|
1387
|
+
const [signResultState, setSignResultState] = (0, import_react9.useState)({ status: "idle" });
|
|
1388
|
+
const [isSigning, setIsSigning] = (0, import_react9.useState)(false);
|
|
1216
1389
|
const handleSign = async () => {
|
|
1217
1390
|
setIsSigning(true);
|
|
1218
1391
|
setSignResultState({ status: "loading" });
|
|
@@ -1242,7 +1415,7 @@ function useMessageSigning(options) {
|
|
|
1242
1415
|
setSignResultState({
|
|
1243
1416
|
status: "success",
|
|
1244
1417
|
message: `Message signed successfully with ${signerType} signer!`,
|
|
1245
|
-
detail: {
|
|
1418
|
+
detail: { ...result }
|
|
1246
1419
|
});
|
|
1247
1420
|
} catch (error) {
|
|
1248
1421
|
const errorMsg = extractErrorMessage(error);
|
|
@@ -1270,7 +1443,7 @@ function useMessageSigning(options) {
|
|
|
1270
1443
|
}
|
|
1271
1444
|
|
|
1272
1445
|
// src/hooks/useTransactionSigning.ts
|
|
1273
|
-
var
|
|
1446
|
+
var import_react10 = require("react");
|
|
1274
1447
|
function useTransactionSigning(options) {
|
|
1275
1448
|
const {
|
|
1276
1449
|
token,
|
|
@@ -1281,9 +1454,9 @@ function useTransactionSigning(options) {
|
|
|
1281
1454
|
walletAdapterPublicKey,
|
|
1282
1455
|
connection
|
|
1283
1456
|
} = options;
|
|
1284
|
-
const [transactionResultState, setTransactionResultState] = (0,
|
|
1285
|
-
const [isSigningTransaction, setIsSigningTransaction] = (0,
|
|
1286
|
-
const [isSendingTransaction, setIsSendingTransaction] = (0,
|
|
1457
|
+
const [transactionResultState, setTransactionResultState] = (0, import_react10.useState)({ status: "idle" });
|
|
1458
|
+
const [isSigningTransaction, setIsSigningTransaction] = (0, import_react10.useState)(false);
|
|
1459
|
+
const [isSendingTransaction, setIsSendingTransaction] = (0, import_react10.useState)(false);
|
|
1287
1460
|
const signTransaction = async (transaction) => {
|
|
1288
1461
|
setIsSigningTransaction(true);
|
|
1289
1462
|
setTransactionResultState({ status: "loading" });
|
|
@@ -1361,6 +1534,7 @@ function useTransactionSigning(options) {
|
|
|
1361
1534
|
message: `Transaction sent with ${signerType} signer!`,
|
|
1362
1535
|
detail: {
|
|
1363
1536
|
signature: result.signature,
|
|
1537
|
+
status: result.status,
|
|
1364
1538
|
confirmationStatus: result.confirmationStatus,
|
|
1365
1539
|
explorerUrl: `https://solscan.io/tx/${result.signature}?cluster=devnet`
|
|
1366
1540
|
}
|
|
@@ -1462,14 +1636,30 @@ var SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /*
|
|
|
1462
1636
|
));
|
|
1463
1637
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
1464
1638
|
|
|
1465
|
-
// src/
|
|
1639
|
+
// src/ui/skeleton.tsx
|
|
1640
|
+
var React2 = __toESM(require("react"));
|
|
1466
1641
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1642
|
+
var Skeleton = React2.forwardRef(
|
|
1643
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1644
|
+
"div",
|
|
1645
|
+
{
|
|
1646
|
+
ref,
|
|
1647
|
+
className: cn("rounded-md bg-muted animate-pulse", className),
|
|
1648
|
+
...props
|
|
1649
|
+
}
|
|
1650
|
+
)
|
|
1651
|
+
);
|
|
1652
|
+
Skeleton.displayName = "Skeleton";
|
|
1653
|
+
|
|
1654
|
+
// src/components/WalletSelector.tsx
|
|
1655
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1467
1656
|
function WalletSelector(props) {
|
|
1468
1657
|
const {
|
|
1469
1658
|
value,
|
|
1470
1659
|
onWalletChange,
|
|
1471
1660
|
className,
|
|
1472
1661
|
classNames,
|
|
1662
|
+
useSkeleton = true,
|
|
1473
1663
|
placeholder = "Select a wallet",
|
|
1474
1664
|
renderTrigger,
|
|
1475
1665
|
renderList,
|
|
@@ -1479,15 +1669,16 @@ function WalletSelector(props) {
|
|
|
1479
1669
|
const effectiveValue = value ?? selectedWallet?.id ?? selectedWallet?.walletId ?? "";
|
|
1480
1670
|
const selected = wallets.find((w) => w.id === effectiveValue || w.walletId === effectiveValue) ?? selectedWallet;
|
|
1481
1671
|
const handleSelect = (wallet) => {
|
|
1482
|
-
|
|
1483
|
-
|
|
1672
|
+
const id = wallet.id ?? wallet.walletId;
|
|
1673
|
+
selectWallet(id);
|
|
1674
|
+
onWalletChange?.(id, wallet);
|
|
1484
1675
|
};
|
|
1485
1676
|
const handleValueChange = (id) => {
|
|
1486
1677
|
selectWallet(id);
|
|
1487
1678
|
onWalletChange?.(id, wallets.find((w) => w.id === id || w.walletId === id) ?? null);
|
|
1488
1679
|
};
|
|
1489
1680
|
if (children) {
|
|
1490
|
-
return /* @__PURE__ */ (0,
|
|
1681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: children({
|
|
1491
1682
|
wallets,
|
|
1492
1683
|
selectedWallet: selected,
|
|
1493
1684
|
selectWallet: (id) => {
|
|
@@ -1499,23 +1690,47 @@ function WalletSelector(props) {
|
|
|
1499
1690
|
}) });
|
|
1500
1691
|
}
|
|
1501
1692
|
if (renderTrigger || renderList) {
|
|
1502
|
-
return /* @__PURE__ */ (0,
|
|
1693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn(className, classNames?.root), "data-cilantro-wallet-selector": true, children: [
|
|
1503
1694
|
renderTrigger?.({ selectedWallet: selected, wallets, isLoading, open: false, setOpen: () => {
|
|
1504
1695
|
} }),
|
|
1505
1696
|
renderList?.({ wallets, selectedWallet: selected, onSelect: handleSelect, isLoading })
|
|
1506
1697
|
] });
|
|
1507
1698
|
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1699
|
+
if (isLoading && useSkeleton) {
|
|
1700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1701
|
+
"div",
|
|
1702
|
+
{
|
|
1703
|
+
className: cn(className, classNames?.root, classNames?.loading),
|
|
1704
|
+
"data-cilantro-wallet-selector": true,
|
|
1705
|
+
"aria-busy": "true",
|
|
1706
|
+
"aria-live": "polite",
|
|
1707
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1708
|
+
"div",
|
|
1709
|
+
{
|
|
1710
|
+
className: cn(
|
|
1711
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2",
|
|
1712
|
+
classNames?.trigger
|
|
1713
|
+
),
|
|
1714
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Skeleton, { className: cn("h-4 flex-1 rounded", classNames?.skeleton) })
|
|
1715
|
+
}
|
|
1716
|
+
)
|
|
1717
|
+
}
|
|
1718
|
+
);
|
|
1719
|
+
}
|
|
1720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-wallet-selector": true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Select, { value: effectiveValue || void 0, onValueChange: handleValueChange, disabled: isLoading, children: [
|
|
1721
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectTrigger, { className: classNames?.trigger, "aria-label": "Select wallet", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectValue, { placeholder: isLoading ? "Loading..." : placeholder }) }),
|
|
1722
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectContent, { className: classNames?.content, children: wallets.map((w) => {
|
|
1723
|
+
const id = w.id ?? w.walletId;
|
|
1724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectItem, { value: id, className: classNames?.item, children: w.walletName || id }, id);
|
|
1725
|
+
}) })
|
|
1511
1726
|
] }) });
|
|
1512
1727
|
}
|
|
1513
1728
|
|
|
1514
1729
|
// src/ui/button.tsx
|
|
1515
|
-
var
|
|
1730
|
+
var React3 = __toESM(require("react"));
|
|
1516
1731
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
1517
1732
|
var import_class_variance_authority = require("class-variance-authority");
|
|
1518
|
-
var
|
|
1733
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1519
1734
|
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
1520
1735
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
1521
1736
|
{
|
|
@@ -1532,7 +1747,8 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
1532
1747
|
default: "h-10 px-4 py-2",
|
|
1533
1748
|
sm: "h-9 rounded-md px-3",
|
|
1534
1749
|
lg: "h-11 rounded-md px-8",
|
|
1535
|
-
icon: "h-10 w-10"
|
|
1750
|
+
icon: "h-10 w-10",
|
|
1751
|
+
touch: "h-12 min-h-[44px] min-w-[44px] rounded-md px-4"
|
|
1536
1752
|
}
|
|
1537
1753
|
},
|
|
1538
1754
|
defaultVariants: {
|
|
@@ -1541,16 +1757,16 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
|
1541
1757
|
}
|
|
1542
1758
|
}
|
|
1543
1759
|
);
|
|
1544
|
-
var Button =
|
|
1760
|
+
var Button = React3.forwardRef(
|
|
1545
1761
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
1546
1762
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1547
|
-
return /* @__PURE__ */ (0,
|
|
1763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Comp, { className: cn(buttonVariants({ variant, size, className })), ref, ...props });
|
|
1548
1764
|
}
|
|
1549
1765
|
);
|
|
1550
1766
|
Button.displayName = "Button";
|
|
1551
1767
|
|
|
1552
1768
|
// src/components/SignerSelector.tsx
|
|
1553
|
-
var
|
|
1769
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1554
1770
|
function SignerSelector({
|
|
1555
1771
|
selectedWalletId,
|
|
1556
1772
|
availableSigners,
|
|
@@ -1559,15 +1775,16 @@ function SignerSelector({
|
|
|
1559
1775
|
onSignerSelect,
|
|
1560
1776
|
className,
|
|
1561
1777
|
classNames,
|
|
1778
|
+
useSkeleton = true,
|
|
1562
1779
|
renderList,
|
|
1563
1780
|
children
|
|
1564
1781
|
}) {
|
|
1565
1782
|
if (!selectedWalletId) return null;
|
|
1566
1783
|
if (children) {
|
|
1567
|
-
return /* @__PURE__ */ (0,
|
|
1784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: children({ signers: availableSigners, selectedSigner, onSignerSelect, isLoading: isLoadingSigners }) });
|
|
1568
1785
|
}
|
|
1569
1786
|
if (renderList) {
|
|
1570
|
-
return /* @__PURE__ */ (0,
|
|
1787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-signer-selector": true, children: renderList({
|
|
1571
1788
|
signers: availableSigners,
|
|
1572
1789
|
selectedSigner,
|
|
1573
1790
|
onSelect: onSignerSelect,
|
|
@@ -1577,29 +1794,53 @@ function SignerSelector({
|
|
|
1577
1794
|
getSignerUniqueId
|
|
1578
1795
|
}) });
|
|
1579
1796
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1797
|
+
const loadingContent = isLoadingSigners && useSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1798
|
+
"div",
|
|
1582
1799
|
{
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
")"
|
|
1594
|
-
]
|
|
1800
|
+
className: cn("space-y-1", classNames?.loading),
|
|
1801
|
+
"aria-busy": "true",
|
|
1802
|
+
"aria-live": "polite",
|
|
1803
|
+
children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1804
|
+
Skeleton,
|
|
1805
|
+
{
|
|
1806
|
+
className: cn("h-8 w-full rounded-md", classNames?.skeleton)
|
|
1807
|
+
},
|
|
1808
|
+
i
|
|
1809
|
+
))
|
|
1595
1810
|
}
|
|
1596
|
-
)
|
|
1811
|
+
) : isLoadingSigners ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Loading signers..." }) : null;
|
|
1812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1813
|
+
"div",
|
|
1814
|
+
{
|
|
1815
|
+
className: cn(className, classNames?.root),
|
|
1816
|
+
"data-cilantro-signer-selector": true,
|
|
1817
|
+
role: "listbox",
|
|
1818
|
+
"aria-label": "Select signer",
|
|
1819
|
+
"aria-busy": isLoadingSigners,
|
|
1820
|
+
"aria-live": "polite",
|
|
1821
|
+
children: loadingContent ?? (availableSigners.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "No signers for this wallet." }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: cn("space-y-1", classNames?.list), children: availableSigners.map((signer) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1822
|
+
Button,
|
|
1823
|
+
{
|
|
1824
|
+
type: "button",
|
|
1825
|
+
variant: selectedSigner?.id === signer.id ? "secondary" : "ghost",
|
|
1826
|
+
size: "sm",
|
|
1827
|
+
className: cn("w-full justify-start", classNames?.item),
|
|
1828
|
+
onClick: () => onSignerSelect(signer),
|
|
1829
|
+
"aria-pressed": selectedSigner?.id === signer.id,
|
|
1830
|
+
children: [
|
|
1831
|
+
getSignerDisplayName(signer),
|
|
1832
|
+
" (",
|
|
1833
|
+
getSignerTypeLabel(signer.type || signer.signerType || ""),
|
|
1834
|
+
")"
|
|
1835
|
+
]
|
|
1836
|
+
}
|
|
1837
|
+
) }, signer.id)) }))
|
|
1838
|
+
}
|
|
1839
|
+
);
|
|
1597
1840
|
}
|
|
1598
1841
|
|
|
1599
1842
|
// src/components/DelegatedKeySelector.tsx
|
|
1600
|
-
var
|
|
1601
|
-
var import_delegated_keys = require("cilantro-sdk/delegated-keys");
|
|
1602
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1843
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1603
1844
|
function DelegatedKeySelector(props) {
|
|
1604
1845
|
const {
|
|
1605
1846
|
walletId,
|
|
@@ -1608,79 +1849,75 @@ function DelegatedKeySelector(props) {
|
|
|
1608
1849
|
filterActive = true,
|
|
1609
1850
|
className,
|
|
1610
1851
|
classNames,
|
|
1852
|
+
useSkeleton = true,
|
|
1611
1853
|
placeholder = "Select a delegated key",
|
|
1612
1854
|
children
|
|
1613
1855
|
} = props;
|
|
1614
|
-
const {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
const loadKeys = (0, import_react8.useCallback)(async () => {
|
|
1619
|
-
if (!walletId) {
|
|
1620
|
-
setKeys([]);
|
|
1621
|
-
return;
|
|
1622
|
-
}
|
|
1623
|
-
setIsLoading(true);
|
|
1624
|
-
setError(null);
|
|
1625
|
-
try {
|
|
1626
|
-
if (token) setSdkAuth(token);
|
|
1627
|
-
const result = await (0, import_delegated_keys.findAll)(walletId);
|
|
1628
|
-
const keysData = extractResponseData(result) ?? [];
|
|
1629
|
-
const list = Array.isArray(keysData) ? keysData : [];
|
|
1630
|
-
let loaded = list.filter((k) => k != null && typeof k === "object" && "id" in k).map((k) => ({
|
|
1631
|
-
id: String(k.id ?? ""),
|
|
1632
|
-
walletId: String(k.walletId ?? ""),
|
|
1633
|
-
name: k.name,
|
|
1634
|
-
publicKey: String(k.publicKey ?? ""),
|
|
1635
|
-
permissions: k.permissions ?? {},
|
|
1636
|
-
isActive: k.isActive !== false,
|
|
1637
|
-
createdAt: k.createdAt,
|
|
1638
|
-
expiresAt: k.expiresAt,
|
|
1639
|
-
...k
|
|
1640
|
-
}));
|
|
1641
|
-
if (filterActive) {
|
|
1642
|
-
const now = Date.now();
|
|
1643
|
-
loaded = loaded.filter((key) => {
|
|
1644
|
-
if (!key.isActive) return false;
|
|
1645
|
-
const exp = key.expiresAt ? new Date(key.expiresAt).getTime() : null;
|
|
1646
|
-
return exp === null || exp > now;
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
setKeys(loaded);
|
|
1650
|
-
} catch (err) {
|
|
1651
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1652
|
-
setKeys([]);
|
|
1653
|
-
} finally {
|
|
1654
|
-
setIsLoading(false);
|
|
1655
|
-
}
|
|
1656
|
-
}, [walletId, token, filterActive]);
|
|
1657
|
-
(0, import_react8.useEffect)(() => {
|
|
1658
|
-
loadKeys();
|
|
1659
|
-
}, [loadKeys]);
|
|
1856
|
+
const { keys, isLoading, error, refresh: loadKeys } = useDelegatedKeys({
|
|
1857
|
+
walletId,
|
|
1858
|
+
filterActive
|
|
1859
|
+
});
|
|
1660
1860
|
const onSelect = (key) => {
|
|
1661
|
-
|
|
1861
|
+
const id = key.id ?? key.delegatedKeyId;
|
|
1862
|
+
onChange?.(id, key);
|
|
1662
1863
|
};
|
|
1663
1864
|
const handleValueChange = (id) => {
|
|
1664
|
-
const key = keys.find((k) => k.id === id) ?? null;
|
|
1865
|
+
const key = keys.find((k) => (k.id ?? k.delegatedKeyId) === id) ?? null;
|
|
1665
1866
|
onChange?.(id, key);
|
|
1666
1867
|
};
|
|
1667
1868
|
if (children) {
|
|
1668
|
-
return /* @__PURE__ */ (0,
|
|
1869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: children({ keys, selectedKeyId: value, onSelect, isLoading, error, refresh: loadKeys }) });
|
|
1669
1870
|
}
|
|
1670
1871
|
if (!walletId) {
|
|
1671
|
-
return /* @__PURE__ */ (0,
|
|
1872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn(className, classNames?.root, "text-sm text-muted-foreground"), children: "Select a wallet first" });
|
|
1672
1873
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1874
|
+
if (isLoading && useSkeleton) {
|
|
1875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1876
|
+
"div",
|
|
1877
|
+
{
|
|
1878
|
+
className: cn(className, classNames?.root, classNames?.loading),
|
|
1879
|
+
"data-cilantro-delegated-key-selector": true,
|
|
1880
|
+
"aria-busy": "true",
|
|
1881
|
+
"aria-live": "polite",
|
|
1882
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1883
|
+
"div",
|
|
1884
|
+
{
|
|
1885
|
+
className: cn(
|
|
1886
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2",
|
|
1887
|
+
classNames?.trigger
|
|
1888
|
+
),
|
|
1889
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Skeleton, { className: cn("h-4 flex-1 rounded", classNames?.skeleton) })
|
|
1890
|
+
}
|
|
1891
|
+
)
|
|
1892
|
+
}
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1896
|
+
"div",
|
|
1897
|
+
{
|
|
1898
|
+
className: cn(className, classNames?.root),
|
|
1899
|
+
"data-cilantro-delegated-key-selector": true,
|
|
1900
|
+
"aria-busy": isLoading,
|
|
1901
|
+
"aria-live": "polite",
|
|
1902
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Loading delegated keys..." }) : error ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: cn("text-sm text-destructive", classNames?.message), role: "alert", children: error }) : keys.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "No delegated keys found." }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Select, { value: (value ?? "") || void 0, onValueChange: handleValueChange, children: [
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectTrigger, { className: classNames?.trigger, "aria-label": "Select delegated key", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectValue, { placeholder }) }),
|
|
1904
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectContent, { className: classNames?.content, children: keys.map((k) => {
|
|
1905
|
+
const id = k.id ?? k.delegatedKeyId;
|
|
1906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(SelectItem, { value: id, className: classNames?.item, children: [
|
|
1907
|
+
k.publicKey.slice(0, 8),
|
|
1908
|
+
"..."
|
|
1909
|
+
] }, id);
|
|
1910
|
+
}) })
|
|
1911
|
+
] })
|
|
1912
|
+
}
|
|
1913
|
+
);
|
|
1677
1914
|
}
|
|
1678
1915
|
|
|
1679
1916
|
// src/ui/textarea.tsx
|
|
1680
|
-
var
|
|
1681
|
-
var
|
|
1682
|
-
var Textarea =
|
|
1683
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1917
|
+
var React4 = __toESM(require("react"));
|
|
1918
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1919
|
+
var Textarea = React4.forwardRef(
|
|
1920
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1684
1921
|
"textarea",
|
|
1685
1922
|
{
|
|
1686
1923
|
className: cn(
|
|
@@ -1695,21 +1932,21 @@ var Textarea = React3.forwardRef(
|
|
|
1695
1932
|
Textarea.displayName = "Textarea";
|
|
1696
1933
|
|
|
1697
1934
|
// src/ui/label.tsx
|
|
1698
|
-
var
|
|
1935
|
+
var React5 = __toESM(require("react"));
|
|
1699
1936
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
1700
1937
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1701
|
-
var
|
|
1938
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1702
1939
|
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
1703
1940
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
1704
1941
|
);
|
|
1705
|
-
var Label =
|
|
1942
|
+
var Label = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LabelPrimitive.Root, { ref, className: cn(labelVariants(), className), ...props }));
|
|
1706
1943
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
1707
1944
|
|
|
1708
1945
|
// src/ui/card.tsx
|
|
1709
|
-
var
|
|
1710
|
-
var
|
|
1711
|
-
var Card =
|
|
1712
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1946
|
+
var React6 = __toESM(require("react"));
|
|
1947
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1948
|
+
var Card = React6.forwardRef(
|
|
1949
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1713
1950
|
"div",
|
|
1714
1951
|
{
|
|
1715
1952
|
ref,
|
|
@@ -1719,12 +1956,12 @@ var Card = React5.forwardRef(
|
|
|
1719
1956
|
)
|
|
1720
1957
|
);
|
|
1721
1958
|
Card.displayName = "Card";
|
|
1722
|
-
var CardHeader =
|
|
1723
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1959
|
+
var CardHeader = React6.forwardRef(
|
|
1960
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
|
|
1724
1961
|
);
|
|
1725
1962
|
CardHeader.displayName = "CardHeader";
|
|
1726
|
-
var CardTitle =
|
|
1727
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1963
|
+
var CardTitle = React6.forwardRef(
|
|
1964
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1728
1965
|
"h3",
|
|
1729
1966
|
{
|
|
1730
1967
|
ref,
|
|
@@ -1734,19 +1971,19 @@ var CardTitle = React5.forwardRef(
|
|
|
1734
1971
|
)
|
|
1735
1972
|
);
|
|
1736
1973
|
CardTitle.displayName = "CardTitle";
|
|
1737
|
-
var CardDescription =
|
|
1974
|
+
var CardDescription = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
1738
1975
|
CardDescription.displayName = "CardDescription";
|
|
1739
|
-
var CardContent =
|
|
1740
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1976
|
+
var CardContent = React6.forwardRef(
|
|
1977
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref, className: cn("p-6 pt-0", className), ...props })
|
|
1741
1978
|
);
|
|
1742
1979
|
CardContent.displayName = "CardContent";
|
|
1743
|
-
var CardFooter =
|
|
1744
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1980
|
+
var CardFooter = React6.forwardRef(
|
|
1981
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref, className: cn("flex items-center p-6 pt-0", className), ...props })
|
|
1745
1982
|
);
|
|
1746
1983
|
CardFooter.displayName = "CardFooter";
|
|
1747
1984
|
|
|
1748
1985
|
// src/components/MessageSigningForm.tsx
|
|
1749
|
-
var
|
|
1986
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1750
1987
|
function MessageSigningForm({
|
|
1751
1988
|
token: tokenOverride,
|
|
1752
1989
|
selectedWalletId: walletIdOverride,
|
|
@@ -1778,7 +2015,7 @@ function MessageSigningForm({
|
|
|
1778
2015
|
walletAdapterPublicKey
|
|
1779
2016
|
});
|
|
1780
2017
|
if (children) {
|
|
1781
|
-
return /* @__PURE__ */ (0,
|
|
2018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-message-signing-form": true, children: children({
|
|
1782
2019
|
messageText: signing.messageText,
|
|
1783
2020
|
setMessageText: signing.setMessageText,
|
|
1784
2021
|
signResultState: signing.signResultState,
|
|
@@ -1790,17 +2027,17 @@ function MessageSigningForm({
|
|
|
1790
2027
|
const resultStatus = signing.signResultState.status;
|
|
1791
2028
|
const isSuccess = resultStatus === "success";
|
|
1792
2029
|
const isError = resultStatus === "error";
|
|
1793
|
-
return /* @__PURE__ */ (0,
|
|
1794
|
-
/* @__PURE__ */ (0,
|
|
1795
|
-
/* @__PURE__ */ (0,
|
|
1796
|
-
/* @__PURE__ */ (0,
|
|
1797
|
-
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0,
|
|
1798
|
-
selectedWalletId && /* @__PURE__ */ (0,
|
|
2030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-message-signing-form": true, children: [
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CardTitle, { className: cn("text-lg", classNames?.title), children: "Sign message" }),
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CardDescription, { className: classNames?.description, children: "Sign a message with your selected wallet or signer. The signature proves you control the key." }),
|
|
2034
|
+
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: cn("mt-1 text-xs text-muted-foreground", classNames?.context), children: [
|
|
2035
|
+
selectedWalletId && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
|
|
1799
2036
|
"Wallet: ",
|
|
1800
2037
|
selectedWalletId.slice(0, 8),
|
|
1801
2038
|
"\u2026"
|
|
1802
2039
|
] }),
|
|
1803
|
-
selectedSigner && /* @__PURE__ */ (0,
|
|
2040
|
+
selectedSigner && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: selectedWalletId ? " ml-2" : "", children: [
|
|
1804
2041
|
"Signer: ",
|
|
1805
2042
|
getSignerDisplayName(selectedSigner),
|
|
1806
2043
|
" (",
|
|
@@ -1809,10 +2046,10 @@ function MessageSigningForm({
|
|
|
1809
2046
|
] })
|
|
1810
2047
|
] })
|
|
1811
2048
|
] }),
|
|
1812
|
-
/* @__PURE__ */ (0,
|
|
1813
|
-
/* @__PURE__ */ (0,
|
|
1814
|
-
/* @__PURE__ */ (0,
|
|
1815
|
-
/* @__PURE__ */ (0,
|
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(CardContent, { className: "space-y-4", children: [
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-2", children: [
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Label, { htmlFor: "cilantro-message-text", className: classNames?.label, children: "Message" }),
|
|
2052
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1816
2053
|
Textarea,
|
|
1817
2054
|
{
|
|
1818
2055
|
id: "cilantro-message-text",
|
|
@@ -1823,24 +2060,25 @@ function MessageSigningForm({
|
|
|
1823
2060
|
rows: 4
|
|
1824
2061
|
}
|
|
1825
2062
|
),
|
|
1826
|
-
showCharCount && /* @__PURE__ */ (0,
|
|
2063
|
+
showCharCount && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: cn("text-right text-xs text-muted-foreground", classNames?.charCount), children: [
|
|
1827
2064
|
signing.messageText.length,
|
|
1828
2065
|
" character",
|
|
1829
2066
|
signing.messageText.length !== 1 ? "s" : ""
|
|
1830
2067
|
] })
|
|
1831
2068
|
] }),
|
|
1832
|
-
/* @__PURE__ */ (0,
|
|
1833
|
-
/* @__PURE__ */ (0,
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-center", children: [
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1834
2071
|
Button,
|
|
1835
2072
|
{
|
|
1836
2073
|
type: "button",
|
|
2074
|
+
size: "touch",
|
|
1837
2075
|
className: cn("w-full sm:w-auto", classNames?.button),
|
|
1838
2076
|
onClick: signing.handleSign,
|
|
1839
2077
|
disabled: signing.isSigning || !signing.messageText.trim(),
|
|
1840
2078
|
children: signing.isSigning ? "Signing..." : "Sign message"
|
|
1841
2079
|
}
|
|
1842
2080
|
),
|
|
1843
|
-
/* @__PURE__ */ (0,
|
|
2081
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1844
2082
|
Button,
|
|
1845
2083
|
{
|
|
1846
2084
|
type: "button",
|
|
@@ -1852,9 +2090,12 @@ function MessageSigningForm({
|
|
|
1852
2090
|
}
|
|
1853
2091
|
)
|
|
1854
2092
|
] }),
|
|
1855
|
-
resultStatus !== "idle" && /* @__PURE__ */ (0,
|
|
2093
|
+
resultStatus !== "idle" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1856
2094
|
"div",
|
|
1857
2095
|
{
|
|
2096
|
+
role: "status",
|
|
2097
|
+
"aria-live": isError ? "assertive" : "polite",
|
|
2098
|
+
"aria-busy": resultStatus === "loading",
|
|
1858
2099
|
className: cn(
|
|
1859
2100
|
"rounded-lg border px-3 py-2 text-sm",
|
|
1860
2101
|
isSuccess && cn("border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-400", classNames?.resultSuccess),
|
|
@@ -1865,7 +2106,7 @@ function MessageSigningForm({
|
|
|
1865
2106
|
"data-status": resultStatus,
|
|
1866
2107
|
children: [
|
|
1867
2108
|
signing.signResultState.message,
|
|
1868
|
-
signing.signResultState.detail != null && /* @__PURE__ */ (0,
|
|
2109
|
+
signing.signResultState.detail != null && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("pre", { className: cn("mt-2 overflow-auto rounded-md bg-muted/80 p-2 text-xs", classNames?.resultPre), children: JSON.stringify(signing.signResultState.detail, null, 2) })
|
|
1869
2110
|
]
|
|
1870
2111
|
}
|
|
1871
2112
|
)
|
|
@@ -1874,7 +2115,7 @@ function MessageSigningForm({
|
|
|
1874
2115
|
}
|
|
1875
2116
|
|
|
1876
2117
|
// src/components/TransactionSigningForm.tsx
|
|
1877
|
-
var
|
|
2118
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1878
2119
|
function TransactionSigningForm({
|
|
1879
2120
|
token: tokenOverride,
|
|
1880
2121
|
selectedWalletId: walletIdOverride,
|
|
@@ -1907,7 +2148,7 @@ function TransactionSigningForm({
|
|
|
1907
2148
|
connection
|
|
1908
2149
|
});
|
|
1909
2150
|
if (children) {
|
|
1910
|
-
return /* @__PURE__ */ (0,
|
|
2151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-transaction-signing-form": true, children: children({
|
|
1911
2152
|
transactionResultState: signing.transactionResultState,
|
|
1912
2153
|
isSigningTransaction: signing.isSigningTransaction,
|
|
1913
2154
|
isSendingTransaction: signing.isSendingTransaction,
|
|
@@ -1919,23 +2160,23 @@ function TransactionSigningForm({
|
|
|
1919
2160
|
const resultStatus = signing.transactionResultState.status;
|
|
1920
2161
|
const isSuccess = resultStatus === "success";
|
|
1921
2162
|
const isError = resultStatus === "error";
|
|
1922
|
-
return /* @__PURE__ */ (0,
|
|
1923
|
-
/* @__PURE__ */ (0,
|
|
1924
|
-
/* @__PURE__ */ (0,
|
|
1925
|
-
/* @__PURE__ */ (0,
|
|
2163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-transaction-signing-form": true, children: [
|
|
2164
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2165
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CardTitle, { className: cn("text-lg", classNames?.title), children: "Sign transaction" }),
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardDescription, { className: classNames?.description, children: [
|
|
1926
2167
|
"Build a transaction in your app, then pass it to ",
|
|
1927
|
-
/* @__PURE__ */ (0,
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { className: "text-xs", children: "signTransaction(tx)" }),
|
|
1928
2169
|
" to sign only, or ",
|
|
1929
|
-
/* @__PURE__ */ (0,
|
|
2170
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("code", { className: "text-xs", children: "signAndSendTransaction(tx)" }),
|
|
1930
2171
|
" to sign and send. Use the render props (children) to wire your own UI."
|
|
1931
2172
|
] }),
|
|
1932
|
-
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0,
|
|
1933
|
-
selectedWalletId && /* @__PURE__ */ (0,
|
|
2173
|
+
showContext && (selectedWalletId || selectedSigner) && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: cn("mt-1 text-xs text-muted-foreground", classNames?.context), children: [
|
|
2174
|
+
selectedWalletId && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { children: [
|
|
1934
2175
|
"Wallet: ",
|
|
1935
2176
|
selectedWalletId.slice(0, 8),
|
|
1936
2177
|
"\u2026"
|
|
1937
2178
|
] }),
|
|
1938
|
-
selectedSigner && /* @__PURE__ */ (0,
|
|
2179
|
+
selectedSigner && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: selectedWalletId ? " ml-2" : "", children: [
|
|
1939
2180
|
"Signer: ",
|
|
1940
2181
|
getSignerDisplayName(selectedSigner),
|
|
1941
2182
|
" (",
|
|
@@ -1944,8 +2185,8 @@ function TransactionSigningForm({
|
|
|
1944
2185
|
] })
|
|
1945
2186
|
] })
|
|
1946
2187
|
] }),
|
|
1947
|
-
/* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
2188
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardContent, { className: "space-y-4", children: [
|
|
2189
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1949
2190
|
Button,
|
|
1950
2191
|
{
|
|
1951
2192
|
type: "button",
|
|
@@ -1956,9 +2197,12 @@ function TransactionSigningForm({
|
|
|
1956
2197
|
children: "Reset status"
|
|
1957
2198
|
}
|
|
1958
2199
|
),
|
|
1959
|
-
resultStatus !== "idle" && /* @__PURE__ */ (0,
|
|
2200
|
+
resultStatus !== "idle" && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1960
2201
|
"div",
|
|
1961
2202
|
{
|
|
2203
|
+
role: "status",
|
|
2204
|
+
"aria-live": isError ? "assertive" : "polite",
|
|
2205
|
+
"aria-busy": resultStatus === "loading",
|
|
1962
2206
|
className: cn(
|
|
1963
2207
|
"rounded-lg border px-3 py-2 text-sm",
|
|
1964
2208
|
isSuccess && cn("border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-400", classNames?.resultSuccess),
|
|
@@ -1969,7 +2213,7 @@ function TransactionSigningForm({
|
|
|
1969
2213
|
"data-status": resultStatus,
|
|
1970
2214
|
children: [
|
|
1971
2215
|
signing.transactionResultState.message,
|
|
1972
|
-
signing.transactionResultState.detail != null && /* @__PURE__ */ (0,
|
|
2216
|
+
signing.transactionResultState.detail != null && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pre", { className: cn("mt-2 overflow-auto rounded-md bg-muted/80 p-2 text-xs", classNames?.resultPre), children: JSON.stringify(signing.transactionResultState.detail, null, 2) })
|
|
1973
2217
|
]
|
|
1974
2218
|
}
|
|
1975
2219
|
)
|
|
@@ -1978,14 +2222,14 @@ function TransactionSigningForm({
|
|
|
1978
2222
|
}
|
|
1979
2223
|
|
|
1980
2224
|
// src/components/LoginForm.tsx
|
|
1981
|
-
var
|
|
2225
|
+
var import_react11 = require("react");
|
|
1982
2226
|
|
|
1983
2227
|
// src/ui/input.tsx
|
|
1984
|
-
var
|
|
1985
|
-
var
|
|
1986
|
-
var Input =
|
|
2228
|
+
var React7 = __toESM(require("react"));
|
|
2229
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2230
|
+
var Input = React7.forwardRef(
|
|
1987
2231
|
({ className, type, ...props }, ref) => {
|
|
1988
|
-
return /* @__PURE__ */ (0,
|
|
2232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1989
2233
|
"input",
|
|
1990
2234
|
{
|
|
1991
2235
|
type,
|
|
@@ -2002,7 +2246,7 @@ var Input = React6.forwardRef(
|
|
|
2002
2246
|
Input.displayName = "Input";
|
|
2003
2247
|
|
|
2004
2248
|
// src/components/LoginForm.tsx
|
|
2005
|
-
var
|
|
2249
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2006
2250
|
function LoginForm({
|
|
2007
2251
|
className,
|
|
2008
2252
|
classNames,
|
|
@@ -2014,9 +2258,9 @@ function LoginForm({
|
|
|
2014
2258
|
renderSwitchToRegister
|
|
2015
2259
|
}) {
|
|
2016
2260
|
const { login, isLoading } = useCilantroAuth();
|
|
2017
|
-
const [usernameOrEmail, setUsernameOrEmail] = (0,
|
|
2018
|
-
const [password, setPassword] = (0,
|
|
2019
|
-
const [error, setError] = (0,
|
|
2261
|
+
const [usernameOrEmail, setUsernameOrEmail] = (0, import_react11.useState)("");
|
|
2262
|
+
const [password, setPassword] = (0, import_react11.useState)("");
|
|
2263
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
2020
2264
|
const handleSubmit = async (e) => {
|
|
2021
2265
|
e.preventDefault();
|
|
2022
2266
|
setError(null);
|
|
@@ -2029,15 +2273,15 @@ function LoginForm({
|
|
|
2029
2273
|
onError?.(message);
|
|
2030
2274
|
}
|
|
2031
2275
|
};
|
|
2032
|
-
return /* @__PURE__ */ (0,
|
|
2033
|
-
/* @__PURE__ */ (0,
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
2035
|
-
description != null && /* @__PURE__ */ (0,
|
|
2276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-login-form": true, children: [
|
|
2277
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2278
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CardTitle, { className: classNames?.title, children: title }),
|
|
2279
|
+
description != null && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CardDescription, { className: classNames?.description, children: description })
|
|
2036
2280
|
] }),
|
|
2037
|
-
/* @__PURE__ */ (0,
|
|
2038
|
-
/* @__PURE__ */ (0,
|
|
2039
|
-
/* @__PURE__ */ (0,
|
|
2040
|
-
/* @__PURE__ */ (0,
|
|
2281
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2282
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-2", children: [
|
|
2283
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { htmlFor: "cilantro-login-username", className: classNames?.label, children: "Username or email" }),
|
|
2284
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2041
2285
|
Input,
|
|
2042
2286
|
{
|
|
2043
2287
|
id: "cilantro-login-username",
|
|
@@ -2052,9 +2296,9 @@ function LoginForm({
|
|
|
2052
2296
|
}
|
|
2053
2297
|
)
|
|
2054
2298
|
] }),
|
|
2055
|
-
/* @__PURE__ */ (0,
|
|
2056
|
-
/* @__PURE__ */ (0,
|
|
2057
|
-
/* @__PURE__ */ (0,
|
|
2299
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-2", children: [
|
|
2300
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { htmlFor: "cilantro-login-password", className: classNames?.label, children: "Password" }),
|
|
2301
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2058
2302
|
Input,
|
|
2059
2303
|
{
|
|
2060
2304
|
id: "cilantro-login-password",
|
|
@@ -2069,7 +2313,7 @@ function LoginForm({
|
|
|
2069
2313
|
}
|
|
2070
2314
|
)
|
|
2071
2315
|
] }),
|
|
2072
|
-
error && /* @__PURE__ */ (0,
|
|
2316
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2073
2317
|
"div",
|
|
2074
2318
|
{
|
|
2075
2319
|
className: cn(
|
|
@@ -2080,23 +2324,24 @@ function LoginForm({
|
|
|
2080
2324
|
children: error
|
|
2081
2325
|
}
|
|
2082
2326
|
),
|
|
2083
|
-
/* @__PURE__ */ (0,
|
|
2327
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2084
2328
|
Button,
|
|
2085
2329
|
{
|
|
2086
2330
|
type: "submit",
|
|
2331
|
+
size: "touch",
|
|
2087
2332
|
className: cn("w-full", classNames?.submitButton),
|
|
2088
2333
|
disabled: isLoading || !usernameOrEmail.trim() || !password,
|
|
2089
2334
|
children: isLoading ? "Signing in..." : submitLabel
|
|
2090
2335
|
}
|
|
2091
2336
|
),
|
|
2092
|
-
renderSwitchToRegister && /* @__PURE__ */ (0,
|
|
2337
|
+
renderSwitchToRegister && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-center text-sm text-muted-foreground", children: renderSwitchToRegister() })
|
|
2093
2338
|
] }) })
|
|
2094
2339
|
] });
|
|
2095
2340
|
}
|
|
2096
2341
|
|
|
2097
2342
|
// src/components/RegisterForm.tsx
|
|
2098
|
-
var
|
|
2099
|
-
var
|
|
2343
|
+
var import_react12 = require("react");
|
|
2344
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2100
2345
|
function RegisterForm({
|
|
2101
2346
|
className,
|
|
2102
2347
|
classNames,
|
|
@@ -2109,10 +2354,10 @@ function RegisterForm({
|
|
|
2109
2354
|
renderSwitchToLogin
|
|
2110
2355
|
}) {
|
|
2111
2356
|
const { register, isLoading } = useCilantroAuth();
|
|
2112
|
-
const [username, setUsername] = (0,
|
|
2113
|
-
const [email, setEmail] = (0,
|
|
2114
|
-
const [password, setPassword] = (0,
|
|
2115
|
-
const [error, setError] = (0,
|
|
2357
|
+
const [username, setUsername] = (0, import_react12.useState)("");
|
|
2358
|
+
const [email, setEmail] = (0, import_react12.useState)("");
|
|
2359
|
+
const [password, setPassword] = (0, import_react12.useState)("");
|
|
2360
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
2116
2361
|
const handleSubmit = async (e) => {
|
|
2117
2362
|
e.preventDefault();
|
|
2118
2363
|
setError(null);
|
|
@@ -2125,15 +2370,15 @@ function RegisterForm({
|
|
|
2125
2370
|
onError?.(message);
|
|
2126
2371
|
}
|
|
2127
2372
|
};
|
|
2128
|
-
return /* @__PURE__ */ (0,
|
|
2129
|
-
/* @__PURE__ */ (0,
|
|
2130
|
-
/* @__PURE__ */ (0,
|
|
2131
|
-
description != null && /* @__PURE__ */ (0,
|
|
2373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Card, { className: cn(className, classNames?.root), "data-cilantro-register-form": true, children: [
|
|
2374
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(CardHeader, { className: classNames?.header, children: [
|
|
2375
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardTitle, { className: classNames?.title, children: title }),
|
|
2376
|
+
description != null && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardDescription, { className: classNames?.description, children: description })
|
|
2132
2377
|
] }),
|
|
2133
|
-
/* @__PURE__ */ (0,
|
|
2134
|
-
/* @__PURE__ */ (0,
|
|
2135
|
-
/* @__PURE__ */ (0,
|
|
2136
|
-
/* @__PURE__ */ (0,
|
|
2378
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2379
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-2", children: [
|
|
2380
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label, { htmlFor: "cilantro-register-username", className: classNames?.label, children: "Username" }),
|
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2137
2382
|
Input,
|
|
2138
2383
|
{
|
|
2139
2384
|
id: "cilantro-register-username",
|
|
@@ -2148,9 +2393,9 @@ function RegisterForm({
|
|
|
2148
2393
|
}
|
|
2149
2394
|
)
|
|
2150
2395
|
] }),
|
|
2151
|
-
/* @__PURE__ */ (0,
|
|
2152
|
-
/* @__PURE__ */ (0,
|
|
2153
|
-
/* @__PURE__ */ (0,
|
|
2396
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-2", children: [
|
|
2397
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label, { htmlFor: "cilantro-register-email", className: classNames?.label, children: "Email" }),
|
|
2398
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2154
2399
|
Input,
|
|
2155
2400
|
{
|
|
2156
2401
|
id: "cilantro-register-email",
|
|
@@ -2165,9 +2410,9 @@ function RegisterForm({
|
|
|
2165
2410
|
}
|
|
2166
2411
|
)
|
|
2167
2412
|
] }),
|
|
2168
|
-
/* @__PURE__ */ (0,
|
|
2169
|
-
/* @__PURE__ */ (0,
|
|
2170
|
-
/* @__PURE__ */ (0,
|
|
2413
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-2", children: [
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Label, { htmlFor: "cilantro-register-password", className: classNames?.label, children: "Password" }),
|
|
2415
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2171
2416
|
Input,
|
|
2172
2417
|
{
|
|
2173
2418
|
id: "cilantro-register-password",
|
|
@@ -2182,7 +2427,7 @@ function RegisterForm({
|
|
|
2182
2427
|
}
|
|
2183
2428
|
)
|
|
2184
2429
|
] }),
|
|
2185
|
-
error && /* @__PURE__ */ (0,
|
|
2430
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2186
2431
|
"div",
|
|
2187
2432
|
{
|
|
2188
2433
|
className: cn(
|
|
@@ -2193,23 +2438,24 @@ function RegisterForm({
|
|
|
2193
2438
|
children: error
|
|
2194
2439
|
}
|
|
2195
2440
|
),
|
|
2196
|
-
/* @__PURE__ */ (0,
|
|
2441
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2197
2442
|
Button,
|
|
2198
2443
|
{
|
|
2199
2444
|
type: "submit",
|
|
2445
|
+
size: "touch",
|
|
2200
2446
|
className: cn("w-full", classNames?.submitButton),
|
|
2201
2447
|
disabled: isLoading || !username.trim() || !email.trim() || !password,
|
|
2202
2448
|
children: isLoading ? "Creating account..." : submitLabel
|
|
2203
2449
|
}
|
|
2204
2450
|
),
|
|
2205
|
-
renderSwitchToLogin && /* @__PURE__ */ (0,
|
|
2451
|
+
renderSwitchToLogin && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-center text-sm text-muted-foreground", children: renderSwitchToLogin() })
|
|
2206
2452
|
] }) })
|
|
2207
2453
|
] });
|
|
2208
2454
|
}
|
|
2209
2455
|
|
|
2210
2456
|
// src/components/AuthForm.tsx
|
|
2211
|
-
var
|
|
2212
|
-
var
|
|
2457
|
+
var import_react13 = require("react");
|
|
2458
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2213
2459
|
function AuthForm({
|
|
2214
2460
|
defaultMode = "login",
|
|
2215
2461
|
className,
|
|
@@ -2227,12 +2473,12 @@ function AuthForm({
|
|
|
2227
2473
|
isActive = true
|
|
2228
2474
|
}) {
|
|
2229
2475
|
const { login, register, isLoading } = useCilantroAuth();
|
|
2230
|
-
const [mode, setMode] = (0,
|
|
2231
|
-
const [usernameOrEmail, setUsernameOrEmail] = (0,
|
|
2232
|
-
const [username, setUsername] = (0,
|
|
2233
|
-
const [email, setEmail] = (0,
|
|
2234
|
-
const [password, setPassword] = (0,
|
|
2235
|
-
const [error, setError] = (0,
|
|
2476
|
+
const [mode, setMode] = (0, import_react13.useState)(defaultMode);
|
|
2477
|
+
const [usernameOrEmail, setUsernameOrEmail] = (0, import_react13.useState)("");
|
|
2478
|
+
const [username, setUsername] = (0, import_react13.useState)("");
|
|
2479
|
+
const [email, setEmail] = (0, import_react13.useState)("");
|
|
2480
|
+
const [password, setPassword] = (0, import_react13.useState)("");
|
|
2481
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
2236
2482
|
const isLogin = mode === "login";
|
|
2237
2483
|
const handleSubmit = async (e) => {
|
|
2238
2484
|
e.preventDefault();
|
|
@@ -2255,16 +2501,16 @@ function AuthForm({
|
|
|
2255
2501
|
setError(null);
|
|
2256
2502
|
};
|
|
2257
2503
|
const canSubmit = isLogin ? usernameOrEmail.trim().length > 0 && password.length > 0 : username.trim().length > 0 && email.trim().length > 0 && password.length > 0;
|
|
2258
|
-
return /* @__PURE__ */ (0,
|
|
2259
|
-
/* @__PURE__ */ (0,
|
|
2260
|
-
/* @__PURE__ */ (0,
|
|
2261
|
-
/* @__PURE__ */ (0,
|
|
2504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Card, { className: cn("w-full max-w-sm", className, classNames?.root), "data-cilantro-auth-form": true, children: [
|
|
2505
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(CardHeader, { className: cn("space-y-1 text-center sm:text-left", classNames?.header), children: [
|
|
2506
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CardTitle, { className: cn("text-xl", classNames?.title), children: isLogin ? loginTitle : registerTitle }),
|
|
2507
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CardDescription, { className: classNames?.description, children: isLogin ? loginDescription : registerDescription })
|
|
2262
2508
|
] }),
|
|
2263
|
-
/* @__PURE__ */ (0,
|
|
2264
|
-
isLogin ? /* @__PURE__ */ (0,
|
|
2265
|
-
/* @__PURE__ */ (0,
|
|
2266
|
-
/* @__PURE__ */ (0,
|
|
2267
|
-
/* @__PURE__ */ (0,
|
|
2509
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CardContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2510
|
+
isLogin ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2511
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2512
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-username", className: classNames?.label, children: "Username or email" }),
|
|
2513
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2268
2514
|
Input,
|
|
2269
2515
|
{
|
|
2270
2516
|
id: "cilantro-auth-username",
|
|
@@ -2279,9 +2525,9 @@ function AuthForm({
|
|
|
2279
2525
|
}
|
|
2280
2526
|
)
|
|
2281
2527
|
] }),
|
|
2282
|
-
/* @__PURE__ */ (0,
|
|
2283
|
-
/* @__PURE__ */ (0,
|
|
2284
|
-
/* @__PURE__ */ (0,
|
|
2528
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2529
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-password", className: classNames?.label, children: "Password" }),
|
|
2530
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2285
2531
|
Input,
|
|
2286
2532
|
{
|
|
2287
2533
|
id: "cilantro-auth-password",
|
|
@@ -2296,10 +2542,10 @@ function AuthForm({
|
|
|
2296
2542
|
}
|
|
2297
2543
|
)
|
|
2298
2544
|
] })
|
|
2299
|
-
] }) : /* @__PURE__ */ (0,
|
|
2300
|
-
/* @__PURE__ */ (0,
|
|
2301
|
-
/* @__PURE__ */ (0,
|
|
2302
|
-
/* @__PURE__ */ (0,
|
|
2545
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
2546
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2547
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-reg-username", className: classNames?.label, children: "Username" }),
|
|
2548
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2303
2549
|
Input,
|
|
2304
2550
|
{
|
|
2305
2551
|
id: "cilantro-auth-reg-username",
|
|
@@ -2314,9 +2560,9 @@ function AuthForm({
|
|
|
2314
2560
|
}
|
|
2315
2561
|
)
|
|
2316
2562
|
] }),
|
|
2317
|
-
/* @__PURE__ */ (0,
|
|
2318
|
-
/* @__PURE__ */ (0,
|
|
2319
|
-
/* @__PURE__ */ (0,
|
|
2563
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2564
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-reg-email", className: classNames?.label, children: "Email" }),
|
|
2565
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2320
2566
|
Input,
|
|
2321
2567
|
{
|
|
2322
2568
|
id: "cilantro-auth-reg-email",
|
|
@@ -2331,9 +2577,9 @@ function AuthForm({
|
|
|
2331
2577
|
}
|
|
2332
2578
|
)
|
|
2333
2579
|
] }),
|
|
2334
|
-
/* @__PURE__ */ (0,
|
|
2335
|
-
/* @__PURE__ */ (0,
|
|
2336
|
-
/* @__PURE__ */ (0,
|
|
2580
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
|
|
2581
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: "cilantro-auth-reg-password", className: classNames?.label, children: "Password" }),
|
|
2582
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2337
2583
|
Input,
|
|
2338
2584
|
{
|
|
2339
2585
|
id: "cilantro-auth-reg-password",
|
|
@@ -2349,7 +2595,7 @@ function AuthForm({
|
|
|
2349
2595
|
)
|
|
2350
2596
|
] })
|
|
2351
2597
|
] }),
|
|
2352
|
-
error && /* @__PURE__ */ (0,
|
|
2598
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2353
2599
|
"div",
|
|
2354
2600
|
{
|
|
2355
2601
|
className: cn(
|
|
@@ -2360,16 +2606,17 @@ function AuthForm({
|
|
|
2360
2606
|
children: error
|
|
2361
2607
|
}
|
|
2362
2608
|
),
|
|
2363
|
-
/* @__PURE__ */ (0,
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2364
2610
|
Button,
|
|
2365
2611
|
{
|
|
2366
2612
|
type: "submit",
|
|
2613
|
+
size: "touch",
|
|
2367
2614
|
className: cn("w-full", classNames?.submitButton),
|
|
2368
2615
|
disabled: isLoading || !canSubmit,
|
|
2369
2616
|
children: isLoading ? isLogin ? "Signing in..." : "Creating account..." : isLogin ? loginSubmitLabel : registerSubmitLabel
|
|
2370
2617
|
}
|
|
2371
2618
|
),
|
|
2372
|
-
/* @__PURE__ */ (0,
|
|
2619
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: cn("text-center text-sm text-muted-foreground", classNames?.toggle), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2373
2620
|
"button",
|
|
2374
2621
|
{
|
|
2375
2622
|
type: "button",
|
|
@@ -2384,35 +2631,49 @@ function AuthForm({
|
|
|
2384
2631
|
}
|
|
2385
2632
|
|
|
2386
2633
|
// src/components/AuthGuard.tsx
|
|
2387
|
-
var
|
|
2634
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2388
2635
|
function AuthGuard({
|
|
2389
2636
|
children,
|
|
2390
2637
|
fallback,
|
|
2391
2638
|
className,
|
|
2392
2639
|
classNames,
|
|
2393
|
-
showFallback = true
|
|
2640
|
+
showFallback = true,
|
|
2641
|
+
useSkeleton = false
|
|
2394
2642
|
}) {
|
|
2395
2643
|
const { isAuthenticated, isLoading } = useCilantroAuth();
|
|
2396
2644
|
if (isLoading) {
|
|
2397
|
-
return /* @__PURE__ */ (0,
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2646
|
+
"div",
|
|
2647
|
+
{
|
|
2648
|
+
className: cn(className, classNames?.root, classNames?.loading),
|
|
2649
|
+
"data-cilantro-auth-guard": true,
|
|
2650
|
+
"aria-busy": "true",
|
|
2651
|
+
"aria-live": "polite",
|
|
2652
|
+
children: useSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: cn("rounded-lg border border-input p-4 space-y-3 w-full max-w-sm", classNames?.fallback), children: [
|
|
2653
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Skeleton, { className: cn("h-6 w-2/3 rounded", classNames?.skeleton) }),
|
|
2654
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Skeleton, { className: cn("h-4 w-full rounded", classNames?.skeleton) }),
|
|
2655
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Skeleton, { className: cn("h-4 w-[80%] rounded", classNames?.skeleton) })
|
|
2656
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: cn("text-sm text-muted-foreground", classNames?.fallback), children: "Loading..." })
|
|
2657
|
+
}
|
|
2658
|
+
);
|
|
2398
2659
|
}
|
|
2399
2660
|
if (!isAuthenticated) {
|
|
2400
2661
|
if (!showFallback) return null;
|
|
2401
|
-
return /* @__PURE__ */ (0,
|
|
2662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-auth-guard": true, children: fallback ?? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LoginForm, { className: classNames?.fallback }) });
|
|
2402
2663
|
}
|
|
2403
|
-
return /* @__PURE__ */ (0,
|
|
2664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2404
2665
|
}
|
|
2405
2666
|
|
|
2406
2667
|
// src/components/AddSignerForm.tsx
|
|
2407
|
-
var
|
|
2668
|
+
var import_react14 = require("react");
|
|
2408
2669
|
|
|
2409
2670
|
// src/ui/dialog.tsx
|
|
2410
|
-
var
|
|
2671
|
+
var React8 = __toESM(require("react"));
|
|
2411
2672
|
var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"));
|
|
2412
|
-
var
|
|
2673
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2413
2674
|
var Dialog = DialogPrimitive.Root;
|
|
2414
2675
|
var DialogPortal = DialogPrimitive.Portal;
|
|
2415
|
-
var DialogOverlay =
|
|
2676
|
+
var DialogOverlay = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2416
2677
|
DialogPrimitive.Overlay,
|
|
2417
2678
|
{
|
|
2418
2679
|
ref,
|
|
@@ -2424,14 +2685,14 @@ var DialogOverlay = React7.forwardRef(({ className, ...props }, ref) => /* @__PU
|
|
|
2424
2685
|
}
|
|
2425
2686
|
));
|
|
2426
2687
|
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
2427
|
-
var DialogContent =
|
|
2428
|
-
/* @__PURE__ */ (0,
|
|
2429
|
-
/* @__PURE__ */ (0,
|
|
2688
|
+
var DialogContent = React8.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DialogPortal, { children: [
|
|
2689
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DialogOverlay, {}),
|
|
2690
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2430
2691
|
DialogPrimitive.Content,
|
|
2431
2692
|
{
|
|
2432
2693
|
ref,
|
|
2433
2694
|
className: cn(
|
|
2434
|
-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
2695
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg max-h-[100dvh] sm:max-h-[90vh] translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 overflow-y-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
2435
2696
|
className
|
|
2436
2697
|
),
|
|
2437
2698
|
...props,
|
|
@@ -2440,9 +2701,9 @@ var DialogContent = React7.forwardRef(({ className, children, ...props }, ref) =
|
|
|
2440
2701
|
)
|
|
2441
2702
|
] }));
|
|
2442
2703
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
2443
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
2704
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
|
|
2444
2705
|
DialogHeader.displayName = "DialogHeader";
|
|
2445
|
-
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
2706
|
+
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2446
2707
|
"div",
|
|
2447
2708
|
{
|
|
2448
2709
|
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
@@ -2450,7 +2711,7 @@ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_r
|
|
|
2450
2711
|
}
|
|
2451
2712
|
);
|
|
2452
2713
|
DialogFooter.displayName = "DialogFooter";
|
|
2453
|
-
var DialogTitle =
|
|
2714
|
+
var DialogTitle = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2454
2715
|
DialogPrimitive.Title,
|
|
2455
2716
|
{
|
|
2456
2717
|
ref,
|
|
@@ -2459,7 +2720,7 @@ var DialogTitle = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
2459
2720
|
}
|
|
2460
2721
|
));
|
|
2461
2722
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
2462
|
-
var DialogDescription =
|
|
2723
|
+
var DialogDescription = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2463
2724
|
DialogPrimitive.Description,
|
|
2464
2725
|
{
|
|
2465
2726
|
ref,
|
|
@@ -2470,7 +2731,7 @@ var DialogDescription = React7.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
2470
2731
|
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
2471
2732
|
|
|
2472
2733
|
// src/components/AddSignerForm.tsx
|
|
2473
|
-
var
|
|
2734
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2474
2735
|
function AddSignerForm({
|
|
2475
2736
|
walletId,
|
|
2476
2737
|
open = true,
|
|
@@ -2482,12 +2743,12 @@ function AddSignerForm({
|
|
|
2482
2743
|
classNames,
|
|
2483
2744
|
asDialog = true
|
|
2484
2745
|
}) {
|
|
2485
|
-
const [signerType, setSignerType] = (0,
|
|
2486
|
-
const [email, setEmail] = (0,
|
|
2487
|
-
const [phone, setPhone] = (0,
|
|
2488
|
-
const [address, setAddress] = (0,
|
|
2489
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
2490
|
-
const [error, setError] = (0,
|
|
2746
|
+
const [signerType, setSignerType] = (0, import_react14.useState)(null);
|
|
2747
|
+
const [email, setEmail] = (0, import_react14.useState)("");
|
|
2748
|
+
const [phone, setPhone] = (0, import_react14.useState)("");
|
|
2749
|
+
const [address, setAddress] = (0, import_react14.useState)("");
|
|
2750
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react14.useState)(false);
|
|
2751
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
2491
2752
|
const resetForm = () => {
|
|
2492
2753
|
setSignerType(null);
|
|
2493
2754
|
setEmail("");
|
|
@@ -2542,12 +2803,12 @@ function AddSignerForm({
|
|
|
2542
2803
|
onError?.(message);
|
|
2543
2804
|
}).finally(() => setIsSubmitting(false));
|
|
2544
2805
|
};
|
|
2545
|
-
const formContent = /* @__PURE__ */ (0,
|
|
2546
|
-
!signerType ? /* @__PURE__ */ (0,
|
|
2547
|
-
/* @__PURE__ */ (0,
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2550
|
-
/* @__PURE__ */ (0,
|
|
2806
|
+
const formContent = /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("form", { onSubmit: handleSubmit, className: cn("space-y-4", classNames?.form), children: [
|
|
2807
|
+
!signerType ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2808
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", role: "group", "aria-labelledby": "add-signer-type-label", children: [
|
|
2809
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { id: "add-signer-type-label", className: classNames?.label, children: "Signer type" }),
|
|
2810
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap gap-2", children: [
|
|
2811
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2551
2812
|
Button,
|
|
2552
2813
|
{
|
|
2553
2814
|
type: "button",
|
|
@@ -2558,7 +2819,7 @@ function AddSignerForm({
|
|
|
2558
2819
|
children: "Email"
|
|
2559
2820
|
}
|
|
2560
2821
|
),
|
|
2561
|
-
/* @__PURE__ */ (0,
|
|
2822
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2562
2823
|
Button,
|
|
2563
2824
|
{
|
|
2564
2825
|
type: "button",
|
|
@@ -2569,7 +2830,7 @@ function AddSignerForm({
|
|
|
2569
2830
|
children: "Phone"
|
|
2570
2831
|
}
|
|
2571
2832
|
),
|
|
2572
|
-
/* @__PURE__ */ (0,
|
|
2833
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2573
2834
|
Button,
|
|
2574
2835
|
{
|
|
2575
2836
|
type: "button",
|
|
@@ -2580,7 +2841,7 @@ function AddSignerForm({
|
|
|
2580
2841
|
children: "Passkey"
|
|
2581
2842
|
}
|
|
2582
2843
|
),
|
|
2583
|
-
/* @__PURE__ */ (0,
|
|
2844
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2584
2845
|
Button,
|
|
2585
2846
|
{
|
|
2586
2847
|
type: "button",
|
|
@@ -2593,7 +2854,7 @@ function AddSignerForm({
|
|
|
2593
2854
|
)
|
|
2594
2855
|
] })
|
|
2595
2856
|
] }),
|
|
2596
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2857
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogFooter, { className: "gap-2 sm:gap-0", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2597
2858
|
Button,
|
|
2598
2859
|
{
|
|
2599
2860
|
type: "button",
|
|
@@ -2604,10 +2865,10 @@ function AddSignerForm({
|
|
|
2604
2865
|
children: "Cancel"
|
|
2605
2866
|
}
|
|
2606
2867
|
) })
|
|
2607
|
-
] }) : signerType === "email" ? /* @__PURE__ */ (0,
|
|
2608
|
-
/* @__PURE__ */ (0,
|
|
2609
|
-
/* @__PURE__ */ (0,
|
|
2610
|
-
/* @__PURE__ */ (0,
|
|
2868
|
+
] }) : signerType === "email" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2869
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { htmlFor: "add-signer-email", className: classNames?.label, children: "Email" }),
|
|
2871
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2611
2872
|
Input,
|
|
2612
2873
|
{
|
|
2613
2874
|
id: "add-signer-email",
|
|
@@ -2622,8 +2883,8 @@ function AddSignerForm({
|
|
|
2622
2883
|
}
|
|
2623
2884
|
)
|
|
2624
2885
|
] }),
|
|
2625
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2886
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
2887
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2627
2888
|
Button,
|
|
2628
2889
|
{
|
|
2629
2890
|
type: "button",
|
|
@@ -2634,10 +2895,10 @@ function AddSignerForm({
|
|
|
2634
2895
|
children: "Back"
|
|
2635
2896
|
}
|
|
2636
2897
|
),
|
|
2637
|
-
/* @__PURE__ */ (0,
|
|
2898
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2638
2899
|
] }),
|
|
2639
|
-
!asDialog && /* @__PURE__ */ (0,
|
|
2640
|
-
/* @__PURE__ */ (0,
|
|
2900
|
+
!asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-2", children: [
|
|
2901
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2641
2902
|
Button,
|
|
2642
2903
|
{
|
|
2643
2904
|
type: "button",
|
|
@@ -2648,12 +2909,12 @@ function AddSignerForm({
|
|
|
2648
2909
|
children: "Back"
|
|
2649
2910
|
}
|
|
2650
2911
|
),
|
|
2651
|
-
/* @__PURE__ */ (0,
|
|
2912
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2652
2913
|
] })
|
|
2653
|
-
] }) : signerType === "phone" ? /* @__PURE__ */ (0,
|
|
2654
|
-
/* @__PURE__ */ (0,
|
|
2655
|
-
/* @__PURE__ */ (0,
|
|
2656
|
-
/* @__PURE__ */ (0,
|
|
2914
|
+
] }) : signerType === "phone" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2915
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
2916
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { htmlFor: "add-signer-phone", className: classNames?.label, children: "Phone number" }),
|
|
2917
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2657
2918
|
Input,
|
|
2658
2919
|
{
|
|
2659
2920
|
id: "add-signer-phone",
|
|
@@ -2668,8 +2929,8 @@ function AddSignerForm({
|
|
|
2668
2929
|
}
|
|
2669
2930
|
)
|
|
2670
2931
|
] }),
|
|
2671
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2672
|
-
/* @__PURE__ */ (0,
|
|
2932
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
2933
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2673
2934
|
Button,
|
|
2674
2935
|
{
|
|
2675
2936
|
type: "button",
|
|
@@ -2680,10 +2941,10 @@ function AddSignerForm({
|
|
|
2680
2941
|
children: "Back"
|
|
2681
2942
|
}
|
|
2682
2943
|
),
|
|
2683
|
-
/* @__PURE__ */ (0,
|
|
2944
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2684
2945
|
] }),
|
|
2685
|
-
!asDialog && /* @__PURE__ */ (0,
|
|
2686
|
-
/* @__PURE__ */ (0,
|
|
2946
|
+
!asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-2", children: [
|
|
2947
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2687
2948
|
Button,
|
|
2688
2949
|
{
|
|
2689
2950
|
type: "button",
|
|
@@ -2694,12 +2955,12 @@ function AddSignerForm({
|
|
|
2694
2955
|
children: "Back"
|
|
2695
2956
|
}
|
|
2696
2957
|
),
|
|
2697
|
-
/* @__PURE__ */ (0,
|
|
2958
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2698
2959
|
] })
|
|
2699
|
-
] }) : signerType === "external" ? /* @__PURE__ */ (0,
|
|
2700
|
-
/* @__PURE__ */ (0,
|
|
2701
|
-
/* @__PURE__ */ (0,
|
|
2702
|
-
/* @__PURE__ */ (0,
|
|
2960
|
+
] }) : signerType === "external" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2961
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "space-y-2", children: [
|
|
2962
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Label, { htmlFor: "add-signer-address", className: classNames?.label, children: "Wallet address" }),
|
|
2963
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2703
2964
|
Input,
|
|
2704
2965
|
{
|
|
2705
2966
|
id: "add-signer-address",
|
|
@@ -2713,8 +2974,8 @@ function AddSignerForm({
|
|
|
2713
2974
|
}
|
|
2714
2975
|
)
|
|
2715
2976
|
] }),
|
|
2716
|
-
asDialog && /* @__PURE__ */ (0,
|
|
2717
|
-
/* @__PURE__ */ (0,
|
|
2977
|
+
asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogFooter, { className: "gap-2 sm:gap-0", children: [
|
|
2978
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2718
2979
|
Button,
|
|
2719
2980
|
{
|
|
2720
2981
|
type: "button",
|
|
@@ -2725,10 +2986,10 @@ function AddSignerForm({
|
|
|
2725
2986
|
children: "Back"
|
|
2726
2987
|
}
|
|
2727
2988
|
),
|
|
2728
|
-
/* @__PURE__ */ (0,
|
|
2989
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2729
2990
|
] }),
|
|
2730
|
-
!asDialog && /* @__PURE__ */ (0,
|
|
2731
|
-
/* @__PURE__ */ (0,
|
|
2991
|
+
!asDialog && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex gap-2", children: [
|
|
2992
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2732
2993
|
Button,
|
|
2733
2994
|
{
|
|
2734
2995
|
type: "button",
|
|
@@ -2739,44 +3000,45 @@ function AddSignerForm({
|
|
|
2739
3000
|
children: "Back"
|
|
2740
3001
|
}
|
|
2741
3002
|
),
|
|
2742
|
-
/* @__PURE__ */ (0,
|
|
3003
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", className: classNames?.submitButton, disabled: isSubmitting, children: isSubmitting ? "Adding..." : "Add signer" })
|
|
2743
3004
|
] })
|
|
2744
3005
|
] }) : null,
|
|
2745
|
-
error && /* @__PURE__ */ (0,
|
|
3006
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: cn("text-sm text-destructive", classNames?.error), role: "alert", children: error })
|
|
2746
3007
|
] });
|
|
2747
3008
|
if (asDialog) {
|
|
2748
|
-
return /* @__PURE__ */ (0,
|
|
2749
|
-
/* @__PURE__ */ (0,
|
|
2750
|
-
/* @__PURE__ */ (0,
|
|
2751
|
-
/* @__PURE__ */ (0,
|
|
3009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogContent, { className: cn(classNames?.dialog), children: [
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogHeader, { children: [
|
|
3011
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogTitle, { children: "Add signer" }),
|
|
3012
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogDescription, { children: "Add a new signer to this wallet." })
|
|
2752
3013
|
] }),
|
|
2753
3014
|
formContent
|
|
2754
3015
|
] }) });
|
|
2755
3016
|
}
|
|
2756
|
-
return /* @__PURE__ */ (0,
|
|
2757
|
-
/* @__PURE__ */ (0,
|
|
3017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: cn(className, classNames?.root), "data-cilantro-add-signer-form": true, children: [
|
|
3018
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { className: "text-sm font-medium mb-2", children: "Add signer" }),
|
|
2758
3019
|
formContent
|
|
2759
3020
|
] });
|
|
2760
3021
|
}
|
|
2761
3022
|
|
|
2762
3023
|
// src/components/SignerList.tsx
|
|
2763
|
-
var
|
|
2764
|
-
var
|
|
3024
|
+
var import_react15 = require("react");
|
|
3025
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2765
3026
|
function SignerList({
|
|
2766
3027
|
walletId,
|
|
2767
3028
|
className,
|
|
2768
3029
|
classNames,
|
|
2769
3030
|
onSignerAdded,
|
|
3031
|
+
useSkeleton = true,
|
|
2770
3032
|
children
|
|
2771
3033
|
}) {
|
|
2772
3034
|
const { signers, isLoading, error, refresh } = useSigners({ walletId });
|
|
2773
|
-
const [addSignerOpen, setAddSignerOpen] = (0,
|
|
3035
|
+
const [addSignerOpen, setAddSignerOpen] = (0, import_react15.useState)(false);
|
|
2774
3036
|
const handleAddSuccess = () => {
|
|
2775
3037
|
refresh();
|
|
2776
3038
|
onSignerAdded?.();
|
|
2777
3039
|
};
|
|
2778
3040
|
if (children) {
|
|
2779
|
-
return /* @__PURE__ */ (0,
|
|
3041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2780
3042
|
children({
|
|
2781
3043
|
signers,
|
|
2782
3044
|
isLoading,
|
|
@@ -2784,7 +3046,7 @@ function SignerList({
|
|
|
2784
3046
|
refresh,
|
|
2785
3047
|
openAddSigner: () => setAddSignerOpen(true)
|
|
2786
3048
|
}),
|
|
2787
|
-
/* @__PURE__ */ (0,
|
|
3049
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2788
3050
|
AddSignerForm,
|
|
2789
3051
|
{
|
|
2790
3052
|
walletId,
|
|
@@ -2797,31 +3059,46 @@ function SignerList({
|
|
|
2797
3059
|
] });
|
|
2798
3060
|
}
|
|
2799
3061
|
if (!walletId) {
|
|
2800
|
-
return /* @__PURE__ */ (0,
|
|
3062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: cn(className, classNames?.root), "data-cilantro-signer-list": true, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Select a wallet first." }) });
|
|
2801
3063
|
}
|
|
2802
|
-
return /* @__PURE__ */ (0,
|
|
2803
|
-
/* @__PURE__ */ (0,
|
|
2804
|
-
/* @__PURE__ */ (0,
|
|
2805
|
-
/* @__PURE__ */ (0,
|
|
3064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cn(className, classNames?.root), "data-cilantro-signer-list": true, "aria-busy": isLoading, "aria-live": "polite", children: [
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: cn("flex items-center justify-between gap-2 mb-2", classNames?.header), children: [
|
|
3066
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-sm font-medium", children: "Signers" }),
|
|
3067
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2806
3068
|
Button,
|
|
2807
3069
|
{
|
|
2808
3070
|
type: "button",
|
|
2809
|
-
size: "
|
|
3071
|
+
size: "touch",
|
|
2810
3072
|
variant: "outline",
|
|
2811
3073
|
className: classNames?.addButton,
|
|
2812
3074
|
onClick: () => setAddSignerOpen(true),
|
|
2813
3075
|
disabled: isLoading,
|
|
3076
|
+
"aria-label": "Add signer",
|
|
2814
3077
|
children: "Add signer"
|
|
2815
3078
|
}
|
|
2816
3079
|
)
|
|
2817
3080
|
] }),
|
|
2818
|
-
isLoading
|
|
3081
|
+
isLoading && useSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3082
|
+
"div",
|
|
3083
|
+
{
|
|
3084
|
+
className: cn("space-y-1", classNames?.loading),
|
|
3085
|
+
"aria-busy": "true",
|
|
3086
|
+
"aria-live": "polite",
|
|
3087
|
+
children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3088
|
+
Skeleton,
|
|
3089
|
+
{
|
|
3090
|
+
className: cn("h-5 w-full rounded-md", classNames?.skeleton)
|
|
3091
|
+
},
|
|
3092
|
+
i
|
|
3093
|
+
))
|
|
3094
|
+
}
|
|
3095
|
+
) : isLoading ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "Loading signers..." }) : error ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-destructive", classNames?.message), role: "alert", children: error }) : signers.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: cn("text-sm text-muted-foreground", classNames?.message), children: "No signers. Add one to get started." }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: cn("space-y-1", classNames?.list), role: "list", children: signers.map((signer) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("li", { className: cn("text-sm", classNames?.item), children: [
|
|
2819
3096
|
getSignerDisplayName(signer),
|
|
2820
3097
|
" (",
|
|
2821
3098
|
getSignerTypeLabel(signer.type || signer.signerType || ""),
|
|
2822
3099
|
")"
|
|
2823
3100
|
] }, signer.id)) }),
|
|
2824
|
-
/* @__PURE__ */ (0,
|
|
3101
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2825
3102
|
AddSignerForm,
|
|
2826
3103
|
{
|
|
2827
3104
|
walletId,
|
|
@@ -2833,6 +3110,74 @@ function SignerList({
|
|
|
2833
3110
|
)
|
|
2834
3111
|
] });
|
|
2835
3112
|
}
|
|
3113
|
+
|
|
3114
|
+
// src/ui/theme-provider.tsx
|
|
3115
|
+
var React9 = __toESM(require("react"));
|
|
3116
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3117
|
+
var DEFAULT_THEME_CSS = `
|
|
3118
|
+
:root,[data-theme="light"]{--background:0 0% 100%;--foreground:222.2 84% 4.9%;--primary:222.2 47.4% 11.2%;--primary-foreground:210 40% 98%;--muted:210 40% 96.1%;--muted-foreground:215.4 16.3% 46.9%;--border:214.3 31.8% 91.4%;--input:214.3 31.8% 91.4%;--ring:222.2 84% 4.9%;--destructive:0 84.2% 60.2%;--destructive-foreground:210 40% 98%;--accent:210 40% 96.1%;--accent-foreground:222.2 47.4% 11.2%;--popover:0 0% 100%;--popover-foreground:222.2 84% 4.9%;--card:0 0% 100%;--card-foreground:222.2 84% 4.9%}
|
|
3119
|
+
[data-theme="dark"]{--background:222.2 84% 4.9%;--foreground:210 40% 98%;--primary:210 40% 98%;--primary-foreground:222.2 47.4% 11.2%;--muted:217.2 32.6% 17.5%;--muted-foreground:215 20.2% 65.1%;--border:217.2 32.6% 17.5%;--input:217.2 32.6% 17.5%;--ring:212.7 26.8% 83.9%;--destructive:0 62.8% 30.6%;--destructive-foreground:210 40% 98%;--accent:217.2 32.6% 17.5%;--accent-foreground:210 40% 98%;--popover:222.2 84% 4.9%;--popover-foreground:210 40% 98%;--card:222.2 84% 4.9%;--card-foreground:210 40% 98%}
|
|
3120
|
+
`;
|
|
3121
|
+
function getSystemTheme() {
|
|
3122
|
+
if (typeof window === "undefined") return "dark";
|
|
3123
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
3124
|
+
}
|
|
3125
|
+
function ThemeProvider({
|
|
3126
|
+
theme = "system",
|
|
3127
|
+
defaultTheme = "dark",
|
|
3128
|
+
storageKey,
|
|
3129
|
+
className,
|
|
3130
|
+
children,
|
|
3131
|
+
injectStyles = true
|
|
3132
|
+
}) {
|
|
3133
|
+
const [resolved, setResolved] = React9.useState(() => {
|
|
3134
|
+
if (theme === "light") return "light";
|
|
3135
|
+
if (theme === "dark") return "dark";
|
|
3136
|
+
if (typeof window !== "undefined" && storageKey) {
|
|
3137
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
3138
|
+
if (stored === "light" || stored === "dark") return stored;
|
|
3139
|
+
}
|
|
3140
|
+
return defaultTheme;
|
|
3141
|
+
});
|
|
3142
|
+
React9.useEffect(() => {
|
|
3143
|
+
if (theme === "light") {
|
|
3144
|
+
setResolved("light");
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
if (theme === "dark") {
|
|
3148
|
+
setResolved("dark");
|
|
3149
|
+
return;
|
|
3150
|
+
}
|
|
3151
|
+
const system = getSystemTheme();
|
|
3152
|
+
setResolved(system);
|
|
3153
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
3154
|
+
const listener = () => {
|
|
3155
|
+
const next = mql.matches ? "dark" : "light";
|
|
3156
|
+
setResolved(next);
|
|
3157
|
+
if (storageKey) window.localStorage.setItem(storageKey, next);
|
|
3158
|
+
};
|
|
3159
|
+
mql.addEventListener("change", listener);
|
|
3160
|
+
return () => mql.removeEventListener("change", listener);
|
|
3161
|
+
}, [theme, storageKey]);
|
|
3162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
3163
|
+
injectStyles && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3164
|
+
"style",
|
|
3165
|
+
{
|
|
3166
|
+
dangerouslySetInnerHTML: { __html: DEFAULT_THEME_CSS },
|
|
3167
|
+
"data-cilantro-theme-styles": true
|
|
3168
|
+
}
|
|
3169
|
+
),
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3171
|
+
"div",
|
|
3172
|
+
{
|
|
3173
|
+
className: cn(className),
|
|
3174
|
+
"data-theme": resolved,
|
|
3175
|
+
"data-cilantro-theme-provider": true,
|
|
3176
|
+
children
|
|
3177
|
+
}
|
|
3178
|
+
)
|
|
3179
|
+
] });
|
|
3180
|
+
}
|
|
2836
3181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2837
3182
|
0 && (module.exports = {
|
|
2838
3183
|
AddSignerForm,
|
|
@@ -2847,6 +3192,8 @@ function SignerList({
|
|
|
2847
3192
|
SIGNER_TYPES,
|
|
2848
3193
|
SignerList,
|
|
2849
3194
|
SignerSelector,
|
|
3195
|
+
Skeleton,
|
|
3196
|
+
ThemeProvider,
|
|
2850
3197
|
TransactionSigningForm,
|
|
2851
3198
|
WalletProvider,
|
|
2852
3199
|
WalletSelector,
|
|
@@ -2857,11 +3204,17 @@ function SignerList({
|
|
|
2857
3204
|
signAndSendTransactionWithSigner,
|
|
2858
3205
|
signMessageWithSigner,
|
|
2859
3206
|
signTransactionWithSigner,
|
|
3207
|
+
useCanSign,
|
|
2860
3208
|
useCilantroAuth,
|
|
3209
|
+
useDelegatedKeys,
|
|
2861
3210
|
useMessageSigning,
|
|
3211
|
+
useSelectedWallet,
|
|
2862
3212
|
useSignerSelection,
|
|
2863
3213
|
useSigners,
|
|
3214
|
+
useSignersForSelectedWallet,
|
|
3215
|
+
useSignersRaw,
|
|
2864
3216
|
useTransactionSigning,
|
|
3217
|
+
useWalletAddress,
|
|
2865
3218
|
useWallets
|
|
2866
3219
|
});
|
|
2867
3220
|
//# sourceMappingURL=index.js.map
|