@meshsdk/react 1.9.0-beta.5 → 1.9.0-beta.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -23443,7 +23443,6 @@ __export(index_exports, {
23443
23443
  CardanoWallet: () => CardanoWallet,
23444
23444
  MeshBadge: () => MeshBadge,
23445
23445
  MeshProvider: () => MeshProvider,
23446
- StakeButton: () => StakeButton,
23447
23446
  WalletContext: () => WalletContext,
23448
23447
  useAddress: () => useAddress,
23449
23448
  useAssets: () => useAssets,
@@ -23457,7 +23456,7 @@ __export(index_exports, {
23457
23456
  module.exports = __toCommonJS(index_exports);
23458
23457
 
23459
23458
  // src/cardano-wallet/index.tsx
23460
- var import_react13 = require("react");
23459
+ var import_react14 = require("react");
23461
23460
 
23462
23461
  // src/common/button.tsx
23463
23462
  var React = __toESM(require("react"), 1);
@@ -23638,6 +23637,7 @@ var import_react2 = require("react");
23638
23637
  // src/contexts/WalletContext.ts
23639
23638
  var import_react = require("react");
23640
23639
  var import_wallet = require("@meshsdk/wallet");
23640
+ var import_web3_sdk = require("@meshsdk/web3-sdk");
23641
23641
  var INITIAL_STATE = {
23642
23642
  walletName: void 0,
23643
23643
  walletInstance: {}
@@ -23651,11 +23651,16 @@ var useWalletStore = () => {
23651
23651
  const [address, setAddress] = (0, import_react.useState)("");
23652
23652
  const [connectedWalletInstance, setConnectedWalletInstance] = (0, import_react.useState)(INITIAL_STATE.walletInstance);
23653
23653
  const [connectedWalletName, setConnectedWalletName] = (0, import_react.useState)(INITIAL_STATE.walletName);
23654
+ const [web3Services, setWeb3Services] = (0, import_react.useState)(void 0);
23655
+ const [web3UserData, setWeb3UserData] = (0, import_react.useState)(
23656
+ void 0
23657
+ );
23654
23658
  const connectWallet = (0, import_react.useCallback)(
23655
- async (walletName, extensions, persist) => {
23659
+ async (walletName, persist) => {
23656
23660
  setConnectingWallet(true);
23657
23661
  setState("CONNECTING" /* CONNECTING */);
23658
23662
  try {
23663
+ const extensions = import_wallet.BrowserWallet.getSupportedExtensions(walletName);
23659
23664
  const walletInstance = await import_wallet.BrowserWallet.enable(
23660
23665
  walletName,
23661
23666
  extensions
@@ -23687,10 +23692,16 @@ var useWalletStore = () => {
23687
23692
  localStorage.removeItem(localstoragePersist);
23688
23693
  }, []);
23689
23694
  const setWallet = (0, import_react.useCallback)(
23690
- async (walletInstance, walletName) => {
23695
+ async (walletInstance, walletName, persist) => {
23691
23696
  setConnectedWalletInstance(walletInstance);
23692
23697
  setConnectedWalletName(walletName);
23693
23698
  setState("CONNECTED" /* CONNECTED */);
23699
+ if (persist) {
23700
+ localStorage.setItem(
23701
+ localstoragePersist,
23702
+ JSON.stringify({ walletName, ...persist })
23703
+ );
23704
+ }
23694
23705
  },
23695
23706
  []
23696
23707
  );
@@ -23714,7 +23725,23 @@ var useWalletStore = () => {
23714
23725
  const persist2 = JSON.parse(
23715
23726
  localStorage.getItem(localstoragePersist) || ""
23716
23727
  );
23717
- connectWallet(persist2.walletName);
23728
+ if (persist2.walletName == "Mesh Web3 Services" && web3Services) {
23729
+ import_web3_sdk.Web3Wallet.initWallet({
23730
+ networkId: web3Services.networkId,
23731
+ address: persist2.walletAddress,
23732
+ fetcher: web3Services.fetcher,
23733
+ submitter: web3Services.submitter,
23734
+ projectId: web3Services.projectId,
23735
+ appUrl: web3Services.appUrl
23736
+ }).then((wallet) => {
23737
+ setConnectedWalletInstance(wallet);
23738
+ setConnectedWalletName(persist2.walletName);
23739
+ setState("CONNECTED" /* CONNECTED */);
23740
+ });
23741
+ setWeb3UserData(persist2.user);
23742
+ } else {
23743
+ connectWallet(persist2.walletName);
23744
+ }
23718
23745
  }
23719
23746
  }, [persistSession]);
23720
23747
  return {
@@ -23726,6 +23753,9 @@ var useWalletStore = () => {
23726
23753
  disconnect,
23727
23754
  setWallet,
23728
23755
  setPersist,
23756
+ setWeb3Services,
23757
+ web3UserData,
23758
+ setWeb3UserData,
23729
23759
  error,
23730
23760
  address,
23731
23761
  state
@@ -23744,6 +23774,11 @@ var WalletContext = (0, import_react.createContext)({
23744
23774
  },
23745
23775
  setPersist: () => {
23746
23776
  },
23777
+ setWeb3Services: () => {
23778
+ },
23779
+ web3UserData: void 0,
23780
+ setWeb3UserData: () => {
23781
+ },
23747
23782
  address: "",
23748
23783
  state: "NOT_CONNECTED" /* NOT_CONNECTED */
23749
23784
  });
@@ -23865,6 +23900,9 @@ var useWallet = () => {
23865
23900
  disconnect,
23866
23901
  setWallet,
23867
23902
  setPersist,
23903
+ setWeb3Services,
23904
+ web3UserData,
23905
+ setWeb3UserData,
23868
23906
  error,
23869
23907
  address,
23870
23908
  state
@@ -23883,6 +23921,9 @@ var useWallet = () => {
23883
23921
  disconnect,
23884
23922
  setWallet,
23885
23923
  setPersist,
23924
+ setWeb3Services,
23925
+ web3UserData,
23926
+ setWeb3UserData,
23886
23927
  error,
23887
23928
  address,
23888
23929
  state
@@ -24055,7 +24096,7 @@ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
24055
24096
  // src/cardano-wallet/connected-button.tsx
24056
24097
  var import_jsx_runtime6 = require("react/jsx-runtime");
24057
24098
  function ConnectedButton() {
24058
- const { wallet, connected, disconnect, address } = useWallet();
24099
+ const { name, disconnect, address } = useWallet();
24059
24100
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenu, { children: [
24060
24101
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Button, { variant: "outline", children: [
24061
24102
  address.slice(0, 6),
@@ -24063,6 +24104,7 @@ function ConnectedButton() {
24063
24104
  address.slice(-6)
24064
24105
  ] }) }),
24065
24106
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenuContent, { children: [
24107
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuLabel, { children: "Wallet" }),
24066
24108
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
24067
24109
  DropdownMenuItem,
24068
24110
  {
@@ -24072,6 +24114,16 @@ function ConnectedButton() {
24072
24114
  children: "Copy Address"
24073
24115
  }
24074
24116
  ),
24117
+ name == "Mesh Web3 Services" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
24118
+ DropdownMenuItem,
24119
+ {
24120
+ onClick: () => {
24121
+ window.open("https://web3.meshjs.dev/dashboard", "_blank");
24122
+ },
24123
+ children: "Open Web3 Wallet"
24124
+ }
24125
+ ),
24126
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuSeparator, {}),
24075
24127
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
24076
24128
  DropdownMenuItem,
24077
24129
  {
@@ -24241,7 +24293,6 @@ function IconDownload() {
24241
24293
  height: "24px",
24242
24294
  strokeWidth: "1px"
24243
24295
  },
24244
- className: "hover:mesh-fill-white",
24245
24296
  children: [
24246
24297
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
24247
24298
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("polyline", { points: "7 10 12 15 17 10" }),
@@ -24346,7 +24397,8 @@ function WalletIcon({
24346
24397
  icon,
24347
24398
  name,
24348
24399
  action,
24349
- iconReactNode
24400
+ iconReactNode,
24401
+ loading = false
24350
24402
  }) {
24351
24403
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Tooltip, { delayDuration: 0, defaultOpen: false, children: [
24352
24404
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
@@ -24354,9 +24406,11 @@ function WalletIcon({
24354
24406
  {
24355
24407
  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",
24356
24408
  onClick: action,
24409
+ disabled: loading,
24357
24410
  children: [
24358
- icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { src: icon, alt: name, className: "mesh-w-8 mesh-h-8" }),
24359
- iconReactNode && iconReactNode
24411
+ icon && !loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { src: icon, alt: name, className: "mesh-w-8 mesh-h-8" }),
24412
+ !loading && iconReactNode && iconReactNode,
24413
+ loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-black", children: "..." })
24360
24414
  ]
24361
24415
  }
24362
24416
  ) }),
@@ -24364,34 +24418,199 @@ function WalletIcon({
24364
24418
  ] });
24365
24419
  }
24366
24420
 
24367
- // src/cardano-wallet/screen-main.tsx
24421
+ // src/cardano-wallet/web3-services.tsx
24422
+ var import_react11 = require("react");
24423
+ var import_web3_sdk2 = require("@meshsdk/web3-sdk");
24424
+
24425
+ // src/common/icons/icon-discord.tsx
24368
24426
  var import_jsx_runtime14 = require("react/jsx-runtime");
24427
+ function IconDiscord() {
24428
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24429
+ "svg",
24430
+ {
24431
+ viewBox: "0 0 20 20",
24432
+ "aria-hidden": "true",
24433
+ style: {
24434
+ width: "24px",
24435
+ height: "24px"
24436
+ },
24437
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24438
+ "path",
24439
+ {
24440
+ 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",
24441
+ fill: "#5865F2"
24442
+ }
24443
+ )
24444
+ }
24445
+ );
24446
+ }
24447
+
24448
+ // src/common/icons/icon-google.tsx
24449
+ var import_jsx_runtime15 = require("react/jsx-runtime");
24450
+ function IconGoogle() {
24451
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
24452
+ "svg",
24453
+ {
24454
+ viewBox: "0 0 262 262",
24455
+ xmlns: "http://www.w3.org/2000/svg",
24456
+ preserveAspectRatio: "xMidYMid",
24457
+ style: {
24458
+ width: "24px",
24459
+ height: "24px"
24460
+ },
24461
+ children: [
24462
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
24463
+ "path",
24464
+ {
24465
+ 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",
24466
+ fill: "#4285F4"
24467
+ }
24468
+ ),
24469
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
24470
+ "path",
24471
+ {
24472
+ 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",
24473
+ fill: "#34A853"
24474
+ }
24475
+ ),
24476
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
24477
+ "path",
24478
+ {
24479
+ 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",
24480
+ fill: "#FBBC05"
24481
+ }
24482
+ ),
24483
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
24484
+ "path",
24485
+ {
24486
+ 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",
24487
+ fill: "#EB4335"
24488
+ }
24489
+ )
24490
+ ]
24491
+ }
24492
+ );
24493
+ }
24494
+
24495
+ // src/common/icons/icon-twitter.tsx
24496
+ var import_jsx_runtime16 = require("react/jsx-runtime");
24497
+ function IconTwitter() {
24498
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
24499
+ "svg",
24500
+ {
24501
+ xmlns: "http://www.w3.org/2000/svg",
24502
+ version: "1.1",
24503
+ viewBox: "0 0 24 24",
24504
+ style: {
24505
+ width: "24px",
24506
+ height: "24px"
24507
+ },
24508
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.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" })
24509
+ }
24510
+ );
24511
+ }
24512
+
24513
+ // src/cardano-wallet/web3-services.tsx
24514
+ var import_jsx_runtime17 = require("react/jsx-runtime");
24515
+ function Web3Services({
24516
+ options,
24517
+ setOpen,
24518
+ persist
24519
+ }) {
24520
+ const { setWallet, setWeb3UserData } = useWallet();
24521
+ const [loading, setLoading] = (0, import_react11.useState)(false);
24522
+ async function loadWallet(directTo) {
24523
+ setLoading(true);
24524
+ const _options = {
24525
+ networkId: 0,
24526
+ fetcher: options.fetcher,
24527
+ submitter: options.submitter,
24528
+ appUrl: options.appUrl,
24529
+ projectId: options.projectId,
24530
+ directTo
24531
+ };
24532
+ const wallet = await import_web3_sdk2.Web3Wallet.enable(_options);
24533
+ const user = wallet.getUser();
24534
+ setWeb3UserData(user);
24535
+ setWallet(
24536
+ wallet,
24537
+ "Mesh Web3 Services",
24538
+ persist ? {
24539
+ walletAddress: await wallet.getChangeAddress(),
24540
+ user
24541
+ } : void 0
24542
+ );
24543
+ setLoading(false);
24544
+ setOpen(false);
24545
+ }
24546
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
24547
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
24548
+ WalletIcon,
24549
+ {
24550
+ iconReactNode: IconGoogle(),
24551
+ name: `Google`,
24552
+ action: () => loadWallet("google"),
24553
+ loading
24554
+ }
24555
+ ),
24556
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
24557
+ WalletIcon,
24558
+ {
24559
+ iconReactNode: IconDiscord(),
24560
+ name: `Discord`,
24561
+ action: () => loadWallet("discord"),
24562
+ loading
24563
+ }
24564
+ ),
24565
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
24566
+ WalletIcon,
24567
+ {
24568
+ iconReactNode: IconTwitter(),
24569
+ name: `Twitter`,
24570
+ action: () => loadWallet("twitter"),
24571
+ loading
24572
+ }
24573
+ )
24574
+ ] });
24575
+ }
24576
+
24577
+ // src/cardano-wallet/screen-main.tsx
24578
+ var import_jsx_runtime18 = require("react/jsx-runtime");
24369
24579
  function ScreenMain({
24370
24580
  injectFn,
24371
- extensions,
24372
24581
  setOpen,
24373
24582
  setScreen,
24374
24583
  persist,
24375
24584
  cardanoPeerConnect,
24376
24585
  burnerWallet,
24377
- webauthn
24586
+ webauthn,
24587
+ showDownload,
24588
+ web3Services
24378
24589
  }) {
24379
24590
  const wallets = useWalletList({ injectFn });
24380
24591
  const { connect: connect2 } = useWallet();
24381
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "mesh-grid mesh-gap-4 mesh-py-4 mesh-grid-cols-5 mesh-place-items-center mesh-gap-y-8", children: [
24382
- wallets.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24592
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "mesh-grid mesh-gap-4 mesh-py-4 mesh-grid-cols-5 mesh-place-items-center mesh-gap-y-8", children: [
24593
+ wallets.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24383
24594
  WalletIcon,
24384
24595
  {
24385
24596
  icon: wallet.icon,
24386
24597
  name: wallet.name,
24387
24598
  action: () => {
24388
- connect2(wallet.id, extensions, persist);
24599
+ connect2(wallet.id, persist);
24389
24600
  setOpen(false);
24390
24601
  }
24391
24602
  },
24392
24603
  index
24393
24604
  )),
24394
- webauthn && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24605
+ web3Services && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24606
+ Web3Services,
24607
+ {
24608
+ options: web3Services,
24609
+ setOpen,
24610
+ persist
24611
+ }
24612
+ ),
24613
+ webauthn && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24395
24614
  WalletIcon,
