@dappworks/kit 0.4.182 → 0.4.183

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/wallet.mjs CHANGED
@@ -12,7 +12,7 @@ import './chunk-K7LFG5BA.mjs';
12
12
  import { __commonJS, __spreadValues, __spreadProps, __toESM } from './chunk-2EXDWOHY.mjs';
13
13
  import { RainbowKitProvider, darkTheme, lightTheme, getDefaultConfig, useConnectModal } from '@rainbow-me/rainbowkit';
14
14
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
15
- import React2, { useEffect } from 'react';
15
+ import React6, { useEffect } from 'react';
16
16
  import { observer } from 'mobx-react-lite';
17
17
  import { WagmiProvider, useWalletClient, useAccount, useSwitchChain, useConnect, useDisconnect } from 'wagmi';
18
18
  import BigNumber from 'bignumber.js';
@@ -20,6 +20,7 @@ import EventEmitter from 'events';
20
20
  import { encodeFunctionData, hashMessage, hashTypedData } from 'viem';
21
21
  import { iopayWallet, metaMaskWallet, walletConnectWallet, okxWallet, binanceWallet } from '@rainbow-me/rainbowkit/wallets';
22
22
  import { iotex, iotexTestnet as iotexTestnet$1 } from 'viem/chains';
23
+ import { Checkbox, Tooltip, Button, Popover, PopoverTrigger, PopoverContent, Input, Table, TableHeader, TableColumn, TableBody, TableRow, TableCell } from '@nextui-org/react';
23
24
 
24
25
  // ../../node_modules/@safe-global/safe-gateway-typescript-sdk/dist/utils.js
25
26
  var require_utils = __commonJS({
@@ -2292,7 +2293,7 @@ var render = (icon, props, inline, ref) => {
2292
2293
  componentProps.dangerouslySetInnerHTML = {
2293
2294
  __html: cleanUpInnerHTML(replaceIDs(item.body, id ? () => id + "ID" + localCounter++ : "iconifyReact"))
2294
2295
  };
2295
- return React2.createElement("svg", componentProps);
2296
+ return React6.createElement("svg", componentProps);
2296
2297
  }
2297
2298
  const { body, width, height } = icon;
2298
2299
  const useMask = mode === "mask" || (mode === "bg" ? false : body.indexOf("currentColor") !== -1);
@@ -2305,7 +2306,7 @@ var render = (icon, props, inline, ref) => {
2305
2306
  "width": fixSize(renderAttribs.width),
2306
2307
  "height": fixSize(renderAttribs.height)
2307
2308
  }), commonProps), useMask ? monotoneProps : coloredProps), customStyle);
2308
- return React2.createElement("span", componentProps);
2309
+ return React6.createElement("span", componentProps);
2309
2310
  };
2310
2311
  allowSimpleNames(true);
2311
2312
  setAPIModule("", fetchAPIModule);
@@ -2352,7 +2353,7 @@ if (typeof document !== "undefined" && typeof window !== "undefined") {
2352
2353
  }
2353
2354
  }
2354
2355
  }
