@thenamespace/ens-components 0.0.5-alpha → 0.0.7-alpha

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.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { forwardRef, createElement, useState, useRef, useEffect, useMemo, useCallback, createContext, useContext } from 'react';
3
- import { isAddress as isAddress$1, parseAbi } from 'viem';
4
- import { mainnet, base as base$1, arbitrum, polygon, optimism, zora } from 'viem/chains';
5
- import { usePublicClient, useWalletClient } from 'wagmi';
2
+ import { forwardRef, createElement, useState, useRef, useEffect, useCallback, useMemo, createContext, useContext } from 'react';
3
+ import { isAddress as isAddress$1, parseAbi, namehash, encodeFunctionData, toHex, ContractFunctionExecutionError } from 'viem';
4
+ import { mainnet, base as base$1, arbitrum, polygon, optimism, zora, celo } from 'viem/chains';
5
+ import { usePublicClient, useWalletClient, useAccount, useSwitchChain } from 'wagmi';
6
6
 
7
7
  const sizeToClass = {
8
8
  sm: "ns-btn--sm",
@@ -671,16 +671,27 @@ const Icon = ({
671
671
  );
672
672
  };
673
673
 
674
- const ChainIcon = ({
675
- chain,
676
- size = 20,
677
- className,
678
- ...props
679
- }) => {
680
- const renderIcon = () => {
681
- switch (chain) {
682
- case "eth":
683
- return /* @__PURE__ */ jsxs("g", { clipPath: "url(#clip0_597_2890)", children: [
674
+ const EthSvg = ({ size = 20, ...props }) => {
675
+ return /* @__PURE__ */ jsxs(
676
+ "svg",
677
+ {
678
+ width: size,
679
+ height: size,
680
+ viewBox: "0 0 20 20",
681
+ fill: "none",
682
+ xmlns: "http://www.w3.org/2000/svg",
683
+ ...props,
684
+ children: [
685
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_597_2890", children: /* @__PURE__ */ jsx(
686
+ "rect",
687
+ {
688
+ width: "19",
689
+ height: "19",
690
+ fill: "white",
691
+ transform: "translate(0.255859 0.5)"
692
+ }
693
+ ) }) }),
694
+ /* @__PURE__ */ jsxs("g", { clipPath: "url(#clip0_597_2890)", children: [
684
695
  /* @__PURE__ */ jsx(
685
696
  "path",
686
697
  {
@@ -734,228 +745,347 @@ const ChainIcon = ({
734
745
  fillOpacity: "0.602"
735
746
  }
736
747
  )
737
- ] });
738
- case "arb":
739
- return /* @__PURE__ */ jsxs(Fragment, { children: [
740
- /* @__PURE__ */ jsx(
741
- "path",
742
- {
743
- fill: "#2d374b",
744
- d: "m24.554 20.16 3.23-5.482 8.71 13.565.005 2.604-.029-17.915a1.35 1.35 0 0 0-.624-1.075l-15.68-9.02a1.38 1.38 0 0 0-1.339.087l-.055.034-15.22 8.82-.06.028a1.34 1.34 0 0 0-.787 1.146L2.73 27.55l8.113-12.574c1.02-1.667 3.246-2.205 5.313-2.175l2.424.064-14.286 22.91 1.684.97 14.457-23.857 6.39-.023-14.42 24.459 6.01 3.457.718.412c.303.124.661.13.968.02L36 31.996l-3.04 1.762zm1.232 17.757-6.069-9.526 3.705-6.287 7.971 12.564-5.607 3.25Z"
745
- }
746
- ),
747
- /* @__PURE__ */ jsx(
748
- "path",
749
- {
750
- fill: "#28a0f0",
751
- d: "m19.715 28.392 6.07 9.525 5.606-3.249-7.97-12.564zm16.783 2.455-.004-2.604-8.71-13.565-3.231 5.483 8.408 13.598L36 31.997c.298-.242.479-.597.498-.98z"
752
- }
753
- ),
754
- /* @__PURE__ */ jsx(
755
- "path",
756
- {
757
- fill: "#fff",
758
- d: "m0 33.302 4.293 2.474L18.58 12.865l-2.424-.064c-2.066-.03-4.291.508-5.313 2.175L2.73 27.55 0 31.743zm26.825-20.437-6.39.023L5.976 36.745l5.053 2.91 1.375-2.331 14.42-24.46Z"
759
- }
760
- ),
761
- /* @__PURE__ */ jsx(
762
- "path",
763
- {
764
- fill: "#96bedc",
765
- d: "M39.191 12.832a4.07 4.07 0 0 0-1.91-3.272L21.394.424a4.13 4.13 0 0 0-3.645 0C17.617.49 2.3 9.373 2.3 9.373a4.04 4.04 0 0 0-2.3 3.45v18.92l2.73-4.194-.024-14.599a1.35 1.35 0 0 1 .562-1.015c.071-.05 15.649-9.068 15.699-9.093a1.38 1.38 0 0 1 1.198-.006l15.68 9.02c.371.236.604.637.624 1.075v18.084c-.018.383-.17.739-.468.98l-3.04 1.763-1.569.909-5.607 3.249-5.685 3.295a1.38 1.38 0 0 1-.968-.02l-6.727-3.868-1.375 2.33 6.046 3.481.524.297c.226.127.38.211.435.238.43.209 1.048.33 1.605.33.51 0 1.009-.094 1.48-.278l16.515-9.564a4.04 4.04 0 0 0 1.556-3.042z"
766
- }
767
- )
768
- ] });
769
- case "base":
770
- return /* @__PURE__ */ jsx(
748
+ ] })
749
+ ]
750
+ }
751
+ );
752
+ };
753
+
754
+ const ArbSvg = ({ size = 20, ...props }) => {
755
+ return /* @__PURE__ */ jsxs(
756
+ "svg",
757
+ {
758
+ width: size,
759
+ height: size,
760
+ viewBox: "0 0 40 44",
761
+ fill: "none",
762
+ xmlns: "http://www.w3.org/2000/svg",
763
+ ...props,
764
+ children: [
765
+ /* @__PURE__ */ jsx(
771
766
  "path",
772
767
  {
773
- fill: "#0052ff",
774
- d: "M54.921 110.034c30.438 0 55.113-24.632 55.113-55.017S85.359 0 54.921 0C26.043 0 2.353 22.171 0 50.392h72.847v9.25H0c2.353 28.22 26.043 50.392 54.921 50.392"
768
+ fill: "#2d374b",
769
+ d: "m24.554 20.16 3.23-5.482 8.71 13.565.005 2.604-.029-17.915a1.35 1.35 0 0 0-.624-1.075l-15.68-9.02a1.38 1.38 0 0 0-1.339.087l-.055.034-15.22 8.82-.06.028a1.34 1.34 0 0 0-.787 1.146L2.73 27.55l8.113-12.574c1.02-1.667 3.246-2.205 5.313-2.175l2.424.064-14.286 22.91 1.684.97 14.457-23.857 6.39-.023-14.42 24.459 6.01 3.457.718.412c.303.124.661.13.968.02L36 31.996l-3.04 1.762zm1.232 17.757-6.069-9.526 3.705-6.287 7.971 12.564-5.607 3.25Z"
775
770
  }
776
- );
777
- case "bitcoin":
778
- return /* @__PURE__ */ jsx(
771
+ ),
772
+ /* @__PURE__ */ jsx(
779
773
  "path",
780
774
  {
781
- fill: "#f39321",
782
- d: "M43.43 125.143c7.71-10.766 14.875-21.901 23.562-31.986 15.8-18.343 33.692-34.063 54.18-47.075 18.379-11.672 37.761-20.872 58.501-27.305 32.294-10.018 65.26-12.997 98.838-9.165 24.544 2.801 48.191 9.067 70.713 19.215 13.633 6.142 26.456 13.731 39.025 21.927 25.328 16.515 45.618 38.014 62.58 62.577 18.116 26.236 29.889 55.421 36.346 86.725 4.535 21.983 6.449 44.171 4.503 66.504-2.399 27.536-8.514 54.086-19.938 79.604-9.662 21.583-21.589 41.401-36.861 59.301-14.94 17.511-31.788 32.831-51.149 45.461-13.184 8.6-26.926 16.276-41.434 21.975-24.274 9.537-49.447 15.986-75.787 17.115-18.545.795-36.985.483-55.279-2.763-15.713-2.788-31.049-6.858-46.063-12.496-14.566-5.47-28.693-11.95-41.709-20.143-18.766-11.812-35.683-26.147-50.737-42.663-16.773-18.403-30.373-38.808-40.779-61.344-14.7-31.835-21.929-65.401-22.359-100.425-.162-13.173 1.349-26.244 3.105-39.283.126-.933-.002-1.899-.012-2.851 1.536-.952 1.4-2.618 1.677-4.071 3.906-20.483 10.494-40.059 19.418-58.906 3.162-6.674 7.525-12.764 9.659-19.928m281.727 129.37c6.537-3.474 12.749-5.465 17.658-9.85 18.918-16.899 23.96-56.673-6.747-75.833-9.566-5.969-19.77-10.393-30.77-14.907 1.819-14.731 7.709-28.516 9.622-43.603-9.076-2.249-17.578-5.234-26.425-6.193l-10.674 41.837c-6.78-2.076-13.761-1.879-20.142-5.473 2.302-14.39 7.773-27.872 9.268-42.314-9.322-1.464-17.216-5.094-26.265-5.485l-10.586 42.215c-17.944-2.75-34.419-8.921-52.52-12.239-3.977 8.91-5.738 18.311-7.334 28.313 5.896 1.392 11.022 2.623 16.158 3.811 12.965 2.998 16.517 10.086 13.439 21.424-2.19 8.065-4.166 16.189-6.182 24.301-7.245 29.16-14.432 58.333-21.72 87.482-1.642 6.567-5.734 8.706-12.398 7.731-6.563-.96-12.757-3.907-19.99-3.693-3.136 10.032-9.378 18.871-11.588 29.946l51.344 13.08c-1.312 15.208-7.614 29.125-9.476 44.441l25.544 6.123c5.653-14.044 6.957-28.803 12.226-43.33 6.351 3.265 13.397 2.317 19.612 6.427l-10.178 42.077c8.986 3.216 17.753 4.528 26.758 6.77l10.578-42.386c2.123-1.091 3.676-.888 5.143-.574a132.9 132.9 0 0 0 42.676 2.14c12.368-1.373 23.343-6.088 32.148-15.372 9.791-10.323 14.71-22.952 17.078-36.535 1.93-11.065 1.436-22.277-5.06-32.071-5.091-7.674-12.084-13.53-21.197-18.26M223.128 312.17c17.411 4.325 34.803 8.95 53.02 5.624 9.715-1.774 17.037-6.73 19.985-16.503 2.78-9.218 1.164-17.593-5.673-24.879-7.11-7.576-16.254-11.514-25.682-14.807-11.264-3.934-22.683-7.508-34.99-8.48l-13.972 56.788c2.981.929 5.117 1.712 7.312 2.257m61.5-80.324c9.628-1.368 17.612-7.738 19.958-16.393 2.869-10.583-.337-19.865-8.902-26.178-9.718-7.163-20.908-10.807-32.47-13.337-4.307-.943-8.544-3.454-13.756-1.759l-12.599 51.209c16.457 4.155 31.611 8.753 47.769 6.458"
775
+ fill: "#28a0f0",
776
+ d: "m19.715 28.392 6.07 9.525 5.606-3.249-7.97-12.564zm16.783 2.455-.004-2.604-8.71-13.565-3.231 5.483 8.408 13.598L36 31.997c.298-.242.479-.597.498-.98z"
783
777
  }
784
- );
785
- case "matic":
786
- return /* @__PURE__ */ jsx("path", { d: "M377.3 163.9c-9.2-5.4-21.2-5.4-31.4 0l-72 41.7-48.9 27.2-72 41.7c-9.2 5.4-21.2 5.4-31.4 0l-57.2-32.6c-9.2-5.4-15.7-15.4-15.7-26.3v-64.3c0-10.9 5.5-20.8 15.7-26.3l56.3-31.7c9.2-5.4 21.2-5.4 31.4 0l56.3 31.7c9.2 5.4 15.7 15.4 15.7 26.3V193l48.9-28.1v-41.7c0-10.9-5.5-20.8-15.7-26.3L153.1 37.1c-9.2-5.4-21.2-5.4-31.4 0l-106 59.8C5.5 102.3 0 112.3 0 123.2v120.5c0 10.9 5.5 20.8 15.7 26.3l106.1 59.8c9.2 5.4 21.2 5.4 31.4 0l72-40.8 48.9-28.1 72-40.8c9.2-5.4 21.2-5.4 31.4 0l56.3 31.7c9.2 5.4 15.7 15.4 15.7 26.3v64.3c0 10.9-5.5 20.8-15.7 26.3l-56.3 32.6c-9.2 5.4-21.2 5.4-31.4 0l-56.3-31.7c-9.2-5.4-15.7-15.4-15.7-26.3v-41.7l-48.9 28.1v41.7c0 10.9 5.5 20.8 15.7 26.3L347 457.5c9.2 5.4 21.2 5.4 31.4 0l106.1-59.8c9.2-5.4 15.7-15.4 15.7-26.3V250.9c0-10.9-5.5-20.8-15.7-26.3z" });
787
- case "op":
788
- return /* @__PURE__ */ jsxs(Fragment, { children: [
789
- /* @__PURE__ */ jsx(
790
- "path",
791
- {
792
- fill: "#ff0420",
793
- d: "M42 84c23.196 0 42-18.804 42-42S65.196 0 42 0 0 18.804 0 42s18.804 42 42 42"
794
- }
795
- ),
796
- /* @__PURE__ */ jsx(
797
- "path",
798
- {
799
- fill: "#fff",
800
- d: "M30.461 53.76q-3.8 0-6.226-1.83-2.395-1.861-2.395-5.291 0-.72.16-1.764.414-2.352 1.181-5.651 2.171-8.984 11.208-8.984 2.46 0 4.407.85 1.947.817 3.065 2.482 1.118 1.635 1.118 3.92 0 .687-.16 1.732a76 76 0 0 1-1.15 5.65q-1.116 4.476-3.863 6.697-2.747 2.19-7.345 2.19Zm.448-4.704q1.788 0 3.033-1.078 1.277-1.077 1.82-3.3.735-3.07 1.118-5.356.127-.687.127-1.405 0-2.973-3.033-2.973-1.788 0-3.065 1.078-1.245 1.078-1.789 3.3-.574 2.188-1.15 5.357a7 7 0 0 0-.127 1.372q0 3.005 3.066 3.005m13.536 4.377q-.351 0-.543-.229a.8.8 0 0 1-.096-.588l4.407-21.233a.94.94 0 0 1 .351-.588.96.96 0 0 1 .607-.229h8.494q3.544 0 5.684 1.503 2.17 1.503 2.171 4.345a8 8 0 0 1-.192 1.698q-.798 3.757-3.225 5.554-2.395 1.797-6.578 1.797h-4.31l-1.47 7.153a.94.94 0 0 1-.35.588.96.96 0 0 1-.607.23zm11.304-12.478q1.34 0 2.33-.752 1.023-.751 1.342-2.156.096-.555.096-.98 0-.947-.543-1.437-.544-.523-1.852-.523H53.29l-1.213 5.848z"
801
- }
802
- )
803
- ] });
804
- case "sol":
805
- return /* @__PURE__ */ jsxs(Fragment, { children: [
806
- /* @__PURE__ */ jsx("path", { d: "M250 0c138 0 250 111.9 250 250S388 500 250 500 0 388 0 250 111.9 0 250 0" }),
807
- /* @__PURE__ */ jsxs(
808
- "linearGradient",
809
- {
810
- id: "SolIcon_svg__a",
811
- x1: "242.52",
812
- x2: "755.68",
813
- y1: "267.33",
814
- y2: "-245.83",
815
- gradientTransform: "matrix(.5 0 0 .5 0 250)",
816
- gradientUnits: "userSpaceOnUse",
817
- children: [
818
- /* @__PURE__ */ jsx("stop", { offset: "0", style: { stopColor: "rgb(203, 78, 232)" } }),
819
- /* @__PURE__ */ jsx("stop", { offset: "1", style: { stopColor: "rgb(16, 244, 177)" } })
820
- ]
821
- }
822
- ),
823
- /* @__PURE__ */ jsx(
824
- "path",
825
- {
826
- d: "M115.6 226.1H347c2.9 0 5.6 1.1 7.6 3.2l36.6 36.8c6.8 6.8 2 18.4-7.6 18.4H152.2c-2.9 0-5.6-1.1-7.6-3.2L108 244.5c-6.8-6.7-2-18.4 7.6-18.4m-7.7-48.8 36.6-36.8c2.1-2.1 4.8-3.2 7.6-3.2h231.3c9.6 0 14.5 11.6 7.6 18.4l-36.5 36.8c-2 2.1-4.8 3.2-7.6 3.2H115.6c-9.6 0-14.4-11.6-7.7-18.4m283.2 156.2-36.6 36.9c-2 2-4.8 3.2-7.6 3.2H115.6c-9.6 0-14.4-11.6-7.7-18.4l36.6-36.9c2.1-2 4.8-3.2 7.6-3.2h231.3c9.7-.1 14.6 11.5 7.7 18.4",
827
- style: {
828
- fillRule: "evenodd",
829
- clipRule: "evenodd",
830
- fill: "url(#SolIcon_svg__a)"
831
- }
832
- }
833
- )
834
- ] });
835
- case "zora":
836
- return /* @__PURE__ */ jsxs(Fragment, { children: [
837
- /* @__PURE__ */ jsx(
838
- "path",
839
- {
840
- fill: "url(#ZoraIcon_svg__a)",
841
- d: "M70.615 141.23C31.615 141.23 0 109.615 0 70.615S31.616 0 70.615 0c39 0 70.615 31.615 70.615 70.615s-31.615 70.615-70.614 70.615Z"
842
- }
843
- ),
844
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
845
- "radialGradient",
846
- {
847
- id: "ZoraIcon_svg__a",
848
- cx: "0",
849
- cy: "0",
850
- r: "1",
851
- gradientTransform: "translate(102.676 37.972)scale(-119.284)",
852
- gradientUnits: "userSpaceOnUse",
853
- children: [
854
- /* @__PURE__ */ jsx("stop", { offset: "0.007", stopColor: "#f2cefe" }),
855
- /* @__PURE__ */ jsx("stop", { offset: "0.191", stopColor: "#afbaf1" }),
856
- /* @__PURE__ */ jsx("stop", { offset: "0.498", stopColor: "#4281d3" }),
857
- /* @__PURE__ */ jsx("stop", { offset: "0.667", stopColor: "#2e427d" }),
858
- /* @__PURE__ */ jsx("stop", { offset: "0.823", stopColor: "#230101" }),
859
- /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#8f6b40" })
860
- ]
861
- }
862
- ) })
863
- ] });
864
- default:
865
- return null;
778
+ ),
779
+ /* @__PURE__ */ jsx(
780
+ "path",
781
+ {
782
+ fill: "#fff",
783
+ d: "m0 33.302 4.293 2.474L18.58 12.865l-2.424-.064c-2.066-.03-4.291.508-5.313 2.175L2.73 27.55 0 31.743zm26.825-20.437-6.39.023L5.976 36.745l5.053 2.91 1.375-2.331 14.42-24.46Z"
784
+ }
785
+ ),
786
+ /* @__PURE__ */ jsx(
787
+ "path",
788
+ {
789
+ fill: "#96bedc",
790
+ d: "M39.191 12.832a4.07 4.07 0 0 0-1.91-3.272L21.394.424a4.13 4.13 0 0 0-3.645 0C17.617.49 2.3 9.373 2.3 9.373a4.04 4.04 0 0 0-2.3 3.45v18.92l2.73-4.194-.024-14.599a1.35 1.35 0 0 1 .562-1.015c.071-.05 15.649-9.068 15.699-9.093a1.38 1.38 0 0 1 1.198-.006l15.68 9.02c.371.236.604.637.624 1.075v18.084c-.018.383-.17.739-.468.98l-3.04 1.763-1.569.909-5.607 3.249-5.685 3.295a1.38 1.38 0 0 1-.968-.02l-6.727-3.868-1.375 2.33 6.046 3.481.524.297c.226.127.38.211.435.238.43.209 1.048.33 1.605.33.51 0 1.009-.094 1.48-.278l16.515-9.564a4.04 4.04 0 0 0 1.556-3.042z"
791
+ }
792
+ )
793
+ ]
866
794
  }