24396
24615
  {
24397
24616
  iconReactNode: IconFingerprint(),
@@ -24401,7 +24620,7 @@ function ScreenMain({
24401
24620
  }
24402
24621
  }
24403
24622
  ),
24404
- cardanoPeerConnect && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24623
+ cardanoPeerConnect && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24405
24624
  WalletIcon,
24406
24625
  {
24407
24626
  iconReactNode: IconMonitorSmartphone(),
@@ -24411,7 +24630,7 @@ function ScreenMain({
24411
24630
  }
24412
24631
  }
24413
24632
  ),
24414
- burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24633
+ burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24415
24634
  WalletIcon,
24416
24635
  {
24417
24636
  iconReactNode: IconBookDashed(),
@@ -24421,7 +24640,7 @@ function ScreenMain({
24421
24640
  }
24422
24641
  }
24423
24642
  ),
24424
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
24643
+ showDownload && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24425
24644
  WalletIcon,
24426
24645
  {
24427
24646
  iconReactNode: IconDownload(),
@@ -24438,19 +24657,19 @@ function ScreenMain({
24438
24657
  }
24439
24658
 
24440
24659
  // src/cardano-wallet/screen-p2p.tsx
24441
- var import_react11 = require("react");
24660
+ var import_react12 = require("react");
24442
24661
  var import_cardano_peer_connect = __toESM(require_dist(), 1);
24443
- var import_jsx_runtime15 = require("react/jsx-runtime");
24662
+ var import_jsx_runtime19 = require("react/jsx-runtime");
24444
24663
  function ScreenP2P({
24445
24664
  cardanoPeerConnect,
24446
24665
  setOpen
24447
24666
  }) {
24448
- const dAppConnect = (0, import_react11.useRef)(null);
24449
- const qrCodeField = (0, import_react11.useRef)(null);
24450
- const [address, setAddress] = (0, import_react11.useState)("");
24451
- const [copied, setCopied] = (0, import_react11.useState)(false);
24667
+ const dAppConnect = (0, import_react12.useRef)(null);
24668
+ const qrCodeField = (0, import_react12.useRef)(null);
24669
+ const [address, setAddress] = (0, import_react12.useState)("");
24670
+ const [copied, setCopied] = (0, import_react12.useState)(false);
24452
24671
  const { connect: connect2 } = useWallet();
24453
- (0, import_react11.useEffect)(() => {
24672
+ (0, import_react12.useEffect)(() => {
24454
24673
  if (cardanoPeerConnect) {
24455
24674
  if (dAppConnect.current === null) {
24456
24675
  dAppConnect.current = new import_cardano_peer_connect.DAppPeerConnect({
@@ -24484,9 +24703,9 @@ function ScreenP2P({
24484
24703
  }
24485
24704
  }
24486
24705
  }, []);
24487
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "mesh-flex mesh-flex-col mesh-items-center mesh-justify-center", children: [
24488
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { marginTop: 16, marginBottom: 16 }, ref: qrCodeField }),
24489
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
24706
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "mesh-flex mesh-flex-col mesh-items-center mesh-justify-center", children: [
24707
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { marginTop: 16, marginBottom: 16 }, ref: qrCodeField }),
24708
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24490
24709
  Button,
24491
24710
  {
24492
24711
  variant: "outline",
@@ -24501,15 +24720,15 @@ function ScreenP2P({
24501
24720
  }
24502
24721
 
24503
24722
  // src/cardano-wallet/screen-webauthn.tsx
24504
- var import_react12 = require("react");
24723
+ var import_react13 = require("react");
24505
24724
  var import_wallet4 = require("@meshsdk/wallet");
24506
24725
 
24507
24726
  // src/common/input.tsx
24508
24727
  var React5 = __toESM(require("react"), 1);
24509
- var import_jsx_runtime16 = require("react/jsx-runtime");
24728
+ var import_jsx_runtime20 = require("react/jsx-runtime");
24510
24729
  var Input = React5.forwardRef(
24511
24730
  ({ className, type, ...props }, ref) => {
24512
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
24731
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
24513
24732
  "input",
24514
24733
  {
24515
24734
  type,
@@ -24529,11 +24748,11 @@ Input.displayName = "Input";
24529
24748
  var React6 = __toESM(require("react"), 1);
24530
24749
  var LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
24531
24750
  var import_class_variance_authority2 = require("class-variance-authority");
24532
- var import_jsx_runtime17 = require("react/jsx-runtime");
24751
+ var import_jsx_runtime21 = require("react/jsx-runtime");
24533
24752
  var labelVariants = (0, import_class_variance_authority2.cva)(
24534
24753
  "mesh-text-sm mesh-font-medium mesh-leading-none peer-disabled:mesh-cursor-not-allowed peer-disabled:mesh-opacity-70"
24535
24754
  );
24536
- var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
24755
+ var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
24537
24756
  LabelPrimitive.Root,
24538
24757
  {
24539
24758
  ref,
@@ -24544,16 +24763,16 @@ var Label2 = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
24544
24763
  Label2.displayName = LabelPrimitive.Root.displayName;
24545
24764
 
24546
24765
  // src/cardano-wallet/screen-webauthn.tsx
24547
- var import_jsx_runtime18 = require("react/jsx-runtime");
24766
+ var import_jsx_runtime22 = require("react/jsx-runtime");
24548
24767
  function ScreenWebauthn({
24549
24768
  url,
24550
24769
  networkId,
24551
24770
  provider,
24552
24771
  setOpen
24553
24772
  }) {
24554
- const [loading, setLoading] = (0, import_react12.useState)(false);
24555
- const [userName, setUserName] = (0, import_react12.useState)("");
24556
- const [password, setPassword] = (0, import_react12.useState)("");
24773
+ const [loading, setLoading] = (0, import_react13.useState)(false);
24774
+ const [userName, setUserName] = (0, import_react13.useState)("");
24775
+ const [password, setPassword] = (0, import_react13.useState)("");
24557
24776
  const { setWallet } = useWallet();
24558
24777
  function createWallet(root) {
24559
24778
  setTimeout(() => {
@@ -24578,10 +24797,10 @@ function ScreenWebauthn({
24578
24797
  createWallet(res.wallet.bech32PrivateKey);
24579
24798
  }
24580
24799
  }
24581
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "mesh-flex mesh-flex-row mesh-flex-gap-4 mesh-items-center mesh-justify-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: "Connecting wallet..." }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "mesh-flex mesh-flex-col mesh-gap-6 mesh-w-full mesh-mx-8", children: [
24582
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "mesh-grid mesh-gap-2", children: [
24583
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label2, { htmlFor: "username", children: "Username" }),
24584
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24800
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "mesh-flex mesh-flex-row mesh-flex-gap-4 mesh-items-center mesh-justify-center", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: "Connecting wallet..." }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "mesh-flex mesh-flex-col mesh-gap-6 mesh-w-full mesh-mx-8", children: [
24801
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "mesh-grid mesh-gap-2", children: [
24802
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Label2, { htmlFor: "username", children: "Username" }),
24803
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24585
24804
  Input,
24586
24805
  {
24587
24806
  id: "username",
@@ -24591,11 +24810,11 @@ function ScreenWebauthn({
24591
24810
  onChange: (e2) => setUserName(e2.target.value)
24592
24811
  }
24593
24812
  ),
24594
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Unique to the application you are connecting." })
24813
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Unique to the application you are connecting." })
24595
24814
  ] }),
24596
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "mesh-grid mesh-gap-2", children: [
24597
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "mesh-flex mesh-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label2, { htmlFor: "password", children: "Unique Code" }) }),
24598
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24815
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "mesh-grid mesh-gap-2", children: [
24816
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "mesh-flex mesh-items-center", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Label2, { htmlFor: "password", children: "Unique Code" }) }),
24817
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24599
24818
  Input,
24600
24819
  {
24601
24820
  id: "password",
@@ -24605,9 +24824,9 @@ function ScreenWebauthn({
24605
24824
  onChange: (e2) => setPassword(e2.target.value)
24606
24825
  }
24607
24826
  ),
24608
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Additional security to derive your wallet." })
24827
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "mesh-text-gray-500 mesh-text-xs", children: "Additional security to derive your wallet." })
24609
24828
  ] }),
24610
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
24829
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24611
24830
  Button,
24612
24831
  {
24613
24832
  className: "mesh-w-full",
@@ -24620,59 +24839,62 @@ function ScreenWebauthn({
24620
24839
  }
24621
24840
 
24622
24841
  // src/cardano-wallet/index.tsx
24623
- var import_jsx_runtime19 = require("react/jsx-runtime");
24842
+ var import_jsx_runtime23 = require("react/jsx-runtime");
24624
24843
  var CardanoWallet = ({
24625
24844
  label = "Connect Wallet",
24626
24845
  onConnected = void 0,
24627
24846
  isDark = false,
24628
24847
  persist = false,
24629
- extensions = [],
24630
24848
  injectFn = void 0,
24631
24849
  cardanoPeerConnect = void 0,
24632
24850
  burnerWallet = void 0,
24633
- webauthn = void 0
24851
+ webauthn = void 0,
24852
+ showDownload = true,
24853
+ web3Services = void 0
24634
24854
  }) => {
24635
- const [open, setOpen] = (0, import_react13.useState)(false);
24636
- const [screen, setScreen] = (0, import_react13.useState)("main");
24637
- const { wallet, connected, setPersist } = useWallet();
24638
- (0, import_react13.useEffect)(() => {
24855
+ const [open, setOpen] = (0, import_react14.useState)(false);
24856
+ const [screen, setScreen] = (0, import_react14.useState)("main");
24857
+ const { wallet, connected, setPersist, setWeb3Services } = useWallet();
24858
+ (0, import_react14.useEffect)(() => {
24639
24859
  setPersist(persist);
24640
- }, [persist]);
24641
- (0, import_react13.useEffect)(() => {
24860
+ if (web3Services) setWeb3Services(web3Services);
24861
+ }, []);
24862
+ (0, import_react14.useEffect)(() => {
24642
24863
  if (connected) {
24643
24864
  if (onConnected) onConnected();
24644
24865
  }
24645
24866
  }, [connected, wallet]);
24646
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
24647
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: isDark ? "mesh-dark" : "", children: !connected ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "outline", children: label }) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ConnectedButton, {}) }),
24648
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
24867
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
24868
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: isDark ? "mesh-dark" : "", children: !connected ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "outline", className: isDark ? "mesh-dark" : "", children: label }) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ConnectedButton, {}) }),
24869
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24649
24870
  DialogContent,
24650
24871
  {
24651
24872
  className: "sm:mesh-max-w-[425px] mesh-dark",
24652
24873
  onOpenAutoFocus: (event) => event.preventDefault(),
24653
24874
  children: [
24654
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Header, { screen, setScreen }),
24655
- screen == "main" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24875
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Header, { screen, setScreen }),
24876
+ screen == "main" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24656
24877
  ScreenMain,
24657
24878
  {
24658
24879
  injectFn,
24659
- extensions,
24660
24880
  setOpen,
24661
24881
  setScreen,
24662
24882
  persist,
24663
24883
  cardanoPeerConnect: cardanoPeerConnect != void 0,
24664
24884
  burnerWallet: burnerWallet != void 0,
24665
- webauthn: webauthn != void 0
24885
+ webauthn: webauthn != void 0,
24886
+ showDownload,
24887
+ web3Services
24666
24888
  }
24667
24889
  ),
24668
- screen == "p2p" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24890
+ screen == "p2p" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24669
24891
  ScreenP2P,
24670
24892
  {
24671
24893
  cardanoPeerConnect,
24672
24894
  setOpen
24673
24895
  }
24674
24896
  ),
24675
- screen == "burner" && burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24897
+ screen == "burner" && burnerWallet && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24676
24898
  ScreenBurner,
24677
24899
  {
24678
24900
  networkId: burnerWallet.networkId,
@@ -24680,7 +24902,7 @@ var CardanoWallet = ({
24680
24902
  setOpen
24681
24903
  }
24682
24904
  ),
24683
- screen == "webauthn" && webauthn && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24905
+ screen == "webauthn" && webauthn && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24684
24906
  ScreenWebauthn,
24685
24907
  {
24686
24908
  url: webauthn.url,
@@ -24689,7 +24911,7 @@ var CardanoWallet = ({
24689
24911
  setOpen
24690
24912
  }
24691
24913
  ),
24692
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Footer, {})
24914
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Footer, {})
24693
24915
  ]
24694
24916
  }
24695
24917
  )
