@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.cjs
CHANGED
|
@@ -30,8 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
CardanoBrowserWallet: () => import_wallet6.CardanoBrowserWallet,
|
|
34
|
+
CardanoHeadlessWallet: () => import_wallet6.CardanoHeadlessWallet,
|
|
33
35
|
CardanoWallet: () => CardanoWallet,
|
|
34
36
|
MeshBadge: () => MeshBadge,
|
|
37
|
+
MeshCardanoBrowserWallet: () => import_wallet6.MeshCardanoBrowserWallet,
|
|
38
|
+
MeshCardanoHeadlessWallet: () => import_wallet6.MeshCardanoHeadlessWallet,
|
|
35
39
|
MeshProvider: () => MeshProvider,
|
|
36
40
|
WalletContext: () => WalletContext,
|
|
37
41
|
useAddress: () => useAddress,
|
|
@@ -46,7 +50,7 @@ __export(index_exports, {
|
|
|
46
50
|
module.exports = __toCommonJS(index_exports);
|
|
47
51
|
|
|
48
52
|
// src/cardano-wallet/index.tsx
|
|
49
|
-
var
|
|
53
|
+
var import_react13 = require("react");
|
|
50
54
|
|
|
51
55
|
// src/common/button.tsx
|
|
52
56
|
var React = __toESM(require("react"), 1);
|
|
@@ -227,7 +231,6 @@ var import_react2 = require("react");
|
|
|
227
231
|
// src/contexts/WalletContext.ts
|
|
228
232
|
var import_react = require("react");
|
|
229
233
|
var import_wallet = require("@meshsdk/wallet");
|
|
230
|
-
var import_web3_sdk = require("@meshsdk/web3-sdk");
|
|
231
234
|
var INITIAL_STATE = {
|
|
232
235
|
walletName: void 0,
|
|
233
236
|
walletInstance: {}
|
|
@@ -250,8 +253,8 @@ var useWalletStore = () => {
|
|
|
250
253
|
setConnectingWallet(true);
|
|
251
254
|
setState("CONNECTING" /* CONNECTING */);
|
|
252
255
|
try {
|
|
253
|
-
const extensions =
|
|
254
|
-
const walletInstance = await import_wallet.
|
|
256
|
+
const extensions = globalThis?.cardano?.[walletName]?.supportedExtensions ?? [];
|
|
257
|
+
const walletInstance = await import_wallet.MeshCardanoBrowserWallet.enable(
|
|
255
258
|
walletName,
|
|
256
259
|
extensions
|
|
257
260
|
);
|
|
@@ -283,7 +286,8 @@ var useWalletStore = () => {
|
|
|
283
286
|
}, []);
|
|
284
287
|
const setWallet = (0, import_react.useCallback)(
|
|
285
288
|
async (walletInstance, walletName, persist) => {
|
|
286
|
-
|
|
289
|
+
const wrapped = walletInstance instanceof import_wallet.MeshCardanoBrowserWallet ? walletInstance : new import_wallet.MeshCardanoBrowserWallet(walletInstance);
|
|
290
|
+
setConnectedWalletInstance(wrapped);
|
|
287
291
|
setConnectedWalletName(walletName);
|
|
288
292
|
setState("CONNECTED" /* CONNECTED */);
|
|
289
293
|
if (persist) {
|
|
@@ -301,39 +305,33 @@ var useWalletStore = () => {
|
|
|
301
305
|
(0, import_react.useEffect)(() => {
|
|
302
306
|
async function load() {
|
|
303
307
|
if (Object.keys(connectedWalletInstance).length > 0 && address.length === 0) {
|
|
304
|
-
let address2 = (await connectedWalletInstance.
|
|
308
|
+
let address2 = (await connectedWalletInstance.getUnusedAddressesBech32())[0];
|
|
305
309
|
if (!address2)
|
|
306
|
-
address2 = await connectedWalletInstance.
|
|
310
|
+
address2 = await connectedWalletInstance.getChangeAddressBech32();
|
|
307
311
|
setAddress(address2);
|
|
308
312
|
}
|
|
309
313
|
}
|
|
310
314
|
load();
|
|
311
315
|
}, [connectedWalletInstance]);
|
|
312
316
|
(0, import_react.useEffect)(() => {
|
|
313
|
-
const
|
|
314
|
-
if (persistSession &&
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
setConnectedWalletName(persist2.walletName);
|
|
329
|
-
setState("CONNECTED" /* CONNECTED */);
|
|
330
|
-
});
|
|
331
|
-
setWeb3UserData(persist2.user);
|
|
332
|
-
} else {
|
|
333
|
-
connectWallet(persist2.walletName);
|
|
317
|
+
const persistData = localStorage.getItem(localstoragePersist);
|
|
318
|
+
if (persistSession && persistData) {
|
|
319
|
+
try {
|
|
320
|
+
const persist = JSON.parse(persistData);
|
|
321
|
+
if (!persist || typeof persist.walletName !== "string") {
|
|
322
|
+
throw new Error("Invalid persist data structure");
|
|
323
|
+
}
|
|
324
|
+
if (persist.walletName === "utxos") {
|
|
325
|
+
localStorage.removeItem(localstoragePersist);
|
|
326
|
+
} else {
|
|
327
|
+
connectWallet(persist.walletName);
|
|
328
|
+
}
|
|
329
|
+
} catch (error2) {
|
|
330
|
+
console.error("Failed to restore wallet session:", error2);
|
|
331
|
+
localStorage.removeItem(localstoragePersist);
|
|
334
332
|
}
|
|
335
333
|
}
|
|
336
|
-
}, [persistSession]);
|
|
334
|
+
}, [persistSession, connectWallet]);
|
|
337
335
|
return {
|
|
338
336
|
hasConnectedWallet: INITIAL_STATE.walletName !== connectedWalletName,
|
|
339
337
|
connectedWalletInstance,
|
|
@@ -375,9 +373,9 @@ var WalletContext = (0, import_react.createContext)({
|
|
|
375
373
|
|
|
376
374
|
// src/contexts/index.tsx
|
|
377
375
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
378
|
-
var MeshProvider = (
|
|
376
|
+
var MeshProvider = ({ children }) => {
|
|
379
377
|
const store = useWalletStore();
|
|
380
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WalletContext.Provider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children
|
|
378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WalletContext.Provider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children }) });
|
|
381
379
|
};
|
|
382
380
|
|
|
383
381
|
// src/hooks/useAddress.ts
|
|
@@ -386,7 +384,7 @@ var useAddress = (accountId = 0) => {
|
|
|
386
384
|
const { hasConnectedWallet, connectedWalletInstance } = (0, import_react2.useContext)(WalletContext);
|
|
387
385
|
(0, import_react2.useEffect)(() => {
|
|
388
386
|
if (hasConnectedWallet) {
|
|
389
|
-
connectedWalletInstance.
|
|
387
|
+
connectedWalletInstance.getUsedAddressesBech32().then((addresses) => {
|
|
390
388
|
if (addresses[accountId]) {
|
|
391
389
|
setAddress(addresses[accountId]);
|
|
392
390
|
}
|
|
@@ -398,12 +396,21 @@ var useAddress = (accountId = 0) => {
|
|
|
398
396
|
|
|
399
397
|
// src/hooks/useAssets.ts
|
|
400
398
|
var import_react3 = require("react");
|
|
399
|
+
var import_common = require("@meshsdk/common");
|
|
401
400
|
var useAssets = () => {
|
|
402
401
|
const [assets, setAssets] = (0, import_react3.useState)();
|
|
403
402
|
const { hasConnectedWallet, connectedWalletInstance } = (0, import_react3.useContext)(WalletContext);
|
|
404
403
|
(0, import_react3.useEffect)(() => {
|
|
405
404
|
if (hasConnectedWallet) {
|
|
406
|
-
connectedWalletInstance.
|
|
405
|
+
connectedWalletInstance.getBalanceMesh().then((balance) => {
|
|
406
|
+
const derived = balance.filter((v) => v.unit !== "lovelace").map((v) => {
|
|
407
|
+
const policyId = v.unit.slice(0, import_common.POLICY_ID_LENGTH);
|
|
408
|
+
const assetName = v.unit.slice(import_common.POLICY_ID_LENGTH);
|
|
409
|
+
const fingerprint = (0, import_common.resolveFingerprint)(policyId, assetName);
|
|
410
|
+
return { unit: v.unit, policyId, assetName, fingerprint, quantity: v.quantity };
|
|
411
|
+
});
|
|
412
|
+
setAssets(derived);
|
|
413
|
+
});
|
|
407
414
|
}
|
|
408
415
|
}, [hasConnectedWallet, connectedWalletInstance]);
|
|
409
416
|
return assets;
|
|
@@ -418,7 +425,10 @@ var useWalletList = ({
|
|
|
418
425
|
const [wallets, setWallets] = (0, import_react4.useState)([]);
|
|
419
426
|
(0, import_react4.useEffect)(() => {
|
|
420
427
|
async function get() {
|
|
421
|
-
|
|
428
|
+
if (injectFn) {
|
|
429
|
+
await injectFn();
|
|
430
|
+
}
|
|
431
|
+
setWallets(import_wallet2.MeshCardanoBrowserWallet.getInstalledWallets());
|
|
422
432
|
}
|
|
423
433
|
get();
|
|
424
434
|
}, []);
|
|
@@ -434,7 +444,9 @@ var useLovelace = () => {
|
|
|
434
444
|
(0, import_react5.useEffect)(() => {
|
|
435
445
|
async function getLovelace() {
|
|
436
446
|
if (hasConnectedWallet && !hasFetchedLovelace.current) {
|
|
437
|
-
|
|
447
|
+
const balance = await connectedWalletInstance.getBalanceMesh();
|
|
448
|
+
const lovelaceAmount = balance.find((v) => v.unit === "lovelace")?.quantity ?? "0";
|
|
449
|
+
setLovelace(lovelaceAmount);
|
|
438
450
|
hasFetchedLovelace.current = true;
|
|
439
451
|
}
|
|
440
452
|
}
|
|
@@ -468,7 +480,7 @@ var useRewardAddress = (accountId = 0) => {
|
|
|
468
480
|
const { hasConnectedWallet, connectedWalletInstance } = (0, import_react7.useContext)(WalletContext);
|
|
469
481
|
(0, import_react7.useEffect)(() => {
|
|
470
482
|
if (hasConnectedWallet) {
|
|
471
|
-
connectedWalletInstance.
|
|
483
|
+
connectedWalletInstance.getRewardAddressesBech32().then((addresses) => {
|
|
472
484
|
if (addresses[accountId]) {
|
|
473
485
|
setRewardAddress(addresses[accountId]);
|
|
474
486
|
}
|
|
@@ -530,19 +542,21 @@ var useWalletSubmit = () => {
|
|
|
530
542
|
const submitTx = (0, import_react9.useCallback)(async (signedTx) => {
|
|
531
543
|
setSubmitting(true);
|
|
532
544
|
setError(void 0);
|
|
545
|
+
setResult(void 0);
|
|
533
546
|
try {
|
|
534
|
-
if (hasConnectedWallet) {
|
|
535
|
-
|
|
536
|
-
|
|
547
|
+
if (!hasConnectedWallet) {
|
|
548
|
+
throw new Error(
|
|
549
|
+
"Please make sure to connect a wallet before calling useWalletSubmit"
|
|
550
|
+
);
|
|
537
551
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
);
|
|
552
|
+
const txHash = await connectedWalletInstance.submitTx(signedTx);
|
|
553
|
+
setResult(txHash);
|
|
541
554
|
} catch (error2) {
|
|
542
555
|
setError(error2);
|
|
556
|
+
} finally {
|
|
557
|
+
setSubmitting(false);
|
|
543
558
|
}
|
|
544
|
-
|
|
545
|
-
}, []);
|
|
559
|
+
}, [hasConnectedWallet, connectedWalletInstance]);
|
|
546
560
|
return {
|
|
547
561
|
error,
|
|
548
562
|
result,
|
|
@@ -736,11 +750,8 @@ function ConnectedButton() {
|
|
|
736
750
|
// src/cardano-wallet/data.ts
|
|
737
751
|
var screens = {
|
|
738
752
|
main: {
|
|
739
|
-
title: "Connect Wallet"
|
|
740
|
-
|
|
741
|
-
p2p: {
|
|
742
|
-
title: "Peer Connect (CIP45)",
|
|
743
|
-
subtitle: "Use wallet that supports CIP-45, scan this QR code to connect."
|
|
753
|
+
title: "Connect Wallet",
|
|
754
|
+
subtitle: void 0
|
|
744
755
|
},
|
|
745
756
|
burner: {
|
|
746
757
|
title: "Burner Wallet",
|
|
@@ -754,6 +765,7 @@ var screens = {
|
|
|
754
765
|
|
|
755
766
|
// src/cardano-wallet/screen-burner.tsx
|
|
756
767
|
var import_react10 = require("react");
|
|
768
|
+
var import_common2 = require("@meshsdk/common");
|
|
757
769
|
var import_wallet3 = require("@meshsdk/wallet");
|
|
758
770
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
759
771
|
var localstoragekey = "mesh-burnerwallet";
|
|
@@ -774,34 +786,45 @@ function ScreenBurner({
|
|
|
774
786
|
setHasKeyInStorage(true);
|
|
775
787
|
}
|
|
776
788
|
}, []);
|
|
777
|
-
function
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
setWallet(wallet, screens.burner.title);
|
|
792
|
-
setLoading(false);
|
|
793
|
-
setOpen(false);
|
|
794
|
-
}, 500);
|
|
789
|
+
async function createWalletFromMnemonic(mnemonic) {
|
|
790
|
+
const wallet = await import_wallet3.MeshCardanoHeadlessWallet.fromMnemonic({
|
|
791
|
+
mnemonic,
|
|
792
|
+
networkId,
|
|
793
|
+
walletAddressType: import_wallet3.AddressType.Base,
|
|
794
|
+
fetcher: provider,
|
|
795
|
+
submitter: provider
|
|
796
|
+
});
|
|
797
|
+
if (!hasKeyInStorage) {
|
|
798
|
+
localStorage.setItem(localstoragekey, mnemonic.join(" "));
|
|
799
|
+
}
|
|
800
|
+
setWallet(wallet, screens.burner.title);
|
|
801
|
+
setLoading(false);
|
|
802
|
+
setOpen(false);
|
|
795
803
|
}
|
|
796
|
-
function handleRestoreWallet() {
|
|
804
|
+
async function handleRestoreWallet() {
|
|
797
805
|
setLoading(true);
|
|
798
|
-
const
|
|
799
|
-
|
|
806
|
+
const stored = getKeyFromStorage();
|
|
807
|
+
if (stored) {
|
|
808
|
+
if (stored.includes(" ")) {
|
|
809
|
+
await createWalletFromMnemonic(stored.split(" "));
|
|
810
|
+
} else {
|
|
811
|
+
const wallet = await import_wallet3.MeshCardanoHeadlessWallet.fromBip32Root({
|
|
812
|
+
bech32: stored,
|
|
813
|
+
networkId,
|
|
814
|
+
walletAddressType: import_wallet3.AddressType.Base,
|
|
815
|
+
fetcher: provider,
|
|
816
|
+
submitter: provider
|
|
817
|
+
});
|
|
818
|
+
setWallet(wallet, screens.burner.title);
|
|
819
|
+
setLoading(false);
|
|
820
|
+
setOpen(false);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
800
823
|
}
|
|
801
|
-
function handleCreateWallet() {
|
|
824
|
+
async function handleCreateWallet() {
|
|
802
825
|
setLoading(true);
|
|
803
|
-
const
|
|
804
|
-
|
|
826
|
+
const mnemonic = (0, import_common2.generateMnemonic)(256).split(" ");
|
|
827
|
+
await createWalletFromMnemonic(mnemonic);
|
|
805
828
|
}
|
|
806
829
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "mesh-flex mesh-flex-row mesh-flex-gap-4 mesh-items-center mesh-justify-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: "Setting up wallet..." }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
807
830
|
hasKeyInStorage && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -935,45 +958,14 @@ function IconFingerprint() {
|
|
|
935
958
|
);
|
|
936
959
|
}
|
|
937
960
|
|
|
938
|
-
// src/common/icons/icon-monitor-smartphone.tsx
|
|
939
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
940
|
-
function IconMonitorSmartphone() {
|
|
941
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
942
|
-
"svg",
|
|
943
|
-
{
|
|
944
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
945
|
-
width: "24",
|
|
946
|
-
height: "24",
|
|
947
|
-
viewBox: "0 0 24 24",
|
|
948
|
-
fill: "none",
|
|
949
|
-
stroke: "black",
|
|
950
|
-
strokeWidth: "2",
|
|
951
|
-
strokeLinecap: "round",
|
|
952
|
-
strokeLinejoin: "round",
|
|
953
|
-
style: {
|
|
954
|
-
color: "#ffadff",
|
|
955
|
-
width: "56px",
|
|
956
|
-
height: "56px",
|
|
957
|
-
strokeWidth: "1px"
|
|
958
|
-
},
|
|
959
|
-
children: [
|
|
960
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8" }),
|
|
961
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M10 19v-3.96 3.15" }),
|
|
962
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M7 19h5" }),
|
|
963
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("rect", { width: "6", height: "10", x: "16", y: "12", rx: "2" })
|
|
964
|
-
]
|
|
965
|
-
}
|
|
966
|
-
);
|
|
967
|
-
}
|
|
968
|
-
|
|
969
961
|
// src/common/tooltip.tsx
|
|
970
962
|
var React4 = __toESM(require("react"), 1);
|
|
971
963
|
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"), 1);
|
|
972
|
-
var
|
|
964
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
973
965
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
974
966
|
var Tooltip = TooltipPrimitive.Root;
|
|
975
967
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
976
|
-
var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0,
|
|
968
|
+
var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
977
969
|
TooltipPrimitive.Content,
|
|
978
970
|
{
|
|
979
971
|
ref,
|
|
@@ -988,7 +980,7 @@ var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props },
|
|
|
988
980
|
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
989
981
|
|
|
990
982
|
// src/cardano-wallet/wallet-icon.tsx
|
|
991
|
-
var
|
|
983
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
992
984
|
function WalletIcon({
|
|
993
985
|
icon,
|
|
994
986
|
name,
|
|
@@ -996,32 +988,33 @@ function WalletIcon({
|
|
|
996
988
|
iconReactNode,
|
|
997
989
|
loading = false
|
|
998
990
|
}) {
|
|
999
|
-
return /* @__PURE__ */ (0,
|
|
1000
|
-
/* @__PURE__ */ (0,
|
|
991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Tooltip, { delayDuration: 0, defaultOpen: false, children: [
|
|
992
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1001
993
|
"button",
|
|
1002
994
|
{
|
|
1003
995
|
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",
|
|
1004
996
|
onClick: action,
|
|
1005
997
|
disabled: loading,
|
|
1006
998
|
children: [
|
|
1007
|
-
icon && !loading && /* @__PURE__ */ (0,
|
|
999
|
+
icon && !loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: icon, alt: name, className: "mesh-w-8 mesh-h-8" }),
|
|
1008
1000
|
!loading && iconReactNode && iconReactNode,
|
|
1009
|
-
loading && /* @__PURE__ */ (0,
|
|
1001
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-black", children: "..." })
|
|
1010
1002
|
]
|
|
1011
1003
|
}
|
|
1012
1004
|
) }),
|
|
1013
|
-
/* @__PURE__ */ (0,
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TooltipContent, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: name }) })
|
|
1014
1006
|
] });
|
|
1015
1007
|
}
|
|
1016
1008
|
|
|
1017
1009
|
// src/cardano-wallet/web3-services.tsx
|
|
1018
1010
|
var import_react11 = require("react");
|
|
1019
|
-
var
|
|
1011
|
+
var import_wallet4 = require("@meshsdk/wallet");
|
|
1012
|
+
var import_sdk = require("@utxos/sdk");
|
|
1020
1013
|
|
|
1021
1014
|
// src/common/icons/icon-discord.tsx
|
|
1022
|
-
var
|
|
1015
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1023
1016
|
function IconDiscord() {
|
|
1024
|
-
return /* @__PURE__ */ (0,
|
|
1017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1025
1018
|
"svg",
|
|
1026
1019
|
{
|
|
1027
1020
|
viewBox: "0 0 20 20",
|
|
@@ -1030,7 +1023,7 @@ function IconDiscord() {
|
|
|
1030
1023
|
width: "24px",
|
|
1031
1024
|
height: "24px"
|
|
1032
1025
|
},
|
|
1033
|
-
children: /* @__PURE__ */ (0,
|
|
1026
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1034
1027
|
"path",
|
|
1035
1028
|
{
|
|
1036
1029
|
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",
|
|
@@ -1042,9 +1035,9 @@ function IconDiscord() {
|
|
|
1042
1035
|
}
|
|
1043
1036
|
|
|
1044
1037
|
// src/common/icons/icon-google.tsx
|
|
1045
|
-
var
|
|
1038
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1046
1039
|
function IconGoogle() {
|
|
1047
|
-
return /* @__PURE__ */ (0,
|
|
1040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1048
1041
|
"svg",
|
|
1049
1042
|
{
|
|
1050
1043
|
viewBox: "0 0 262 262",
|
|
@@ -1055,28 +1048,28 @@ function IconGoogle() {
|
|
|
1055
1048
|
height: "24px"
|
|
1056
1049
|
},
|
|
1057
1050
|
children: [
|
|
1058
|
-
/* @__PURE__ */ (0,
|
|
1051
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1059
1052
|
"path",
|
|
1060
1053
|
{
|
|
1061
1054
|
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",
|
|
1062
1055
|
fill: "#4285F4"
|
|
1063
1056
|
}
|
|
1064
1057
|
),
|
|
1065
|
-
/* @__PURE__ */ (0,
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1066
1059
|
"path",
|
|
1067
1060
|
{
|
|
1068
1061
|
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",
|
|
1069
1062
|
fill: "#34A853"
|
|
1070
1063
|
}
|
|
1071
1064
|
),
|
|
1072
|
-
/* @__PURE__ */ (0,
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1073
1066
|
"path",
|
|
1074
1067
|
{
|
|
1075
1068
|
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",
|
|
1076
1069
|
fill: "#FBBC05"
|
|
1077
1070
|
}
|
|
1078
1071
|
),
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1080
1073
|
"path",
|
|
1081
1074
|
{
|
|
1082
1075
|
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",
|
|
@@ -1089,9 +1082,9 @@ function IconGoogle() {
|
|
|
1089
1082
|
}
|
|
1090
1083
|
|
|
1091
1084
|
// src/common/icons/icon-twitter.tsx
|
|
1092
|
-
var
|
|
1085
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1093
1086
|
function IconTwitter() {
|
|
1094
|
-
return /* @__PURE__ */ (0,
|
|
1087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1095
1088
|
"svg",
|
|
1096
1089
|
{
|
|
1097
1090
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1101,13 +1094,13 @@ function IconTwitter() {
|
|
|
1101
1094
|
width: "24px",
|
|
1102
1095
|
height: "24px"
|
|
1103
1096
|
},
|
|
1104
|
-
children: /* @__PURE__ */ (0,
|
|
1097
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("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" })
|
|
1105
1098
|
}
|
|
1106
1099
|
);
|
|
1107
1100
|
}
|
|
1108
1101
|
|
|
1109
1102
|
// src/cardano-wallet/web3-services.tsx
|
|
1110
|
-
var
|
|
1103
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1111
1104
|
function Web3Services({
|
|
1112
1105
|
options,
|
|
1113
1106
|
setOpen,
|
|
@@ -1125,22 +1118,24 @@ function Web3Services({
|
|
|
1125
1118
|
projectId: options.projectId,
|
|
1126
1119
|
directTo
|
|
1127
1120
|
};
|
|
1128
|
-
const wallet = await
|
|
1121
|
+
const wallet = await import_sdk.Web3Wallet.enable(_options);
|
|
1129
1122
|
const user = wallet.getUser();
|
|
1130
1123
|
setWeb3UserData(user);
|
|
1124
|
+
const wrapped = new import_wallet4.MeshCardanoBrowserWallet(wallet.cardano);
|
|
1125
|
+
const walletAddress = await wrapped.getChangeAddressBech32();
|
|
1131
1126
|
setWallet(
|
|
1132
|
-
|
|
1127
|
+
wrapped,
|
|
1133
1128
|
"utxos",
|
|
1134
1129
|
persist ? {
|
|
1135
|
-
walletAddress
|
|
1130
|
+
walletAddress,
|
|
1136
1131
|
user
|
|
1137
1132
|
} : void 0
|
|
1138
1133
|
);
|
|
1139
1134
|
setLoading(false);
|
|
1140
1135
|
setOpen(false);
|
|
1141
1136
|
}
|
|
1142
|
-
return /* @__PURE__ */ (0,
|
|
1143
|
-
/* @__PURE__ */ (0,
|
|
1137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1138
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1144
1139
|
WalletIcon,
|
|
1145
1140
|
{
|
|
1146
1141
|
iconReactNode: IconGoogle(),
|
|
@@ -1149,7 +1144,7 @@ function Web3Services({
|
|
|
1149
1144
|
loading
|
|
1150
1145
|
}
|
|
1151
1146
|
),
|
|
1152
|
-
/* @__PURE__ */ (0,
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1153
1148
|
WalletIcon,
|
|
1154
1149
|
{
|
|
1155
1150
|
iconReactNode: IconDiscord(),
|
|
@@ -1158,7 +1153,7 @@ function Web3Services({
|
|
|
1158
1153
|
loading
|
|
1159
1154
|
}
|
|
1160
1155
|
),
|
|
1161
|
-
/* @__PURE__ */ (0,
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1162
1157
|
WalletIcon,
|
|
1163
1158
|
{
|
|
1164
1159
|
iconReactNode: IconTwitter(),
|
|
@@ -1171,34 +1166,33 @@ function Web3Services({
|
|
|
1171
1166
|
}
|
|
1172
1167
|
|
|
1173
1168
|
// src/cardano-wallet/screen-main.tsx
|
|
1174
|
-
var
|
|
1169
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1175
1170
|
function ScreenMain({
|
|
1176
1171
|
injectFn,
|
|
1177
1172
|
setOpen,
|
|
1178
1173
|
setScreen,
|
|
1179
1174
|
persist,
|
|
1180
|
-
cardanoPeerConnect,
|
|
1181
1175
|
burnerWallet,
|
|
1182
1176
|
webauthn,
|
|
1183
1177
|
showDownload,
|
|
1184
1178
|
web3Services
|
|
1185
1179
|
}) {
|
|
1186
1180
|
const wallets = useWalletList({ injectFn });
|
|
1187
|
-
const { connect
|
|
1188
|
-
return /* @__PURE__ */ (0,
|
|
1189
|
-
wallets.map((wallet, index) => /* @__PURE__ */ (0,
|
|
1181
|
+
const { connect } = useWallet();
|
|
1182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "mesh-grid mesh-gap-4 mesh-py-4 mesh-grid-cols-5 mesh-place-items-center mesh-gap-y-8", children: [
|
|
1183
|
+
wallets.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1190
1184
|
WalletIcon,
|
|
1191
1185
|
{
|
|
1192
1186
|
icon: wallet.icon,
|
|
1193
1187
|
name: wallet.name,
|
|
1194
1188
|
action: () => {
|
|
1195
|
-
|
|
1189
|
+
connect(wallet.id, persist);
|
|
1196
1190
|
setOpen(false);
|
|
1197
1191
|
}
|
|
1198
1192
|
},
|
|
1199
1193
|
index
|
|
1200
1194
|
)),
|
|
1201
|
-
web3Services && /* @__PURE__ */ (0,
|
|
1195
|
+
web3Services && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1202
1196
|
Web3Services,
|
|
1203
1197
|
{
|
|
1204
1198
|
options: web3Services,
|
|
@@ -1206,7 +1200,7 @@ function ScreenMain({
|
|
|
1206
1200
|
persist
|
|
1207
1201
|
}
|
|
1208
1202
|
),
|
|
1209
|
-
webauthn && /* @__PURE__ */ (0,
|
|
1203
|
+
webauthn && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1210
1204
|
WalletIcon,
|
|
1211
1205
|
{
|
|
1212
1206
|
iconReactNode: IconFingerprint(),
|
|
@@ -1216,17 +1210,7 @@ function ScreenMain({
|
|
|
1216
1210
|
}
|
|
1217
1211
|
}
|
|
1218
1212
|
),
|
|
1219
|
-
|
|
1220
|
-
WalletIcon,
|
|
1221
|
-
{
|
|
1222
|
-
iconReactNode: IconMonitorSmartphone(),
|
|
1223
|
-
name: screens.p2p.title,
|
|
1224
|
-
action: () => {
|
|
1225
|
-
setScreen("p2p");
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
),
|
|
1229
|
-
burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1213
|
+
burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1230
1214
|
WalletIcon,
|
|
1231
1215
|
{
|
|
1232
1216
|
iconReactNode: IconBookDashed(),
|
|
@@ -1236,7 +1220,7 @@ function ScreenMain({
|
|
|
1236
1220
|
}
|
|
1237
1221
|
}
|
|
1238
1222
|
),
|
|
1239
|
-
showDownload && /* @__PURE__ */ (0,
|
|
1223
|
+
showDownload && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1240
1224
|
WalletIcon,
|
|
1241
1225
|
{
|
|
1242
1226
|
iconReactNode: IconDownload(),
|
|
@@ -1252,79 +1236,16 @@ function ScreenMain({
|
|
|
1252
1236
|
] }) });
|
|
1253
1237
|
}
|
|
1254
1238
|
|
|
1255
|
-
// src/cardano-wallet/screen-p2p.tsx
|
|
1256
|
-
var import_react12 = require("react");
|
|
1257
|
-
var import_cardano_peer_connect = require("@fabianbormann/cardano-peer-connect");
|
|
1258
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1259
|
-
function ScreenP2P({
|
|
1260
|
-
cardanoPeerConnect,
|
|
1261
|
-
setOpen
|
|
1262
|
-
}) {
|
|
1263
|
-
const dAppConnect = (0, import_react12.useRef)(null);
|
|
1264
|
-
const qrCodeField = (0, import_react12.useRef)(null);
|
|
1265
|
-
const [address, setAddress] = (0, import_react12.useState)("");
|
|
1266
|
-
const [copied, setCopied] = (0, import_react12.useState)(false);
|
|
1267
|
-
const { connect: connect2 } = useWallet();
|
|
1268
|
-
(0, import_react12.useEffect)(() => {
|
|
1269
|
-
if (cardanoPeerConnect) {
|
|
1270
|
-
if (dAppConnect.current === null) {
|
|
1271
|
-
dAppConnect.current = new import_cardano_peer_connect.DAppPeerConnect({
|
|
1272
|
-
dAppInfo: {
|
|
1273
|
-
name: cardanoPeerConnect.dAppInfo.name,
|
|
1274
|
-
url: cardanoPeerConnect.dAppInfo.url
|
|
1275
|
-
},
|
|
1276
|
-
announce: cardanoPeerConnect.announce,
|
|
1277
|
-
onApiInject: async (name, address2) => {
|
|
1278
|
-
await connect2(name);
|
|
1279
|
-
setOpen(false);
|
|
1280
|
-
},
|
|
1281
|
-
onApiEject: (name, address2) => {
|
|
1282
|
-
},
|
|
1283
|
-
onConnect: (address2, walletInfo) => {
|
|
1284
|
-
},
|
|
1285
|
-
onDisconnect: () => {
|
|
1286
|
-
},
|
|
1287
|
-
verifyConnection: (walletInfo, callback) => {
|
|
1288
|
-
callback(true, true);
|
|
1289
|
-
},
|
|
1290
|
-
useWalletDiscovery: true
|
|
1291
|
-
});
|
|
1292
|
-
if (dAppConnect.current) {
|
|
1293
|
-
const address2 = dAppConnect.current.getAddress();
|
|
1294
|
-
setAddress(address2);
|
|
1295
|
-
if (qrCodeField.current !== null) {
|
|
1296
|
-
dAppConnect.current.generateQRCode(qrCodeField.current);
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}, []);
|
|
1302
|
-
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mesh-flex mesh-flex-col mesh-items-center mesh-justify-center", children: [
|
|
1303
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { marginTop: 16, marginBottom: 16 }, ref: qrCodeField }),
|
|
1304
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1305
|
-
Button,
|
|
1306
|
-
{
|
|
1307
|
-
variant: "outline",
|
|
1308
|
-
onClick: () => {
|
|
1309
|
-
navigator.clipboard.writeText(address);
|
|
1310
|
-
setCopied(true);
|
|
1311
|
-
},
|
|
1312
|
-
children: copied ? "Copied" : "Copy Address"
|
|
1313
|
-
}
|
|
1314
|
-
)
|
|
1315
|
-
] });
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
1239
|
// src/cardano-wallet/screen-webauthn.tsx
|
|
1319
|
-
var
|
|
1320
|
-
var
|
|
1240
|
+
var import_react12 = require("react");
|
|
1241
|
+
var import_wallet5 = require("@meshsdk/wallet");
|
|
1321
1242
|
|
|
1322
1243
|
// src/common/input.tsx
|
|
1323
1244
|
var React5 = __toESM(require("react"), 1);
|
|
1324
|
-
var
|
|
1245
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1325
1246
|
var Input = React5.forwardRef(
|
|
1326
1247
|
({ className, type, ...props }, ref) => {
|
|
1327
|
-
return /* @__PURE__ */ (0,
|
|
1248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1328
1249
|
"input",
|
|
1329
1250
|
{
|
|
1330
1251
|
type,
|
|
@@ -1344,11 +1265,11 @@ Input.displayName = "Input";
|
|
|
1344
1265
|
var React6 = __toESM(require("react"), 1);
|
|
1345
1266
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
|
|
1346
1267
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1347
|
-
var
|
|
1268
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1348
1269
|
var labelVariants = (0, import_class_variance_authority2.cva)(
|
|
1349
1270
|
"mesh-text-sm mesh-font-medium mesh-leading-none peer-disabled:mesh-cursor-not-allowed peer-disabled:mesh-opacity-70"
|
|
1350
1271
|
);
|
|
1351
|
-
var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
1272
|
+
var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1352
1273
|
LabelPrimitive.Root,
|
|
1353
1274
|
{
|
|
1354
1275
|
ref,
|
|
@@ -1359,44 +1280,46 @@ var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
1359
1280
|
Label2.displayName = LabelPrimitive.Root.displayName;
|
|
1360
1281
|
|
|
1361
1282
|
// src/cardano-wallet/screen-webauthn.tsx
|
|
1362
|
-
var
|
|
1283
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1363
1284
|
function ScreenWebauthn({
|
|
1364
1285
|
url,
|
|
1365
1286
|
networkId,
|
|
1366
1287
|
provider,
|
|
1367
1288
|
setOpen
|
|
1368
1289
|
}) {
|
|
1369
|
-
const [loading, setLoading] = (0,
|
|
1370
|
-
const [userName, setUserName] = (0,
|
|
1371
|
-
const [password, setPassword] = (0,
|
|
1290
|
+
const [loading, setLoading] = (0, import_react12.useState)(false);
|
|
1291
|
+
const [userName, setUserName] = (0, import_react12.useState)("");
|
|
1292
|
+
const [password, setPassword] = (0, import_react12.useState)("");
|
|
1372
1293
|
const { setWallet } = useWallet();
|
|
1373
|
-
function createWallet(root) {
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
setWallet(wallet, screens.webauthn.title);
|
|
1385
|
-
setLoading(false);
|
|
1386
|
-
setOpen(false);
|
|
1387
|
-
}, 500);
|
|
1294
|
+
async function createWallet(root) {
|
|
1295
|
+
const wallet = await import_wallet5.MeshCardanoHeadlessWallet.fromBip32Root({
|
|
1296
|
+
bech32: root,
|
|
1297
|
+
networkId,
|
|
1298
|
+
walletAddressType: import_wallet5.AddressType.Base,
|
|
1299
|
+
fetcher: provider,
|
|
1300
|
+
submitter: provider
|
|
1301
|
+
});
|
|
1302
|
+
setWallet(wallet, screens.webauthn.title);
|
|
1303
|
+
setLoading(false);
|
|
1304
|
+
setOpen(false);
|
|
1388
1305
|
}
|
|
1389
1306
|
async function handleConnect() {
|
|
1390
1307
|
setLoading(true);
|
|
1391
|
-
const
|
|
1392
|
-
if (
|
|
1393
|
-
|
|
1308
|
+
const connectModule = await import("@meshsdk/wallet");
|
|
1309
|
+
if (typeof connectModule.connect === "function") {
|
|
1310
|
+
const res = await connectModule.connect({ username: userName, password, serverUrl: url });
|
|
1311
|
+
if (res.success && res.wallet) {
|
|
1312
|
+
await createWallet(res.wallet.bech32PrivateKey);
|
|
1313
|
+
}
|
|
1314
|
+
} else {
|
|
1315
|
+
console.error("WebAuthn connect is not available in this version of @meshsdk/wallet");
|
|
1316
|
+
setLoading(false);
|
|
1394
1317
|
}
|
|
1395
1318
|
}
|
|
1396
|
-
return /* @__PURE__ */ (0,
|
|
1397
|
-
/* @__PURE__ */ (0,
|
|
1398
|
-
/* @__PURE__ */ (0,
|
|
1399
|
-
/* @__PURE__ */ (0,
|
|
1319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mesh-flex mesh-flex-row mesh-flex-gap-4 mesh-items-center mesh-justify-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: "Connecting wallet..." }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "mesh-flex mesh-flex-col mesh-gap-6 mesh-w-full mesh-mx-8", children: [
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "mesh-grid mesh-gap-2", children: [
|
|
1321
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Label2, { htmlFor: "username", children: "Username" }),
|
|
1322
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1400
1323
|
Input,
|
|
1401
1324
|
{
|
|
1402
1325
|
id: "username",
|
|
@@ -1406,11 +1329,11 @@ function ScreenWebauthn({
|
|
|
1406
1329
|
onChange: (e) => setUserName(e.target.value)
|
|
1407
1330
|
}
|
|
1408
1331
|
),
|
|
1409
|
-
/* @__PURE__ */ (0,
|
|
1332
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Unique to the application you are connecting." })
|
|
1410
1333
|
] }),
|
|
1411
|
-
/* @__PURE__ */ (0,
|
|
1412
|
-
/* @__PURE__ */ (0,
|
|
1413
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "mesh-grid mesh-gap-2", children: [
|
|
1335
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mesh-flex mesh-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Label2, { htmlFor: "password", children: "Unique Code" }) }),
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1414
1337
|
Input,
|
|
1415
1338
|
{
|
|
1416
1339
|
id: "password",
|
|
@@ -1420,9 +1343,9 @@ function ScreenWebauthn({
|
|
|
1420
1343
|
onChange: (e) => setPassword(e.target.value)
|
|
1421
1344
|
}
|
|
1422
1345
|
),
|
|
1423
|
-
/* @__PURE__ */ (0,
|
|
1346
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Additional security to derive your wallet." })
|
|
1424
1347
|
] }),
|
|
1425
|
-
/* @__PURE__ */ (0,
|
|
1348
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1426
1349
|
Button,
|
|
1427
1350
|
{
|
|
1428
1351
|
className: "mesh-w-full",
|
|
@@ -1435,62 +1358,53 @@ function ScreenWebauthn({
|
|
|
1435
1358
|
}
|
|
1436
1359
|
|
|
1437
1360
|
// src/cardano-wallet/index.tsx
|
|
1438
|
-
var
|
|
1361
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1439
1362
|
var CardanoWallet = ({
|
|
1440
1363
|
label = "Connect Wallet",
|
|
1441
1364
|
onConnected = void 0,
|
|
1442
1365
|
isDark = false,
|
|
1443
1366
|
persist = false,
|
|
1444
1367
|
injectFn = void 0,
|
|
1445
|
-
cardanoPeerConnect = void 0,
|
|
1446
1368
|
burnerWallet = void 0,
|
|
1447
1369
|
webauthn = void 0,
|
|
1448
1370
|
showDownload = true,
|
|
1449
1371
|
web3Services = void 0
|
|
1450
1372
|
}) => {
|
|
1451
|
-
const [open, setOpen] = (0,
|
|
1452
|
-
const [screen, setScreen] = (0,
|
|
1373
|
+
const [open, setOpen] = (0, import_react13.useState)(false);
|
|
1374
|
+
const [screen, setScreen] = (0, import_react13.useState)("main");
|
|
1453
1375
|
const { wallet, connected, setPersist, setWeb3Services } = useWallet();
|
|
1454
|
-
(0,
|
|
1376
|
+
(0, import_react13.useEffect)(() => {
|
|
1455
1377
|
setPersist(persist);
|
|
1456
1378
|
if (web3Services) setWeb3Services(web3Services);
|
|
1457
|
-
}, []);
|
|
1458
|
-
(0,
|
|
1379
|
+
}, [persist, web3Services, setPersist, setWeb3Services]);
|
|
1380
|
+
(0, import_react13.useEffect)(() => {
|
|
1459
1381
|
if (connected) {
|
|
1460
1382
|
if (onConnected) onConnected();
|
|
1461
1383
|
}
|
|
1462
1384
|
}, [connected, wallet]);
|
|
1463
|
-
return /* @__PURE__ */ (0,
|
|
1464
|
-
/* @__PURE__ */ (0,
|
|
1465
|
-
/* @__PURE__ */ (0,
|
|
1385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
|
|
1386
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: isDark ? "mesh-dark" : "", children: !connected ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "outline", className: isDark ? "mesh-dark" : "", children: label }) }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ConnectedButton, {}) }),
|
|
1387
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1466
1388
|
DialogContent,
|
|
1467
1389
|
{
|
|
1468
1390
|
className: "sm:mesh-max-w-[425px] mesh-dark",
|
|
1469
1391
|
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
1470
1392
|
children: [
|
|
1471
|
-
/* @__PURE__ */ (0,
|
|
1472
|
-
screen == "main" && /* @__PURE__ */ (0,
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Header, { screen, setScreen }),
|
|
1394
|
+
screen == "main" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1473
1395
|
ScreenMain,
|
|
1474
1396
|
{
|
|
1475
1397
|
injectFn,
|
|
1476
1398
|
setOpen,
|
|
1477
1399
|
setScreen,
|
|
1478
1400
|
persist,
|
|
1479
|
-
cardanoPeerConnect: cardanoPeerConnect != void 0,
|
|
1480
1401
|
burnerWallet: burnerWallet != void 0,
|
|
1481
1402
|
webauthn: webauthn != void 0,
|
|
1482
1403
|
showDownload,
|
|
1483
1404
|
web3Services
|
|
1484
1405
|
}
|
|
1485
1406
|
),
|
|
1486
|
-
screen == "
|
|
1487
|
-
ScreenP2P,
|
|
1488
|
-
{
|
|
1489
|
-
cardanoPeerConnect,
|
|
1490
|
-
setOpen
|
|
1491
|
-
}
|
|
1492
|
-
),
|
|
1493
|
-
screen == "burner" && burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1407
|
+
screen == "burner" && burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1494
1408
|
ScreenBurner,
|
|
1495
1409
|
{
|
|
1496
1410
|
networkId: burnerWallet.networkId,
|
|
@@ -1498,7 +1412,7 @@ var CardanoWallet = ({
|
|
|
1498
1412
|
setOpen
|
|
1499
1413
|
}
|
|
1500
1414
|
),
|
|
1501
|
-
screen == "webauthn" && webauthn && /* @__PURE__ */ (0,
|
|
1415
|
+
screen == "webauthn" && webauthn && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1502
1416
|
ScreenWebauthn,
|
|
1503
1417
|
{
|
|
1504
1418
|
url: webauthn.url,
|
|
@@ -1507,7 +1421,7 @@ var CardanoWallet = ({
|
|
|
1507
1421
|
setOpen
|
|
1508
1422
|
}
|
|
1509
1423
|
),
|
|
1510
|
-
/* @__PURE__ */ (0,
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Footer, {})
|
|
1511
1425
|
]
|
|
1512
1426
|
}
|
|
1513
1427
|
)
|
|
@@ -1517,25 +1431,33 @@ function Header({
|
|
|
1517
1431
|
screen,
|
|
1518
1432
|
setScreen
|
|
1519
1433
|
}) {
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
/* @__PURE__ */ (0,
|
|
1524
|
-
|
|
1434
|
+
const screenData = screens[screen];
|
|
1435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogHeader, { children: [
|
|
1436
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(DialogTitle, { className: "mesh-flex mesh-justify-between", children: [
|
|
1437
|
+
screen !== "main" ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1438
|
+
"button",
|
|
1439
|
+
{
|
|
1440
|
+
onClick: () => setScreen("main"),
|
|
1441
|
+
"aria-label": "Back to wallet selection",
|
|
1442
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(IconChevronRight, {})
|
|
1443
|
+
}
|
|
1444
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { width: "24px" } }),
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "mesh-text-white", children: screenData.title }),
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { width: "24px" } })
|
|
1525
1447
|
] }),
|
|
1526
|
-
/* @__PURE__ */ (0,
|
|
1448
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogDescription, { children: screenData.subtitle && screenData.subtitle })
|
|
1527
1449
|
] });
|
|
1528
1450
|
}
|
|
1529
1451
|
function Footer() {
|
|
1530
|
-
return /* @__PURE__ */ (0,
|
|
1452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(DialogFooter, { className: "mesh-justify-center mesh-text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1531
1453
|
"a",
|
|
1532
1454
|
{
|
|
1533
1455
|
href: "https://meshjs.dev/",
|
|
1534
1456
|
target: "_blank",
|
|
1535
1457
|
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",
|
|
1536
1458
|
children: [
|
|
1537
|
-
/* @__PURE__ */ (0,
|
|
1538
|
-
/* @__PURE__ */ (0,
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "", children: "Powered by" }),
|
|
1460
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1539
1461
|
"svg",
|
|
1540
1462
|
{
|
|
1541
1463
|
width: 24,
|
|
@@ -1543,31 +1465,31 @@ function Footer() {
|
|
|
1543
1465
|
enableBackground: "new 0 0 300 200",
|
|
1544
1466
|
viewBox: "0 0 300 200",
|
|
1545
1467
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1546
|
-
children: /* @__PURE__ */ (0,
|
|
1468
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("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" })
|
|
1547
1469
|
}
|
|
1548
1470
|
),
|
|
1549
|
-
/* @__PURE__ */ (0,
|
|
1471
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "", children: "Mesh SDK" })
|
|
1550
1472
|
]
|
|
1551
1473
|
}
|
|
1552
1474
|
) });
|
|
1553
1475
|
}
|
|
1554
1476
|
|
|
1555
1477
|
// src/mesh-badge/mesh-logo.tsx
|
|
1556
|
-
var
|
|
1557
|
-
var MeshLogo = () => /* @__PURE__ */ (0,
|
|
1478
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1479
|
+
var MeshLogo = () => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1558
1480
|
"svg",
|
|
1559
1481
|
{
|
|
1560
1482
|
className: "mesh-h-16 mesh-p-2",
|
|
1561
1483
|
fill: "currentColor",
|
|
1562
1484
|
viewBox: "0 0 300 200",
|
|
1563
1485
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1564
|
-
children: /* @__PURE__ */ (0,
|
|
1486
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("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" })
|
|
1565
1487
|
}
|
|
1566
1488
|
);
|
|
1567
1489
|
|
|
1568
1490
|
// src/mesh-badge/index.tsx
|
|
1569
|
-
var
|
|
1570
|
-
var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0,
|
|
1491
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1492
|
+
var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1571
1493
|
"a",
|
|
1572
1494
|
{
|
|
1573
1495
|
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`}`,
|
|
@@ -1579,15 +1501,22 @@ var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0, import_jsx_runtime25
|
|
|
1579
1501
|
rel: "noopener noreferrer",
|
|
1580
1502
|
target: "_blank",
|
|
1581
1503
|
children: [
|
|
1582
|
-
/* @__PURE__ */ (0,
|
|
1504
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(MeshLogo, {}),
|
|
1583
1505
|
"Mesh"
|
|
1584
1506
|
]
|
|
1585
1507
|
}
|
|
1586
1508
|
);
|
|
1509
|
+
|
|
1510
|
+
// src/index.ts
|
|
1511
|
+
var import_wallet6 = require("@meshsdk/wallet");
|
|
1587
1512
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1588
1513
|
0 && (module.exports = {
|
|
1514
|
+
CardanoBrowserWallet,
|
|
1515
|
+
CardanoHeadlessWallet,
|
|
1589
1516
|
CardanoWallet,
|
|
1590
1517
|
MeshBadge,
|
|
1518
|
+
MeshCardanoBrowserWallet,
|
|
1519
|
+
MeshCardanoHeadlessWallet,
|
|
1591
1520
|
MeshProvider,
|
|
1592
1521
|
WalletContext,
|
|
1593
1522
|
useAddress,
|