867
- };
868
- const getViewBox = () => {
869
- switch (chain) {
870
- case "eth":
871
- return "0 0 20 20";
872
- case "arb":
873
- return "0 0 40 44";
874
- case "base":
875
- return "0 0 111 111";
876
- case "bitcoin":
877
- return "0 0 500 500";
878
- case "op":
879
- return "0 0 84 84";
880
- case "sol":
881
- return "0 0 500 500";
882
- case "zora":
883
- return "0 0 142 142";
884
- default:
885
- return "0 0 24 24";
795
+ );
796
+ };
797
+
798
+ const BaseSvg = ({ size = 20, ...props }) => {
799
+ return /* @__PURE__ */ jsx(
800
+ "svg",
801
+ {
802
+ width: size,
803
+ height: size,
804
+ viewBox: "0 0 111 111",
805
+ fill: "none",
806
+ xmlns: "http://www.w3.org/2000/svg",
807
+ ...props,
808
+ children: /* @__PURE__ */ jsx(
809
+ "path",
810
+ {
811
+ fill: "#0052ff",
812
+ d: "M54.921 110.034c30.438 0 55.113-24.632 55.113-55.017S85.359 0 54.921 0C26.043 0 2.353 22.171 0 50.392h72.847v9.25H0c2.353 28.22 26.043 50.392 54.921 50.392"
813
+ }
814
+ )
886
815
  }
887
- };
888
- return /* @__PURE__ */ jsx("div", { className: `ns-chain-icon ${className || ""}`, children: /* @__PURE__ */ jsxs(
816
+ );
817
+ };
818
+
819
+ const BitcoinSvg = ({ size = 20, ...props }) => {
820
+ return /* @__PURE__ */ jsx(
821
+ "svg",
822
+ {
823
+ width: size,
824
+ height: size,
825
+ viewBox: "0 0 500 500",
826
+ fill: "none",
827
+ xmlns: "http://www.w3.org/2000/svg",
828
+ ...props,
829
+ children: /* @__PURE__ */ jsx(
830
+ "path",
831
+ {
832
+ fill: "#f39321",
833
+ d: "M43.43 125.143c7.71-10.766 14.875-21.901 23.562-31.986 15.8-18.343 33.692-34.063 54.18-47.075 18.379-11.672 37.761-20.872 58.501-27.305 32.294-10.018 65.26-12.997 98.838-9.165 24.544 2.801 48.191 9.067 70.713 19.215 13.633 6.142 26.456 13.731 39.025 21.927 25.328 16.515 45.618 38.014 62.58 62.577 18.116 26.236 29.889 55.421 36.346 86.725 4.535 21.983 6.449 44.171 4.503 66.504-2.399 27.536-8.514 54.086-19.938 79.604-9.662 21.583-21.589 41.401-36.861 59.301-14.94 17.511-31.788 32.831-51.149 45.461-13.184 8.6-26.926 16.276-41.434 21.975-24.274 9.537-49.447 15.986-75.787 17.115-18.545.795-36.985.483-55.279-2.763-15.713-2.788-31.049-6.858-46.063-12.496-14.566-5.47-28.693-11.95-41.709-20.143-18.766-11.812-35.683-26.147-50.737-42.663-16.773-18.403-30.373-38.808-40.779-61.344-14.7-31.835-21.929-65.401-22.359-100.425-.162-13.173 1.349-26.244 3.105-39.283.126-.933-.002-1.899-.012-2.851 1.536-.952 1.4-2.618 1.677-4.071 3.906-20.483 10.494-40.059 19.418-58.906 3.162-6.674 7.525-12.764 9.659-19.928m281.727 129.37c6.537-3.474 12.749-5.465 17.658-9.85 18.918-16.899 23.96-56.673-6.747-75.833-9.566-5.969-19.77-10.393-30.77-14.907 1.819-14.731 7.709-28.516 9.622-43.603-9.076-2.249-17.578-5.234-26.425-6.193l-10.674 41.837c-6.78-2.076-13.761-1.879-20.142-5.473 2.302-14.39 7.773-27.872 9.268-42.314-9.322-1.464-17.216-5.094-26.265-5.485l-10.586 42.215c-17.944-2.75-34.419-8.921-52.52-12.239-3.977 8.91-5.738 18.311-7.334 28.313 5.896 1.392 11.022 2.623 16.158 3.811 12.965 2.998 16.517 10.086 13.439 21.424-2.19 8.065-4.166 16.189-6.182 24.301-7.245 29.16-14.432 58.333-21.72 87.482-1.642 6.567-5.734 8.706-12.398 7.731-6.563-.96-12.757-3.907-19.99-3.693-3.136 10.032-9.378 18.871-11.588 29.946l51.344 13.08c-1.312 15.208-7.614 29.125-9.476 44.441l25.544 6.123c5.653-14.044 6.957-28.803 12.226-43.33 6.351 3.265 13.397 2.317 19.612 6.427l-10.178 42.077c8.986 3.216 17.753 4.528 26.758 6.77l10.578-42.386c2.123-1.091 3.676-.888 5.143-.574a132.9 132.9 0 0 0 42.676 2.14c12.368-1.373 23.343-6.088 32.148-15.372 9.791-10.323 14.71-22.952 17.078-36.535 1.93-11.065 1.436-22.277-5.06-32.071-5.091-7.674-12.084-13.53-21.197-18.26M223.128 312.17c17.411 4.325 34.803 8.95 53.02 5.624 9.715-1.774 17.037-6.73 19.985-16.503 2.78-9.218 1.164-17.593-5.673-24.879-7.11-7.576-16.254-11.514-25.682-14.807-11.264-3.934-22.683-7.508-34.99-8.48l-13.972 56.788c2.981.929 5.117 1.712 7.312 2.257m61.5-80.324c9.628-1.368 17.612-7.738 19.958-16.393 2.869-10.583-.337-19.865-8.902-26.178-9.718-7.163-20.908-10.807-32.47-13.337-4.307-.943-8.544-3.454-13.756-1.759l-12.599 51.209c16.457 4.155 31.611 8.753 47.769 6.458"
834
+ }
835
+ )
836
+ }
837
+ );
838
+ };
839
+
840
+ const MaticSvg = ({ size = 20, ...props }) => {
841
+ return /* @__PURE__ */ jsx(
842
+ "svg",
843
+ {
844
+ width: size,
845
+ height: size,
846
+ viewBox: "0 0 32 32",
847
+ fill: "none",
848
+ xmlns: "http://www.w3.org/2000/svg",
849
+ ...props,
850
+ children: /* @__PURE__ */ jsxs("g", { fill: "none", children: [
851
+ /* @__PURE__ */ jsx("circle", { fill: "#6F41D8", cx: "16", cy: "16", r: "16" }),
852
+ /* @__PURE__ */ jsx("path", { d: "M21.092 12.693c-.369-.215-.848-.215-1.254 0l-2.879 1.654-1.955 1.078-2.879 1.653c-.369.216-.848.216-1.254 0l-2.288-1.294c-.369-.215-.627-.61-.627-1.042V12.19c0-.431.221-.826.627-1.042l2.25-1.258c.37-.216.85-.216 1.256 0l2.25 1.258c.37.216.628.611.628 1.042v1.654l1.955-1.115v-1.653a1.16 1.16 0 00-.627-1.042l-4.17-2.372c-.369-.216-.848-.216-1.254 0l-4.244 2.372A1.16 1.16 0 006 11.076v4.78c0 .432.221.827.627 1.043l4.244 2.372c.369.215.849.215 1.254 0l2.879-1.618 1.955-1.114 2.879-1.617c.369-.216.848-.216 1.254 0l2.251 1.258c.37.215.627.61.627 1.042v2.552c0 .431-.22.826-.627 1.042l-2.25 1.294c-.37.216-.85.216-1.255 0l-2.251-1.258c-.37-.216-.628-.611-.628-1.042v-1.654l-1.955 1.115v1.653c0 .431.221.827.627 1.042l4.244 2.372c.369.216.848.216 1.254 0l4.244-2.372c.369-.215.627-.61.627-1.042v-4.78a1.16 1.16 0 00-.627-1.042l-4.28-2.409z", fill: "#FFF" })
853
+ ] })
854
+ }
855
+ );
856
+ };
857
+
858
+ const OpSvg = ({ size = 20, ...props }) => {
859
+ return /* @__PURE__ */ jsxs(
889
860
  "svg",
890
861
  {
891
862
  width: size,
892
863
  height: size,
893
- viewBox: getViewBox(),
864
+ viewBox: "0 0 84 84",
894
865
  fill: "none",
895
866
  xmlns: "http://www.w3.org/2000/svg",
896
867
  ...props,
897
868
  children: [
898
- renderIcon(),
899
- chain === "eth" && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: "clip0_597_2890", children: /* @__PURE__ */ jsx(
900
- "rect",
869
+ /* @__PURE__ */ jsx(
870
+ "path",
901
871
  {
902
- width: "19",
903
- height: "19",
904
- fill: "white",
905
- transform: "translate(0.255859 0.5)"
872
+ fill: "#ff0420",
873
+ d: "M42 84c23.196 0 42-18.804 42-42S65.196 0 42 0 0 18.804 0 42s18.804 42 42 42"
874
+ }
875
+ ),
876
+ /* @__PURE__ */ jsx(
877
+ "path",
878
+ {
879
+ fill: "#fff",
880
+ d: "M30.461 53.76q-3.8 0-6.226-1.83-2.395-1.861-2.395-5.291 0-.72.16-1.764.414-2.352 1.181-5.651 2.171-8.984 11.208-8.984 2.46 0 4.407.85 1.947.817 3.065 2.482 1.118 1.635 1.118 3.92 0 .687-.16 1.732a76 76 0 0 1-1.15 5.65q-1.116 4.476-3.863 6.697-2.747 2.19-7.345 2.19Zm.448-4.704q1.788 0 3.033-1.078 1.277-1.077 1.82-3.3.735-3.07 1.118-5.356.127-.687.127-1.405 0-2.973-3.033-2.973-1.788 0-3.065 1.078-1.245 1.078-1.789 3.3-.574 2.188-1.15 5.357a7 7 0 0 0-.127 1.372q0 3.005 3.066 3.005m13.536 4.377q-.351 0-.543-.229a.8.8 0 0 1-.096-.588l4.407-21.233a.94.94 0 0 1 .351-.588.96.96 0 0 1 .607-.229h8.494q3.544 0 5.684 1.503 2.17 1.503 2.171 4.345a8 8 0 0 1-.192 1.698q-.798 3.757-3.225 5.554-2.395 1.797-6.578 1.797h-4.31l-1.47 7.153a.94.94 0 0 1-.35.588.96.96 0 0 1-.607.23zm11.304-12.478q1.34 0 2.33-.752 1.023-.751 1.342-2.156.096-.555.096-.98 0-.947-.543-1.437-.544-.523-1.852-.523H53.29l-1.213 5.848z"
906
881
  }
907
- ) }) })
882
+ )
908
883
  ]
909
884
  }
910
- ) });
885
+ );
911
886
  };
912
887
 