@@ -24699,25 +24921,25 @@ function Header({
24699
24921
  screen,
24700
24922
  setScreen
24701
24923
  }) {
24702
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(DialogHeader, { children: [
24703
- /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(DialogTitle, { className: "mesh-flex mesh-justify-between", children: [
24704
- screen != "main" ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { onClick: () => setScreen("main"), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IconChevronRight, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { style: { width: "24px" } }),
24705
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: screens[screen].title }),
24706
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { style: { width: "24px" } })
24924
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(DialogHeader, { children: [
24925
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(DialogTitle, { className: "mesh-flex mesh-justify-between", children: [
24926
+ screen != "main" ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { onClick: () => setScreen("main"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconChevronRight, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { style: { width: "24px" } }),
24927
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: screens[screen].title }),
24928
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { style: { width: "24px" } })
24707
24929
  ] }),
24708
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DialogDescription, { children: screens[screen].subtitle && screens[screen].subtitle })
24930
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DialogDescription, { children: screens[screen].subtitle && screens[screen].subtitle })
24709
24931
  ] });
24710
24932
  }
24711
24933
  function Footer() {
24712
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DialogFooter, { className: "mesh-justify-center mesh-text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
24934
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DialogFooter, { className: "mesh-justify-center mesh-text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24713
24935
  "a",
24714
24936
  {
24715
24937
  href: "https://meshjs.dev/",
24716
24938
  target: "_blank",
24717
24939
  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",
24718
24940
  children: [
24719
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "", children: "Powered by" }),
24720
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
24941
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "", children: "Powered by" }),
24942
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
24721
24943
  "svg",
24722
24944
  {
24723
24945
  width: 24,
@@ -24725,31 +24947,31 @@ function Footer() {
24725
24947
  enableBackground: "new 0 0 300 200",
24726
24948
  viewBox: "0 0 300 200",
24727
24949
  xmlns: "http://www.w3.org/2000/svg",
24728
- children: /* @__PURE__ */ (0, import_jsx_runtime19.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" })
24950
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.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" })
24729
24951
  }
24730
24952
  ),
24731
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "", children: "Mesh SDK" })
24953
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "", children: "Mesh SDK" })
24732
24954
  ]
