@meshsdk/react 1.9.0-beta.97 → 2.0.0-beta.1
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/LICENSE +201 -0
- package/README.md +328 -3
- package/dist/index.cjs +223 -294
- package/dist/index.d.cts +16 -21
- package/dist/index.d.ts +16 -21
- package/dist/index.js +228 -300
- package/package.json +5 -10
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/cardano-wallet/index.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect9, useState as useState12 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/common/button.tsx
|
|
5
5
|
import * as React from "react";
|
|
@@ -179,10 +179,7 @@ import { useContext, useEffect as useEffect2, useState as useState2 } from "reac
|
|
|
179
179
|
|
|
180
180
|
// src/contexts/WalletContext.ts
|
|
181
181
|
import { createContext, useCallback, useEffect, useState } from "react";
|
|
182
|
-
import {
|
|
183
|
-
import {
|
|
184
|
-
Web3Wallet
|
|
185
|
-
} from "@meshsdk/web3-sdk";
|
|
182
|
+
import { MeshCardanoBrowserWallet } from "@meshsdk/wallet";
|
|
186
183
|
var INITIAL_STATE = {
|
|
187
184
|
walletName: void 0,
|
|
188
185
|
walletInstance: {}
|
|
@@ -205,8 +202,8 @@ var useWalletStore = () => {
|
|
|
205
202
|
setConnectingWallet(true);
|
|
206
203
|
setState("CONNECTING" /* CONNECTING */);
|
|
207
204
|
try {
|
|
208
|
-
const extensions =
|
|
209
|
-
const walletInstance = await
|
|
205
|
+
const extensions = globalThis?.cardano?.[walletName]?.supportedExtensions ?? [];
|
|
206
|
+
const walletInstance = await MeshCardanoBrowserWallet.enable(
|
|
210
207
|
walletName,
|
|
211
208
|
extensions
|
|
212
209
|
);
|
|
@@ -238,7 +235,8 @@ var useWalletStore = () => {
|
|
|
238
235
|
}, []);
|
|
239
236
|
const setWallet = useCallback(
|
|
240
237
|
async (walletInstance, walletName, persist) => {
|
|
241
|
-
|
|
238
|
+
const wrapped = walletInstance instanceof MeshCardanoBrowserWallet ? walletInstance : new MeshCardanoBrowserWallet(walletInstance);
|
|
239
|
+
setConnectedWalletInstance(wrapped);
|
|
242
240
|
setConnectedWalletName(walletName);
|
|
243
241
|
setState("CONNECTED" /* CONNECTED */);
|
|
244
242
|
if (persist) {
|
|
@@ -256,39 +254,33 @@ var useWalletStore = () => {
|
|
|
256
254
|
useEffect(() => {
|
|
257
255
|
async function load() {
|
|
258
256
|
if (Object.keys(connectedWalletInstance).length > 0 && address.length === 0) {
|
|
259
|
-
let address2 = (await connectedWalletInstance.
|
|
257
|
+
let address2 = (await connectedWalletInstance.getUnusedAddressesBech32())[0];
|
|
260
258
|
if (!address2)
|
|
261
|
-
address2 = await connectedWalletInstance.
|
|
259
|
+
address2 = await connectedWalletInstance.getChangeAddressBech32();
|
|
262
260
|
setAddress(address2);
|
|
263
261
|
}
|
|
264
262
|
}
|
|
265
263
|
load();
|
|
266
264
|
}, [connectedWalletInstance]);
|
|
267
265
|
useEffect(() => {
|
|
268
|
-
const
|
|
269
|
-
if (persistSession &&
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
setConnectedWalletName(persist2.walletName);
|
|
284
|
-
setState("CONNECTED" /* CONNECTED */);
|
|
285
|
-
});
|
|
286
|
-
setWeb3UserData(persist2.user);
|
|
287
|
-
} else {
|
|
288
|
-
connectWallet(persist2.walletName);
|
|
266
|
+
const persistData = localStorage.getItem(localstoragePersist);
|
|
267
|
+
if (persistSession && persistData) {
|
|
268
|
+
try {
|
|
269
|
+
const persist = JSON.parse(persistData);
|
|
270
|
+
if (!persist || typeof persist.walletName !== "string") {
|
|
271
|
+
throw new Error("Invalid persist data structure");
|
|
272
|
+
}
|
|
273
|
+
if (persist.walletName === "utxos") {
|
|
274
|
+
localStorage.removeItem(localstoragePersist);
|
|
275
|
+
} else {
|
|
276
|
+
connectWallet(persist.walletName);
|
|
277
|
+
}
|
|
278
|
+
} catch (error2) {
|
|
279
|
+
console.error("Failed to restore wallet session:", error2);
|
|
280
|
+
localStorage.removeItem(localstoragePersist);
|
|
289
281
|
}
|
|
290
282
|
}
|
|
291
|
-
}, [persistSession]);
|
|
283
|
+
}, [persistSession, connectWallet]);
|
|
292
284
|
return {
|
|
293
285
|
hasConnectedWallet: INITIAL_STATE.walletName !== connectedWalletName,
|
|
294
286
|
connectedWalletInstance,
|
|
@@ -330,9 +322,9 @@ var WalletContext = createContext({
|
|
|
330
322
|
|
|
331
323
|
// src/contexts/index.tsx
|
|
332
324
|
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
333
|
-
var MeshProvider = (
|
|
325
|
+
var MeshProvider = ({ children }) => {
|
|
334
326
|
const store = useWalletStore();
|
|
335
|
-
return /* @__PURE__ */ jsx4(WalletContext.Provider, { value: store, children: /* @__PURE__ */ jsx4(Fragment, { children
|
|
327
|
+
return /* @__PURE__ */ jsx4(WalletContext.Provider, { value: store, children: /* @__PURE__ */ jsx4(Fragment, { children }) });
|
|
336
328
|
};
|
|
337
329
|
|
|
338
330
|
// src/hooks/useAddress.ts
|
|
@@ -341,7 +333,7 @@ var useAddress = (accountId = 0) => {
|
|
|
341
333
|
const { hasConnectedWallet, connectedWalletInstance } = useContext(WalletContext);
|
|
342
334
|
useEffect2(() => {
|
|
343
335
|
if (hasConnectedWallet) {
|
|
344
|
-
connectedWalletInstance.
|
|
336
|
+
connectedWalletInstance.getUsedAddressesBech32().then((addresses) => {
|
|
345
337
|
if (addresses[accountId]) {
|
|
346
338
|
setAddress(addresses[accountId]);
|
|
347
339
|
}
|
|
@@ -353,12 +345,21 @@ var useAddress = (accountId = 0) => {
|
|
|
353
345
|
|
|
354
346
|
// src/hooks/useAssets.ts
|
|
355
347
|
import { useContext as useContext2, useEffect as useEffect3, useState as useState3 } from "react";
|
|
348
|
+
import { POLICY_ID_LENGTH, resolveFingerprint } from "@meshsdk/common";
|
|
356
349
|
var useAssets = () => {
|
|
357
350
|
const [assets, setAssets] = useState3();
|
|
358
351
|
const { hasConnectedWallet, connectedWalletInstance } = useContext2(WalletContext);
|
|
359
352
|
useEffect3(() => {
|
|
360
353
|
if (hasConnectedWallet) {
|
|
361
|
-
connectedWalletInstance.
|
|
354
|
+
connectedWalletInstance.getBalanceMesh().then((balance) => {
|
|
355
|
+
const derived = balance.filter((v) => v.unit !== "lovelace").map((v) => {
|
|
356
|
+
const policyId = v.unit.slice(0, POLICY_ID_LENGTH);
|
|
357
|
+
const assetName = v.unit.slice(POLICY_ID_LENGTH);
|
|
358
|
+
const fingerprint = resolveFingerprint(policyId, assetName);
|
|
359
|
+
return { unit: v.unit, policyId, assetName, fingerprint, quantity: v.quantity };
|
|
360
|
+
});
|
|
361
|
+
setAssets(derived);
|
|
362
|
+
});
|
|
362
363
|
}
|
|
363
364
|
}, [hasConnectedWallet, connectedWalletInstance]);
|
|
364
365
|
return assets;
|
|
@@ -366,14 +367,17 @@ var useAssets = () => {
|
|
|
366
367
|
|
|
367
368
|
// src/hooks/useWalletList.ts
|
|
368
369
|
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
369
|
-
import {
|
|
370
|
+
import { MeshCardanoBrowserWallet as MeshCardanoBrowserWallet2 } from "@meshsdk/wallet";
|
|
370
371
|
var useWalletList = ({
|
|
371
372
|
injectFn = void 0
|
|
372
373
|
} = {}) => {
|
|
373
374
|
const [wallets, setWallets] = useState4([]);
|
|
374
375
|
useEffect4(() => {
|
|
375
376
|
async function get() {
|
|
376
|
-
|
|
377
|
+
if (injectFn) {
|
|
378
|
+
await injectFn();
|
|
379
|
+
}
|
|
380
|
+
setWallets(MeshCardanoBrowserWallet2.getInstalledWallets());
|
|
377
381
|
}
|
|
378
382
|
get();
|
|
379
383
|
}, []);
|
|
@@ -389,7 +393,9 @@ var useLovelace = () => {
|
|
|
389
393
|
useEffect5(() => {
|
|
390
394
|
async function getLovelace() {
|
|
391
395
|
if (hasConnectedWallet && !hasFetchedLovelace.current) {
|
|
392
|
-
|
|
396
|
+
const balance = await connectedWalletInstance.getBalanceMesh();
|
|
397
|
+
const lovelaceAmount = balance.find((v) => v.unit === "lovelace")?.quantity ?? "0";
|
|
398
|
+
setLovelace(lovelaceAmount);
|
|
393
399
|
hasFetchedLovelace.current = true;
|
|
394
400
|
}
|
|
395
401
|
}
|
|
@@ -423,7 +429,7 @@ var useRewardAddress = (accountId = 0) => {
|
|
|
423
429
|
const { hasConnectedWallet, connectedWalletInstance } = useContext5(WalletContext);
|
|
424
430
|
useEffect7(() => {
|
|
425
431
|
if (hasConnectedWallet) {
|
|
426
|
-
connectedWalletInstance.
|
|
432
|
+
connectedWalletInstance.getRewardAddressesBech32().then((addresses) => {
|
|
427
433
|
if (addresses[accountId]) {
|
|
428
434
|
setRewardAddress(addresses[accountId]);
|
|
429
435
|
}
|
|
@@ -485,19 +491,21 @@ var useWalletSubmit = () => {
|
|
|
485
491
|
const submitTx = useCallback2(async (signedTx) => {
|
|
486
492
|
setSubmitting(true);
|
|
487
493
|
setError(void 0);
|
|
494
|
+
setResult(void 0);
|
|
488
495
|
try {
|
|
489
|
-
if (hasConnectedWallet) {
|
|
490
|
-
|
|
491
|
-
|
|
496
|
+
if (!hasConnectedWallet) {
|
|
497
|
+
throw new Error(
|
|
498
|
+
"Please make sure to connect a wallet before calling useWalletSubmit"
|
|
499
|
+
);
|
|
492
500
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
);
|
|
501
|
+
const txHash = await connectedWalletInstance.submitTx(signedTx);
|
|
502
|
+
setResult(txHash);
|
|
496
503
|
} catch (error2) {
|
|
497
504
|
setError(error2);
|
|
505
|
+
} finally {
|
|
506
|
+
setSubmitting(false);
|
|
498
507
|
}
|
|
499
|
-
|
|
500
|
-
}, []);
|
|
508
|
+
}, [hasConnectedWallet, connectedWalletInstance]);
|
|
501
509
|
return {
|
|
502
510
|
error,
|
|
503
511
|
result,
|
|
@@ -695,11 +703,8 @@ function ConnectedButton() {
|
|
|
695
703
|
// src/cardano-wallet/data.ts
|
|
696
704
|
var screens = {
|
|
697
705
|
main: {
|
|
698
|
-
title: "Connect Wallet"
|
|
699
|
-
|
|
700
|
-
p2p: {
|
|
701
|
-
title: "Peer Connect (CIP45)",
|
|
702
|
-
subtitle: "Use wallet that supports CIP-45, scan this QR code to connect."
|
|
706
|
+
title: "Connect Wallet",
|
|
707
|
+
subtitle: void 0
|
|
703
708
|
},
|
|
704
709
|
burner: {
|
|
705
710
|
title: "Burner Wallet",
|
|
@@ -713,7 +718,8 @@ var screens = {
|
|
|
713
718
|
|
|
714
719
|
// src/cardano-wallet/screen-burner.tsx
|
|
715
720
|
import { useEffect as useEffect8, useState as useState9 } from "react";
|
|
716
|
-
import {
|
|
721
|
+
import { generateMnemonic } from "@meshsdk/common";
|
|
722
|
+
import { MeshCardanoHeadlessWallet, AddressType } from "@meshsdk/wallet";
|
|
717
723
|
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
718
724
|
var localstoragekey = "mesh-burnerwallet";
|
|
719
725
|
function ScreenBurner({
|
|
@@ -733,34 +739,45 @@ function ScreenBurner({
|
|
|
733
739
|
setHasKeyInStorage(true);
|
|
734
740
|
}
|
|
735
741
|
}, []);
|
|
736
|
-
function
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
setWallet(wallet, screens.burner.title);
|
|
751
|
-
setLoading(false);
|
|
752
|
-
setOpen(false);
|
|
753
|
-
}, 500);
|
|
742
|
+
async function createWalletFromMnemonic(mnemonic) {
|
|
743
|
+
const wallet = await MeshCardanoHeadlessWallet.fromMnemonic({
|
|
744
|
+
mnemonic,
|
|
745
|
+
networkId,
|
|
746
|
+
walletAddressType: AddressType.Base,
|
|
747
|
+
fetcher: provider,
|
|
748
|
+
submitter: provider
|
|
749
|
+
});
|
|
750
|
+
if (!hasKeyInStorage) {
|
|
751
|
+
localStorage.setItem(localstoragekey, mnemonic.join(" "));
|
|
752
|
+
}
|
|
753
|
+
setWallet(wallet, screens.burner.title);
|
|
754
|
+
setLoading(false);
|
|
755
|
+
setOpen(false);
|
|
754
756
|
}
|
|
755
|
-
function handleRestoreWallet() {
|
|
757
|
+
async function handleRestoreWallet() {
|
|
756
758
|
setLoading(true);
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
+
const stored = getKeyFromStorage();
|
|
760
|
+
if (stored) {
|
|
761
|
+
if (stored.includes(" ")) {
|
|
762
|
+
await createWalletFromMnemonic(stored.split(" "));
|
|
763
|
+
} else {
|
|
764
|
+
const wallet = await MeshCardanoHeadlessWallet.fromBip32Root({
|
|
765
|
+
bech32: stored,
|
|
766
|
+
networkId,
|
|
767
|
+
walletAddressType: AddressType.Base,
|
|
768
|
+
fetcher: provider,
|
|
769
|
+
submitter: provider
|
|
770
|
+
});
|
|
771
|
+
setWallet(wallet, screens.burner.title);
|
|
772
|
+
setLoading(false);
|
|
773
|
+
setOpen(false);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
759
776
|
}
|
|
760
|
-
function handleCreateWallet() {
|
|
777
|
+
async function handleCreateWallet() {
|
|
761
778
|
setLoading(true);
|
|
762
|
-
const
|
|
763
|
-
|
|
779
|
+
const mnemonic = generateMnemonic(256).split(" ");
|
|
780
|
+
await createWalletFromMnemonic(mnemonic);
|
|
764
781
|
}
|
|
765
782
|
return /* @__PURE__ */ jsx7("div", { className: "mesh-flex mesh-flex-row mesh-flex-gap-4 mesh-items-center mesh-justify-center", children: loading ? /* @__PURE__ */ jsx7(Fragment2, { children: "Setting up wallet..." }) : /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
766
783
|
hasKeyInStorage && /* @__PURE__ */ jsx7(
|
|
@@ -894,45 +911,14 @@ function IconFingerprint() {
|
|
|
894
911
|
);
|
|
895
912
|
}
|
|
896
913
|
|
|
897
|
-
// src/common/icons/icon-monitor-smartphone.tsx
|
|
898
|
-
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
899
|
-
function IconMonitorSmartphone() {
|
|
900
|
-
return /* @__PURE__ */ jsxs8(
|
|
901
|
-
"svg",
|
|
902
|
-
{
|
|
903
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
904
|
-
width: "24",
|
|
905
|
-
height: "24",
|
|
906
|
-
viewBox: "0 0 24 24",
|
|
907
|
-
fill: "none",
|
|
908
|
-
stroke: "black",
|
|
909
|
-
strokeWidth: "2",
|
|
910
|
-
strokeLinecap: "round",
|
|
911
|
-
strokeLinejoin: "round",
|
|
912
|
-
style: {
|
|
913
|
-
color: "#ffadff",
|
|
914
|
-
width: "56px",
|
|
915
|
-
height: "56px",
|
|
916
|
-
strokeWidth: "1px"
|
|
917
|
-
},
|
|
918
|
-
children: [
|
|
919
|
-
/* @__PURE__ */ jsx11("path", { d: "M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8" }),
|
|
920
|
-
/* @__PURE__ */ jsx11("path", { d: "M10 19v-3.96 3.15" }),
|
|
921
|
-
/* @__PURE__ */ jsx11("path", { d: "M7 19h5" }),
|
|
922
|
-
/* @__PURE__ */ jsx11("rect", { width: "6", height: "10", x: "16", y: "12", rx: "2" })
|
|
923
|
-
]
|
|
924
|
-
}
|
|
925
|
-
);
|
|
926
|
-
}
|
|
927
|
-
|
|
928
914
|
// src/common/tooltip.tsx
|
|
929
915
|
import * as React4 from "react";
|
|
930
916
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
931
|
-
import { jsx as
|
|
917
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
932
918
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
933
919
|
var Tooltip = TooltipPrimitive.Root;
|
|
934
920
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
935
|
-
var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */
|
|
921
|
+
var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx11(
|
|
936
922
|
TooltipPrimitive.Content,
|
|
937
923
|
{
|
|
938
924
|
ref,
|
|
@@ -947,7 +933,7 @@ var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props },
|
|
|
947
933
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
948
934
|
|
|
949
935
|
// src/cardano-wallet/wallet-icon.tsx
|
|
950
|
-
import { jsx as
|
|
936
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
951
937
|
function WalletIcon({
|
|
952
938
|
icon,
|
|
953
939
|
name,
|
|
@@ -955,34 +941,35 @@ function WalletIcon({
|
|
|
955
941
|
iconReactNode,
|
|
956
942
|
loading = false
|
|
957
943
|
}) {
|
|
958
|
-
return /* @__PURE__ */
|
|
959
|
-
/* @__PURE__ */
|
|
944
|
+
return /* @__PURE__ */ jsxs8(Tooltip, { delayDuration: 0, defaultOpen: false, children: [
|
|
945
|
+
/* @__PURE__ */ jsx12(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs8(
|
|
960
946
|
"button",
|
|
961
947
|
{
|
|
962
948
|
className: "mesh-flex mesh-items-center mesh-justify-center mesh-rounded-lg mesh-w-10 mesh-h-10 mesh-bg-neutral-50 mesh-border mesh-border-zinc-700 hover:mesh-border-zinc-200 mesh-cursor-pointer",
|
|
963
949
|
onClick: action,
|
|
964
950
|
disabled: loading,
|
|
965
951
|
children: [
|
|
966
|
-
icon && !loading && /* @__PURE__ */
|
|
952
|
+
icon && !loading && /* @__PURE__ */ jsx12("img", { src: icon, alt: name, className: "mesh-w-8 mesh-h-8" }),
|
|
967
953
|
!loading && iconReactNode && iconReactNode,
|
|
968
|
-
loading && /* @__PURE__ */
|
|
954
|
+
loading && /* @__PURE__ */ jsx12("span", { className: "text-black", children: "..." })
|
|
969
955
|
]
|
|
970
956
|
}
|
|
971
957
|
) }),
|
|
972
|
-
/* @__PURE__ */
|
|
958
|
+
/* @__PURE__ */ jsx12(TooltipContent, { children: /* @__PURE__ */ jsx12("p", { children: name }) })
|
|
973
959
|
] });
|
|
974
960
|
}
|
|
975
961
|
|
|
976
962
|
// src/cardano-wallet/web3-services.tsx
|
|
977
963
|
import { useState as useState10 } from "react";
|
|
964
|
+
import { MeshCardanoBrowserWallet as MeshCardanoBrowserWallet3 } from "@meshsdk/wallet";
|
|
978
965
|
import {
|
|
979
|
-
Web3Wallet
|
|
980
|
-
} from "@
|
|
966
|
+
Web3Wallet
|
|
967
|
+
} from "@utxos/sdk";
|
|
981
968
|
|
|
982
969
|
// src/common/icons/icon-discord.tsx
|
|
983
|
-
import { jsx as
|
|
970
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
984
971
|
function IconDiscord() {
|
|
985
|
-
return /* @__PURE__ */
|
|
972
|
+
return /* @__PURE__ */ jsx13(
|
|
986
973
|
"svg",
|
|
987
974
|
{
|
|
988
975
|
viewBox: "0 0 20 20",
|
|
@@ -991,7 +978,7 @@ function IconDiscord() {
|
|
|
991
978
|
width: "24px",
|
|
992
979
|
height: "24px"
|
|
993
980
|
},
|
|
994
|
-
children: /* @__PURE__ */
|
|
981
|
+
children: /* @__PURE__ */ jsx13(
|
|
995
982
|
"path",
|
|
996
983
|
{
|
|
997
984
|
d: "M16.238 4.515a14.842 14.842 0 0 0-3.664-1.136.055.055 0 0 0-.059.027 10.35 10.35 0 0 0-.456.938 13.702 13.702 0 0 0-4.115 0 9.479 9.479 0 0 0-.464-.938.058.058 0 0 0-.058-.027c-1.266.218-2.497.6-3.664 1.136a.052.052 0 0 0-.024.02C1.4 8.023.76 11.424 1.074 14.782a.062.062 0 0 0 .024.042 14.923 14.923 0 0 0 4.494 2.272.058.058 0 0 0 .064-.02c.346-.473.654-.972.92-1.496a.057.057 0 0 0-.032-.08 9.83 9.83 0 0 1-1.404-.669.058.058 0 0 1-.029-.046.058.058 0 0 1 .023-.05c.094-.07.189-.144.279-.218a.056.056 0 0 1 .058-.008c2.946 1.345 6.135 1.345 9.046 0a.056.056 0 0 1 .059.007c.09.074.184.149.28.22a.058.058 0 0 1 .023.049.059.059 0 0 1-.028.046 9.224 9.224 0 0 1-1.405.669.058.058 0 0 0-.033.033.056.056 0 0 0 .002.047c.27.523.58 1.022.92 1.495a.056.056 0 0 0 .062.021 14.878 14.878 0 0 0 4.502-2.272.055.055 0 0 0 .016-.018.056.056 0 0 0 .008-.023c.375-3.883-.63-7.256-2.662-10.246a.046.046 0 0 0-.023-.021Zm-9.223 8.221c-.887 0-1.618-.814-1.618-1.814s.717-1.814 1.618-1.814c.908 0 1.632.821 1.618 1.814 0 1-.717 1.814-1.618 1.814Zm5.981 0c-.887 0-1.618-.814-1.618-1.814s.717-1.814 1.618-1.814c.908 0 1.632.821 1.618 1.814 0 1-.71 1.814-1.618 1.814Z",
|
|
@@ -1003,9 +990,9 @@ function IconDiscord() {
|
|
|
1003
990
|
}
|
|
1004
991
|
|
|
1005
992
|
// src/common/icons/icon-google.tsx
|
|
1006
|
-
import { jsx as
|
|
993
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1007
994
|
function IconGoogle() {
|
|
1008
|
-
return /* @__PURE__ */
|
|
995
|
+
return /* @__PURE__ */ jsxs9(
|
|
1009
996
|
"svg",
|
|
1010
997
|
{
|
|
1011
998
|
viewBox: "0 0 262 262",
|
|
@@ -1016,28 +1003,28 @@ function IconGoogle() {
|
|
|
1016
1003
|
height: "24px"
|
|
1017
1004
|
},
|
|
1018
1005
|
children: [
|
|
1019
|
-
/* @__PURE__ */
|
|
1006
|
+
/* @__PURE__ */ jsx14(
|
|
1020
1007
|
"path",
|
|
1021
1008
|
{
|
|
1022
1009
|
d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027",
|
|
1023
1010
|
fill: "#4285F4"
|
|
1024
1011
|
}
|
|
1025
1012
|
),
|
|
1026
|
-
/* @__PURE__ */
|
|
1013
|
+
/* @__PURE__ */ jsx14(
|
|
1027
1014
|
"path",
|
|
1028
1015
|
{
|
|
1029
1016
|
d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1",
|
|
1030
1017
|
fill: "#34A853"
|
|
1031
1018
|
}
|
|
1032
1019
|
),
|
|
1033
|
-
/* @__PURE__ */
|
|
1020
|
+
/* @__PURE__ */ jsx14(
|
|
1034
1021
|
"path",
|
|
1035
1022
|
{
|
|
1036
1023
|
d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782",
|
|
1037
1024
|
fill: "#FBBC05"
|
|
1038
1025
|
}
|
|
1039
1026
|
),
|
|
1040
|
-
/* @__PURE__ */
|
|
1027
|
+
/* @__PURE__ */ jsx14(
|
|
1041
1028
|
"path",
|
|
1042
1029
|
{
|
|
1043
1030
|
d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251",
|
|
@@ -1050,9 +1037,9 @@ function IconGoogle() {
|
|
|
1050
1037
|
}
|
|
1051
1038
|
|
|
1052
1039
|
// src/common/icons/icon-twitter.tsx
|
|
1053
|
-
import { jsx as
|
|
1040
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1054
1041
|
function IconTwitter() {
|
|
1055
|
-
return /* @__PURE__ */
|
|
1042
|
+
return /* @__PURE__ */ jsx15(
|
|
1056
1043
|
"svg",
|
|
1057
1044
|
{
|
|
1058
1045
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1062,13 +1049,13 @@ function IconTwitter() {
|
|
|
1062
1049
|
width: "24px",
|
|
1063
1050
|
height: "24px"
|
|
1064
1051
|
},
|
|
1065
|
-
children: /* @__PURE__ */
|
|
1052
|
+
children: /* @__PURE__ */ jsx15("path", { d: "M14.095479,10.316482L22.286354,1h-1.940718l-7.115352,8.087682L7.551414,1H1l8.589488,12.231093L1,23h1.940717 l7.509372-8.542861L16.448587,23H23L14.095479,10.316482z M11.436522,13.338465l-0.871624-1.218704l-6.924311-9.68815h2.981339 l5.58978,7.82155l0.867949,1.218704l7.26506,10.166271h-2.981339L11.436522,13.338465z" })
|
|
1066
1053
|
}
|
|
1067
1054
|
);
|
|
1068
1055
|
}
|
|
1069
1056
|
|
|
1070
1057
|
// src/cardano-wallet/web3-services.tsx
|
|
1071
|
-
import { Fragment as Fragment3, jsx as
|
|
1058
|
+
import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1072
1059
|
function Web3Services({
|
|
1073
1060
|
options,
|
|
1074
1061
|
setOpen,
|
|
@@ -1086,22 +1073,24 @@ function Web3Services({
|
|
|
1086
1073
|
projectId: options.projectId,
|
|
1087
1074
|
directTo
|
|
1088
1075
|
};
|
|
1089
|
-
const wallet = await
|
|
1076
|
+
const wallet = await Web3Wallet.enable(_options);
|
|
1090
1077
|
const user = wallet.getUser();
|
|
1091
1078
|
setWeb3UserData(user);
|
|
1079
|
+
const wrapped = new MeshCardanoBrowserWallet3(wallet.cardano);
|
|
1080
|
+
const walletAddress = await wrapped.getChangeAddressBech32();
|
|
1092
1081
|
setWallet(
|
|
1093
|
-
|
|
1082
|
+
wrapped,
|
|
1094
1083
|
"utxos",
|
|
1095
1084
|
persist ? {
|
|
1096
|
-
walletAddress
|
|
1085
|
+
walletAddress,
|
|
1097
1086
|
user
|
|
1098
1087
|
} : void 0
|
|
1099
1088
|
);
|
|
1100
1089
|
setLoading(false);
|
|
1101
1090
|
setOpen(false);
|
|
1102
1091
|
}
|
|
1103
|
-
return /* @__PURE__ */
|
|
1104
|
-
/* @__PURE__ */
|
|
1092
|
+
return /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
1093
|
+
/* @__PURE__ */ jsx16(
|
|
1105
1094
|
WalletIcon,
|
|
1106
1095
|
{
|
|
1107
1096
|
iconReactNode: IconGoogle(),
|
|
@@ -1110,7 +1099,7 @@ function Web3Services({
|
|
|
1110
1099
|
loading
|
|
1111
1100
|
}
|
|
1112
1101
|
),
|
|
1113
|
-
/* @__PURE__ */
|
|
1102
|
+
/* @__PURE__ */ jsx16(
|
|
1114
1103
|
WalletIcon,
|
|
1115
1104
|
{
|
|
1116
1105
|
iconReactNode: IconDiscord(),
|
|
@@ -1119,7 +1108,7 @@ function Web3Services({
|
|
|
1119
1108
|
loading
|
|
1120
1109
|
}
|
|
1121
1110
|
),
|
|
1122
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ jsx16(
|
|
1123
1112
|
WalletIcon,
|
|
1124
1113
|
{
|
|
1125
1114
|
iconReactNode: IconTwitter(),
|
|
@@ -1132,34 +1121,33 @@ function Web3Services({
|
|
|
1132
1121
|
}
|
|
1133
1122
|
|
|
1134
1123
|
// src/cardano-wallet/screen-main.tsx
|
|
1135
|
-
import { jsx as
|
|
1124
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1136
1125
|
function ScreenMain({
|
|
1137
1126
|
injectFn,
|
|
1138
1127
|
setOpen,
|
|
1139
1128
|
setScreen,
|
|
1140
1129
|
persist,
|
|
1141
|
-
cardanoPeerConnect,
|
|
1142
1130
|
burnerWallet,
|
|
1143
1131
|
webauthn,
|
|
1144
1132
|
showDownload,
|
|
1145
1133
|
web3Services
|
|
1146
1134
|
}) {
|
|
1147
1135
|
const wallets = useWalletList({ injectFn });
|
|
1148
|
-
const { connect
|
|
1149
|
-
return /* @__PURE__ */
|
|
1150
|
-
wallets.map((wallet, index) => /* @__PURE__ */
|
|
1136
|
+
const { connect } = useWallet();
|
|
1137
|
+
return /* @__PURE__ */ jsx17(TooltipProvider, { children: /* @__PURE__ */ jsxs11("div", { className: "mesh-grid mesh-gap-4 mesh-py-4 mesh-grid-cols-5 mesh-place-items-center mesh-gap-y-8", children: [
|
|
1138
|
+
wallets.map((wallet, index) => /* @__PURE__ */ jsx17(
|
|
1151
1139
|
WalletIcon,
|
|
1152
1140
|
{
|
|
1153
1141
|
icon: wallet.icon,
|
|
1154
1142
|
name: wallet.name,
|
|
1155
1143
|
action: () => {
|
|
1156
|
-
|
|
1144
|
+
connect(wallet.id, persist);
|
|
1157
1145
|
setOpen(false);
|
|
1158
1146
|
}
|
|
1159
1147
|
},
|
|
1160
1148
|
index
|
|
1161
1149
|
)),
|
|
1162
|
-
web3Services && /* @__PURE__ */
|
|
1150
|
+
web3Services && /* @__PURE__ */ jsx17(
|
|
1163
1151
|
Web3Services,
|
|
1164
1152
|
{
|
|
1165
1153
|
options: web3Services,
|
|
@@ -1167,7 +1155,7 @@ function ScreenMain({
|
|
|
1167
1155
|
persist
|
|
1168
1156
|
}
|
|
1169
1157
|
),
|
|
1170
|
-
webauthn && /* @__PURE__ */
|
|
1158
|
+
webauthn && /* @__PURE__ */ jsx17(
|
|
1171
1159
|
WalletIcon,
|
|
1172
1160
|
{
|
|
1173
1161
|
iconReactNode: IconFingerprint(),
|
|
@@ -1177,17 +1165,7 @@ function ScreenMain({
|
|
|
1177
1165
|
}
|
|
1178
1166
|
}
|
|
1179
1167
|
),
|
|
1180
|
-
|
|
1181
|
-
WalletIcon,
|
|
1182
|
-
{
|
|
1183
|
-
iconReactNode: IconMonitorSmartphone(),
|
|
1184
|
-
name: screens.p2p.title,
|
|
1185
|
-
action: () => {
|
|
1186
|
-
setScreen("p2p");
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
),
|
|
1190
|
-
burnerWallet && /* @__PURE__ */ jsx18(
|
|
1168
|
+
burnerWallet && /* @__PURE__ */ jsx17(
|
|
1191
1169
|
WalletIcon,
|
|
1192
1170
|
{
|
|
1193
1171
|
iconReactNode: IconBookDashed(),
|
|
@@ -1197,7 +1175,7 @@ function ScreenMain({
|
|
|
1197
1175
|
}
|
|
1198
1176
|
}
|
|
1199
1177
|
),
|
|
1200
|
-
showDownload && /* @__PURE__ */
|
|
1178
|
+
showDownload && /* @__PURE__ */ jsx17(
|
|
1201
1179
|
WalletIcon,
|
|
1202
1180
|
{
|
|
1203
1181
|
iconReactNode: IconDownload(),
|
|
@@ -1213,79 +1191,16 @@ function ScreenMain({
|
|
|
1213
1191
|
] }) });
|
|
1214
1192
|
}
|
|
1215
1193
|
|
|
1216
|
-
// src/cardano-wallet/screen-p2p.tsx
|
|
1217
|
-
import { useEffect as useEffect9, useRef as useRef2, useState as useState11 } from "react";
|
|
1218
|
-
import { DAppPeerConnect } from "@fabianbormann/cardano-peer-connect";
|
|
1219
|
-
import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1220
|
-
function ScreenP2P({
|
|
1221
|
-
cardanoPeerConnect,
|
|
1222
|
-
setOpen
|
|
1223
|
-
}) {
|
|
1224
|
-
const dAppConnect = useRef2(null);
|
|
1225
|
-
const qrCodeField = useRef2(null);
|
|
1226
|
-
const [address, setAddress] = useState11("");
|
|
1227
|
-
const [copied, setCopied] = useState11(false);
|
|
1228
|
-
const { connect: connect2 } = useWallet();
|
|
1229
|
-
useEffect9(() => {
|
|
1230
|
-
if (cardanoPeerConnect) {
|
|
1231
|
-
if (dAppConnect.current === null) {
|
|
1232
|
-
dAppConnect.current = new DAppPeerConnect({
|
|
1233
|
-
dAppInfo: {
|
|
1234
|
-
name: cardanoPeerConnect.dAppInfo.name,
|
|
1235
|
-
url: cardanoPeerConnect.dAppInfo.url
|
|
1236
|
-
},
|
|
1237
|
-
announce: cardanoPeerConnect.announce,
|
|
1238
|
-
onApiInject: async (name, address2) => {
|
|
1239
|
-
await connect2(name);
|
|
1240
|
-
setOpen(false);
|
|
1241
|
-
},
|
|
1242
|
-
onApiEject: (name, address2) => {
|
|
1243
|
-
},
|
|
1244
|
-
onConnect: (address2, walletInfo) => {
|
|
1245
|
-
},
|
|
1246
|
-
onDisconnect: () => {
|
|
1247
|
-
},
|
|
1248
|
-
verifyConnection: (walletInfo, callback) => {
|
|
1249
|
-
callback(true, true);
|
|
1250
|
-
},
|
|
1251
|
-
useWalletDiscovery: true
|
|
1252
|
-
});
|
|
1253
|
-
if (dAppConnect.current) {
|
|
1254
|
-
const address2 = dAppConnect.current.getAddress();
|
|
1255
|
-
setAddress(address2);
|
|
1256
|
-
if (qrCodeField.current !== null) {
|
|
1257
|
-
dAppConnect.current.generateQRCode(qrCodeField.current);
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
}, []);
|
|
1263
|
-
return /* @__PURE__ */ jsxs13("div", { className: "mesh-flex mesh-flex-col mesh-items-center mesh-justify-center", children: [
|
|
1264
|
-
/* @__PURE__ */ jsx19("div", { style: { marginTop: 16, marginBottom: 16 }, ref: qrCodeField }),
|
|
1265
|
-
/* @__PURE__ */ jsx19(
|
|
1266
|
-
Button,
|
|
1267
|
-
{
|
|
1268
|
-
variant: "outline",
|
|
1269
|
-
onClick: () => {
|
|
1270
|
-
navigator.clipboard.writeText(address);
|
|
1271
|
-
setCopied(true);
|
|
1272
|
-
},
|
|
1273
|
-
children: copied ? "Copied" : "Copy Address"
|
|
1274
|
-
}
|
|
1275
|
-
)
|
|
1276
|
-
] });
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
1194
|
// src/cardano-wallet/screen-webauthn.tsx
|
|
1280
|
-
import { useState as
|
|
1281
|
-
import {
|
|
1195
|
+
import { useState as useState11 } from "react";
|
|
1196
|
+
import { MeshCardanoHeadlessWallet as MeshCardanoHeadlessWallet2, AddressType as AddressType2 } from "@meshsdk/wallet";
|
|
1282
1197
|
|
|
1283
1198
|
// src/common/input.tsx
|
|
1284
1199
|
import * as React5 from "react";
|
|
1285
|
-
import { jsx as
|
|
1200
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1286
1201
|
var Input = React5.forwardRef(
|
|
1287
1202
|
({ className, type, ...props }, ref) => {
|
|
1288
|
-
return /* @__PURE__ */
|
|
1203
|
+
return /* @__PURE__ */ jsx18(
|
|
1289
1204
|
"input",
|
|
1290
1205
|
{
|
|
1291
1206
|
type,
|
|
@@ -1305,11 +1220,11 @@ Input.displayName = "Input";
|
|
|
1305
1220
|
import * as React6 from "react";
|
|
1306
1221
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
1307
1222
|
import { cva as cva2 } from "class-variance-authority";
|
|
1308
|
-
import { jsx as
|
|
1223
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1309
1224
|
var labelVariants = cva2(
|
|
1310
1225
|
"mesh-text-sm mesh-font-medium mesh-leading-none peer-disabled:mesh-cursor-not-allowed peer-disabled:mesh-opacity-70"
|
|
1311
1226
|
);
|
|
1312
|
-
var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
1227
|
+
var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx19(
|
|
1313
1228
|
LabelPrimitive.Root,
|
|
1314
1229
|
{
|
|
1315
1230
|
ref,
|
|
@@ -1320,44 +1235,46 @@ var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
1320
1235
|
Label2.displayName = LabelPrimitive.Root.displayName;
|
|
1321
1236
|
|
|
1322
1237
|
// src/cardano-wallet/screen-webauthn.tsx
|
|
1323
|
-
import { Fragment as Fragment4, jsx as
|
|
1238
|
+
import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1324
1239
|
function ScreenWebauthn({
|
|
1325
1240
|
url,
|
|
1326
1241
|
networkId,
|
|
1327
1242
|
provider,
|
|
1328
1243
|
setOpen
|
|
1329
1244
|
}) {
|
|
1330
|
-
const [loading, setLoading] =
|
|
1331
|
-
const [userName, setUserName] =
|
|
1332
|
-
const [password, setPassword] =
|
|
1245
|
+
const [loading, setLoading] = useState11(false);
|
|
1246
|
+
const [userName, setUserName] = useState11("");
|
|
1247
|
+
const [password, setPassword] = useState11("");
|
|
1333
1248
|
const { setWallet } = useWallet();
|
|
1334
|
-
function createWallet(root) {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
setWallet(wallet, screens.webauthn.title);
|
|
1346
|
-
setLoading(false);
|
|
1347
|
-
setOpen(false);
|
|
1348
|
-
}, 500);
|
|
1249
|
+
async function createWallet(root) {
|
|
1250
|
+
const wallet = await MeshCardanoHeadlessWallet2.fromBip32Root({
|
|
1251
|
+
bech32: root,
|
|
1252
|
+
networkId,
|
|
1253
|
+
walletAddressType: AddressType2.Base,
|
|
1254
|
+
fetcher: provider,
|
|
1255
|
+
submitter: provider
|
|
1256
|
+
});
|
|
1257
|
+
setWallet(wallet, screens.webauthn.title);
|
|
1258
|
+
setLoading(false);
|
|
1259
|
+
setOpen(false);
|
|
1349
1260
|
}
|
|
1350
1261
|
async function handleConnect() {
|
|
1351
1262
|
setLoading(true);
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1354
|
-
|
|
1263
|
+
const connectModule = await import("@meshsdk/wallet");
|
|
1264
|
+
if (typeof connectModule.connect === "function") {
|
|
1265
|
+
const res = await connectModule.connect({ username: userName, password, serverUrl: url });
|
|
1266
|
+
if (res.success && res.wallet) {
|
|
1267
|
+
await createWallet(res.wallet.bech32PrivateKey);
|
|
1268
|
+
}
|
|
1269
|
+
} else {
|
|
1270
|
+
console.error("WebAuthn connect is not available in this version of @meshsdk/wallet");
|
|
1271
|
+
setLoading(false);
|
|
1355
1272
|
}
|
|
1356
1273
|
}
|
|
1357
|
-
return /* @__PURE__ */
|
|
1358
|
-
/* @__PURE__ */
|
|
1359
|
-
/* @__PURE__ */
|
|
1360
|
-
/* @__PURE__ */
|
|
1274
|
+
return /* @__PURE__ */ jsx20("div", { className: "mesh-flex mesh-flex-row mesh-flex-gap-4 mesh-items-center mesh-justify-center", children: loading ? /* @__PURE__ */ jsx20(Fragment4, { children: "Connecting wallet..." }) : /* @__PURE__ */ jsx20(Fragment4, { children: /* @__PURE__ */ jsxs12("div", { className: "mesh-flex mesh-flex-col mesh-gap-6 mesh-w-full mesh-mx-8", children: [
|
|
1275
|
+
/* @__PURE__ */ jsxs12("div", { className: "mesh-grid mesh-gap-2", children: [
|
|
1276
|
+
/* @__PURE__ */ jsx20(Label2, { htmlFor: "username", children: "Username" }),
|
|
1277
|
+
/* @__PURE__ */ jsx20(
|
|
1361
1278
|
Input,
|
|
1362
1279
|
{
|
|
1363
1280
|
id: "username",
|
|
@@ -1367,11 +1284,11 @@ function ScreenWebauthn({
|
|
|
1367
1284
|
onChange: (e) => setUserName(e.target.value)
|
|
1368
1285
|
}
|
|
1369
1286
|
),
|
|
1370
|
-
/* @__PURE__ */
|
|
1287
|
+
/* @__PURE__ */ jsx20("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Unique to the application you are connecting." })
|
|
1371
1288
|
] }),
|
|
1372
|
-
/* @__PURE__ */
|
|
1373
|
-
/* @__PURE__ */
|
|
1374
|
-
/* @__PURE__ */
|
|
1289
|
+
/* @__PURE__ */ jsxs12("div", { className: "mesh-grid mesh-gap-2", children: [
|
|
1290
|
+
/* @__PURE__ */ jsx20("div", { className: "mesh-flex mesh-items-center", children: /* @__PURE__ */ jsx20(Label2, { htmlFor: "password", children: "Unique Code" }) }),
|
|
1291
|
+
/* @__PURE__ */ jsx20(
|
|
1375
1292
|
Input,
|
|
1376
1293
|
{
|
|
1377
1294
|
id: "password",
|
|
@@ -1381,9 +1298,9 @@ function ScreenWebauthn({
|
|
|
1381
1298
|
onChange: (e) => setPassword(e.target.value)
|
|
1382
1299
|
}
|
|
1383
1300
|
),
|
|
1384
|
-
/* @__PURE__ */
|
|
1301
|
+
/* @__PURE__ */ jsx20("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Additional security to derive your wallet." })
|
|
1385
1302
|
] }),
|
|
1386
|
-
/* @__PURE__ */
|
|
1303
|
+
/* @__PURE__ */ jsx20(
|
|
1387
1304
|
Button,
|
|
1388
1305
|
{
|
|
1389
1306
|
className: "mesh-w-full",
|
|
@@ -1396,62 +1313,53 @@ function ScreenWebauthn({
|
|
|
1396
1313
|
}
|
|
1397
1314
|
|
|
1398
1315
|
// src/cardano-wallet/index.tsx
|
|
1399
|
-
import { jsx as
|
|
1316
|
+
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1400
1317
|
var CardanoWallet = ({
|
|
1401
1318
|
label = "Connect Wallet",
|
|
1402
1319
|
onConnected = void 0,
|
|
1403
1320
|
isDark = false,
|
|
1404
1321
|
persist = false,
|
|
1405
1322
|
injectFn = void 0,
|
|
1406
|
-
cardanoPeerConnect = void 0,
|
|
1407
1323
|
burnerWallet = void 0,
|
|
1408
1324
|
webauthn = void 0,
|
|
1409
1325
|
showDownload = true,
|
|
1410
1326
|
web3Services = void 0
|
|
1411
1327
|
}) => {
|
|
1412
|
-
const [open, setOpen] =
|
|
1413
|
-
const [screen, setScreen] =
|
|
1328
|
+
const [open, setOpen] = useState12(false);
|
|
1329
|
+
const [screen, setScreen] = useState12("main");
|
|
1414
1330
|
const { wallet, connected, setPersist, setWeb3Services } = useWallet();
|
|
1415
|
-
|
|
1331
|
+
useEffect9(() => {
|
|
1416
1332
|
setPersist(persist);
|
|
1417
1333
|
if (web3Services) setWeb3Services(web3Services);
|
|
1418
|
-
}, []);
|
|
1419
|
-
|
|
1334
|
+
}, [persist, web3Services, setPersist, setWeb3Services]);
|
|
1335
|
+
useEffect9(() => {
|
|
1420
1336
|
if (connected) {
|
|
1421
1337
|
if (onConnected) onConnected();
|
|
1422
1338
|
}
|
|
1423
1339
|
}, [connected, wallet]);
|
|
1424
|
-
return /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1340
|
+
return /* @__PURE__ */ jsxs13(Dialog, { open, onOpenChange: setOpen, children: [
|
|
1341
|
+
/* @__PURE__ */ jsx21("div", { className: isDark ? "mesh-dark" : "", children: !connected ? /* @__PURE__ */ jsx21(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx21(Button, { variant: "outline", className: isDark ? "mesh-dark" : "", children: label }) }) : /* @__PURE__ */ jsx21(ConnectedButton, {}) }),
|
|
1342
|
+
/* @__PURE__ */ jsxs13(
|
|
1427
1343
|
DialogContent,
|
|
1428
1344
|
{
|
|
1429
1345
|
className: "sm:mesh-max-w-[425px] mesh-dark",
|
|
1430
1346
|
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
1431
1347
|
children: [
|
|
1432
|
-
/* @__PURE__ */
|
|
1433
|
-
screen == "main" && /* @__PURE__ */
|
|
1348
|
+
/* @__PURE__ */ jsx21(Header, { screen, setScreen }),
|
|
1349
|
+
screen == "main" && /* @__PURE__ */ jsx21(
|
|
1434
1350
|
ScreenMain,
|
|
1435
1351
|
{
|
|
1436
1352
|
injectFn,
|
|
1437
1353
|
setOpen,
|
|
1438
1354
|
setScreen,
|
|
1439
1355
|
persist,
|
|
1440
|
-
cardanoPeerConnect: cardanoPeerConnect != void 0,
|
|
1441
1356
|
burnerWallet: burnerWallet != void 0,
|
|
1442
1357
|
webauthn: webauthn != void 0,
|
|
1443
1358
|
showDownload,
|
|
1444
1359
|
web3Services
|
|
1445
1360
|
}
|
|
1446
1361
|
),
|
|
1447
|
-
screen == "
|
|
1448
|
-
ScreenP2P,
|
|
1449
|
-
{
|
|
1450
|
-
cardanoPeerConnect,
|
|
1451
|
-
setOpen
|
|
1452
|
-
}
|
|
1453
|
-
),
|
|
1454
|
-
screen == "burner" && burnerWallet && /* @__PURE__ */ jsx23(
|
|
1362
|
+
screen == "burner" && burnerWallet && /* @__PURE__ */ jsx21(
|
|
1455
1363
|
ScreenBurner,
|
|
1456
1364
|
{
|
|
1457
1365
|
networkId: burnerWallet.networkId,
|
|
@@ -1459,7 +1367,7 @@ var CardanoWallet = ({
|
|
|
1459
1367
|
setOpen
|
|
1460
1368
|
}
|
|
1461
1369
|
),
|
|
1462
|
-
screen == "webauthn" && webauthn && /* @__PURE__ */
|
|
1370
|
+
screen == "webauthn" && webauthn && /* @__PURE__ */ jsx21(
|
|
1463
1371
|
ScreenWebauthn,
|
|
1464
1372
|
{
|
|
1465
1373
|
url: webauthn.url,
|
|
@@ -1468,7 +1376,7 @@ var CardanoWallet = ({
|
|
|
1468
1376
|
setOpen
|
|
1469
1377
|
}
|
|
1470
1378
|
),
|
|
1471
|
-
/* @__PURE__ */
|
|
1379
|
+
/* @__PURE__ */ jsx21(Footer, {})
|
|
1472
1380
|
]
|
|
1473
1381
|
}
|
|
1474
1382
|
)
|
|
@@ -1478,25 +1386,33 @@ function Header({
|
|
|
1478
1386
|
screen,
|
|
1479
1387
|
setScreen
|
|
1480
1388
|
}) {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1389
|
+
const screenData = screens[screen];
|
|
1390
|
+
return /* @__PURE__ */ jsxs13(DialogHeader, { children: [
|
|
1391
|
+
/* @__PURE__ */ jsxs13(DialogTitle, { className: "mesh-flex mesh-justify-between", children: [
|
|
1392
|
+
screen !== "main" ? /* @__PURE__ */ jsx21(
|
|
1393
|
+
"button",
|
|
1394
|
+
{
|
|
1395
|
+
onClick: () => setScreen("main"),
|
|
1396
|
+
"aria-label": "Back to wallet selection",
|
|
1397
|
+
children: /* @__PURE__ */ jsx21(IconChevronRight, {})
|
|
1398
|
+
}
|
|
1399
|
+
) : /* @__PURE__ */ jsx21("span", { style: { width: "24px" } }),
|
|
1400
|
+
/* @__PURE__ */ jsx21("span", { className: "mesh-text-white", children: screenData.title }),
|
|
1401
|
+
/* @__PURE__ */ jsx21("span", { style: { width: "24px" } })
|
|
1486
1402
|
] }),
|
|
1487
|
-
/* @__PURE__ */
|
|
1403
|
+
/* @__PURE__ */ jsx21(DialogDescription, { children: screenData.subtitle && screenData.subtitle })
|
|
1488
1404
|
] });
|
|
1489
1405
|
}
|
|
1490
1406
|
function Footer() {
|
|
1491
|
-
return /* @__PURE__ */
|
|
1407
|
+
return /* @__PURE__ */ jsx21(DialogFooter, { className: "mesh-justify-center mesh-text-sm", children: /* @__PURE__ */ jsxs13(
|
|
1492
1408
|
"a",
|
|
1493
1409
|
{
|
|
1494
1410
|
href: "https://meshjs.dev/",
|
|
1495
1411
|
target: "_blank",
|
|
1496
1412
|
className: "mesh-grow mesh-flex mesh-gap-1 mesh-items-center mesh-justify-center mesh-text-zinc-500 hover:mesh-text-white mesh-fill-zinc-500 hover:mesh-fill-white",
|
|
1497
1413
|
children: [
|
|
1498
|
-
/* @__PURE__ */
|
|
1499
|
-
/* @__PURE__ */
|
|
1414
|
+
/* @__PURE__ */ jsx21("span", { className: "", children: "Powered by" }),
|
|
1415
|
+
/* @__PURE__ */ jsx21(
|
|
1500
1416
|
"svg",
|
|
1501
1417
|
{
|
|
1502
1418
|
width: 24,
|
|
@@ -1504,31 +1420,31 @@ function Footer() {
|
|
|
1504
1420
|
enableBackground: "new 0 0 300 200",
|
|
1505
1421
|
viewBox: "0 0 300 200",
|
|
1506
1422
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1507
|
-
children: /* @__PURE__ */
|
|
1423
|
+
children: /* @__PURE__ */ jsx21("path", { d: "m289 127-45-60-45-60c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-37 49.3c-2 2.7-6 2.7-8 0l-37-49.3c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-45 60-45 60c-1.3 1.8-1.3 4.2 0 6l45 60c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l45-60c1.3-1.8 1.3-4.2 0-6zm-90-103.3 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-90 0 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-53 152.6-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0z" })
|
|
1508
1424
|
}
|
|
1509
1425
|
),
|
|
1510
|
-
/* @__PURE__ */
|
|
1426
|
+
/* @__PURE__ */ jsx21("span", { className: "", children: "Mesh SDK" })
|
|
1511
1427
|
]
|
|
1512
1428
|
}
|
|
1513
1429
|
) });
|
|
1514
1430
|
}
|
|
1515
1431
|
|
|
1516
1432
|
// src/mesh-badge/mesh-logo.tsx
|
|
1517
|
-
import { jsx as
|
|
1518
|
-
var MeshLogo = () => /* @__PURE__ */
|
|
1433
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1434
|
+
var MeshLogo = () => /* @__PURE__ */ jsx22(
|
|
1519
1435
|
"svg",
|
|
1520
1436
|
{
|
|
1521
1437
|
className: "mesh-h-16 mesh-p-2",
|
|
1522
1438
|
fill: "currentColor",
|
|
1523
1439
|
viewBox: "0 0 300 200",
|
|
1524
1440
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1525
|
-
children: /* @__PURE__ */
|
|
1441
|
+
children: /* @__PURE__ */ jsx22("path", { d: "m289 127-45-60-45-60c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-37 49.3c-2 2.7-6 2.7-8 0l-37-49.3c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-45 60-45 60c-1.3 1.8-1.3 4.2 0 6l45 60c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l45-60c1.3-1.8 1.3-4.2 0-6zm-90-103.3 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-90 0 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-53 152.6-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0z" })
|
|
1526
1442
|
}
|
|
1527
1443
|
);
|
|
1528
1444
|
|
|
1529
1445
|
// src/mesh-badge/index.tsx
|
|
1530
|
-
import { jsx as
|
|
1531
|
-
var MeshBadge = ({ isDark = false }) => /* @__PURE__ */
|
|
1446
|
+
import { jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1447
|
+
var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ jsxs14(
|
|
1532
1448
|
"a",
|
|
1533
1449
|
{
|
|
1534
1450
|
className: `mesh-flex mesh-max-w-fit mesh-flex-col mesh-items-center mesh-rounded-md mesh-border mesh-border-solid mesh-border-current mesh-p-1 mesh-text-xl mesh-font-semibold mesh-no-underline ${isDark ? `mesh-bg-neutral-950 mesh-text-neutral-50` : `mesh-bg-neutral-50 mesh-text-neutral-950`}`,
|
|
@@ -1540,14 +1456,26 @@ var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ jsxs16(
|
|
|
1540
1456
|
rel: "noopener noreferrer",
|
|
1541
1457
|
target: "_blank",
|
|
1542
1458
|
children: [
|
|
1543
|
-
/* @__PURE__ */
|
|
1459
|
+
/* @__PURE__ */ jsx23(MeshLogo, {}),
|
|
1544
1460
|
"Mesh"
|
|
1545
1461
|
]
|
|
1546
1462
|
}
|
|
1547
1463
|
);
|
|
1464
|
+
|
|
1465
|
+
// src/index.ts
|
|
1466
|
+
import {
|
|
1467
|
+
MeshCardanoBrowserWallet as MeshCardanoBrowserWallet4,
|
|
1468
|
+
MeshCardanoHeadlessWallet as MeshCardanoHeadlessWallet3,
|
|
1469
|
+
CardanoBrowserWallet,
|
|
1470
|
+
CardanoHeadlessWallet
|
|
1471
|
+
} from "@meshsdk/wallet";
|
|
1548
1472
|
export {
|
|
1473
|
+
CardanoBrowserWallet,
|
|
1474
|
+
CardanoHeadlessWallet,
|
|
1549
1475
|
CardanoWallet,
|
|
1550
1476
|
MeshBadge,
|
|
1477
|
+
MeshCardanoBrowserWallet4 as MeshCardanoBrowserWallet,
|
|
1478
|
+
MeshCardanoHeadlessWallet3 as MeshCardanoHeadlessWallet,
|
|
1551
1479
|
MeshProvider,
|
|
1552
1480
|
WalletContext,
|
|
1553
1481
|
useAddress,
|