913
- const Tooltip = ({
914
- children,
915
- content,
916
- position = "top",
917
- delay = 200,
918
- disabled = false,
919
- className = "",
920
- contentClassName = "",
921
- trigger = "hover",
922
- maxWidth = 200,
923
- offset = 8
924
- }) => {
925
- const [isVisible, setIsVisible] = useState(false);
926
- const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });
927
- const triggerRef = useRef(null);
928
- const tooltipRef = useRef(null);
929
- const timeoutRef = useRef(void 0);
930
- const showTooltip = () => {
931
- if (disabled) return;
932
- if (timeoutRef.current) {
933
- clearTimeout(timeoutRef.current);
934
- }
935
- timeoutRef.current = setTimeout(() => {
936
- setIsVisible(true);
937
- }, delay);
938
- };
939
- const hideTooltip = () => {
940
- if (timeoutRef.current) {
941
- clearTimeout(timeoutRef.current);
888
+ const SolSvg = ({ size = 20, ...props }) => {
889
+ return /* @__PURE__ */ jsxs(
890
+ "svg",
891
+ {
892
+ width: size,
893
+ height: size,
894
+ viewBox: "0 0 500 500",
895
+ fill: "none",
896
+ xmlns: "http://www.w3.org/2000/svg",
897
+ ...props,
898
+ children: [
899
+ /* @__PURE__ */ jsx("path", { d: "M250 0c138 0 250 111.9 250 250S388 500 250 500 0 388 0 250 111.9 0 250 0" }),
900
+ /* @__PURE__ */ jsxs(
901
+ "linearGradient",
902
+ {
903
+ id: "SolIcon_svg__a",
904
+ x1: "242.52",
905
+ x2: "755.68",
906
+ y1: "267.33",
907
+ y2: "-245.83",
908
+ gradientTransform: "matrix(.5 0 0 .5 0 250)",
909
+ gradientUnits: "userSpaceOnUse",
910
+ children: [
911
+ /* @__PURE__ */ jsx("stop", { offset: "0", style: { stopColor: "rgb(203, 78, 232)" } }),
912
+ /* @__PURE__ */ jsx("stop", { offset: "1", style: { stopColor: "rgb(16, 244, 177)" } })
913
+ ]
914
+ }
915
+ ),
916
+ /* @__PURE__ */ jsx(
917
+ "path",
918
+ {
919
+ d: "M115.6 226.1H347c2.9 0 5.6 1.1 7.6 3.2l36.6 36.8c6.8 6.8 2 18.4-7.6 18.4H152.2c-2.9 0-5.6-1.1-7.6-3.2L108 244.5c-6.8-6.7-2-18.4 7.6-18.4m-7.7-48.8 36.6-36.8c2.1-2.1 4.8-3.2 7.6-3.2h231.3c9.6 0 14.5 11.6 7.6 18.4l-36.5 36.8c-2 2.1-4.8 3.2-7.6 3.2H115.6c-9.6 0-14.4-11.6-7.7-18.4m283.2 156.2-36.6 36.9c-2 2-4.8 3.2-7.6 3.2H115.6c-9.6 0-14.4-11.6-7.7-18.4l36.6-36.9c2.1-2 4.8-3.2 7.6-3.2h231.3c9.7-.1 14.6 11.5 7.7 18.4",
920
+ style: {
921
+ fillRule: "evenodd",
922
+ clipRule: "evenodd",
923
+ fill: "url(#SolIcon_svg__a)"
924
+ }
925
+ }
926
+ )
927
+ ]
942
928
  }
943
- setIsVisible(false);
944
- };
945
- const calculatePosition = () => {
946
- if (!triggerRef.current || !tooltipRef.current) return;
947
- const triggerRect = triggerRef.current.getBoundingClientRect();
948
- const tooltipRect = tooltipRef.current.getBoundingClientRect();
949
- const viewport = {
950
- width: window.innerWidth,
951
- height: window.innerHeight
952
- };
953
- let top = 0;
954
- let left = 0;
955
- const baseOffset = offset;
956
- const triggerCenterX = triggerRect.left + triggerRect.width / 2;
957
- const triggerCenterY = triggerRect.top + triggerRect.height / 2;
958
- switch (position) {
929
+ );
930
+ };
931
+
932
+ const ZoraSvg = ({ size = 20, ...props }) => {
933
+ return /* @__PURE__ */ jsxs(
934
+ "svg",
935
+ {
936
+ width: size,
937
+ height: size,
938
+ viewBox: "0 0 142 142",
939
+ fill: "none",
940
+ xmlns: "http://www.w3.org/2000/svg",
941
+ ...props,
942
+ children: [
943
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
944
+ "radialGradient",
945
+ {
946
+ id: "ZoraIcon_svg__a",
947
+ cx: "0",
948
+ cy: "0",
949
+ r: "1",
950
+ gradientTransform: "translate(102.676 37.972)scale(-119.284)",
951
+ gradientUnits: "userSpaceOnUse",
952
+ children: [
953
+ /* @__PURE__ */ jsx("stop", { offset: "0.007", stopColor: "#f2cefe" }),
954
+ /* @__PURE__ */ jsx("stop", { offset: "0.191", stopColor: "#afbaf1" }),
955
+ /* @__PURE__ */ jsx("stop", { offset: "0.498", stopColor: "#4281d3" }),
956
+ /* @__PURE__ */ jsx("stop", { offset: "0.667", stopColor: "#2e427d" }),
957
+ /* @__PURE__ */ jsx("stop", { offset: "0.823", stopColor: "#230101" }),
958
+ /* @__PURE__ */ jsx("stop", { offset: "1", stopColor: "#8f6b40" })
959
+ ]
960
+ }
961
+ ) }),
962
+ /* @__PURE__ */ jsx(
963
+ "path",
964
+ {
965
+ fill: "url(#ZoraIcon_svg__a)",
966
+ d: "M70.615 141.23C31.615 141.23 0 109.615 0 70.615S31.616 0 70.615 0c39 0 70.615 31.615 70.615 70.615s-31.615 70.615-70.614 70.615Z"
967
+ }
968
+ )
969
+ ]
970
+ }
971
+ );
972
+ };
973
+
974
+ const CeloSvg = ({ size = 20, ...props }) => {
975
+ return /* @__PURE__ */ jsxs(
976
+ "svg",
977
+ {
978
+ width: size,
979
+ height: size,
980
+ viewBox: "0 0 2500 2500",
981
+ fill: "none",
982
+ xmlns: "http://www.w3.org/2000/svg",
983
+ ...props,
984
+ children: [
985
+ /* @__PURE__ */ jsx(
986
+ "circle",
987
+ {
988
+ cx: "1250",
989
+ cy: "1250",
990
+ r: "1250",
991
+ fill: "#FCFF52",
992
+ fillRule: "evenodd",
993
+ clipRule: "evenodd"
994
+ }
995
+ ),
996
+ /* @__PURE__ */ jsx(
997
+ "path",
998
+ {
999
+ d: "M1949.3,546.2H550.7v1407.7h1398.7v-491.4h-232.1c-80,179.3-260.1,304.1-466.2,304.1 c-284.1,0-514.2-233.6-514.2-517.5c0-284,230.1-515.6,514.2-515.6c210.1,0,390.2,128.9,470.2,312.1h228.1V546.2z",
1000
+ fill: "currentColor",
1001
+ fillRule: "evenodd",
1002
+ clipRule: "evenodd"
1003
+ }
1004
+ )
1005
+ ]
1006
+ }
1007
+ );
1008
+ };
1009
+
1010
+ const ChainIcon = ({
1011
+ chain,
1012
+ size = 20,
1013
+ className,
1014
+ ...props
1015
+ }) => {
1016
+ const renderIcon = () => {
1017
+ switch (chain) {
1018
+ case "eth":
1019
+ return /* @__PURE__ */ jsx(EthSvg, { size, ...props });
1020
+ case "arb":
1021
+ return /* @__PURE__ */ jsx(ArbSvg, { size, ...props });
1022
+ case "base":
1023
+ return /* @__PURE__ */ jsx(BaseSvg, { size, ...props });
1024
+ case "bitcoin":
1025
+ return /* @__PURE__ */ jsx(BitcoinSvg, { size, ...props });
1026
+ case "matic":
1027
+ return /* @__PURE__ */ jsx(MaticSvg, { size, ...props });
1028
+ case "op":
1029
+ return /* @__PURE__ */ jsx(OpSvg, { size, ...props });
1030
+ case "sol":
1031
+ return /* @__PURE__ */ jsx(SolSvg, { size, ...props });
1032
+ case "zora":
1033
+ return /* @__PURE__ */ jsx(ZoraSvg, { size, ...props });
1034
+ case "celo":
1035
+ return /* @__PURE__ */ jsx(CeloSvg, { size, ...props });
1036
+ default:
1037
+ return null;
1038
+ }
1039
+ };
1040
+ return /* @__PURE__ */ jsx("div", { className: `ns-chain-icon ${className || ""}`, children: renderIcon() });
1041
+ };
1042
+
1043
+ const Tooltip = ({
1044
+ children,
1045
+ content,
1046
+ position = "top",
1047
+ delay = 200,
1048
+ disabled = false,
1049
+ className = "",
1050
+ contentClassName = "",
1051
+ trigger = "hover",
1052
+ maxWidth = 200,
1053
+ offset = 8
1054
+ }) => {
1055
+ const [isVisible, setIsVisible] = useState(false);
1056
+ const [tooltipPosition, setTooltipPosition] = useState({ top: 0, left: 0 });
1057
+ const triggerRef = useRef(null);
1058
+ const tooltipRef = useRef(null);
1059
+ const timeoutRef = useRef(void 0);
1060
+ const showTooltip = () => {
1061
+ if (disabled) return;
1062
+ if (timeoutRef.current) {
1063
+ clearTimeout(timeoutRef.current);
1064
+ }
1065
+ timeoutRef.current = setTimeout(() => {
1066
+ setIsVisible(true);
1067
+ }, delay);
1068
+ };
1069
+ const hideTooltip = () => {
1070
+ if (timeoutRef.current) {
1071
+ clearTimeout(timeoutRef.current);
1072
+ }
1073
+ setIsVisible(false);
1074
+ };
1075
+ const calculatePosition = () => {
1076
+ if (!triggerRef.current || !tooltipRef.current) return;
1077
+ const triggerRect = triggerRef.current.getBoundingClientRect();
1078
+ const tooltipRect = tooltipRef.current.getBoundingClientRect();
1079
+ const viewport = {
1080
+ width: window.innerWidth,
1081
+ height: window.innerHeight
1082
+ };
1083
+ let top = 0;
1084
+ let left = 0;
1085
+ const baseOffset = offset;
1086
+ const triggerCenterX = triggerRect.left + triggerRect.width / 2;
1087
+ const triggerCenterY = triggerRect.top + triggerRect.height / 2;
1088
+ switch (position) {
959
1089
  case "top":
960
1090
  top = triggerRect.top - tooltipRect.height - baseOffset;
961
1091
  left = triggerCenterX - tooltipRect.width / 2;
@@ -1116,93 +1246,518 @@ const Tooltip = ({
1116
1246
  );
1117
1247
  };
1118
1248
 
1119
- const capitalize = (value) => {
1120
- return value.charAt(0).toLocaleUpperCase() + value.substring(1);
1121
- };
1122
- const equalsIgnoreCase = (a, b) => {
1123
- return a.toLocaleLowerCase() === b.toLocaleLowerCase();
1124
- };
1125
- const deepCopy = (a) => {
1126
- return JSON.parse(JSON.stringify(a));
1127
- };
1128
-
1129
- function convertEVMChainIdToCoinType(chainId) {
1130
- return (2147483648 | chainId) >>> 0;
1131
- }
1132
-
1133
- const getEnsRecordsDiff = (oldRecords, newRecords) => {
1134
- const { textsAdded, textsModified, textsRemoved } = getEnsTextDiff(
1135
- oldRecords.texts,
1136
- newRecords.texts
1137
- );
1138
- const { addressesAdded, addressesModified, addressesRemoved } = getEnsAddressDiff(oldRecords.addresses, newRecords.addresses);
1139
- const { contenthashAdded, contenthashModified, contenthashRemoved } = getEnsContenthashDiff(oldRecords.contenthash, newRecords.contenthash);
1140
- return {
1141
- addressesAdded,
1142
- addressesModified,
1143
- addressesRemoved,
1144
- textsAdded,
1145
- textsModified,
1146
- textsRemoved,
1147
- contenthashAdded,
1148
- contenthashModified,
1149
- contenthashRemoved
1249
+ var TransactionState = /* @__PURE__ */ ((TransactionState2) => {
1250
+ TransactionState2["InProgress"] = "In Progress";
1251
+ TransactionState2["Completed"] = "Completed";
1252
+ TransactionState2["Failed"] = "Failed";
1253
+ return TransactionState2;
1254
+ })(TransactionState || {});
1255
+ const PendingTransaction = ({
1256
+ state,
1257
+ blockExplorerUrl,
1258
+ transactionHash,
1259
+ className = ""
1260
+ }) => {
1261
+ const getStatusIcon = () => {
1262
+ switch (state) {
1263
+ case "In Progress" /* InProgress */:
1264
+ return /* @__PURE__ */ jsx("div", { className: "ns-pending-tx__spinner" });
1265
+ case "Completed" /* Completed */:
1266
+ return /* @__PURE__ */ jsx(Icon, { name: "check-circle", size: 24 });
1267
+ case "Failed" /* Failed */:
1268
+ return /* @__PURE__ */ jsx(Icon, { name: "x-circle", size: 24 });
1269
+ default:
1270
+ return null;
1271
+ }
1150
1272
  };
1151
- };
1152
- const getEnsTextDiff = (oldTexts, newTexts) => {
1153
- if (oldTexts.length === 0) {
1154
- return {
1155
- textsAdded: newTexts,
1156
- textsModified: [],
1157
- textsRemoved: []
1158
- };
1159
- }
1160
- const oldTextMap = {};
1161
- const textsRemoved = [];
1162
- oldTexts.forEach((text) => {
1163
- oldTextMap[text.key] = text;
1164
- const existsInNew = newTexts.find((newText) => newText.key === text.key);
1165
- if (!existsInNew) {
1166
- textsRemoved.push(text);
1273
+ const getStatusMessage = () => {
1274
+ switch (state) {
1275
+ case "In Progress" /* InProgress */:
1276
+ return "Transaction is being executed...";
1277
+ case "Completed" /* Completed */:
1278
+ return "Transaction completed successfully!";
1279
+ case "Failed" /* Failed */:
1280
+ return "Transaction failed!";
1281
+ default:
1282
+ return "";
1167
1283
  }
1168
- });
1169
- const textsAdded = [];
1170
- const textsModified = [];
1171
- newTexts.forEach((newText) => {
1172
- const matchingOldText = oldTextMap[newText.key];
1173
- if (!matchingOldText) {
1174
- textsAdded.push(newText);
1175
- } else if (matchingOldText.value !== newText.value) {
1176
- textsModified.push(newText);
1284
+ };
1285
+ const getStatusClass = () => {
1286
+ switch (state) {
1287
+ case "In Progress" /* InProgress */:
1288
+ return "ns-pending-tx--in-progress";
1289
+ case "Completed" /* Completed */:
1290
+ return "ns-pending-tx--completed";
1291
+ case "Failed" /* Failed */:
1292
+ return "ns-pending-tx--failed";
1293
+ default:
1294
+ return "";
1177
1295
  }
1178
- });
1179
- return {
1180
- textsAdded,
1181
- textsModified,
1182
- textsRemoved
1183
1296
  };
1184
- };
1185
- const getEnsAddressDiff = (oldAddresses, newAddresses) => {
1186
- if (oldAddresses.length === 0) {
1187
- return {
1188
- addressesAdded: newAddresses,
1189
- addressesModified: [],
1190
- addressesRemoved: []
1191
- };
1192
- }
1193
- const oldAddressMap = {};
1194
- const addressesRemoved = [];
1195
- oldAddresses.forEach((address) => {
1196
- oldAddressMap[address.coinType] = address;
1197
- const existsInNew = newAddresses.find(
1198
- (newAddress) => newAddress.coinType === address.coinType
1199
- );
1200
- if (!existsInNew) {
1201
- addressesRemoved.push(address);
1297
+ const getIconClass = () => {
1298
+ switch (state) {
1299
+ case "In Progress" /* InProgress */:
1300
+ return "ns-pending-tx__icon--in-progress";
1301
+ case "Completed" /* Completed */:
1302
+ return "ns-pending-tx__icon--completed";
1303
+ case "Failed" /* Failed */:
1304
+ return "ns-pending-tx__icon--failed";
1305
+ default:
1306
+ return "";
1202
1307
  }
1203
- });
1204
- const addressesAdded = [];
1205
- const addressesModified = [];
1308
+ };
1309
+ return /* @__PURE__ */ jsx("div", { className: `ns-pending-tx ${getStatusClass()} ${className}`, children: /* @__PURE__ */ jsxs("div", { className: "ns-pending-tx__content", children: [
1310
+ /* @__PURE__ */ jsx("div", { className: `ns-pending-tx__icon ${getIconClass()}`, children: getStatusIcon() }),
1311
+ /* @__PURE__ */ jsx("div", { className: "ns-pending-tx__status", children: /* @__PURE__ */ jsx(Text, { children: getStatusMessage() }) }),
1312
+ transactionHash && /* @__PURE__ */ jsxs("p", { className: "ns-pending-tx__message", children: [
1313
+ "Hash: ",
1314
+ transactionHash.slice(0, 10),
1315
+ "...",
1316
+ transactionHash.slice(-8)
1317
+ ] }),
1318
+ /* @__PURE__ */ jsxs(
1319
+ "a",
1320
+ {
1321
+ href: blockExplorerUrl,
1322
+ target: "_blank",
1323
+ rel: "noopener noreferrer",
1324
+ className: "ns-pending-tx__link",
1325
+ children: [
1326
+ /* @__PURE__ */ jsx(Icon, { name: "globe", size: 16, className: "ns-pending-tx__link-icon" }),
1327
+ "View on Block Explorer"
1328
+ ]
1329
+ }
1330
+ )
1331
+ ] }) });
1332
+ };
1333
+
1334
+ const Dropdown = ({
1335
+ trigger,
1336
+ children,
1337
+ placement = "bottom",
1338
+ align = "start",
1339
+ disabled = false,
1340
+ dataTestId
1341
+ }) => {
1342
+ const [isOpen, setIsOpen] = useState(false);
1343
+ const triggerRef = useRef(null);
1344
+ const dropdownRef = useRef(null);
1345
+ const handleToggle = useCallback(() => {
1346
+ if (!disabled) {
1347
+ setIsOpen((prev) => !prev);
1348
+ }
1349
+ }, [disabled]);
1350
+ const handleClickOutside = useCallback((event) => {
1351
+ if (triggerRef.current && !triggerRef.current.contains(event.target) && dropdownRef.current && !dropdownRef.current.contains(event.target)) {
1352
+ setIsOpen(false);
1353
+ }
1354
+ }, []);
1355
+ useEffect(() => {
1356
+ if (isOpen) {
1357
+ document.addEventListener("mousedown", handleClickOutside);
1358
+ document.addEventListener("keydown", (e) => {
1359
+ if (e.key === "Escape") setIsOpen(false);
1360
+ });
1361
+ }
1362
+ return () => {
1363
+ document.removeEventListener("mousedown", handleClickOutside);
1364
+ };
1365
+ }, [isOpen, handleClickOutside]);
1366
+ const getPlacementClasses = () => {
1367
+ const placementClass = `ns-dropdown--${placement}`;
1368
+ const alignClass = `ns-dropdown--align-${align}`;
1369
+ return `${placementClass} ${alignClass}`;
1370
+ };
1371
+ return /* @__PURE__ */ jsxs("div", { className: "ns-dropdown", "data-test-id": dataTestId, children: [
1372
+ /* @__PURE__ */ jsx(
1373
+ "div",
1374
+ {
1375
+ ref: triggerRef,
1376
+ className: "ns-dropdown__trigger",
1377
+ onClick: handleToggle,
1378
+ role: "button",
1379
+ tabIndex: disabled ? -1 : 0,
1380
+ "aria-expanded": isOpen,
1381
+ "aria-haspopup": "true",
1382
+ onKeyDown: (e) => {
1383
+ if (e.key === "Enter" || e.key === " ") {
1384
+ e.preventDefault();
1385
+ handleToggle();
1386
+ }
1387
+ },
1388
+ children: trigger
1389
+ }
1390
+ ),
1391
+ isOpen && /* @__PURE__ */ jsx(
1392
+ "div",
1393
+ {
1394
+ ref: dropdownRef,
1395
+ className: `ns-dropdown__menu ${getPlacementClasses()}`,
1396
+ role: "menu",
1397
+ "aria-orientation": "vertical",
1398
+ children
1399
+ }
1400
+ )
1401
+ ] });
1402
+ };
1403
+
1404
+ var ContenthashProtocol = /* @__PURE__ */ ((ContenthashProtocol2) => {
1405
+ ContenthashProtocol2["Ipfs"] = "ipfs";
1406
+ ContenthashProtocol2["Onion"] = "onion3";
1407
+ ContenthashProtocol2["Arweave"] = "arweave";
1408
+ ContenthashProtocol2["Skynet"] = "skynet";
1409
+ ContenthashProtocol2["Swarm"] = "swarm";
1410
+ return ContenthashProtocol2;
1411
+ })(ContenthashProtocol || {});
1412
+
1413
+ const IpfsIcon = ({ size = 20 }) => {
1414
+ return /* @__PURE__ */ jsxs(
1415
+ "svg",
1416
+ {
1417
+ xmlns: "http://www.w3.org/2000/svg",
1418
+ width: size,
1419
+ height: size,
1420
+ viewBox: "0 0 20 22",
1421
+ fill: "none",
1422
+ children: [
1423
+ /* @__PURE__ */ jsx(
1424
+ "path",
1425
+ {
1426
+ fill: "#469EA2",
1427
+ d: "m0 16.44 9.56 5.48 9.559-5.48V5.48L9.559 0 0 5.48z"
1428
+ }
1429
+ ),
1430
+ /* @__PURE__ */ jsx(
1431
+ "path",
1432
+ {
1433
+ fill: "#6ACAD1",
1434
+ d: "M8.58 1.31 1.64 5.289a2 2 0 0 1 0 .373l6.93 3.977a1.66 1.66 0 0 1 1.97 0l6.93-3.977a2 2 0 0 1 0-.373l-6.92-3.977a1.66 1.66 0 0 1-1.968 0m9.56 5.447-6.942 4.023c.038.348-.036.7-.212 1.005a1.67 1.67 0 0 1-.766.69l.011 7.91q.17.073.319.18l6.93-3.978c-.037-.348.037-.7.213-1.005s.444-.545.766-.69V6.939a2.3 2.3 0 0 1-.319-.181M.98 6.802q-.15.107-.319.181v7.955c.326.139.598.38.775.685.176.306.248.66.204 1.01l6.93 3.977q.15-.107.32-.18v-7.955a1.63 1.63 0 0 1-.775-.686 1.6 1.6 0 0 1-.205-1.01z"
1435
+ }
1436
+ ),
1437
+ /* @__PURE__ */ jsx(
1438
+ "path",
1439
+ {
1440
+ fill: "#469EA2",
1441
+ d: "m9.56 1.186 8.546 4.904v9.797L9.56 20.791l-8.547-4.904V6.079zm0-1.163L0 5.503v10.96l9.56 5.48 9.559-5.48V5.503z"
1442
+ }
1443
+ ),
1444
+ /* @__PURE__ */ jsx(
1445
+ "path",
1446
+ {
1447
+ fill: "#469EA2",
1448
+ d: "M9.628 12.825H9.49a1.8 1.8 0 0 1-1.264-.518 1.77 1.77 0 0 1-.522-1.256v-.136a1.76 1.76 0 0 1 .521-1.255 1.78 1.78 0 0 1 1.265-.519h.137a1.8 1.8 0 0 1 1.265.519 1.77 1.77 0 0 1 .521 1.255v.136a1.76 1.76 0 0 1-.521 1.256 1.78 1.78 0 0 1-1.265.518m0 7.288H9.49a1.79 1.79 0 0 0-1.559.904l1.628.927 1.627-.927a1.79 1.79 0 0 0-1.56-.904m9.502-5.48h-.068a1.8 1.8 0 0 0-1.265.518 1.77 1.77 0 0 0-.522 1.256v.135a1.7 1.7 0 0 0 .228.86l1.627-.939zM17.503 4.576a1.73 1.73 0 0 0-.228.859v.136a1.76 1.76 0 0 0 .522 1.255 1.78 1.78 0 0 0 1.265.519h.068V5.503zM9.56.023 7.932.949a1.78 1.78 0 0 0 1.56.915h.136A1.79 1.79 0 0 0 11.187.96zM1.627 4.565 0 5.503v1.842h.068a1.8 1.8 0 0 0 1.265-.519 1.77 1.77 0 0 0 .522-1.255v-.136a1.9 1.9 0 0 0-.228-.87M.068 14.633H0v1.83l1.627.938a1.73 1.73 0 0 0 .228-.859v-.135a1.76 1.76 0 0 0-.522-1.256 1.78 1.78 0 0 0-1.265-.518"
1449
+ }
1450
+ ),
1451
+ /* @__PURE__ */ jsx(
1452
+ "path",
1453
+ {
1454
+ fill: "#083B54",
1455
+ fillOpacity: "0.15",
1456
+ d: "M9.56 22V11.028L0 5.548V16.52z"
1457
+ }
1458
+ ),
1459
+ /* @__PURE__ */ jsx(
1460
+ "path",
1461
+ {
1462
+ fill: "#083B54",
1463
+ fillOpacity: "0.05",
1464
+ d: "M19.13 16.418V5.458l-9.56 5.48V21.91z"
1465
+ }
1466
+ )
1467
+ ]
1468
+ }
1469
+ );
1470
+ };
1471
+
1472
+ const OnionIcon = ({ size = 20 }) => {
1473
+ return /* @__PURE__ */ jsx(
1474
+ "svg",
1475
+ {
1476
+ xmlns: "http://www.w3.org/2000/svg",
1477
+ width: size,
1478
+ height: size * 1.18,
1479
+ "data-name": "Layer 1",
1480
+ viewBox: "0 0 161 190",
1481
+ children: /* @__PURE__ */ jsx(
1482
+ "path",
1483
+ {
1484
+ fill: "#7D50CF",
1485
+ d: "M141.67 74.68c-16.3-17.8-41.29-40.85-44-52.41S102.17 0 102.17 0C90.76-.21 84.29 5.54 80.56 12.07 76.9 5.54 70.36-.21 59 0c0 0 7.25 10.62 4.52 22.26s-27.77 34.62-44 52.43c-45.45 49.76-6 115.82 61 115.82s106.53-66.06 61.15-115.83M80.56 175.29c-27 0-57.73-14.51-64.55-43.81-7.76-34.25 25.77-55.29 45.59-75.9l3.23 3.24c1.73 1.65 3.45 3.37 5.25 5-1.44 1.44-2.88 2.8-4.17 4.09C49.47 84 21 102.33 27.21 128.68c5.53 23.63 31.81 34.69 53.35 34.69s47.82-11.06 53.35-34.69c6.18-26.35-22.26-44.73-38.7-60.75C87.45 60.32 79.7 52.57 72 44.81a95 95 0 0 0 8.41-10.05l.14-.14.14.14c20.76 30.09 74.25 54.57 64.49 96.72-6.89 29.3-37.55 43.81-64.62 43.81m20.54-66.14a48 48 0 0 0-4.46-4.67l8.36-8.76c12.07 12.35 23.56 27.79 5.82 42.87-7.68 6.54-19.24 9.48-30.37 9.48s-22.62-2.94-30.31-9.48c-17.8-15.15-6.1-30.66 6-43.08l8.33 8.83a37.3 37.3 0 0 0-4.67 4.81c-13.14 16.3 6.1 26.43 20.61 26.43s33.83-10.13 20.69-26.43m-10.7 10.63a19.71 19.71 0 0 1-19.61-.07l4.1-23.41a11.62 11.62 0 1 1 17.3-10.13 11.44 11.44 0 0 1-6 10.13z"
1486
+ }
1487
+ )
1488
+ }
1489
+ );
1490
+ };
1491
+
1492
+ const ArweaveIcon = ({ size = 20 }) => {
1493
+ return /* @__PURE__ */ jsxs(
1494
+ "svg",
1495
+ {
1496
+ xmlns: "http://www.w3.org/2000/svg",
1497
+ xmlSpace: "preserve",
1498
+ width: size,
1499
+ height: size,
1500
+ viewBox: "0 0 31.8 31.8",
1501
+ children: [
1502
+ /* @__PURE__ */ jsx(
1503
+ "circle",
1504
+ {
1505
+ cx: "15.9",
1506
+ cy: "15.9",
1507
+ r: "14.7",
1508
+ fill: "none",
1509
+ stroke: "currentColor",
1510
+ strokeWidth: "2.5",
1511
+ className: "arweave_svg__st0"
1512
+ }
1513
+ ),
1514
+ /* @__PURE__ */ jsx(
1515
+ "path",
1516
+ {
1517
+ fill: "currentColor",
1518
+ d: "M18.7 21.2c-.1-.1-.1-.3-.2-.5 0-.2-.1-.4-.1-.6-.2.2-.4.3-.6.5s-.5.3-.7.4c-.3.1-.5.2-.9.3-.3.1-.7.1-1 .1-.6 0-1.1-.1-1.6-.3s-.9-.4-1.3-.7-.6-.7-.8-1.1-.3-.9-.3-1.4c0-1.2.5-2.2 1.4-2.8.9-.7 2.3-1 4.1-1h1.7v-.7c0-.6-.2-1-.5-1.3-.4-.3-.9-.5-1.6-.5-.6 0-1 .1-1.3.4s-.4.6-.4 1h-3c0-.5.1-1 .3-1.4s.5-.8 1-1.2c.4-.3.9-.6 1.5-.8q.9-.3 2.1-.3c.7 0 1.3.1 1.9.3s1.1.4 1.6.8c.4.3.8.8 1 1.3s.4 1.1.4 1.8v5c0 .6 0 1.1.1 1.5s.2.8.3 1v.2zm-2.9-2.1c.3 0 .6 0 .8-.1.3-.1.5-.2.7-.3s.4-.2.5-.4l.4-.4v-2h-1.5c-.5 0-.9 0-1.2.1s-.6.2-.8.4-.4.3-.5.6c-.1.2-.1.5-.1.7 0 .4.1.7.4 1s.8.4 1.3.4",
1519
+ className: "arweave_svg__st1"
1520
+ }
1521
+ )
1522
+ ]
1523
+ }
1524
+ );
1525
+ };
1526
+
1527
+ const SkynetIcon = ({ size = 20 }) => {
1528
+ return /* @__PURE__ */ jsx(
1529
+ "svg",
1530
+ {
1531
+ xmlns: "http://www.w3.org/2000/svg",
1532
+ width: size,
1533
+ height: size,
1534
+ viewBox: "0 0 24 24",
1535
+ style: { color: "rgb(0, 198, 94)" },
1536
+ children: /* @__PURE__ */ jsx(
1537
+ "path",
1538
+ {
1539
+ fill: "#00c65e",
1540
+ d: "m0 6.46 21.389 11.297a.917.917 0 0 1 .2 1.485h-.011a10 10 0 0 1-2.234 1.53c-6.912 3.474-14.991-1.837-14.543-9.56l2.86 1.975c.856 4.508 5.618 7.11 9.874 5.393zm8.647 3.151 14.366 5.679a.87.87 0 0 1 .52 1.046v.018a.872.872 0 0 1-1.257.526zm5.29-7.437c2.71-.233 6.095.787 8.111 3.387 1.7 2.195 2.05 4.877 1.93 7.646V13.2a.878.878 0 0 1-1.197.745l-9.765-3.86 9.065 2.432a7.3 7.3 0 0 0-1.068-4.563c-2.968-4.768-9.984-4.535-12.63.42a8 8 0 0 0-.397.883L5.555 7.961q.104-.15.214-.296c.116-.241.242-.487.38-.727 1.612-2.79 4.31-4.433 7.156-4.697.21-.018.421-.049.632-.067z"
1541
+ }
1542
+ )
1543
+ }
1544
+ );
1545
+ };
1546
+
1547
+ const SwarmIcon = ({ size = 20 }) => {
1548
+ return /* @__PURE__ */ jsx(
1549
+ "svg",
1550
+ {
1551
+ xmlns: "http://www.w3.org/2000/svg",
1552
+ width: size,
1553
+ height: size * 1.03,
1554
+ fill: "none",
1555
+ children: /* @__PURE__ */ jsxs("g", { fill: "#FF8A00", children: [
1556
+ /* @__PURE__ */ jsx("path", { d: "m0 30.47 8.02 4.502 8.022-4.502v-8.986L8.02 16.977 0 21.484zM26.516.03l-4.24 2.381-.006.036v4.758l4.246 2.382.036.017 4.24-2.376V2.43zM34.4 21.484l-8.02-4.507-8.022 4.507v8.986l8.021 4.502L34.4 30.47z" }),
1557
+ /* @__PURE__ */ jsx("path", { d: "m17.137 1.285-8.01 4.502v8.986l8.022 4.501 8.02-4.501v-3.58l-3.905-2.19-1.054-.59V3.119z" })
1558
+ ] })
1559
+ }
1560
+ );
1561
+ };
1562
+
1563
+ const icons = {
1564
+ [ContenthashProtocol.Ipfs]: IpfsIcon,
1565
+ [ContenthashProtocol.Onion]: OnionIcon,
1566
+ [ContenthashProtocol.Arweave]: ArweaveIcon,
1567
+ [ContenthashProtocol.Skynet]: SkynetIcon,
1568
+ [ContenthashProtocol.Swarm]: SwarmIcon
1569
+ };
1570
+ const ContenthashIcon = (props) => {
1571
+ const { className, size, protocol, ...restProps } = props;
1572
+ const _size = size || 20;
1573
+ const IconComponent = icons[protocol];
1574
+ if (!IconComponent) {
1575
+ console.warn(`No icon found for protocol: ${protocol}`);
1576
+ return null;
1577
+ }
1578
+ return /* @__PURE__ */ jsx("div", { className: `ns-chain-icon ${className || ""}`, children: /* @__PURE__ */ jsx(IconComponent, { size: _size }) });
1579
+ };
1580
+
1581
+ const variantConfig = {
1582
+ error: { icon: "x-circle", colorClass: "ns-alert-error" },
1583
+ warning: { icon: "alert-triangle", colorClass: "ns-alert-warning" },
1584
+ info: { icon: "info", colorClass: "ns-alert-info" },
1585
+ success: { icon: "check-circle", colorClass: "ns-alert-success" }
1586
+ };
1587
+ const Alert = ({
1588
+ variant = "info",
1589
+ children,
1590
+ className = "",
1591
+ onClose,
1592
+ dismissible = false,
1593
+ title
1594
+ }) => {
1595
+ const config = variantConfig[variant];
1596
+ return /* @__PURE__ */ jsx("div", { className: `ns-alert ${config.colorClass} ${className}`, role: "alert", children: /* @__PURE__ */ jsxs("div", { className: "ns-alert-content", children: [
1597
+ /* @__PURE__ */ jsx("div", { className: "ns-alert-icon", children: /* @__PURE__ */ jsx(Icon, { name: config.icon, size: 20 }) }),
1598
+ /* @__PURE__ */ jsxs("div", { className: "ns-alert-message", children: [
1599
+ title && /* @__PURE__ */ jsx("div", { className: "ns-alert-title", children: title }),
1600
+ /* @__PURE__ */ jsx("div", { className: "ns-alert-description", children })
1601
+ ] }),
1602
+ dismissible && onClose && /* @__PURE__ */ jsx(
1603
+ "button",
1604
+ {
1605
+ className: "ns-alert-close",
1606
+ onClick: onClose,
1607
+ "aria-label": "Close alert",
1608
+ type: "button",
1609
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 16 })
1610
+ }
1611
+ )
1612
+ ] }) });
1613
+ };
1614
+
1615
+ const Modal = ({
1616
+ isOpen,
1617
+ onClose,
1618
+ title,
1619
+ children,
1620
+ footer,
1621
+ size = "md",
1622
+ isDismissDisabled,
1623
+ titleId,
1624
+ className = "",
1625
+ style
1626
+ }) => {
1627
+ const overlayRef = useRef(null);
1628
+ const dialogRef = useRef(null);
1629
+ useEffect(() => {
1630
+ if (!isOpen || isDismissDisabled) return;
1631
+ const handleKeyDown = (e) => {
1632
+ if (e.key === "Escape") onClose();
1633
+ };
1634
+ window.addEventListener("keydown", handleKeyDown);
1635
+ return () => window.removeEventListener("keydown", handleKeyDown);
1636
+ }, [isOpen, isDismissDisabled, onClose]);
1637
+ const handleOverlayClick = (e) => {
1638
+ if (isDismissDisabled) return;
1639
+ if (e.target === overlayRef.current) onClose();
1640
+ };
1641
+ if (!isOpen) return null;
1642
+ const sizeClass = `ns-modal--${size}`;
1643
+ const classes = ["ns-modal", className, sizeClass].filter(Boolean).join(" ");
1644
+ return /* @__PURE__ */ jsx(
1645
+ "div",
1646
+ {
1647
+ ref: overlayRef,
1648
+ className: "ns-modal-overlay",
1649
+ onMouseDown: handleOverlayClick,
1650
+ "aria-hidden": !isOpen,
1651
+ children: /* @__PURE__ */ jsxs(
1652
+ "div",
1653
+ {
1654
+ ref: dialogRef,
1655
+ className: classes,
1656
+ role: "dialog",
1657
+ "aria-modal": "true",
1658
+ "aria-labelledby": title ? titleId || "ns-modal-title" : void 0,
1659
+ style,
1660
+ children: [
1661
+ (title || !isDismissDisabled) && /* @__PURE__ */ jsxs("div", { className: "ns-modal__header", children: [
1662
+ title && /* @__PURE__ */ jsx("div", { className: "ns-modal__title", id: titleId || "ns-modal-title", children: typeof title === "string" ? /* @__PURE__ */ jsx(Text, { size: "lg", weight: "medium", children: title }) : title }),
1663
+ !isDismissDisabled && /* @__PURE__ */ jsx("button", { className: "ns-modal__close", "aria-label": "Close", onClick: onClose, children: "\xD7" })
1664
+ ] }),
1665
+ /* @__PURE__ */ jsx("div", { className: "ns-modal__body", children }),
1666
+ /* @__PURE__ */ jsx("div", { className: "ns-modal__footer", children: footer !== void 0 ? footer : /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: onClose, children: "Close" }) })
1667
+ ]
1668
+ }
1669
+ )
1670
+ }
1671
+ );
1672
+ };
1673
+
1674
+ const capitalize = (value) => {
1675
+ return value.charAt(0).toLocaleUpperCase() + value.substring(1);
1676
+ };
1677
+ const equalsIgnoreCase = (a, b) => {
1678
+ return a.toLocaleLowerCase() === b.toLocaleLowerCase();
1679
+ };
1680
+ const deepCopy = (a) => {
1681
+ return JSON.parse(JSON.stringify(a));
1682
+ };
1683
+
1684
+ function convertEVMChainIdToCoinType(chainId) {
1685
+ return (2147483648 | chainId) >>> 0;
1686
+ }
1687
+
1688
+ const getEnsRecordsDiff = (oldRecords, newRecords) => {
1689
+ const { textsAdded, textsModified, textsRemoved } = getEnsTextDiff(
1690
+ oldRecords.texts,
1691
+ newRecords.texts
1692
+ );
1693
+ const { addressesAdded, addressesModified, addressesRemoved } = getEnsAddressDiff(oldRecords.addresses, newRecords.addresses);
1694
+ const { contenthashAdded, contenthashModified, contenthashRemoved } = getEnsContenthashDiff(oldRecords.contenthash, newRecords.contenthash);
1695
+ return {
1696
+ addressesAdded,
1697
+ addressesModified,
1698
+ addressesRemoved,
1699
+ textsAdded,
1700
+ textsModified,
1701
+ textsRemoved,
1702
+ contenthashAdded,
1703
+ contenthashModified,
1704
+ contenthashRemoved
1705
+ };
1706
+ };
1707
+ const getEnsTextDiff = (oldTexts, newTexts) => {
1708
+ if (oldTexts.length === 0) {
1709
+ return {
1710
+ textsAdded: newTexts,
1711
+ textsModified: [],
1712
+ textsRemoved: []
1713
+ };
1714
+ }
1715
+ const oldTextMap = {};
1716
+ const textsRemoved = [];
1717
+ oldTexts.forEach((text) => {
1718
+ oldTextMap[text.key] = text;
1719
+ const existsInNew = newTexts.find((newText) => newText.key === text.key);
1720
+ if (!existsInNew) {
1721
+ textsRemoved.push(text);
1722
+ }
1723
+ });
1724
+ const textsAdded = [];
1725
+ const textsModified = [];
1726
+ newTexts.forEach((newText) => {
1727
+ const matchingOldText = oldTextMap[newText.key];
1728
+ if (!matchingOldText) {
1729
+ textsAdded.push(newText);
1730
+ } else if (matchingOldText.value !== newText.value) {
1731
+ textsModified.push(newText);
1732
+ }
1733
+ });
1734
+ return {
1735
+ textsAdded,
1736
+ textsModified,
1737
+ textsRemoved
1738
+ };
1739
+ };
1740
+ const getEnsAddressDiff = (oldAddresses, newAddresses) => {
1741
+ if (oldAddresses.length === 0) {
1742
+ return {
1743
+ addressesAdded: newAddresses,
1744
+ addressesModified: [],
1745
+ addressesRemoved: []
1746
+ };
1747
+ }
1748
+ const oldAddressMap = {};
1749
+ const addressesRemoved = [];
1750
+ oldAddresses.forEach((address) => {
1751
+ oldAddressMap[address.coinType] = address;
1752
+ const existsInNew = newAddresses.find(
1753
+ (newAddress) => newAddress.coinType === address.coinType
1754
+ );
1755
+ if (!existsInNew) {
1756
+ addressesRemoved.push(address);
1757
+ }
1758
+ });
1759
+ const addressesAdded = [];
1760
+ const addressesModified = [];
1206
1761
  newAddresses.forEach((newAddress) => {
1207
1762
  const matchinOldAddress = oldAddressMap[newAddress.coinType];
1208
1763
  if (!matchinOldAddress) {
@@ -9302,7 +9857,7 @@ const nonEvmCoinTypeToNameMap = Object.freeze({
9302
9857
  "5718350": ["wan", "Wanchain"],
9303
9858
  "5741564": ["waves", "Waves"],
9304
9859
  });
9305
- Object.freeze({
9860
+ const coinTypeToNameMap = Object.freeze({
9306
9861
  ...nonEvmCoinTypeToNameMap,
9307
9862
  ...evmCoinTypeToNameMap,
9308
9863
  });
@@ -9341,6 +9896,31 @@ const getCoderByCoinName = (name) => {
9341
9896
  }
9342
9897
  return format;
9343
9898
  };
9899
+ const getCoderByCoinType = (coinType) => {
9900
+ const names = coinTypeToNameMap[String(coinType)];
9901
+ // https://docs.ens.domains/ens-improvement-proposals/ensip-11-evmchain-address-resolution
9902
+ if (coinType >= SLIP44_MSB) {
9903
+ // EVM coin
9904
+ const evmChainId = coinTypeToEvmChainId(coinType);
9905
+ const isUnknownChain = !names;
9906
+ const name = isUnknownChain ? `Unknown Chain (${evmChainId})` : names[0]; // name is derivable
9907
+ const ethFormat = eth;
9908
+ return {
9909
+ name,
9910
+ coinType: coinType,
9911
+ evmChainId,
9912
+ isUnknownChain,
9913
+ encode: ethFormat.encode,
9914
+ decode: ethFormat.decode,
9915
+ };
9916
+ }
9917
+ if (!names) {
9918
+ throw new Error(`Unsupported coin type: ${coinType}`);
9919
+ }
9920
+ const [name] = names;
9921
+ const format = formats[name];
9922
+ return format;
9923
+ };
9344
9924
 
9345
9925
  const isValidEmvAddress = (value) => {
9346
9926
  return isAddress$1(value);
@@ -9407,6 +9987,15 @@ const supportedAddresses = [
9407
9987
  validateFunc: isValidEmvAddress,
9408
9988
  placeholder: "0x1D8...c19f8"
9409
9989
  },
9990
+ {
9991
+ isEMV: true,
9992
+ label: "Celo",
9993
+ coinType: convertEVMChainIdToCoinType(celo.id),
9994
+ chainId: arbitrum.id,
9995
+ chainName: "celo",
9996
+ validateFunc: isValidEmvAddress,
9997
+ placeholder: "0x1D8...c19f8"
9998
+ },
9410
9999
  {
9411
10000
  isEMV: true,
9412
10001
  label: "Polygon",
@@ -9449,15 +10038,6 @@ const getSupportedAddressByName = (name) => {
9449
10038
  return supportedAddresses.find((addr) => addr.chainName === name);
9450
10039
  };
9451
10040
 
9452
- var ContenthashProtocol = /* @__PURE__ */ ((ContenthashProtocol2) => {
9453
- ContenthashProtocol2["Ipfs"] = "ipfs";
9454
- ContenthashProtocol2["Onion"] = "onion3";
9455
- ContenthashProtocol2["Arweave"] = "arweave";
9456
- ContenthashProtocol2["Skynet"] = "skynet";
9457
- ContenthashProtocol2["Swarm"] = "swarm";
9458
- return ContenthashProtocol2;
9459
- })(ContenthashProtocol || {});
9460
-
9461
10041
  /**
9462
10042
  * @param {Uint8Array} aa
9463
10043
  * @param {Uint8Array} bb
@@ -11095,97 +11675,78 @@ var TextRecordCategory = /* @__PURE__ */ ((TextRecordCategory2) => {
11095
11675
  })(TextRecordCategory || {});
11096
11676
  const supportedTexts = [
11097
11677
  {
11098
- icon: "circle-person",
11678
+ icon: "person",
11099
11679
  key: "avatar",
11100
11680
  category: "image" /* Image */,
11101
- label: "Avatar",
11102
- placeholder: "https://"
11681
+ label: "Avatar"
11103
11682
  },
11104
11683
  {
11105
- icon: "image",
11684
+ icon: "person",
11106
11685
  key: "header",
11107
11686
  category: "image" /* Image */,
11108
- label: "Header",
11109
- placeholder: "https://"
11687
+ label: "Header"
11110
11688
  },
11111
11689
  {
11112
11690
  icon: "person",
11113
11691
  key: "name",
11114
11692
  category: "general" /* General */,
11115
- label: "Nickname",
11116
- placeholder: "John Smith"
11693
+ label: "Nickname"
11117
11694
  },
11118
11695
  {
11119
11696
  icon: "book",
11120
11697
  key: "description",
11121
11698
  category: "general" /* General */,
11122
- label: "Short bio",
11123
- placeholder: "I am a ninja from far away land"
11699
+ label: "Short bio"
11124
11700
  },
11125
11701
  {
11126
11702
  icon: "globe",
11127
11703
  key: "url",
11128
11704
  category: "general" /* General */,
11129
- label: "Website",
11130
- placeholder: "https://namespace.ninja"
11705
+ label: "Website"
11131
11706
  },
11132
11707
  {
11133
11708
  icon: "map-pin",
11134
11709
  key: "location",
11135
11710
  category: "general" /* General */,
11136
- label: "Location",
11137
- placeholder: "Metaverse"
11711
+ label: "Location"
11138
11712
  },
11139
11713
  {
11140
11714
  icon: "mail",
11141
11715
  key: "mail",
11142
11716
  category: "general" /* General */,
11143
- label: "E-Mail",
11144
- placeholder: "name@example.com"
11717
+ label: "E-Mail"
11145
11718
  },
11146
11719
  {
11147
- icon: "twitter",
11720
+ icon: "person",
11148
11721
  key: "com.twitter",
11149
11722
  category: "social" /* Social */,
11150
- label: "Twitter",
11151
- placeholder: "eg. namespace"
11723
+ label: "Twitter"
11152
11724
  },
11153
11725
  {
11154
11726
  icon: "discord",
11155
11727
  key: "com.discord",
11156
11728
  category: "social" /* Social */,
11157
- label: "Discord",
11158
- placeholder: "eg. namespace"
11729
+ label: "Discord"
11159
11730
  },
11160
11731
  {
11161
11732
  icon: "github",
11162
11733
  key: "com.github",
11163
11734
  category: "social" /* Social */,
11164
- label: "Github",
11165
- placeholder: "eg. namespace"
11735
+ label: "Github"
11166
11736
  },
11167
11737
  {
11168
11738
  icon: "telegram",
11169
11739
  key: "org.telegram",
11170
11740
  category: "social" /* Social */,
11171
- label: "Telegram",
11172
- placeholder: "eg. namespace"
11741
+ label: "Telegram"
11173
11742
  },
11174
11743
  {
11175
11744
  icon: "youtube",
11176
11745
  key: "com.youtube",
11177
11746
  category: "social" /* Social */,
11178
- label: "Youtube",
11179
- placeholder: "eg. namespace"
11747
+ label: "Youtube"
11180
11748
  }
11181
11749
  ];
11182
- const getSupportedTextMap = () => {
11183
- const map = {};
11184
- supportedTexts.forEach((txt) => {
11185
- map[txt.key] = txt;
11186
- });
11187
- return map;
11188
- };
11189
11750
  const getSupportedText = (key) => {
11190
11751
  return supportedTexts.find((txt) => txt.key === key);
11191
11752
  };
@@ -11212,567 +11773,236 @@ const TextRecords = ({
11212
11773
  behavior: "smooth",
11213
11774
  block: "center"
11214
11775
  });
11215
- inputRefs.current[lastAddedKey]?.focus();
11216
- setLastAddedKey(null);
11217
- }
11218
- }, [texts, lastAddedKey]);
11219
- const handleTextChanged = (key, value) => {
11220
- const _texts = [...texts];
11221
- for (const text of _texts) {
11222
- if (text.key === key) {
11223
- text.value = value;
11224
- }
11225
- }
11226
- onTextsChanged(_texts);
11227
- };
11228
- const handleTextAdded = (key) => {
11229
- const initialText = initialTexts.find((txt) => txt.key === key);
11230
- onTextsChanged([...texts, { key, value: initialText?.value || "" }]);
11231
- setLastAddedKey(key);
11232
- };
11233
- const handleRemoveText = (key) => {
11234
- onTextsChanged(texts.filter((text) => text.key !== key));
11235
- };
11236
- const filterSuggestions = (record) => {
11237
- if (searchFilter && searchFilter.length > 0) {
11238
- const lowercase = searchFilter.toLocaleLowerCase();
11239
- const label = record.label || "";
11240
- return record.key.toLocaleLowerCase().includes(lowercase) || label.toLocaleLowerCase().includes(lowercase);
11241
- }
11242
- return true;
11243
- };
11244
- const filteredItems = useMemo(() => {
11245
- const shownTextCategory = [category];
11246
- if (category === TextRecordCategory.General) {
11247
- shownTextCategory.push(TextRecordCategory.Image);
11248
- }
11249
- return supportedTexts.filter((record) => filterSuggestions(record) && shownTextCategory.includes(record.category));
11250
- }, [searchFilter]);
11251
- if (filteredItems.length === 0) {
11252
- return /* @__PURE__ */ jsx(Fragment, {});
11253
- }
11254
- return /* @__PURE__ */ jsxs("div", { className: "ns-text-records", children: [
11255
- /* @__PURE__ */ jsx(Text, { className: "ns-mb-2", weight: "bold", children: capitalize(category) }),
11256
- filteredItems.filter((record) => existingTextsMap[record.key] !== void 0).map((record) => {
11257
- const current = existingTextsMap[record.key];
11258
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
11259
- /* @__PURE__ */ jsx(
11260
- Text,
11261
- {
11262
- style: { marginBottom: "4px" },
11263
- color: "grey",
11264
- size: "xs",
11265
- weight: "medium",
11266
- children: record.label
11267
- }
11268
- ),
11269
- /* @__PURE__ */ jsxs(
11270
- "div",
11271
- {
11272
- style: { width: "100%" },
11273
- className: "d-flex align-items-center",
11274
- children: [
11275
- /* @__PURE__ */ jsx(
11276
- Input,
11277
- {
11278
- ref: (el) => {
11279
- inputRefs.current[record.key] = el;
11280
- },
11281
- style: { width: "100%" },
11282
- onChange: (e) => handleTextChanged(record.key, e.target.value),
11283
- prefix: /* @__PURE__ */ jsx(Icon, { name: record.icon, size: 18, color: "grey" }),
11284
- value: current.value,
11285
- placeholder: record.placeholder
11286
- }
11287
- ),
11288
- /* @__PURE__ */ jsx(
11289
- "div",
11290
- {
11291
- onClick: () => handleRemoveText(record.key),
11292
- className: "ns-close-icon ns-ms-1",
11293
- children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 18 })
11294
- }
11295
- )
11296
- ]
11297
- }
11298
- )
11299
- ] }, record.key);
11300
- }),
11301
- /* @__PURE__ */ jsx("div", { className: "row g-2", children: filteredItems.filter(
11302
- (record) => existingTextsMap[record.key] === void 0 && record.category !== TextRecordCategory.Image && filterSuggestions(record)
11303
- ).map((record) => /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6", children: /* @__PURE__ */ jsxs(
11304
- "div",
11305
- {
11306
- className: "ns-text-suggestion",
11307
- onClick: () => handleTextAdded(record.key),
11308
- children: [
11309
- /* @__PURE__ */ jsx(Icon, { size: 18, color: "grey", name: record.icon }),
11310
- /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: record.label })
11311
- ]
11312
- }
11313
- ) }, record.key)) })
11314
- ] });
11315
- };
11316
-
11317
- const AddressRecords = ({
11318
- addresses,
11319
- onAddressesChanged,
11320
- initialAddresses,
11321
- searchFilter
11322
- }) => {
11323
- const existingAddressMap = useMemo(() => {
11324
- const map = {};
11325
- addresses.forEach((addr) => {
11326
- map[addr.coinType] = addr;
11327
- });
11328
- return map;
11329
- }, [addresses]);
11330
- const [lastAddedKey, setLastAddedKey] = useState(null);
11331
- const inputRefs = useRef({});
11332
- useEffect(() => {
11333
- if (lastAddedKey && inputRefs.current[lastAddedKey]) {
11334
- inputRefs.current[lastAddedKey]?.scrollIntoView({
11335
- behavior: "smooth",
11336
- block: "center"
11337
- });
11338
- inputRefs.current[lastAddedKey]?.focus();
11339
- setLastAddedKey(null);
11340
- }
11341
- }, [addresses, lastAddedKey]);
11342
- const handleAddressChanged = (coin, value) => {
11343
- const _addresses = [...addresses];
11344
- for (const addr of _addresses) {
11345
- if (addr.coinType === coin) {
11346
- addr.value = value;
11776
+ inputRefs.current[lastAddedKey]?.focus();
11777
+ setLastAddedKey(null);
11778
+ }
11779
+ }, [texts, lastAddedKey]);
11780
+ const handleTextChanged = (key, value) => {
11781
+ const _texts = [...texts];
11782
+ for (const text of _texts) {
11783
+ if (text.key === key) {
11784
+ text.value = value;
11347
11785
  }
11348
11786
  }
11349
- onAddressesChanged(_addresses);
11787
+ onTextsChanged(_texts);
11350
11788
  };
11351
- const handleAddressAdded = (coin) => {
11352
- const initialAddress = initialAddresses.find((i) => i.coinType === coin);
11353
- onAddressesChanged([
11354
- ...addresses,
11355
- { coinType: coin, value: initialAddress?.value || "" }
11356
- ]);
11357
- setLastAddedKey(`${coin}`);
11789
+ const handleTextAdded = (key) => {
11790
+ const initialText = initialTexts.find((txt) => txt.key === key);
11791
+ onTextsChanged([...texts, { key, value: initialText?.value || "" }]);
11792
+ setLastAddedKey(key);
11358
11793
  };
11359
- const handleRemoveAddress = (coin) => {
11360
- onAddressesChanged(addresses.filter((addr) => addr.coinType !== coin));
11794
+ const handleRemoveText = (key) => {
11795
+ onTextsChanged(texts.filter((text) => text.key !== key));
11361
11796
  };
11362
- const filterAddress = (address) => {
11797
+ const filterSuggestions = (record) => {
11363
11798
  if (searchFilter && searchFilter.length > 0) {
11364
11799
  const lowercase = searchFilter.toLocaleLowerCase();
11365
- return address.chainName.includes(lowercase) || address.label.toLocaleLowerCase().includes(lowercase);
11800
+ const label = record.label || "";
11801
+ return record.key.toLocaleLowerCase().includes(lowercase) || label.toLocaleLowerCase().includes(lowercase);
11366
11802
  }
11367
11803
  return true;
11368
11804
  };
11369
- const filteredAddresses = useMemo(() => {
11370
- return supportedAddresses.filter((record) => filterAddress(record));
11371
- }, [searchFilter]);
11372
- if (filteredAddresses.length === 0) {
11373
- return /* @__PURE__ */ jsx(Fragment, {});
11374
- }
11375
- return /* @__PURE__ */ jsxs("div", { className: "ns-text-records", children: [
11376
- /* @__PURE__ */ jsx(Text, { className: "ns-mb-2", weight: "bold", children: "Addresses" }),
11377
- filteredAddresses.filter((record) => existingAddressMap[record.coinType] !== void 0).map((record) => {
11378
- const current = existingAddressMap[record.coinType];
11379
- const isInvalidAddress = current.value.length > 0 && !record.validateFunc?.(current.value);
11380
- return /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
11381
- /* @__PURE__ */ jsx(
11382
- Text,
11383
- {
11384
- style: { marginBottom: "4px" },
11385
- color: "grey",
11386
- size: "xs",
11387
- weight: "medium",
11388
- children: record.label
11389
- }
11390
- ),
11391
- /* @__PURE__ */ jsxs(
11392
- "div",
11393
- {
11394
- style: { width: "100%" },
11395
- className: "d-flex align-items-center",
11396
- children: [
11397
- /* @__PURE__ */ jsx(
11398
- Input,
11399
- {
11400
- ref: (el) => {
11401
- inputRefs.current[record.coinType] = el;
11402
- },
11403
- error: isInvalidAddress,
11404
- style: { width: "100%" },
11405
- onChange: (e) => handleAddressChanged(record.coinType, e.target.value),
11406
- prefix: /* @__PURE__ */ jsx(ChainIcon, { chain: record.chainName, size: 18 }),
11407
- value: current.value,
11408
- placeholder: record.placeholder
11409
- }
11410
- ),
11411
- /* @__PURE__ */ jsx(
11412
- "div",
11413
- {
11414
- onClick: () => handleRemoveAddress(record.coinType),
11415
- className: "ns-close-icon ns-ms-1",
11416
- children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 18 })
11417
- }
11418
- )
11419
- ]
11420
- }
11421
- ),
11422
- isInvalidAddress && /* @__PURE__ */ jsx(
11423
- Text,
11424
- {
11425
- size: "xs",
11426
- color: "danger",
11427
- className: "ns-mt-1",
11428
- children: `${record.label} address is not valid`
11429
- }
11430
- )
11431
- ] }, record.chainName);
11432
- }),
11433
- /* @__PURE__ */ jsx("div", { className: "row g-2", children: filteredAddresses.filter((record) => existingAddressMap[record.coinType] === void 0).map((record) => /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6", children: /* @__PURE__ */ jsxs(
11434
- "div",
11435
- {
11436
- className: "ns-text-suggestion",
11437
- onClick: () => handleAddressAdded(record.coinType),
11438
- children: [
11439
- /* @__PURE__ */ jsx(ChainIcon, { size: 20, chain: record.chainName }),
11440
- /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: record.label })
11441
- ]
11442
- }
11443
- ) }, record.coinType)) })
11444
- ] });
11445
- };
11446
-
11447
- const Dropdown = ({
11448
- trigger,
11449
- children,
11450
- placement = "bottom",
11451
- align = "start",
11452
- disabled = false,
11453
- dataTestId
11454
- }) => {
11455
- const [isOpen, setIsOpen] = useState(false);
11456
- const triggerRef = useRef(null);
11457
- const dropdownRef = useRef(null);
11458
- const handleToggle = useCallback(() => {
11459
- if (!disabled) {
11460
- setIsOpen((prev) => !prev);
11461
- }
11462
- }, [disabled]);
11463
- const handleClickOutside = useCallback((event) => {
11464
- if (triggerRef.current && !triggerRef.current.contains(event.target) && dropdownRef.current && !dropdownRef.current.contains(event.target)) {
11465
- setIsOpen(false);
11466
- }
11467
- }, []);
11468
- useEffect(() => {
11469
- if (isOpen) {
11470
- document.addEventListener("mousedown", handleClickOutside);
11471
- document.addEventListener("keydown", (e) => {
11472
- if (e.key === "Escape") setIsOpen(false);
11473
- });
11474
- }
11475
- return () => {
11476
- document.removeEventListener("mousedown", handleClickOutside);
11477
- };
11478
- }, [isOpen, handleClickOutside]);
11479
- const getPlacementClasses = () => {
11480
- const placementClass = `ns-dropdown--${placement}`;
11481
- const alignClass = `ns-dropdown--align-${align}`;
11482
- return `${placementClass} ${alignClass}`;
11483
- };
11484
- return /* @__PURE__ */ jsxs("div", { className: "ns-dropdown", "data-test-id": dataTestId, children: [
11485
- /* @__PURE__ */ jsx(
11486
- "div",
11487
- {
11488
- ref: triggerRef,
11489
- className: "ns-dropdown__trigger",
11490
- onClick: handleToggle,
11491
- role: "button",
11492
- tabIndex: disabled ? -1 : 0,
11493
- "aria-expanded": isOpen,
11494
- "aria-haspopup": "true",
11495
- onKeyDown: (e) => {
11496
- if (e.key === "Enter" || e.key === " ") {
11497
- e.preventDefault();
11498
- handleToggle();
11499
- }
11500
- },
11501
- children: trigger
11502
- }
11503
- ),
11504
- isOpen && /* @__PURE__ */ jsx(
11505
- "div",
11506
- {
11507
- ref: dropdownRef,
11508
- className: `ns-dropdown__menu ${getPlacementClasses()}`,
11509
- role: "menu",
11510
- "aria-orientation": "vertical",
11511
- children
11512
- }
11513
- )
11514
- ] });
11515
- };
11516
-
11517
- const IpfsIcon = ({ size = 20 }) => {
11518
- return /* @__PURE__ */ jsxs(
11519
- "svg",
11520
- {
11521
- xmlns: "http://www.w3.org/2000/svg",
11522
- width: size,
11523
- height: size,
11524
- viewBox: "0 0 20 22",
11525
- fill: "none",
11526
- children: [
11527
- /* @__PURE__ */ jsx(
11528
- "path",
11529
- {
11530
- fill: "#469EA2",
11531
- d: "m0 16.44 9.56 5.48 9.559-5.48V5.48L9.559 0 0 5.48z"
11532
- }
11533
- ),
11534
- /* @__PURE__ */ jsx(
11535
- "path",
11536
- {
11537
- fill: "#6ACAD1",
11538
- d: "M8.58 1.31 1.64 5.289a2 2 0 0 1 0 .373l6.93 3.977a1.66 1.66 0 0 1 1.97 0l6.93-3.977a2 2 0 0 1 0-.373l-6.92-3.977a1.66 1.66 0 0 1-1.968 0m9.56 5.447-6.942 4.023c.038.348-.036.7-.212 1.005a1.67 1.67 0 0 1-.766.69l.011 7.91q.17.073.319.18l6.93-3.978c-.037-.348.037-.7.213-1.005s.444-.545.766-.69V6.939a2.3 2.3 0 0 1-.319-.181M.98 6.802q-.15.107-.319.181v7.955c.326.139.598.38.775.685.176.306.248.66.204 1.01l6.93 3.977q.15-.107.32-.18v-7.955a1.63 1.63 0 0 1-.775-.686 1.6 1.6 0 0 1-.205-1.01z"
11539
- }
11540
- ),
11541
- /* @__PURE__ */ jsx(
11542
- "path",
11543
- {
11544
- fill: "#469EA2",
11545
- d: "m9.56 1.186 8.546 4.904v9.797L9.56 20.791l-8.547-4.904V6.079zm0-1.163L0 5.503v10.96l9.56 5.48 9.559-5.48V5.503z"
11546
- }
11547
- ),
11548
- /* @__PURE__ */ jsx(
11549
- "path",
11550
- {
11551
- fill: "#469EA2",
11552
- d: "M9.628 12.825H9.49a1.8 1.8 0 0 1-1.264-.518 1.77 1.77 0 0 1-.522-1.256v-.136a1.76 1.76 0 0 1 .521-1.255 1.78 1.78 0 0 1 1.265-.519h.137a1.8 1.8 0 0 1 1.265.519 1.77 1.77 0 0 1 .521 1.255v.136a1.76 1.76 0 0 1-.521 1.256 1.78 1.78 0 0 1-1.265.518m0 7.288H9.49a1.79 1.79 0 0 0-1.559.904l1.628.927 1.627-.927a1.79 1.79 0 0 0-1.56-.904m9.502-5.48h-.068a1.8 1.8 0 0 0-1.265.518 1.77 1.77 0 0 0-.522 1.256v.135a1.7 1.7 0 0 0 .228.86l1.627-.939zM17.503 4.576a1.73 1.73 0 0 0-.228.859v.136a1.76 1.76 0 0 0 .522 1.255 1.78 1.78 0 0 0 1.265.519h.068V5.503zM9.56.023 7.932.949a1.78 1.78 0 0 0 1.56.915h.136A1.79 1.79 0 0 0 11.187.96zM1.627 4.565 0 5.503v1.842h.068a1.8 1.8 0 0 0 1.265-.519 1.77 1.77 0 0 0 .522-1.255v-.136a1.9 1.9 0 0 0-.228-.87M.068 14.633H0v1.83l1.627.938a1.73 1.73 0 0 0 .228-.859v-.135a1.76 1.76 0 0 0-.522-1.256 1.78 1.78 0 0 0-1.265-.518"
11553
- }
11554
- ),
11555
- /* @__PURE__ */ jsx(
11556
- "path",
11557
- {
11558
- fill: "#083B54",
11559
- fillOpacity: "0.15",
11560
- d: "M9.56 22V11.028L0 5.548V16.52z"
11561
- }
11562
- ),
11563
- /* @__PURE__ */ jsx(
11564
- "path",
11565
- {
11566
- fill: "#083B54",
11567
- fillOpacity: "0.05",
11568
- d: "M19.13 16.418V5.458l-9.56 5.48V21.91z"
11569
- }
11570
- )
11571
- ]
11572
- }
11573
- );
11574
- };
11575
-
11576
- const OnionIcon = ({ size = 20 }) => {
11577
- return /* @__PURE__ */ jsx(
11578
- "svg",
11579
- {
11580
- xmlns: "http://www.w3.org/2000/svg",
11581
- width: size,
11582
- height: size * 1.18,
11583
- "data-name": "Layer 1",
11584
- viewBox: "0 0 161 190",
11585
- children: /* @__PURE__ */ jsx(
11586
- "path",
11587
- {
11588
- fill: "#7D50CF",
11589
- d: "M141.67 74.68c-16.3-17.8-41.29-40.85-44-52.41S102.17 0 102.17 0C90.76-.21 84.29 5.54 80.56 12.07 76.9 5.54 70.36-.21 59 0c0 0 7.25 10.62 4.52 22.26s-27.77 34.62-44 52.43c-45.45 49.76-6 115.82 61 115.82s106.53-66.06 61.15-115.83M80.56 175.29c-27 0-57.73-14.51-64.55-43.81-7.76-34.25 25.77-55.29 45.59-75.9l3.23 3.24c1.73 1.65 3.45 3.37 5.25 5-1.44 1.44-2.88 2.8-4.17 4.09C49.47 84 21 102.33 27.21 128.68c5.53 23.63 31.81 34.69 53.35 34.69s47.82-11.06 53.35-34.69c6.18-26.35-22.26-44.73-38.7-60.75C87.45 60.32 79.7 52.57 72 44.81a95 95 0 0 0 8.41-10.05l.14-.14.14.14c20.76 30.09 74.25 54.57 64.49 96.72-6.89 29.3-37.55 43.81-64.62 43.81m20.54-66.14a48 48 0 0 0-4.46-4.67l8.36-8.76c12.07 12.35 23.56 27.79 5.82 42.87-7.68 6.54-19.24 9.48-30.37 9.48s-22.62-2.94-30.31-9.48c-17.8-15.15-6.1-30.66 6-43.08l8.33 8.83a37.3 37.3 0 0 0-4.67 4.81c-13.14 16.3 6.1 26.43 20.61 26.43s33.83-10.13 20.69-26.43m-10.7 10.63a19.71 19.71 0 0 1-19.61-.07l4.1-23.41a11.62 11.62 0 1 1 17.3-10.13 11.44 11.44 0 0 1-6 10.13z"
11590
- }
11591
- )
11805
+ const filteredItems = useMemo(() => {
11806
+ const shownTextCategory = [category];
11807
+ if (category === TextRecordCategory.General) {
11808
+ shownTextCategory.push(TextRecordCategory.Image);
11592
11809
  }
11593
- );
11594
- };
11595
-
11596
- const ArweaveIcon = ({ size = 20 }) => {
11597
- return /* @__PURE__ */ jsxs(
11598
- "svg",
11599
- {
11600
- xmlns: "http://www.w3.org/2000/svg",
11601
- xmlSpace: "preserve",
11602
- width: size,
11603
- height: size,
11604
- viewBox: "0 0 31.8 31.8",
11605
- children: [
11810
+ return supportedTexts.filter((record) => filterSuggestions(record) && shownTextCategory.includes(record.category));
11811
+ }, [searchFilter]);
11812
+ if (filteredItems.length === 0) {
11813
+ return /* @__PURE__ */ jsx(Fragment, {});
11814
+ }
11815
+ return /* @__PURE__ */ jsxs("div", { className: "ns-text-records", children: [
11816
+ /* @__PURE__ */ jsx(Text, { className: "ns-mb-2", weight: "bold", children: capitalize(category) }),
11817
+ filteredItems.filter((record) => existingTextsMap[record.key] !== void 0).map((record) => {
11818
+ const current = existingTextsMap[record.key];
11819
+ return /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
11606
11820
  /* @__PURE__ */ jsx(
11607
- "circle",
11821
+ Text,
11608
11822
  {
11609
- cx: "15.9",
11610
- cy: "15.9",
11611
- r: "14.7",
11612
- fill: "none",
11613
- stroke: "currentColor",
11614
- strokeWidth: "2.5",
11615
- className: "arweave_svg__st0"
11823
+ style: { marginBottom: "4px" },
11824
+ color: "grey",
11825
+ size: "xs",
11826
+ weight: "medium",
11827
+ children: record.label
11616
11828
  }
11617
11829
  ),
11618
- /* @__PURE__ */ jsx(
11619
- "path",
11830
+ /* @__PURE__ */ jsxs(
11831
+ "div",
11620
11832
  {
11621
- fill: "currentColor",
11622
- d: "M18.7 21.2c-.1-.1-.1-.3-.2-.5 0-.2-.1-.4-.1-.6-.2.2-.4.3-.6.5s-.5.3-.7.4c-.3.1-.5.2-.9.3-.3.1-.7.1-1 .1-.6 0-1.1-.1-1.6-.3s-.9-.4-1.3-.7-.6-.7-.8-1.1-.3-.9-.3-1.4c0-1.2.5-2.2 1.4-2.8.9-.7 2.3-1 4.1-1h1.7v-.7c0-.6-.2-1-.5-1.3-.4-.3-.9-.5-1.6-.5-.6 0-1 .1-1.3.4s-.4.6-.4 1h-3c0-.5.1-1 .3-1.4s.5-.8 1-1.2c.4-.3.9-.6 1.5-.8q.9-.3 2.1-.3c.7 0 1.3.1 1.9.3s1.1.4 1.6.8c.4.3.8.8 1 1.3s.4 1.1.4 1.8v5c0 .6 0 1.1.1 1.5s.2.8.3 1v.2zm-2.9-2.1c.3 0 .6 0 .8-.1.3-.1.5-.2.7-.3s.4-.2.5-.4l.4-.4v-2h-1.5c-.5 0-.9 0-1.2.1s-.6.2-.8.4-.4.3-.5.6c-.1.2-.1.5-.1.7 0 .4.1.7.4 1s.8.4 1.3.4",
11623
- className: "arweave_svg__st1"
11833
+ style: { width: "100%" },
11834
+ className: "d-flex align-items-center",
11835
+ children: [
11836
+ /* @__PURE__ */ jsx(
11837
+ Input,
11838
+ {
11839
+ ref: (el) => {
11840
+ inputRefs.current[record.key] = el;
11841
+ },
11842
+ style: { width: "100%" },
11843
+ onChange: (e) => handleTextChanged(record.key, e.target.value),
11844
+ prefix: /* @__PURE__ */ jsx(Icon, { name: record.icon, size: 18, color: "grey" }),
11845
+ value: current.value,
11846
+ placeholder: record.placeholder
11847
+ }
11848
+ ),
11849
+ /* @__PURE__ */ jsx(
11850
+ "div",
11851
+ {
11852
+ onClick: () => handleRemoveText(record.key),
11853
+ className: "ns-close-icon ns-ms-1",
11854
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 18 })
11855
+ }
11856
+ )
11857
+ ]
11624
11858
  }
11625
11859
  )
11626
- ]
11627
- }
11628
- );
11860
+ ] }, record.key);
11861
+ }),
11862
+ /* @__PURE__ */ jsx("div", { className: "row g-2", children: filteredItems.filter(
11863
+ (record) => existingTextsMap[record.key] === void 0 && record.category !== TextRecordCategory.Image && filterSuggestions(record)
11864
+ ).map((record) => /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6", children: /* @__PURE__ */ jsxs(
11865
+ "div",
11866
+ {
11867
+ className: "ns-text-suggestion",
11868
+ onClick: () => handleTextAdded(record.key),
11869
+ children: [
11870
+ /* @__PURE__ */ jsx(Icon, { size: 18, color: "grey", name: record.icon }),
11871
+ /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: record.label })
11872
+ ]
11873
+ }
11874
+ ) }, record.key)) })
11875
+ ] });
11629
11876
  };