24733
24955
  }
24734
24956
  ) });
24735
24957
  }
24736
24958
 
24737
24959
  // src/mesh-badge/mesh-logo.tsx
24738
- var import_jsx_runtime20 = require("react/jsx-runtime");
24739
- var MeshLogo = () => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
24960
+ var import_jsx_runtime24 = require("react/jsx-runtime");
24961
+ var MeshLogo = () => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
24740
24962
  "svg",
24741
24963
  {
24742
24964
  className: "mesh-h-16 mesh-p-2",
24743
24965
  fill: "currentColor",
24744
24966
  viewBox: "0 0 300 200",
24745
24967
  xmlns: "http://www.w3.org/2000/svg",
24746
- children: /* @__PURE__ */ (0, import_jsx_runtime20.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" })
24968
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.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" })
24747
24969
  }
24748
24970
  );
24749
24971
 
24750
24972
  // src/mesh-badge/index.tsx
24751
- var import_jsx_runtime21 = require("react/jsx-runtime");
24752
- var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
24973
+ var import_jsx_runtime25 = require("react/jsx-runtime");
24974
+ var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
24753
24975
  "a",
24754
24976
  {
24755
24977
  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`}`,
@@ -24761,296 +24983,16 @@ var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0, import_jsx_runtime21
24761
24983
  rel: "noopener noreferrer",
24762
24984
  target: "_blank",
24763
24985
  children: [
24764
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(MeshLogo, {}),
24986
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(MeshLogo, {}),
24765
24987
  "Mesh"
24766
24988
  ]
24767
24989
  }