2355
- var IconComponent = class extends React2.Component {
2356
+ var IconComponent = class extends React6.Component {
2356
2357
  constructor(props) {
2357
2358
  super(props);
2358
2359
  this.state = {
@@ -2462,7 +2463,7 @@ var IconComponent = class extends React2.Component {
2462
2463
  const props = this.props;
2463
2464
  const icon = this.state.icon;
2464
2465
  if (icon === null) {
2465
- return props.children ? props.children : React2.createElement("span", {});
2466
+ return props.children ? props.children : React6.createElement("span", {});
2466
2467
  }
2467
2468
  let newProps = props;
2468
2469
  if (icon.classes) {
@@ -2473,19 +2474,19 @@ var IconComponent = class extends React2.Component {
2473
2474
  return render(__spreadValues(__spreadValues({}, defaultIconProps), icon.data), newProps, props._inline, props._ref);
2474
2475
  }
2475
2476
  };
2476
- var Icon = React2.forwardRef(function Icon2(props, ref) {
2477
+ var Icon = React6.forwardRef(function Icon2(props, ref) {
2477
2478
  const newProps = __spreadProps(__spreadValues({}, props), {
2478
2479
  _ref: ref,
2479
2480
  _inline: false
2480
2481
  });
2481
- return React2.createElement(IconComponent, newProps);
2482
+ return React6.createElement(IconComponent, newProps);
2482
2483
  });
2483
- React2.forwardRef(function InlineIcon2(props, ref) {
2484
+ React6.forwardRef(function InlineIcon2(props, ref) {
2484
2485
  const newProps = __spreadProps(__spreadValues({}, props), {
2485
2486
  _ref: ref,
2486
2487
  _inline: true
2487
2488
  });
2488
- return React2.createElement(IconComponent, newProps);
2489
+ return React6.createElement(IconComponent, newProps);
2489
2490
  });
2490
2491
 
2491
2492
  // module/Wallet/walletPluginStore.tsx
@@ -2612,15 +2613,15 @@ var WalletRpcStore = class {
2612
2613
  }
2613
2614
  scoreIcon(score) {
2614
2615
  if (score < 0) {
2615
- return /* @__PURE__ */ React.createElement(Icon, { icon: "codicon:error", width: "18", height: "18", style: { color: "#FF0000" } });
2616
+ return /* @__PURE__ */ React6.createElement(Icon, { icon: "codicon:error", width: "18", height: "18", style: { color: "#FF0000" } });
2616
2617
  }
2617
2618
  if (score < 1) {
2618
- return /* @__PURE__ */ React.createElement(Icon, { icon: "icon-park-solid:check-one", width: "18", height: "18", style: { color: "#289726" } });
2619
+ return /* @__PURE__ */ React6.createElement(Icon, { icon: "icon-park-solid:check-one", width: "18", height: "18", style: { color: "#289726" } });
2619
2620
  }
2620
2621
  if (score < 2) {
2621
- return /* @__PURE__ */ React.createElement(Icon, { icon: "bxs:error", width: "18", height: "18", style: { color: "#FFA500" } });
2622
+ return /* @__PURE__ */ React6.createElement(Icon, { icon: "bxs:error", width: "18", height: "18", style: { color: "#FFA500" } });
2622
2623
  }
2623
- return /* @__PURE__ */ React.createElement(Icon, { icon: "codicon:error", width: "18", height: "18", style: { color: "#FF0000" } });
2624
+ return /* @__PURE__ */ React6.createElement(Icon, { icon: "codicon:error", width: "18", height: "18", style: { color: "#FF0000" } });
2624
2625
  }
2625
2626
  get wallet() {
2626
2627
  return RootStore.Get(WalletStore);
@@ -3236,20 +3237,20 @@ var sdk_default = SafeAppsSDK;
3236
3237
  // ../../node_modules/@safe-global/safe-apps-sdk/dist/esm/index.js
3237
3238
  var esm_default = sdk_default;
3238
3239
  var SuccessTxDialog = observer((props) => {
3239
- return /* @__PURE__ */ React2.createElement("div", { className: "flex-col gap-4 py-10" }, /* @__PURE__ */ React2.createElement("div", { className: "w-full flex items-center justify-center" }, /* @__PURE__ */ React2.createElement(Icon, { icon: "icon-park-solid:check-one", width: "48", height: "48", className: "text-green-500" })), /* @__PURE__ */ React2.createElement("div", { className: "text-2xl font-[900] text-center mt-4" }, props.msg), /* @__PURE__ */ React2.createElement(
3240
+ return /* @__PURE__ */ React6.createElement("div", { className: "flex-col gap-4 py-10" }, /* @__PURE__ */ React6.createElement("div", { className: "w-full flex items-center justify-center" }, /* @__PURE__ */ React6.createElement(Icon, { icon: "icon-park-solid:check-one", width: "48", height: "48", className: "text-green-500" })), /* @__PURE__ */ React6.createElement("div", { className: "text-2xl font-[900] text-center mt-4" }, props.msg), /* @__PURE__ */ React6.createElement(
3240
3241
  "div",
3241
3242
  {
3242
3243
  className: "flex items-center justify-center text-green-500 text-sm mt-6 gap-2 cursor-pointer hover:text-green-600 transition",
3243
3244
  onClick: (e) => window.open(`https://iotexscan.io/tx/${props.hash}`, "_blank")
3244
3245
  },
3245
3246
  "View on IoTeXScan ",
3246
- /* @__PURE__ */ React2.createElement(Icon, { icon: "material-symbols:chip-extraction-rounded", width: "18", height: "18" })
3247
+ /* @__PURE__ */ React6.createElement(Icon, { icon: "material-symbols:chip-extraction-rounded", width: "18", height: "18" })
3247
3248
  ));
3248
3249
  });
3249
3250
  var ShowSuccessTxDialog = ({ msg, hash }) => {
3250
3251
  RootStore.Get(DialogStore).setData({
3251
3252
  title: "",
3252
- content: /* @__PURE__ */ React2.createElement(SuccessTxDialog, { msg, hash }),
3253
+ content: /* @__PURE__ */ React6.createElement(SuccessTxDialog, { msg, hash }),
3253
3254
  isOpen: true
3254
3255
  });
3255
3256
  };
@@ -3402,8 +3403,6 @@ var WalletStore = class _WalletStore {
3402
3403
  const promise = new Promise(async (res, rej) => {
3403
3404
  var _a, _b;
3404
3405
  try {
3405
- if (typeof window == "undefined")
3406
- return;
3407
3406
  if (this.account) {
3408
3407
  if (Number((_a = this.chain) == null ? void 0 : _a.id) == Number(chainId)) {
3409
3408
  res();
@@ -3643,14 +3642,57 @@ var WalletProvider = observer(({
3643
3642
  }, [appName]);
3644
3643
  return (
3645
3644
  //@ts-ignore
3646
- /* @__PURE__ */ React2.createElement(WagmiProvider, { config: walletConfig.rainbowKitConfig, reconnectOnMount: true }, /* @__PURE__ */ React2.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React2.createElement(RainbowKitProvider, { locale: "en", theme: theme == "dark" ? darkTheme() : lightTheme() }, children, /* @__PURE__ */ React2.createElement(WalletConnect, null))))
3645
+ /* @__PURE__ */ React6.createElement(WagmiProvider, { config: walletConfig.rainbowKitConfig, reconnectOnMount: true }, /* @__PURE__ */ React6.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React6.createElement(RainbowKitProvider, { locale: "en", theme: theme == "dark" ? darkTheme() : lightTheme() }, children, /* @__PURE__ */ React6.createElement(WalletConnect, null))))
3647
3646
  );
3648
3647
  });
3649
3648
  var WalletConnect = () => {
3650
3649
  const wallet = RootStore.Get(WalletStore);
3651
3650
  wallet.use();
3652
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null);
3651
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null);
3653
3652
  };
3653
+ var RpcList = observer(() => {
3654
+ var _a, _b;
3655
+ RootStore.Get(WalletStore);
3656
+ const rpcStore = RootStore.Get(WalletRpcStore);
3657
+ useEffect(() => {
3658
+ rpcStore.testRpc();
3659
+ }, []);
3660
+ return /* @__PURE__ */ React6.createElement("div", { className: "mb-3 mt-2" }, /* @__PURE__ */ React6.createElement("div", { className: "w-full flex mb-2" }, /* @__PURE__ */ React6.createElement("div", { className: "flex items-center justify-center gap-2" }, /* @__PURE__ */ React6.createElement(Checkbox, { size: "sm", isSelected: rpcStore.isAutoSelectRpc.value, onValueChange: (e) => rpcStore.isAutoSelectRpc.save(e) }, "Auto select rpc"), /* @__PURE__ */ React6.createElement(Tooltip, { content: /* @__PURE__ */ React6.createElement("div", { className: "w-[300px]" }, "Once selected, if the current RPC cannot send a request, an available RPC will be automatically chosen.") }, /* @__PURE__ */ React6.createElement(Icon, { icon: "ph:question", width: "18", height: "18", className: "text-gray-500" }))), /* @__PURE__ */ React6.createElement(Button, { startContent: /* @__PURE__ */ React6.createElement(Icon, { icon: "tabler:test-pipe", width: "18", height: "18" }), className: "ml-auto", onClick: (e) => {
3661
+ rpcStore.testRpc();
3662
+ } }, "Test"), /* @__PURE__ */ React6.createElement(Popover, { placement: "bottom", offset: 20, showArrow: true, isOpen: rpcStore.showCustomRpc, onOpenChange: (open) => rpcStore.showCustomRpc = open }, /* @__PURE__ */ React6.createElement(PopoverTrigger, null, /* @__PURE__ */ React6.createElement(Button, { color: "primary", startContent: /* @__PURE__ */ React6.createElement(Icon, { icon: "basil:add-solid", width: "18", height: "18" }), className: "ml-4" }, "Add custom rpc")), /* @__PURE__ */ React6.createElement(PopoverContent, null, /* @__PURE__ */ React6.createElement("div", { className: "px-1 py-2" }, /* @__PURE__ */ React6.createElement(
3663
+ Input,
3664
+ {
3665
+ type: "url",
3666
+ className: "mb-4",
3667
+ placeholder: "https://rpc.com",
3668
+ value: rpcStore.customRpc,
3669
+ onValueChange: (value) => {
3670
+ rpcStore.customRpc = value;
3671
+ }
3672
+ }
3673
+ ), /* @__PURE__ */ React6.createElement(Button, { color: "primary", isDisabled: !rpcStore.customRpc, onClick: (e) => rpcStore.addCustomRpc() }, "Save"))))), /* @__PURE__ */ React6.createElement(
3674
+ Table,
3675
+ {
3676
+ color: "success",
3677
+ selectionMode: "single",
3678
+ defaultSelectedKeys: [rpcStore.curRpc.value],
3679
+ "aria-label": "Example static collection table"
3680
+ },
3681
+ /* @__PURE__ */ React6.createElement(TableHeader, null, /* @__PURE__ */ React6.createElement(TableColumn, null, "RPC Server Address"), /* @__PURE__ */ React6.createElement(TableColumn, { align: "center" }, "Score"), /* @__PURE__ */ React6.createElement(TableColumn, { align: "center" }, "Height"), /* @__PURE__ */ React6.createElement(TableColumn, { align: "center" }, "Latency"), /* @__PURE__ */ React6.createElement(TableColumn, { align: "center" }, "Action")),
3682
+ /* @__PURE__ */ React6.createElement(TableBody, null, (_b = (_a = rpcStore.rpcList) == null ? void 0 : _a.value) == null ? void 0 : _b.map((item, index) => {
3683
+ return /* @__PURE__ */ React6.createElement(TableRow, { className: "cursor-pointer", key: item.name, onClick: (e) => {
3684
+ rpcStore.curRpc.save(item.name);
3685
+ RootStore.Get(ToastPlugin).success("Set rpc success");
3686
+ } }, /* @__PURE__ */ React6.createElement(TableCell, null, item.name), /* @__PURE__ */ React6.createElement(TableCell, null, rpcStore.scoreIcon(item.latency)), /* @__PURE__ */ React6.createElement(TableCell, null, item.height), /* @__PURE__ */ React6.createElement(TableCell, { className: rpcStore.latencyColor(item.latency) }, item.latency, "s"), /* @__PURE__ */ React6.createElement(TableCell, null, /* @__PURE__ */ React6.createElement("div", { className: "relative flex items-center gap-2" }, /* @__PURE__ */ React6.createElement(Tooltip, { content: "Add to metamask" }, /* @__PURE__ */ React6.createElement("span", { className: "text-lg text-danger cursor-pointer active:opacity-50", onClick: (e) => {
3687
+ e.stopPropagation();
3688
+ rpcStore.addToMetamask(item.name);
3689
+ } }, /* @__PURE__ */ React6.createElement(Icon, { icon: "logos:metamask-icon", width: "18", height: "18" }))), item.custom && /* @__PURE__ */ React6.createElement(Tooltip, { content: "Remove" }, /* @__PURE__ */ React6.createElement("span", { className: "text-lg text-danger cursor-pointer active:opacity-50", onClick: (e) => {
3690
+ e.stopPropagation();
3691
+ rpcStore.removeRpc(item.name);
3692
+ } }, /* @__PURE__ */ React6.createElement(Icon, { icon: "solar:trash-bin-minimalistic-broken", width: "20", height: "20" }))))));
3693
+ }))
3694
+ ));
3695
+ });
3654
3696
  var iotex2 = __spreadValues({
3655
3697
  iconUrl: "https://icons.llamao.fi/icons/chains/rsz_iotex.jpg"
3656
3698
  }, iotex);
@@ -3658,6 +3700,6 @@ var iotexTestnet = __spreadValues({
3658
3700
  iconUrl: "https://icons.llamao.fi/icons/chains/rsz_iotex.jpg"
3659
3701
  }, iotexTestnet$1);
3660
3702
 
3661
- export { WalletConfigStore, WalletHistoryStore, WalletProvider, WalletRpcStore, WalletStore, iotex2 as iotex, iotexTestnet };
3703
+ export { RpcList, WalletConfigStore, WalletHistoryStore, WalletProvider, WalletRpcStore, WalletStore, iotex2 as iotex, iotexTestnet };
3662
3704
  //# sourceMappingURL=out.js.map
3663
3705
  //# sourceMappingURL=wallet.mjs.map