11630
11877
 
11631
- const SkynetIcon = ({ size = 20 }) => {
11632
- return /* @__PURE__ */ jsx(
11633
- "svg",
11634
- {
11635
- xmlns: "http://www.w3.org/2000/svg",
11636
- width: size,
11637
- height: size,
11638
- viewBox: "0 0 24 24",
11639
- style: { color: "rgb(0, 198, 94)" },
11640
- children: /* @__PURE__ */ jsx(
11641
- "path",
11642
- {
11643
- fill: "#00c65e",
11644
- d: "m0 6.46 21.389 11.297a.917.917 0 0 1 .2 1.485h-.011a10 10 0 0 1-2.234 1.53c-6.912 3.474-14.991-1.837-14.543-9.56l2.86 1.975c.856 4.508 5.618 7.11 9.874 5.393zm8.647 3.151 14.366 5.679a.87.87 0 0 1 .52 1.046v.018a.872.872 0 0 1-1.257.526zm5.29-7.437c2.71-.233 6.095.787 8.111 3.387 1.7 2.195 2.05 4.877 1.93 7.646V13.2a.878.878 0 0 1-1.197.745l-9.765-3.86 9.065 2.432a7.3 7.3 0 0 0-1.068-4.563c-2.968-4.768-9.984-4.535-12.63.42a8 8 0 0 0-.397.883L5.555 7.961q.104-.15.214-.296c.116-.241.242-.487.38-.727 1.612-2.79 4.31-4.433 7.156-4.697.21-.018.421-.049.632-.067z"
11645
- }
11646
- )
11878
+ const AddressRecords = ({
11879
+ addresses,
11880
+ onAddressesChanged,
11881
+ initialAddresses,
11882
+ searchFilter
11883
+ }) => {
11884
+ const existingAddressMap = useMemo(() => {
11885
+ const map = {};
11886
+ addresses.forEach((addr) => {
11887
+ map[addr.coinType] = addr;
11888
+ });
11889
+ return map;
11890
+ }, [addresses]);
11891
+ const [lastAddedKey, setLastAddedKey] = useState(null);
11892
+ const inputRefs = useRef({});
11893
+ useEffect(() => {
11894
+ if (lastAddedKey && inputRefs.current[lastAddedKey]) {
11895
+ inputRefs.current[lastAddedKey]?.scrollIntoView({
11896
+ behavior: "smooth",
11897
+ block: "center"
11898
+ });
11899
+ inputRefs.current[lastAddedKey]?.focus();
11900
+ setLastAddedKey(null);
11647
11901
  }
11648
- );
11649
- };
11650
-
11651
- const SwarmIcon = ({ size = 20 }) => {
11652
- return /* @__PURE__ */ jsx(
11653
- "svg",
11654
- {
11655
- xmlns: "http://www.w3.org/2000/svg",
11656
- width: size,
11657
- height: size * 1.03,
11658
- fill: "none",
11659
- children: /* @__PURE__ */ jsxs("g", { fill: "#FF8A00", children: [
11660
- /* @__PURE__ */ jsx("path", { d: "m0 30.47 8.02 4.502 8.022-4.502v-8.986L8.02 16.977 0 21.484zM26.516.03l-4.24 2.381-.006.036v4.758l4.246 2.382.036.017 4.24-2.376V2.43zM34.4 21.484l-8.02-4.507-8.022 4.507v8.986l8.021 4.502L34.4 30.47z" }),
11661
- /* @__PURE__ */ jsx("path", { d: "m17.137 1.285-8.01 4.502v8.986l8.022 4.501 8.02-4.501v-3.58l-3.905-2.19-1.054-.59V3.119z" })
11662
- ] })
11902
+ }, [addresses, lastAddedKey]);
11903
+ const handleAddressChanged = (coin, value) => {
11904
+ const _addresses = [...addresses];
11905
+ for (const addr of _addresses) {
11906
+ if (addr.coinType === coin) {
11907
+ addr.value = value;
11908
+ }
11663
11909
  }
11664
- );
11665
- };
11666
-
11667
- const icons = {
11668
- [ContenthashProtocol.Ipfs]: IpfsIcon,
11669
- [ContenthashProtocol.Onion]: OnionIcon,
11670
- [ContenthashProtocol.Arweave]: ArweaveIcon,
11671
- [ContenthashProtocol.Skynet]: SkynetIcon,
11672
- [ContenthashProtocol.Swarm]: SwarmIcon
11673
- };
11674
- const ContenthashIcon = (props) => {
11675
- const { className, size, protocol, ...restProps } = props;
11676
- const _size = size || 20;
11677
- const IconComponent = icons[protocol];
11678
- if (!IconComponent) {
11679
- console.warn(`No icon found for protocol: ${protocol}`);
11680
- return null;
11910
+ onAddressesChanged(_addresses);
11911
+ };
11912
+ const handleAddressAdded = (coin) => {
11913
+ const initialAddress = initialAddresses.find((i) => i.coinType === coin);
11914
+ onAddressesChanged([
11915
+ ...addresses,
11916
+ { coinType: coin, value: initialAddress?.value || "" }
11917
+ ]);
11918
+ setLastAddedKey(`${coin}`);
11919
+ };
11920
+ const handleRemoveAddress = (coin) => {
11921
+ onAddressesChanged(addresses.filter((addr) => addr.coinType !== coin));
11922
+ };
11923
+ const filterAddress = (address) => {
11924
+ if (searchFilter && searchFilter.length > 0) {
11925
+ const lowercase = searchFilter.toLocaleLowerCase();
11926
+ return address.chainName.includes(lowercase) || address.label.toLocaleLowerCase().includes(lowercase);
11927
+ }
11928
+ return true;
11929
+ };
11930
+ const filteredAddresses = useMemo(() => {
11931
+ return supportedAddresses.filter((record) => filterAddress(record));
11932
+ }, [searchFilter]);
11933
+ if (filteredAddresses.length === 0) {
11934
+ return /* @__PURE__ */ jsx(Fragment, {});
11681
11935
  }
11682
- return /* @__PURE__ */ jsx("div", { className: `ns-chain-icon ${className || ""}`, children: /* @__PURE__ */ jsx(IconComponent, { size: _size }) });
11683
- };
11684
-
11685
- const variantConfig = {
11686
- error: { icon: "x-circle", colorClass: "ns-alert-error" },
11687
- warning: { icon: "alert-triangle", colorClass: "ns-alert-warning" },
11688
- info: { icon: "info", colorClass: "ns-alert-info" },
11689
- success: { icon: "check-circle", colorClass: "ns-alert-success" }
11690
- };
11691
- const Alert = ({
11692
- variant = "info",
11693
- children,
11694
- className = "",
11695
- onClose,
11696
- dismissible = false,
11697
- title
11698
- }) => {
11699
- const config = variantConfig[variant];
11700
- return /* @__PURE__ */ jsx("div", { className: `ns-alert ${config.colorClass} ${className}`, role: "alert", children: /* @__PURE__ */ jsxs("div", { className: "ns-alert-content", children: [
11701
- /* @__PURE__ */ jsx("div", { className: "ns-alert-icon", children: /* @__PURE__ */ jsx(Icon, { name: config.icon, size: 20 }) }),
11702
- /* @__PURE__ */ jsxs("div", { className: "ns-alert-message", children: [
11703
- title && /* @__PURE__ */ jsx("div", { className: "ns-alert-title", children: title }),
11704
- /* @__PURE__ */ jsx("div", { className: "ns-alert-description", children })
11705
- ] }),
11706
- dismissible && onClose && /* @__PURE__ */ jsx(
11707
- "button",
11936
+ return /* @__PURE__ */ jsxs("div", { className: "ns-text-records", children: [
11937
+ /* @__PURE__ */ jsx(Text, { className: "ns-mb-2", weight: "bold", children: "Addresses" }),
11938
+ filteredAddresses.filter((record) => existingAddressMap[record.coinType] !== void 0).map((record) => {
11939
+ const current = existingAddressMap[record.coinType];
11940
+ const isInvalidAddress = current.value.length > 0 && !record.validateFunc?.(current.value);
11941
+ return /* @__PURE__ */ jsxs("div", { style: { marginBottom: 10 }, children: [
11942
+ /* @__PURE__ */ jsx(
11943
+ Text,
11944
+ {
11945
+ style: { marginBottom: "4px" },
11946
+ color: "grey",
11947
+ size: "xs",
11948
+ weight: "medium",
11949
+ children: record.label
11950
+ }
11951
+ ),
11952
+ /* @__PURE__ */ jsxs(
11953
+ "div",
11954
+ {
11955
+ style: { width: "100%" },
11956
+ className: "d-flex align-items-center",
11957
+ children: [
11958
+ /* @__PURE__ */ jsx(
11959
+ Input,
11960
+ {
11961
+ ref: (el) => {
11962
+ inputRefs.current[record.coinType] = el;
11963
+ },
11964
+ error: isInvalidAddress,
11965
+ style: { width: "100%" },
11966
+ onChange: (e) => handleAddressChanged(record.coinType, e.target.value),
11967
+ prefix: /* @__PURE__ */ jsx(ChainIcon, { chain: record.chainName, size: 18 }),
11968
+ value: current.value,
11969
+ placeholder: record.placeholder
11970
+ }
11971
+ ),
11972
+ /* @__PURE__ */ jsx(
11973
+ "div",
11974
+ {
11975
+ onClick: () => handleRemoveAddress(record.coinType),
11976
+ className: "ns-close-icon ns-ms-1",
11977
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 18 })
11978
+ }
11979
+ )
11980
+ ]
11981
+ }
11982
+ ),
11983
+ isInvalidAddress && /* @__PURE__ */ jsx(
11984
+ Text,
11985
+ {
11986
+ size: "xs",
11987
+ color: "danger",
11988
+ className: "ns-mt-1",
11989
+ children: `${record.label} address is not valid`
11990
+ }
11991
+ )
11992
+ ] }, record.chainName);
11993
+ }),
11994
+ /* @__PURE__ */ jsx("div", { className: "row g-2", children: filteredAddresses.filter((record) => existingAddressMap[record.coinType] === void 0).map((record) => /* @__PURE__ */ jsx("div", { className: "col col-lg-3 col-sm-6", children: /* @__PURE__ */ jsxs(
11995
+ "div",
11708
11996
  {
11709
- className: "ns-alert-close",
11710
- onClick: onClose,
11711
- "aria-label": "Close alert",
11712
- type: "button",
11713
- children: /* @__PURE__ */ jsx(Icon, { name: "x", size: 16 })
11997
+ className: "ns-text-suggestion",
11998
+ onClick: () => handleAddressAdded(record.coinType),
11999
+ children: [
12000
+ /* @__PURE__ */ jsx(ChainIcon, { size: 20, chain: record.chainName }),
12001
+ /* @__PURE__ */ jsx(Text, { className: "ns-mt-1", size: "xs", weight: "medium", children: record.label })
12002
+ ]
11714
12003
  }
11715
- )
11716
- ] }) });
11717
- };
11718
-
11719
- const Modal = ({
11720
- isOpen,
11721
- onClose,
11722
- title,
11723
- children,
11724
- footer,
11725
- size = "md",
11726
- isDismissDisabled,
11727
- titleId,
11728
- className = "",
11729
- style
11730
- }) => {
11731
- const overlayRef = useRef(null);
11732
- const dialogRef = useRef(null);
11733
- useEffect(() => {
11734
- if (!isOpen || isDismissDisabled) return;
11735
- const handleKeyDown = (e) => {
11736
- if (e.key === "Escape") onClose();
11737
- };
11738
- window.addEventListener("keydown", handleKeyDown);
11739
- return () => window.removeEventListener("keydown", handleKeyDown);
11740
- }, [isOpen, isDismissDisabled, onClose]);
11741
- const handleOverlayClick = (e) => {
11742
- if (isDismissDisabled) return;
11743
- if (e.target === overlayRef.current) onClose();
11744
- };
11745
- if (!isOpen) return null;
11746
- const sizeClass = `ns-modal--${size}`;
11747
- const classes = ["ns-modal", className, sizeClass].filter(Boolean).join(" ");
11748
- return /* @__PURE__ */ jsx(
11749
- "div",
11750
- {
11751
- ref: overlayRef,
11752
- className: "ns-modal-overlay",
11753
- onMouseDown: handleOverlayClick,
11754
- "aria-hidden": !isOpen,
11755
- children: /* @__PURE__ */ jsxs(
11756
- "div",
11757
- {
11758
- ref: dialogRef,
11759
- className: classes,
11760
- role: "dialog",
11761
- "aria-modal": "true",
11762
- "aria-labelledby": title ? titleId || "ns-modal-title" : void 0,
11763
- style,
11764
- children: [
11765
- (title || !isDismissDisabled) && /* @__PURE__ */ jsxs("div", { className: "ns-modal__header", children: [
11766
- title && /* @__PURE__ */ jsx("div", { className: "ns-modal__title", id: titleId || "ns-modal-title", children: typeof title === "string" ? /* @__PURE__ */ jsx(Text, { size: "lg", weight: "medium", children: title }) : title }),
11767
- !isDismissDisabled && /* @__PURE__ */ jsx("button", { className: "ns-modal__close", "aria-label": "Close", onClick: onClose, children: "\xD7" })
11768
- ] }),
11769
- /* @__PURE__ */ jsx("div", { className: "ns-modal__body", children }),
11770
- /* @__PURE__ */ jsx("div", { className: "ns-modal__footer", children: footer !== void 0 ? footer : /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: onClose, children: "Close" }) })
11771
- ]
11772
- }
11773
- )
11774
- }
11775
- );
12004
+ ) }, record.coinType)) })
12005
+ ] });
11776
12006
  };
