@meshsdk/react 1.9.0-beta.42 → 1.9.0-beta.45

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,
@@ -24989,291 +24988,11 @@ var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ (0, import_jsx_runtime25
24989
24988
  ]
24990
24989
  }
24991
24990
  );
24992
-
24993
- // src/stake-button/index.tsx
24994
- var import_react16 = require("react");
24995
- var import_transaction = require("@meshsdk/transaction");
24996
-
24997
- // src/cardano-wallet-dropdown/index.tsx
24998
- var import_react15 = require("react");
24999
-
25000
- // src/common/button-dropdown.tsx
25001
- var import_jsx_runtime26 = require("react/jsx-runtime");
25002
- function ButtonDropdown({
25003
- children,
25004
- isDarkMode = false,
25005
- hideMenuList = false,
25006
- setHideMenuList,
25007
- onMouseEnter,
25008
- onMouseLeave
25009
- }) {
25010
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
25011
- "button",
25012
- {
25013
- 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`}`,
25014
- onClick: () => setHideMenuList && setHideMenuList(!hideMenuList),
25015
- onMouseEnter,
25016
- onMouseLeave,
25017
- children
25018
- }
25019
- );
25020
- }
25021
-
25022
- // src/cardano-wallet-dropdown/menu-item.tsx
25023
- var import_jsx_runtime27 = require("react/jsx-runtime");
25024
- function MenuItem({
25025
- icon,
25026
- label,
25027
- action,
25028
- active
25029
- }) {
25030
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
25031
- "div",
25032
- {
25033
- 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",
25034
- onClick: action,
25035
- children: [
25036
- icon && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { className: "mesh-pr-2 mesh-m-1 mesh-h-8", src: icon }),
25037
- /* @__PURE__ */ (0, import_jsx_runtime27.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) => {
25038
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
25039
- }).join(" ") })
25040
- ]
25041
- }
25042
- );
25043
- }
25044
-
25045
- // src/cardano-wallet-dropdown/chevron-down.tsx
25046
- var import_jsx_runtime28 = require("react/jsx-runtime");
25047
- var ChevronDown = () => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
25048
- "svg",
25049
- {
25050
- className: "mesh-m-2 mesh-h-6",
25051
- fill: "none",
25052
- "aria-hidden": "true",
25053
- viewBox: "0 0 24 24",
25054
- stroke: "currentColor",
25055
- xmlns: "http://www.w3.org/2000/svg",
25056
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
25057
- "path",
25058
- {
25059
- strokeLinecap: "round",
25060
- strokeLinejoin: "round",
25061
- strokeWidth: "2",
25062
- d: "M19 9l-7 7-7-7"
25063
- }
25064
- )
25065
- }
25066
- );
25067
-
25068
- // src/cardano-wallet-dropdown/wallet-balance.tsx
25069
- var import_jsx_runtime29 = require("react/jsx-runtime");
25070
- var WalletBalance = ({
25071
- connected,
25072
- connecting,
25073
- label,
25074
- wallet
25075
- }) => {
25076
- const lovelace = useLovelace();
25077
- return connected && lovelace && wallet?.icon ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
25078
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { className: "mesh-m-2 mesh-h-6", src: wallet.icon }),
25079
- "\u20B3",
25080
- " ",
25081
- parseInt((parseInt(lovelace, 10) / 1e6).toString(), 10),
25082
- ".",
25083
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "mesh-text-xs", children: lovelace.substring(lovelace.length - 6) })
25084
- ] }) : connected && wallet?.icon ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { className: "mesh-m-2 mesh-h-6", src: wallet.icon }) }) : connecting ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, { children: "Connecting..." }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
25085
- label,
25086
- " ",
25087
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChevronDown, {})
25088
- ] });
25089
- };
25090
-
25091
- // src/cardano-wallet-dropdown/index.tsx
25092
- var import_jsx_runtime30 = require("react/jsx-runtime");
25093
- var CardanoWallet2 = ({
25094
- label = "Connect Wallet",
25095
- onConnected = void 0,
25096
- isDark = false,
25097
- extensions = [],
25098
- cardanoPeerConnect = void 0
25099
- }) => {
25100
- const [isDarkMode, setIsDarkMode] = (0, import_react15.useState)(false);
25101
- const [hideMenuList, setHideMenuList] = (0, import_react15.useState)(true);
25102
- const { connect: connect2, connecting, connected, disconnect, name } = useWallet();
25103
- const wallets = useWalletList();
25104
- (0, import_react15.useEffect)(() => {
25105
- if (connected && onConnected) {
25106
- onConnected();
25107
- }
25108
- }, [connected]);
25109
- (0, import_react15.useEffect)(() => {
25110
- setIsDarkMode(isDark);
25111
- }, [isDark]);
25112
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
25113
- "div",
25114
- {
25115
- onMouseEnter: () => setHideMenuList(false),
25116
- onMouseLeave: () => setHideMenuList(true),
25117
- style: { width: "min-content", zIndex: 50 },
25118
- children: [
25119
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
25120
- ButtonDropdown,
25121
- {
25122
- isDarkMode,
25123
- hideMenuList,
25124
- setHideMenuList,
25125
- children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
25126
- WalletBalance,
25127
- {
25128
- connected,
25129
- connecting,
25130
- label,
25131
- wallet: wallets.find((wallet) => wallet.id === name)
25132
- }
25133
- )
25134
- }
25135
- ),
25136
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
25137
- "div",
25138
- {
25139
- 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`}`,
25140
- style: { zIndex: 50 },
25141
- children: !connected && wallets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: wallets.map((wallet, index) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
25142
- MenuItem,
25143
- {
25144
- icon: wallet.icon,
25145
- label: wallet.name,
25146
- action: () => {
25147
- connect2(wallet.id, extensions);
25148
- setHideMenuList(!hideMenuList);
25149
- },
25150
- active: name === wallet.id
25151
- },
25152
- index
25153
- )) }) : wallets.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: "No Wallet Found" }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
25154
- MenuItem,
25155
- {
25156
- active: false,
25157
- label: "disconnect",
25158
- action: disconnect,
25159
- icon: void 0
25160
- }
25161
- ) })
25162
- }
25163
- )
25164
- ]
25165
- }
25166
- );
25167
- };
25168
-
25169
- // src/stake-button/index.tsx
25170
- var import_jsx_runtime31 = require("react/jsx-runtime");
25171
- var StakeButton = ({
25172
- label = "Stake your ADA",
25173
- isDark = false,
25174
- poolId,
25175
- onCheck,
25176
- onDelegated = void 0
25177
- }) => {
25178
- const [isDarkMode, setIsDarkMode] = (0, import_react16.useState)(false);
25179
- const { connected } = useWallet();
25180
- (0, import_react16.useEffect)(() => {
25181
- setIsDarkMode(isDark);
25182
- }, [isDark]);
25183
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: connected ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ButtonDropdown, { isDarkMode, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
25184
- Delegate,
25185
- {
25186
- poolId,
25187
- onCheck,
25188
- onDelegated
25189
- }
25190
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(CardanoWallet2, { label, isDark }) });
25191
- };
25192
- var Delegate = ({
25193
- poolId,
25194
- onCheck,
25195
- onDelegated
25196
- }) => {
25197
- const { wallet } = useWallet();
25198
- const rewardAddress = useRewardAddress();
25199
- const [_, setError] = (0, import_react16.useState)();
25200
- const [checking, setChecking] = (0, import_react16.useState)(false);
25201
- const [accountInfo, setAccountInfo] = (0, import_react16.useState)();
25202
- const [processing, setProcessing] = (0, import_react16.useState)(false);
25203
- const [done, setDone] = (0, import_react16.useState)(false);
25204
- const checkAccountStatus = async () => {
25205
- try {
25206
- setChecking(true);
25207
- if (rewardAddress) {
25208
- const info = await onCheck(rewardAddress);
25209
- setAccountInfo(info);
25210
- }
25211
- setChecking(false);
25212
- } catch (error) {
25213
- setError(error);
25214
- }
25215
- };
25216
- const registerAddress = async () => {
25217
- setProcessing(true);
25218
- setDone(false);
25219
- try {
25220
- if (rewardAddress) {
25221
- const tx = new import_transaction.Transaction({ initiator: wallet }).registerStake(rewardAddress).delegateStake(rewardAddress, poolId);
25222
- const unsignedTx = await tx.build();
25223
- const signedTx = await wallet.signTx(unsignedTx);
25224
- await wallet.submitTx(signedTx);
25225
- if (onDelegated) {
25226
- onDelegated();
25227
- }
25228
- setDone(true);
25229
- }
25230
- } catch (error) {
25231
- setError(error);
25232
- }
25233
- setProcessing(false);
25234
- };
25235
- const delegateStake = async () => {
25236
- setProcessing(true);
25237
- setDone(false);
25238
- try {
25239
- if (rewardAddress) {
25240
- const tx = new import_transaction.Transaction({ initiator: wallet }).delegateStake(rewardAddress, poolId);
25241
- const unsignedTx = await tx.build();
25242
- const signedTx = await wallet.signTx(unsignedTx);
25243
- await wallet.submitTx(signedTx);
25244
- if (onDelegated) {
25245
- onDelegated();
25246
- }
25247
- setDone(true);
25248
- }
25249
- } catch (error) {
25250
- setError(error);
25251
- }
25252
- setProcessing(false);
25253
- };
25254
- (0, import_react16.useEffect)(() => {
25255
- checkAccountStatus();
25256
- }, [rewardAddress]);
25257
- if (checking) {
25258
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: "Checking..." });
25259
- }
25260
- if (processing) {
25261
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: "Loading..." });
25262
- }
25263
- if (done) {
25264
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: "Stake Delegated" });
25265
- }
25266
- if (accountInfo?.active) {
25267
- return accountInfo.poolId === poolId ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: "Stake Delegated" }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { onClick: delegateStake, children: "Begin Staking" });
25268
- }
25269
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { onClick: registerAddress, children: "Begin Staking" });
25270
- };
25271
24991
  // Annotate the CommonJS export names for ESM import in node:
25272
24992
  0 && (module.exports = {
25273
24993
  CardanoWallet,
25274
24994
  MeshBadge,
25275
24995
  MeshProvider,
25276
- StakeButton,
25277
24996
  WalletContext,
25278
24997
  useAddress,
25279
24998
  useAssets,
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _meshsdk_common from '@meshsdk/common';
3
- import { IFetcher, ISubmitter, IWallet, Asset, Wallet, AccountInfo } from '@meshsdk/common';
3
+ import { IFetcher, ISubmitter, IWallet, Asset, Wallet } from '@meshsdk/common';
4
4
  import * as _meshsdk_web3_sdk from '@meshsdk/web3-sdk';
5
5
  import { EnableWeb3WalletOptions, UserSocialData } from '@meshsdk/web3-sdk';
6
6
  import * as react from 'react';
7
7
 
8
- interface ButtonProps$1 {
8
+ interface ButtonProps {
9
9
  label?: string;
10
10
  onConnected?: Function;
11
11
  isDark?: boolean;
@@ -30,7 +30,7 @@ interface ButtonProps$1 {
30
30
  showDownload?: boolean;
31
31
  web3Services?: EnableWeb3WalletOptions;
32
32
  }
33
- declare const CardanoWallet: ({ label, onConnected, isDark, persist, injectFn, cardanoPeerConnect, burnerWallet, webauthn, showDownload, web3Services, }: ButtonProps$1) => react_jsx_runtime.JSX.Element;
33
+ declare const CardanoWallet: ({ label, onConnected, isDark, persist, injectFn, cardanoPeerConnect, burnerWallet, webauthn, showDownload, web3Services, }: ButtonProps) => react_jsx_runtime.JSX.Element;
34
34
 
35
35
  declare enum WalletState {
36
36
  NOT_CONNECTED = "NOT_CONNECTED",
@@ -106,13 +106,4 @@ declare const MeshBadge: ({ isDark }: {
106
106
  isDark?: boolean | undefined;
107
107
  }) => react_jsx_runtime.JSX.Element;
108
108
 
109
- interface ButtonProps {
110
- label?: string;
111
- isDark?: boolean;
112
- poolId: string;
113
- onCheck: (rewardAddress: string) => Promise<AccountInfo>;
114
- onDelegated?: () => void;
115
- }
116
- declare const StakeButton: ({ label, isDark, poolId, onCheck, onDelegated, }: ButtonProps) => react_jsx_runtime.JSX.Element;
117
-
118
- export { CardanoWallet, MeshBadge, MeshProvider, StakeButton, WalletContext, useAddress, useAssets, useLovelace, useNetwork, useRewardAddress, useWallet, useWalletList, useWalletSubmit };
109
+ export { CardanoWallet, MeshBadge, MeshProvider, WalletContext, useAddress, useAssets, useLovelace, useNetwork, useRewardAddress, useWallet, useWalletList, useWalletSubmit };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _meshsdk_common from '@meshsdk/common';
3
- import { IFetcher, ISubmitter, IWallet, Asset, Wallet, AccountInfo } from '@meshsdk/common';
3
+ import { IFetcher, ISubmitter, IWallet, Asset, Wallet } from '@meshsdk/common';
4
4
  import * as _meshsdk_web3_sdk from '@meshsdk/web3-sdk';
5
5
  import { EnableWeb3WalletOptions, UserSocialData } from '@meshsdk/web3-sdk';
6
6
  import * as react from 'react';
7
7
 
8
- interface ButtonProps$1 {
8
+ interface ButtonProps {
9
9
  label?: string;
10
10
  onConnected?: Function;
11
11
  isDark?: boolean;
@@ -30,7 +30,7 @@ interface ButtonProps$1 {
30
30
  showDownload?: boolean;
31
31
  web3Services?: EnableWeb3WalletOptions;
32
32
  }
33
- declare const CardanoWallet: ({ label, onConnected, isDark, persist, injectFn, cardanoPeerConnect, burnerWallet, webauthn, showDownload, web3Services, }: ButtonProps$1) => react_jsx_runtime.JSX.Element;
33
+ declare const CardanoWallet: ({ label, onConnected, isDark, persist, injectFn, cardanoPeerConnect, burnerWallet, webauthn, showDownload, web3Services, }: ButtonProps) => react_jsx_runtime.JSX.Element;
34
34
 
35
35
  declare enum WalletState {
36
36
  NOT_CONNECTED = "NOT_CONNECTED",
@@ -106,13 +106,4 @@ declare const MeshBadge: ({ isDark }: {
106
106
  isDark?: boolean | undefined;
107
107
  }) => react_jsx_runtime.JSX.Element;
108
108
 
109
- interface ButtonProps {
110
- label?: string;
111
- isDark?: boolean;
112
- poolId: string;
113
- onCheck: (rewardAddress: string) => Promise<AccountInfo>;
114
- onDelegated?: () => void;
115
- }
116
- declare const StakeButton: ({ label, isDark, poolId, onCheck, onDelegated, }: ButtonProps) => react_jsx_runtime.JSX.Element;
117
-
118
- export { CardanoWallet, MeshBadge, MeshProvider, StakeButton, WalletContext, useAddress, useAssets, useLovelace, useNetwork, useRewardAddress, useWallet, useWalletList, useWalletSubmit };
109
+ export { CardanoWallet, MeshBadge, MeshProvider, WalletContext, useAddress, useAssets, useLovelace, useNetwork, useRewardAddress, useWallet, useWalletList, useWalletSubmit };
package/dist/index.js CHANGED
@@ -24972,290 +24972,10 @@ var MeshBadge = ({ isDark = false }) => /* @__PURE__ */ jsxs16(
24972
24972
  ]
24973
24973
  }
24974
24974
  );
24975
-
24976
- // src/stake-button/index.tsx
24977
- import { useEffect as useEffect12, useState as useState15 } from "react";
24978
- import { Transaction } from "@meshsdk/transaction";
24979
-
24980
- // src/cardano-wallet-dropdown/index.tsx
24981
- import { useEffect as useEffect11, useState as useState14 } from "react";
24982
-
24983
- // src/common/button-dropdown.tsx
24984
- import { jsx as jsx26 } from "react/jsx-runtime";
24985
- function ButtonDropdown({
24986
- children,
24987
- isDarkMode = false,
24988
- hideMenuList = false,
24989
- setHideMenuList,
24990
- onMouseEnter,
24991
- onMouseLeave
24992
- }) {
24993
- return /* @__PURE__ */ jsx26(
24994
- "button",
24995
- {
24996
- 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`}`,
24997
- onClick: () => setHideMenuList && setHideMenuList(!hideMenuList),
24998
- onMouseEnter,
24999
- onMouseLeave,
25000
- children
25001
- }
25002
- );
25003
- }
25004
-
25005
- // src/cardano-wallet-dropdown/menu-item.tsx
25006
- import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
25007
- function MenuItem({
25008
- icon,
25009
- label,
25010
- action,
25011
- active
25012
- }) {
25013
- return /* @__PURE__ */ jsxs17(
25014
- "div",
25015
- {
25016
- 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",
25017
- onClick: action,
25018
- children: [
25019
- icon && /* @__PURE__ */ jsx27("img", { className: "mesh-pr-2 mesh-m-1 mesh-h-8", src: icon }),
25020
- /* @__PURE__ */ jsx27("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) => {
25021
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
25022
- }).join(" ") })
25023
- ]
25024
- }
25025
- );
25026
- }
25027
-
25028
- // src/cardano-wallet-dropdown/chevron-down.tsx
25029
- import { jsx as jsx28 } from "react/jsx-runtime";
25030
- var ChevronDown = () => /* @__PURE__ */ jsx28(
25031
- "svg",
25032
- {
25033
- className: "mesh-m-2 mesh-h-6",
25034
- fill: "none",
25035
- "aria-hidden": "true",
25036
- viewBox: "0 0 24 24",
25037
- stroke: "currentColor",
25038
- xmlns: "http://www.w3.org/2000/svg",
25039
- children: /* @__PURE__ */ jsx28(
25040
- "path",
25041
- {
25042
- strokeLinecap: "round",
25043
- strokeLinejoin: "round",
25044
- strokeWidth: "2",
25045
- d: "M19 9l-7 7-7-7"
25046
- }
25047
- )
25048
- }
25049
- );
25050
-
25051
- // src/cardano-wallet-dropdown/wallet-balance.tsx
25052
- import { Fragment as Fragment5, jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
25053
- var WalletBalance = ({
25054
- connected,
25055
- connecting,
25056
- label,
25057
- wallet
25058
- }) => {
25059
- const lovelace = useLovelace();
25060
- return connected && lovelace && wallet?.icon ? /* @__PURE__ */ jsxs18(Fragment5, { children: [
25061
- /* @__PURE__ */ jsx29("img", { className: "mesh-m-2 mesh-h-6", src: wallet.icon }),
25062
- "\u20B3",
25063
- " ",
25064
- parseInt((parseInt(lovelace, 10) / 1e6).toString(), 10),
25065
- ".",
25066
- /* @__PURE__ */ jsx29("span", { className: "mesh-text-xs", children: lovelace.substring(lovelace.length - 6) })
25067
- ] }) : connected && wallet?.icon ? /* @__PURE__ */ jsx29(Fragment5, { children: /* @__PURE__ */ jsx29("img", { className: "mesh-m-2 mesh-h-6", src: wallet.icon }) }) : connecting ? /* @__PURE__ */ jsx29(Fragment5, { children: "Connecting..." }) : /* @__PURE__ */ jsxs18(Fragment5, { children: [
25068
- label,
25069
- " ",
25070
- /* @__PURE__ */ jsx29(ChevronDown, {})
25071
- ] });
25072
- };
25073
-
25074
- // src/cardano-wallet-dropdown/index.tsx
25075
- import { Fragment as Fragment6, jsx as jsx30, jsxs as jsxs19 } from "react/jsx-runtime";
25076
- var CardanoWallet2 = ({
25077
- label = "Connect Wallet",
25078
- onConnected = void 0,
25079
- isDark = false,
25080
- extensions = [],
25081
- cardanoPeerConnect = void 0
25082
- }) => {
25083
- const [isDarkMode, setIsDarkMode] = useState14(false);
25084
- const [hideMenuList, setHideMenuList] = useState14(true);
25085
- const { connect: connect2, connecting, connected, disconnect, name } = useWallet();
25086
- const wallets = useWalletList();
25087
- useEffect11(() => {
25088
- if (connected && onConnected) {
25089
- onConnected();
25090
- }
25091
- }, [connected]);
25092
- useEffect11(() => {
25093
- setIsDarkMode(isDark);
25094
- }, [isDark]);
25095
- return /* @__PURE__ */ jsxs19(
25096
- "div",
25097
- {
25098
- onMouseEnter: () => setHideMenuList(false),
25099
- onMouseLeave: () => setHideMenuList(true),
25100
- style: { width: "min-content", zIndex: 50 },
25101
- children: [
25102
- /* @__PURE__ */ jsx30(
25103
- ButtonDropdown,
25104
- {
25105
- isDarkMode,
25106
- hideMenuList,
25107
- setHideMenuList,
25108
- children: /* @__PURE__ */ jsx30(
25109
- WalletBalance,
25110
- {
25111
- connected,
25112
- connecting,
25113
- label,
25114
- wallet: wallets.find((wallet) => wallet.id === name)
25115
- }
25116
- )
25117
- }
25118
- ),
25119
- /* @__PURE__ */ jsx30(
25120
- "div",
25121
- {
25122
- 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`}`,
25123
- style: { zIndex: 50 },
25124
- children: !connected && wallets.length > 0 ? /* @__PURE__ */ jsx30(Fragment6, { children: wallets.map((wallet, index) => /* @__PURE__ */ jsx30(
25125
- MenuItem,
25126
- {
25127
- icon: wallet.icon,
25128
- label: wallet.name,
25129
- action: () => {
25130
- connect2(wallet.id, extensions);
25131
- setHideMenuList(!hideMenuList);
25132
- },
25133
- active: name === wallet.id
25134
- },
25135
- index
25136
- )) }) : wallets.length === 0 ? /* @__PURE__ */ jsx30("span", { children: "No Wallet Found" }) : /* @__PURE__ */ jsx30(Fragment6, { children: /* @__PURE__ */ jsx30(
25137
- MenuItem,
25138
- {
25139
- active: false,
25140
- label: "disconnect",
25141
- action: disconnect,
25142
- icon: void 0
25143
- }
25144
- ) })
25145
- }
25146
- )
25147
- ]
25148
- }
25149
- );
25150
- };
25151
-
25152
- // src/stake-button/index.tsx
25153
- import { Fragment as Fragment7, jsx as jsx31 } from "react/jsx-runtime";
25154
- var StakeButton = ({
25155
- label = "Stake your ADA",
25156
- isDark = false,
25157
- poolId,
25158
- onCheck,
25159
- onDelegated = void 0
25160
- }) => {
25161
- const [isDarkMode, setIsDarkMode] = useState15(false);
25162
- const { connected } = useWallet();
25163
- useEffect12(() => {
25164
- setIsDarkMode(isDark);
25165
- }, [isDark]);
25166
- return /* @__PURE__ */ jsx31(Fragment7, { children: connected ? /* @__PURE__ */ jsx31(ButtonDropdown, { isDarkMode, children: /* @__PURE__ */ jsx31(
25167
- Delegate,
25168
- {
25169
- poolId,
25170
- onCheck,
25171
- onDelegated
25172
- }
25173
- ) }) : /* @__PURE__ */ jsx31(CardanoWallet2, { label, isDark }) });
25174
- };
25175
- var Delegate = ({
25176
- poolId,
25177
- onCheck,
25178
- onDelegated
25179
- }) => {
25180
- const { wallet } = useWallet();
25181
- const rewardAddress = useRewardAddress();
25182
- const [_, setError] = useState15();
25183
- const [checking, setChecking] = useState15(false);
25184
- const [accountInfo, setAccountInfo] = useState15();
25185
- const [processing, setProcessing] = useState15(false);
25186
- const [done, setDone] = useState15(false);
25187
- const checkAccountStatus = async () => {
25188
- try {
25189
- setChecking(true);
25190
- if (rewardAddress) {
25191
- const info = await onCheck(rewardAddress);
25192
- setAccountInfo(info);
25193
- }
25194
- setChecking(false);
25195
- } catch (error) {
25196
- setError(error);
25197
- }
25198
- };
25199
- const registerAddress = async () => {
25200
- setProcessing(true);
25201
- setDone(false);
25202
- try {
25203
- if (rewardAddress) {
25204
- const tx = new Transaction({ initiator: wallet }).registerStake(rewardAddress).delegateStake(rewardAddress, poolId);
25205
- const unsignedTx = await tx.build();
25206
- const signedTx = await wallet.signTx(unsignedTx);
25207
- await wallet.submitTx(signedTx);
25208
- if (onDelegated) {
25209
- onDelegated();
25210
- }
25211
- setDone(true);
25212
- }
25213
- } catch (error) {
25214
- setError(error);
25215
- }
25216
- setProcessing(false);
25217
- };
25218
- const delegateStake = async () => {
25219
- setProcessing(true);
25220
- setDone(false);
25221
- try {
25222
- if (rewardAddress) {
25223
- const tx = new Transaction({ initiator: wallet }).delegateStake(rewardAddress, poolId);
25224
- const unsignedTx = await tx.build();
25225
- const signedTx = await wallet.signTx(unsignedTx);
25226
- await wallet.submitTx(signedTx);
25227
- if (onDelegated) {
25228
- onDelegated();
25229
- }
25230
- setDone(true);
25231
- }
25232
- } catch (error) {
25233
- setError(error);
25234
- }
25235
- setProcessing(false);
25236
- };
25237
- useEffect12(() => {
25238
- checkAccountStatus();
25239
- }, [rewardAddress]);
25240
- if (checking) {
25241
- return /* @__PURE__ */ jsx31("span", { children: "Checking..." });
25242
- }
25243
- if (processing) {
25244
- return /* @__PURE__ */ jsx31("span", { children: "Loading..." });
25245
- }
25246
- if (done) {
25247
- return /* @__PURE__ */ jsx31("span", { children: "Stake Delegated" });
25248
- }
25249
- if (accountInfo?.active) {
25250
- return accountInfo.poolId === poolId ? /* @__PURE__ */ jsx31("span", { children: "Stake Delegated" }) : /* @__PURE__ */ jsx31("span", { onClick: delegateStake, children: "Begin Staking" });
25251
- }
25252
- return /* @__PURE__ */ jsx31("span", { onClick: registerAddress, children: "Begin Staking" });
25253
- };
25254
24975
  export {
25255
24976
  CardanoWallet,
25256
24977
  MeshBadge,
25257
24978
  MeshProvider,
25258
- StakeButton,
25259
24979
  WalletContext,
25260
24980
  useAddress,
25261
24981
  useAssets,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/react",
3
- "version": "1.9.0-beta.42",
3
+ "version": "1.9.0-beta.45",
4
4
  "description": "React component library - https://meshjs.dev/react",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -30,9 +30,8 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@fabianbormann/cardano-peer-connect": "^1.2.18",
33
- "@meshsdk/common": "1.9.0-beta.42",
34
- "@meshsdk/transaction": "1.9.0-beta.42",
35
- "@meshsdk/wallet": "1.9.0-beta.42",
33
+ "@meshsdk/common": "1.9.0-beta.45",
34
+ "@meshsdk/wallet": "1.9.0-beta.45",
36
35
  "@meshsdk/web3-sdk": "0.0.26",
37
36
  "@radix-ui/react-dialog": "^1.1.2",
38
37
  "@radix-ui/react-dropdown-menu": "^2.1.2",