24768
24990
  );
24769
-
24770
- // src/stake-button/index.tsx
24771
- var import_react15 = require("react");
24772
- var import_transaction = require("@meshsdk/transaction");
24773
-
24774
- // src/cardano-wallet-dropdown/index.tsx
24775
- var import_react14 = require("react");
24776
-
24777
- // src/common/button-dropdown.tsx
24778
- var import_jsx_runtime22 = require("react/jsx-runtime");
24779
- function ButtonDropdown({
24780
- children,
24781
- isDarkMode = false,
24782
- hideMenuList = false,
24783
- setHideMenuList,
24784
- onMouseEnter,
24785
- onMouseLeave
24786
- }) {
24787
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
24788
- "button",
24789
- {
24790
- className: `mesh-mr-menu-list mesh-flex mesh-w-60 mesh-items-center mesh-justify-center mesh-rounded-t-md mesh-border mesh-px-4 mesh-py-2 mesh-text-lg mesh-font-normal mesh-shadow-sm ${isDarkMode ? `mesh-bg-neutral-950 mesh-text-neutral-50` : `mesh-bg-neutral-50 mesh-text-neutral-950`}`,
24791
- onClick: () => setHideMenuList && setHideMenuList(!hideMenuList),
24792
- onMouseEnter,
24793
- onMouseLeave,
24794
- children
24795
- }
24796
- );
24797
- }
24798
-
24799
- // src/cardano-wallet-dropdown/menu-item.tsx
24800
- var import_jsx_runtime23 = require("react/jsx-runtime");
24801
- function MenuItem({
24802
- icon,
24803
- label,
24804
- action,
24805
- active
24806
- }) {
24807
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
24808
- "div",
24809
- {
24810
- className: "mesh-flex mesh-cursor-pointer mesh-items-center mesh-px-4 mesh-py-2 mesh-opacity-80 hover:mesh-opacity-100 mesh-h-16",
24811
- onClick: action,
24812
- children: [
24813
- icon && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("img", { className: "mesh-pr-2 mesh-m-1 mesh-h-8", src: icon }),
24814
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "mesh-mr-menu-item mesh-text-xl mesh-font-normal mesh-text-neutral-700 hover:mesh-text-black", children: label.split(" ").map((word) => {
24815
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
24816
- }).join(" ") })
24817
- ]
24818
- }
24819
- );
24820
- }
24821
-
24822
- // src/cardano-wallet-dropdown/chevron-down.tsx
24823
- var import_jsx_runtime24 = require("react/jsx-runtime");
24824
- var ChevronDown = () => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
24825
- "svg",
24826
- {
24827
- className: "mesh-m-2 mesh-h-6",
24828
- fill: "none",
24829
- "aria-hidden": "true",
24830
- viewBox: "0 0 24 24",
24831
- stroke: "currentColor",
24832
- xmlns: "http://www.w3.org/2000/svg",
24833
- children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
24834
- "path",
24835
- {
24836
- strokeLinecap: "round",
24837
- strokeLinejoin: "round",
24838
- strokeWidth: "2",
24839
- d: "M19 9l-7 7-7-7"
24840
- }
24841
- )
24842
- }
24843
- );
24844
-
24845
- // src/cardano-wallet-dropdown/wallet-balance.tsx
24846
- var import_jsx_runtime25 = require("react/jsx-runtime");
24847
- var WalletBalance = ({
24848
- connected,
24849
- connecting,
24850
- label,
24851
- wallet
24852
- }) => {
24853
- const lovelace = useLovelace();
24854
- return connected && lovelace && wallet?.icon ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
24855
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("img", { className: "mesh-m-2 mesh-h-6", src: wallet.icon }),
24856
- "\u20B3",
24857
- " ",
24858
- parseInt((parseInt(lovelace, 10) / 1e6).toString(), 10),
24859
- ".",
24860
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "mesh-text-xs", children: lovelace.substring(lovelace.length - 6) })
24861
- ] }) : connected && wallet?.icon ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("img", { className: "mesh-m-2 mesh-h-6", src: wallet.icon }) }) : connecting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: "Connecting..." }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
24862
- label,
24863
- " ",
24864
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChevronDown, {})
24865
- ] });
24866
- };
24867
-
24868
- // src/cardano-wallet-dropdown/index.tsx
24869
- var import_jsx_runtime26 = require("react/jsx-runtime");
24870
- var CardanoWallet2 = ({
24871
- label = "Connect Wallet",
24872
- onConnected = void 0,
24873
- isDark = false,
24874
- extensions = [],
24875
- cardanoPeerConnect = void 0
24876
- }) => {
24877
- const [isDarkMode, setIsDarkMode] = (0, import_react14.useState)(false);
24878
- const [hideMenuList, setHideMenuList] = (0, import_react14.useState)(true);
24879
- const { connect: connect2, connecting, connected, disconnect, name } = useWallet();
24880
- const wallets = useWalletList();
24881
- (0, import_react14.useEffect)(() => {
24882
- if (connected && onConnected) {
24883
- onConnected();
24884
- }
24885
- }, [connected]);
24886
- (0, import_react14.useEffect)(() => {
24887
- setIsDarkMode(isDark);
24888
- }, [isDark]);
24889
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
24890
- "div",
24891
- {
24892
- onMouseEnter: () => setHideMenuList(false),
24893
- onMouseLeave: () => setHideMenuList(true),
24894
- style: { width: "min-content", zIndex: 50 },
24895
- children: [
24896
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
24897
- ButtonDropdown,
24898
- {
24899
- isDarkMode,
24900
- hideMenuList,
24901
- setHideMenuList,
24902
- children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
24903
- WalletBalance,
24904
- {
24905
- connected,
24906
- connecting,
24907
- label,
24908
- wallet: wallets.find((wallet) => wallet.id === name)
24909
- }
24910
- )
24911
- }
24912
- ),
24913
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
24914
- "div",
24915
- {
24916
- className: `mesh-mr-menu-list mesh-absolute mesh-w-60 mesh-rounded-b-md mesh-border mesh-text-center mesh-shadow-sm mesh-backdrop-blur ${hideMenuList && "mesh-hidden"} ${isDarkMode ? `mesh-bg-neutral-950 mesh-text-neutral-50` : `mesh-bg-neutral-50 mesh-text-neutral-950`}`,
24917
- style: { zIndex: 50 },
24918
- children: !connected && wallets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: wallets.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
24919
- MenuItem,
24920
- {
24921
- icon: wallet.icon,
24922
- label: wallet.name,
24923
- action: () => {
24924
- connect2(wallet.id, extensions);
24925
- setHideMenuList(!hideMenuList);
24926
- },
24927
- active: name === wallet.id
24928
- },
24929
- index
24930
- )) }) : wallets.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: "No Wallet Found" }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
24931
- MenuItem,
24932
- {
24933
- active: false,
24934
- label: "disconnect",
24935
- action: disconnect,
24936
- icon: void 0
24937
- }
24938
- ) })
24939
- }
24940
- )
24941
- ]
24942
- }
24943
- );
24944
- };
24945
-
24946
- // src/stake-button/index.tsx
24947
- var import_jsx_runtime27 = require("react/jsx-runtime");
24948
- var StakeButton = ({
24949
- label = "Stake your ADA",
24950
- isDark = false,
24951
- poolId,
24952
- onCheck,
24953
- onDelegated = void 0
24954
- }) => {
24955
- const [isDarkMode, setIsDarkMode] = (0, import_react15.useState)(false);
24956
- const { connected } = useWallet();
24957
- (0, import_react15.useEffect)(() => {
24958
- setIsDarkMode(isDark);
24959
- }, [isDark]);
24960
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_jsx_runtime27.Fragment, { children: connected ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ButtonDropdown, { isDarkMode, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
24961
- Delegate,
24962
- {
24963
- poolId,
24964
- onCheck,
24965
- onDelegated
24966
- }
24967
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CardanoWallet2, { label, isDark }) });
24968
- };
24969
- var Delegate = ({
24970
- poolId,
24971
- onCheck,
24972
- onDelegated
24973
- }) => {
24974
- const { wallet } = useWallet();
24975
- const rewardAddress = useRewardAddress();
24976
- const [_, setError] = (0, import_react15.useState)();
24977
- const [checking, setChecking] = (0, import_react15.useState)(false);
24978
- const [accountInfo, setAccountInfo] = (0, import_react15.useState)();
24979
- const [processing, setProcessing] = (0, import_react15.useState)(false);
24980
- const [done, setDone] = (0, import_react15.useState)(false);
24981
- const checkAccountStatus = async () => {
24982
- try {
24983
- setChecking(true);
24984
- if (rewardAddress) {
24985
- const info = await onCheck(rewardAddress);
24986
- setAccountInfo(info);
24987
- }
24988
- setChecking(false);
24989
- } catch (error) {
24990
- setError(error);
24991
- }
24992
- };
24993
- const registerAddress = async () => {
24994
- setProcessing(true);
24995
- setDone(false);
24996
- try {
24997
- if (rewardAddress) {
24998
- const tx = new import_transaction.Transaction({ initiator: wallet }).registerStake(rewardAddress).delegateStake(rewardAddress, poolId);
24999
- const unsignedTx = await tx.build();
25000
- const signedTx = await wallet.signTx(unsignedTx);
25001
- await wallet.submitTx(signedTx);
25002
- if (onDelegated) {
25003
- onDelegated();
25004
- }
25005
- setDone(true);
25006
- }
25007
- } catch (error) {
25008
- setError(error);
25009
- }
25010
- setProcessing(false);
25011
- };
25012
- const delegateStake = async () => {
25013
- setProcessing(true);
25014
- setDone(false);
25015
- try {
25016
- if (rewardAddress) {
25017
- const tx = new import_transaction.Transaction({ initiator: wallet }).delegateStake(rewardAddress, poolId);
25018
- const unsignedTx = await tx.build();
25019
- const signedTx = await wallet.signTx(unsignedTx);
25020
- await wallet.submitTx(signedTx);
25021
- if (onDelegated) {
25022
- onDelegated();
25023
- }
25024
- setDone(true);
25025
- }
25026
- } catch (error) {
25027
- setError(error);
25028
- }
25029
- setProcessing(false);
25030
- };
25031
- (0, import_react15.useEffect)(() => {
25032
- checkAccountStatus();
25033
- }, [rewardAddress]);
25034
- if (checking) {
25035
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Checking..." });
25036
- }
25037
- if (processing) {
25038
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Loading..." });
25039
- }
25040
- if (done) {
25041
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Stake Delegated" });
25042
- }
25043
- if (accountInfo?.active) {
25044
- return accountInfo.poolId === poolId ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Stake Delegated" }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { onClick: delegateStake, children: "Begin Staking" });
25045
- }
25046
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { onClick: registerAddress, children: "Begin Staking" });
25047
- };
25048
24991
  // Annotate the CommonJS export names for ESM import in node:
25049
24992
  0 && (module.exports = {
25050
24993
  CardanoWallet,
25051
24994
  MeshBadge,
25052
24995
  MeshProvider,
25053
- StakeButton,
25054
24996
  WalletContext,
25055
24997
  useAddress,
25056
24998
  useAssets,