11777
12007
 
11778
12008
  const ContenthashRecord = ({
@@ -12094,89 +12324,284 @@ const SelectRecordsForm = ({
12094
12324
  ] });
12095
12325
  };
12096
12326
 
12097
- var TransactionState = /* @__PURE__ */ ((TransactionState2) => {
12098
- TransactionState2["InProgress"] = "In Progress";
12099
- TransactionState2["Completed"] = "Completed";
12100
- TransactionState2["Failed"] = "Failed";
12101
- return TransactionState2;
12102
- })(TransactionState || {});
12103
- const PendingTransaction = ({
12104
- state,
12105
- blockExplorerUrl,
12106
- transactionHash,
12107
- className = ""
12327
+ const SET_TEXT_FUNC = "function setText(bytes32 node, string key, string value)";
12328
+ const SET_ADDRESS_FUNC = "function setAddr(bytes32 node, uint256 coin, bytes value)";
12329
+ const SET_CONTENTHASH_FUNC = "function setContenthash(bytes32 node, bytes value)";
12330
+ const MULTICALL = "function multicall(bytes[] data)";
12331
+ const ENS_RESOLVER_ABI = parseAbi([
12332
+ SET_TEXT_FUNC,
12333
+ SET_ADDRESS_FUNC,
12334
+ SET_CONTENTHASH_FUNC,
12335
+ MULTICALL
12336
+ ]);
12337
+
12338
+ const convertToMulticallResolverData = (name, recordsDiff) => {
12339
+ const node = namehash(name);
12340
+ const resolverMulticallData = [];
12341
+ convertTextData(node, resolverMulticallData, recordsDiff);
12342
+ convertAddressData(node, resolverMulticallData, recordsDiff);
12343
+ convertContenthashData(node, resolverMulticallData, recordsDiff);
12344
+ return resolverMulticallData;
12345
+ };
12346
+ const convertTextData = (node, resolverData, diff) => {
12347
+ const modifiedTexts = [
12348
+ ...diff.textsAdded,
12349
+ ...diff.textsModified
12350
+ ];
12351
+ modifiedTexts.forEach((text) => {
12352
+ const data = encodeFunctionData({
12353
+ functionName: "setText",
12354
+ abi: parseAbi([SET_TEXT_FUNC]),
12355
+ args: [node, text.key, text.value]
12356
+ });
12357
+ resolverData.push(data);
12358
+ });
12359
+ diff.textsModified.forEach((text) => {
12360
+ const data = encodeFunctionData({
12361
+ functionName: "setText",
12362
+ abi: parseAbi([SET_TEXT_FUNC]),
12363
+ args: [node, text.key, ""]
12364
+ });
12365
+ resolverData.push(data);
12366
+ });
12367
+ };
12368
+ const convertAddressData = (node, resolverData, diff) => {
12369
+ const modifiedAddressMap = {};
12370
+ diff.addressesAdded.forEach((addr) => {
12371
+ modifiedAddressMap[addr.coinType] = addr;
12372
+ });
12373
+ diff.addressesModified.forEach((addr) => {
12374
+ modifiedAddressMap[addr.coinType] = addr;
12375
+ });
12376
+ const modifiedAddresses = Object.values(modifiedAddressMap);
12377
+ modifiedAddresses.forEach((addr) => {
12378
+ const coinEncoder = getCoderByCoinType(addr.coinType);
12379
+ if (!coinEncoder) {
12380
+ throw Error(
12381
+ `Coin type is not supported: ${addr.coinType}. Cannot get an encoder`
12382
+ );
12383
+ }
12384
+ const decode = coinEncoder.decode(addr.value);
12385
+ const hexValue = toHex(decode);
12386
+ const data = encodeFunctionData({
12387
+ functionName: "setAddr",
12388
+ abi: parseAbi([SET_ADDRESS_FUNC]),
12389
+ args: [node, BigInt(addr.coinType), hexValue]
12390
+ });
12391
+ resolverData.push(data);
12392
+ });
12393
+ diff.addressesRemoved.forEach((addr) => {
12394
+ const data = encodeFunctionData({
12395
+ functionName: "setAddr",
12396
+ abi: parseAbi([SET_ADDRESS_FUNC]),
12397
+ args: [node, BigInt(addr.coinType), "0x"]
12398
+ });
12399
+ resolverData.push(data);
12400
+ });
12401
+ };
12402
+ const convertContenthashData = (node, resolverData, diff) => {
12403
+ if (diff.contenthashRemoved) {
12404
+ const data = encodeFunctionData({
12405
+ functionName: "setContenthash",
12406
+ abi: parseAbi([SET_CONTENTHASH_FUNC]),
12407
+ args: [node, "0x"]
12408
+ });
12409
+ resolverData.push(data);
12410
+ return;
12411
+ }
12412
+ let contenthash = void 0;
12413
+ if (diff.contenthashModified !== void 0) {
12414
+ contenthash = diff.contenthashModified;
12415
+ } else if (diff.contenthashAdded !== void 0) {
12416
+ contenthash = diff.contenthashAdded;
12417
+ }
12418
+ if (contenthash !== void 0) {
12419
+ const { protocol, value } = contenthash;
12420
+ const encodedValue = `0x${encode(protocol, value)}`;
12421
+ const data = encodeFunctionData({
12422
+ functionName: "setContenthash",
12423
+ abi: parseAbi([SET_CONTENTHASH_FUNC]),
12424
+ args: [node, encodedValue]
12425
+ });
12426
+ resolverData.push(data);
12427
+ }
12428
+ };
12429
+
12430
+ const addressMapByCoin = getSupportedAddressMap();
12431
+ const EnsRecordsForm = ({
12432
+ name,
12433
+ initialRecords,
12434
+ chainId,
12435
+ resolverAddress,
12436
+ onCancel,
12437
+ onSuccess
12108
12438
  }) => {
12109
- const getStatusIcon = () => {
12110
- switch (state) {
12111
- case "In Progress" /* InProgress */:
12112
- return /* @__PURE__ */ jsx("div", { className: "ns-pending-tx__spinner" });
12113
- case "Completed" /* Completed */:
12114
- return /* @__PURE__ */ jsx(Icon, { name: "check-circle", size: 24 });
12115
- case "Failed" /* Failed */:
12116
- return /* @__PURE__ */ jsx(Icon, { name: "x-circle", size: 24 });
12117
- default:
12118
- return null;
12439
+ const [records, setRecords] = useState(
12440
+ initialRecords ? deepCopy(initialRecords) : { texts: [], addresses: [] }
12441
+ );
12442
+ const currentChainId = chainId || mainnet.id;
12443
+ const publicClient = usePublicClient({ chainId: currentChainId });
12444
+ const { data: walletClient } = useWalletClient({ chainId: currentChainId });
12445
+ const { address, chain, isConnected } = useAccount();
12446
+ const { switchChain } = useSwitchChain();
12447
+ const [contractError, setContractError] = useState(null);
12448
+ const [generalError, setGeneralError] = useState(null);
12449
+ const [txIndicator, setTxIndicator] = useState({
12450
+ isWaitingForTx: false,
12451
+ isWaitingForWallet: false
12452
+ });
12453
+ const shouldSwitchNetwork = chain && chain.id !== currentChainId;
12454
+ useEffect(() => {
12455
+ if (!address) {
12456
+ setGeneralError({
12457
+ title: "Not connected",
12458
+ subtitle: "Connect wallet to continue"
12459
+ });
12460
+ } else {
12461
+ setGeneralError(null);
12462
+ }
12463
+ }, [address, publicClient, walletClient]);
12464
+ const areValidAddresses = useMemo(() => {
12465
+ for (const addr of records.addresses) {
12466
+ const validateFuc = addressMapByCoin[addr.coinType].validateFunc;
12467
+ if (!validateFuc) {
12468
+ throw Error("Validate function not present for coin:" + addr.coinType);
12469
+ }
12470
+ if (addr.value?.length === 0 || !validateFuc(addr.value)) {
12471
+ return false;
12472
+ }
12119
12473
  }
12120
- };
12121
- const getStatusMessage = () => {
12122
- switch (state) {
12123
- case "In Progress" /* InProgress */:
12124
- return "Transaction is being executed...";
12125
- case "Completed" /* Completed */:
12126
- return "Transaction completed successfully!";
12127
- case "Failed" /* Failed */:
12128
- return "Transaction failed!";
12129
- default:
12130
- return "";
12474
+ return true;
12475
+ }, [records.addresses]);
12476
+ const areValidTexts = useMemo(() => {
12477
+ for (const text of records.texts) {
12478
+ if (text.value.length === 0) {
12479
+ return false;
12480
+ }
12481
+ }
12482
+ return true;
12483
+ }, [records.texts]);
12484
+ useMemo(() => {
12485
+ if (!records.contenthash) {
12486
+ return true;
12131
12487
  }
12488
+ return isContenthashValid(
12489
+ records.contenthash.protocol,
12490
+ records.contenthash.value
12491
+ );
12492
+ }, [records.contenthash]);
12493
+ const getInitalRecords = () => {
12494
+ return initialRecords ? initialRecords : { texts: [], addresses: [] };
12132
12495
  };
12133
- const getStatusClass = () => {
12134
- switch (state) {
12135
- case "In Progress" /* InProgress */:
12136
- return "ns-pending-tx--in-progress";
12137
- case "Completed" /* Completed */:
12138
- return "ns-pending-tx--completed";
12139
- case "Failed" /* Failed */:
12140
- return "ns-pending-tx--failed";
12141
- default:
12142
- return "";
12496
+ const isDiffPresent = useMemo(() => {
12497
+ const diff = getEnsRecordsDiff(getInitalRecords(), records);
12498
+ const {
12499
+ addressesAdded,
12500
+ addressesModified,
12501
+ addressesRemoved,
12502
+ textsAdded,
12503
+ textsModified,
12504
+ textsRemoved,
12505
+ contenthashRemoved,
12506
+ contenthashAdded,
12507
+ contenthashModified
12508
+ } = diff;
12509
+ return addressesAdded.length > 0 || addressesModified.length > 0 || addressesRemoved.length || textsAdded.length > 0 || textsRemoved.length > 0 || textsModified.length > 0 || contenthashRemoved === true || contenthashModified !== void 0 || contenthashAdded !== void 0;
12510
+ }, [records, initialRecords]);
12511
+ const handleUpdateRecords = async () => {
12512
+ try {
12513
+ const old = initialRecords ? initialRecords : { texts: [], addresses: [] };
12514
+ const diff = getEnsRecordsDiff(old, records);
12515
+ const resolverData = convertToMulticallResolverData(name, diff);
12516
+ setTxIndicator({ ...txIndicator, isWaitingForWallet: true });
12517
+ const { request } = await publicClient.simulateContract({
12518
+ abi: ENS_RESOLVER_ABI,
12519
+ args: [resolverData],
12520
+ functionName: "multicall",
12521
+ address: resolverAddress,
12522
+ account: address
12523
+ });
12524
+ const tx = await walletClient.writeContract(request);
12525
+ setTxIndicator({ isWaitingForTx: true, isWaitingForWallet: false });
12526
+ await publicClient.waitForTransactionReceipt({ hash: tx });
12527
+ onSuccess?.(tx);
12528
+ } catch (err) {
12529
+ console.error(err);
12530
+ if (err instanceof ContractFunctionExecutionError) {
12531
+ const _err = err;
12532
+ setContractError(_err.details);
12533
+ } else {
12534
+ setContractError("Transaction failed for unknown reason!");
12535
+ }
12536
+ } finally {
12537
+ setTxIndicator({ isWaitingForTx: false, isWaitingForWallet: false });
12143
12538
  }
12144
12539
  };
12145
- const getIconClass = () => {
12146
- switch (state) {
12147
- case "In Progress" /* InProgress */:
12148
- return "ns-pending-tx__icon--in-progress";
12149
- case "Completed" /* Completed */:
12150
- return "ns-pending-tx__icon--completed";
12151
- case "Failed" /* Failed */:
12152
- return "ns-pending-tx__icon--failed";
12153
- default:
12154
- return "";
12540
+ const getActionButton = () => {
12541
+ const areInputsValue = areValidAddresses && areValidTexts && isContenthashValid;
12542
+ const style = { width: "100%" };
12543
+ if (!isConnected) {
12544
+ return /* @__PURE__ */ jsx(
12545
+ Button,
12546
+ {
12547
+ style,
12548
+ size: "lg",
12549
+ disabled: true,
12550
+ prefix: /* @__PURE__ */ jsx(Icon, { name: "alert-triangle" }),
12551
+ children: "Connect Wallet"
12552
+ }
12553
+ );
12554
+ } else if (shouldSwitchNetwork) {
12555
+ return /* @__PURE__ */ jsx(
12556
+ Button,
12557
+ {
12558
+ style,
12559
+ size: "lg",
12560
+ onClick: () => switchChain({ chainId: currentChainId }),
12561
+ children: "Switch Network"
12562
+ }
12563
+ );
12564
+ } else if (!areInputsValue) {
12565
+ return /* @__PURE__ */ jsx(Tooltip, { content: "Invalid inputs", position: "top", children: /* @__PURE__ */ jsx(Button, { style, size: "lg", disabled: true, children: "Update" }) });
12566
+ } else if (!isDiffPresent) {
12567
+ return /* @__PURE__ */ jsx(Tooltip, { content: "No Records updated", position: "top", children: /* @__PURE__ */ jsx(Button, { style, size: "lg", disabled: true, children: "Update" }) });
12568
+ } else {
12569
+ const updateBtnLoading = txIndicator.isWaitingForTx || txIndicator.isWaitingForWallet;
12570
+ return /* @__PURE__ */ jsx(
12571
+ Button,
12572
+ {
12573
+ style,
12574
+ size: "lg",
12575
+ disabled: updateBtnLoading,
12576
+ loading: updateBtnLoading,
12577
+ onClick: () => handleUpdateRecords(),
12578
+ children: "Update"
12579
+ }
12580
+ );
12155
12581
  }
12156
12582
  };
12157
- return /* @__PURE__ */ jsx("div", { className: `ns-pending-tx ${getStatusClass()} ${className}`, children: /* @__PURE__ */ jsxs("div", { className: "ns-pending-tx__content", children: [
12158
- /* @__PURE__ */ jsx("div", { className: `ns-pending-tx__icon ${getIconClass()}`, children: getStatusIcon() }),
12159
- /* @__PURE__ */ jsx("div", { className: "ns-pending-tx__status", children: /* @__PURE__ */ jsx(Text, { children: getStatusMessage() }) }),
12160
- transactionHash && /* @__PURE__ */ jsxs("p", { className: "ns-pending-tx__message", children: [
12161
- "Hash: ",
12162
- transactionHash.slice(0, 10),
12163
- "...",
12164
- transactionHash.slice(-8)
12165
- ] }),
12166
- /* @__PURE__ */ jsxs(
12167
- "a",
12583
+ return /* @__PURE__ */ jsxs("div", { className: "ns-edit-records-form", children: [
12584
+ /* @__PURE__ */ jsx(
12585
+ SelectRecordsForm,
12168
12586
  {
12169
- href: blockExplorerUrl,
12170
- target: "_blank",
12171
- rel: "noopener noreferrer",
12172
- className: "ns-pending-tx__link",
12173
- children: [
12174
- /* @__PURE__ */ jsx(Icon, { name: "globe", size: 16, className: "ns-pending-tx__link-icon" }),
12175
- "View on Block Explorer"
12176
- ]
12587
+ records,
12588
+ onRecordsUpdated: (records2) => setRecords(records2)
12177
12589
  }
12178
- )
12179
- ] }) });
12590
+ ),
12591
+ /* @__PURE__ */ jsx("div", { style: { padding: 15, paddingTop: 0 }, children: /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center", style: { gap: "8px" }, children: [
12592
+ /* @__PURE__ */ jsx(
12593
+ Button,
12594
+ {
12595
+ onClick: () => onCancel?.(),
12596
+ size: "lg",
12597
+ style: { width: "100%" },
12598
+ variant: "outline",
12599
+ children: "Cancel"
12600
+ }
12601
+ ),
12602
+ getActionButton()
12603
+ ] }) })
12604
+ ] });
12180
12605
  };
12181
12606
 
12182
12607
  const useWaitForTransaction = ({ chainId: number }) => {
@@ -12191,17 +12616,6 @@ const useWeb3Client = ({ chainId }) => {
12191
12616
  };
12192
12617
  };
12193
12618
 
12194
- const SET_TEXT_FUNC = "function setText(bytes32 node, string key, string value)";
12195
- const SET_ADDRESS_FUNC = "function setAddr(bytes32 node, uint256 coin, bytes value)";
12196
- const SET_CONTENTHASH_FUNC = "function setContenthash(bytes32 node, bytes value)";
12197
- const MULTICALL = "function multicall(bytes[] data)";
12198
- const ENS_RESOLVER_ABI = parseAbi([
12199
- SET_TEXT_FUNC,
12200
- SET_ADDRESS_FUNC,
12201
- SET_CONTENTHASH_FUNC,
12202
- MULTICALL
12203
- ]);
12204
-
12205
12619
  const ThemeContext = createContext(void 0);
12206
12620
  const ThemeProvider = ({
12207
12621
  initialTheme = "light",
@@ -12237,5 +12651,5 @@ const useTheme = () => {
12237
12651
  return ctx;
12238
12652
  };
12239
12653
 
12240
- export { Alert, Button, ChainIcon, ContenthashIcon, ContenthashProtocol, Dropdown, ENS_RESOLVER_ABI, Icon, Input, MULTICALL, Modal, PendingTransaction, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, Text, TextRecordCategory, ThemeProvider, Tooltip, TransactionState, capitalize, convertEVMChainIdToCoinType, deepCopy, equalsIgnoreCase, getEnsRecordsDiff, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, getSupportedTextMap, isContenthashValid, supportedAddresses, supportedContenthashRecords, supportedTexts, useTheme, useWaitForTransaction, useWeb3Client };
12654
+ export { Alert, Button, ChainIcon, ContenthashIcon, ContenthashProtocol, Dropdown, ENS_RESOLVER_ABI, EnsRecordsForm, Icon, Input, MULTICALL, Modal, PendingTransaction, SET_ADDRESS_FUNC, SET_CONTENTHASH_FUNC, SET_TEXT_FUNC, SelectRecordsForm, Text, TextRecordCategory, ThemeProvider, Tooltip, TransactionState, capitalize, convertEVMChainIdToCoinType, deepCopy, equalsIgnoreCase, getEnsRecordsDiff, getSupportedAddressByCoin, getSupportedAddressByName, getSupportedAddressMap, getSupportedChashByProtocol, getSupportedText, isContenthashValid, supportedAddresses, supportedContenthashRecords, supportedTexts, useTheme, useWaitForTransaction, useWeb3Client };
12241
12655
  //# sourceMappingURL=index.js.map