@thenamespace/ens-components 0.12.0 → 0.13.0
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
|
@@ -126619,93 +126619,218 @@ function RegistrationForm({
|
|
|
126619
126619
|
onClose,
|
|
126620
126620
|
onNext,
|
|
126621
126621
|
onCompleteProfile,
|
|
126622
|
+
onRecordsChange,
|
|
126622
126623
|
isLoadingPrice = false,
|
|
126623
126624
|
priceError = null,
|
|
126624
126625
|
nameAvailability = { isAvailable: false, isChecking: false },
|
|
126625
126626
|
canProceed = false
|
|
126626
126627
|
}) {
|
|
126627
126628
|
const [isDurationExpanded, setIsDurationExpanded] = useState(false);
|
|
126628
|
-
|
|
126629
|
-
|
|
126630
|
-
|
|
126631
|
-
|
|
126632
|
-
|
|
126633
|
-
|
|
126634
|
-
|
|
126635
|
-
|
|
126636
|
-
|
|
126637
|
-
|
|
126638
|
-
|
|
126639
|
-
|
|
126640
|
-
|
|
126641
|
-
|
|
126642
|
-
|
|
126643
|
-
|
|
126644
|
-
|
|
126645
|
-
|
|
126646
|
-
|
|
126647
|
-
|
|
126648
|
-
|
|
126649
|
-
|
|
126650
|
-
|
|
126651
|
-
|
|
126652
|
-
|
|
126653
|
-
|
|
126654
|
-
|
|
126655
|
-
|
|
126656
|
-
|
|
126657
|
-
|
|
126658
|
-
|
|
126659
|
-
|
|
126660
|
-
|
|
126661
|
-
|
|
126662
|
-
|
|
126629
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
126630
|
+
const [records, setRecords] = useState({
|
|
126631
|
+
addresses: [],
|
|
126632
|
+
texts: []
|
|
126633
|
+
});
|
|
126634
|
+
const [initialRecords, setInitialRecords] = useState({
|
|
126635
|
+
addresses: [],
|
|
126636
|
+
texts: []
|
|
126637
|
+
});
|
|
126638
|
+
const { connectedAddress } = useConnectedPrincipal();
|
|
126639
|
+
const eth_address = getSupportedAddressByName("eth");
|
|
126640
|
+
const celo_address = getSupportedAddressByName("celo");
|
|
126641
|
+
useEffect(() => {
|
|
126642
|
+
if (connectedAddress && records.addresses.length === 0) {
|
|
126643
|
+
const newAddresses = [];
|
|
126644
|
+
if (eth_address) {
|
|
126645
|
+
newAddresses.push({ coinType: eth_address.coinType, value: connectedAddress });
|
|
126646
|
+
}
|
|
126647
|
+
if (celo_address) {
|
|
126648
|
+
newAddresses.push({ coinType: celo_address.coinType, value: connectedAddress });
|
|
126649
|
+
}
|
|
126650
|
+
if (newAddresses.length > 0) {
|
|
126651
|
+
setRecords((prevRecords) => ({
|
|
126652
|
+
...prevRecords,
|
|
126653
|
+
addresses: newAddresses
|
|
126654
|
+
}));
|
|
126655
|
+
}
|
|
126656
|
+
}
|
|
126657
|
+
}, [connectedAddress]);
|
|
126658
|
+
const recordsToAdd = useMemo(() => {
|
|
126659
|
+
let count = 0;
|
|
126660
|
+
records.texts.forEach((text) => {
|
|
126661
|
+
if (text.value.length > 0) {
|
|
126662
|
+
count++;
|
|
126663
|
+
}
|
|
126664
|
+
});
|
|
126665
|
+
records.addresses.forEach((addr) => {
|
|
126666
|
+
const supportedAddr = getSupportedAddressByCoin(addr.coinType);
|
|
126667
|
+
if (supportedAddr) {
|
|
126668
|
+
if (addr.value.length > 0 && supportedAddr.validateFunc?.(addr.value)) {
|
|
126669
|
+
count++;
|
|
126670
|
+
}
|
|
126671
|
+
}
|
|
126672
|
+
});
|
|
126673
|
+
if (records.contenthash && records.contenthash.value.length > 0) {
|
|
126674
|
+
count++;
|
|
126675
|
+
}
|
|
126676
|
+
return count;
|
|
126677
|
+
}, [records]);
|
|
126678
|
+
const handleAddProfile = () => {
|
|
126679
|
+
setIsModalOpen(true);
|
|
126680
|
+
};
|
|
126681
|
+
const handleRecordsAdded = () => {
|
|
126682
|
+
const _initialRecords = deepCopy$2(records);
|
|
126683
|
+
setInitialRecords(_initialRecords);
|
|
126684
|
+
onRecordsChange?.(records);
|
|
126685
|
+
setIsModalOpen(false);
|
|
126686
|
+
onCompleteProfile?.();
|
|
126687
|
+
};
|
|
126688
|
+
const handleRecordsCancel = () => {
|
|
126689
|
+
setRecords(deepCopy$2(initialRecords));
|
|
126690
|
+
setIsModalOpen(false);
|
|
126691
|
+
};
|
|
126692
|
+
return /* @__PURE__ */ jsxs("div", { className: "ens-names-register-container", children: [
|
|
126693
|
+
/* @__PURE__ */ jsxs("div", { className: "ens-names-register-card", children: [
|
|
126694
|
+
/* @__PURE__ */ jsx(Header, { showBack: true, onBack, onClose }),
|
|
126695
|
+
/* @__PURE__ */ jsxs("div", { className: "ens-names-register-title-section", children: [
|
|
126696
|
+
/* @__PURE__ */ jsx(Text$1, { size: "xl", weight: "light", className: "ens-names-register-title", children: "ENS Registration" }),
|
|
126697
|
+
/* @__PURE__ */ jsx(Text$1, { size: "md", color: "grey", className: "ens-names-register-subtitle", children: "Your about to mint this ENS name" })
|
|
126698
|
+
] }),
|
|
126699
|
+
ensName && /* @__PURE__ */ jsx("div", { className: "ens-names-register-name-display", children: /* @__PURE__ */ jsxs(Text$1, { size: "xl", weight: "bold", children: [
|
|
126700
|
+
ensName,
|
|
126701
|
+
".eth"
|
|
126702
|
+
] }) }),
|
|
126703
|
+
/* @__PURE__ */ jsxs("div", { className: "ens-names-register-duration-section", children: [
|
|
126704
|
+
/* @__PURE__ */ jsxs("div", { className: "ens-names-register-duration-controls", children: [
|
|
126705
|
+
/* @__PURE__ */ jsx(
|
|
126706
|
+
"button",
|
|
126707
|
+
{
|
|
126708
|
+
className: "ens-names-register-duration-btn",
|
|
126709
|
+
onClick: () => onDurationChange(-1),
|
|
126710
|
+
disabled: duration <= 1,
|
|
126711
|
+
children: /* @__PURE__ */ jsx("span", { style: { fontSize: "20px", lineHeight: "1" }, children: "\u2212" })
|
|
126712
|
+
}
|
|
126713
|
+
),
|
|
126714
|
+
/* @__PURE__ */ jsx(
|
|
126715
|
+
"div",
|
|
126716
|
+
{
|
|
126717
|
+
className: "ens-names-register-duration-text",
|
|
126718
|
+
onClick: () => setIsDurationExpanded(!isDurationExpanded),
|
|
126719
|
+
children: /* @__PURE__ */ jsxs(Text$1, { size: "md", weight: "medium", children: [
|
|
126720
|
+
duration,
|
|
126721
|
+
" year",
|
|
126722
|
+
duration !== 1 ? "s" : ""
|
|
126723
|
+
] })
|
|
126724
|
+
}
|
|
126725
|
+
),
|
|
126726
|
+
/* @__PURE__ */ jsx(
|
|
126727
|
+
"button",
|
|
126728
|
+
{
|
|
126729
|
+
className: "ens-names-register-duration-btn",
|
|
126730
|
+
onClick: () => onDurationChange(1),
|
|
126731
|
+
children: /* @__PURE__ */ jsx("span", { style: { fontSize: "20px", lineHeight: "1" }, children: "+" })
|
|
126732
|
+
}
|
|
126733
|
+
)
|
|
126734
|
+
] }),
|
|
126735
|
+
isDurationExpanded && /* @__PURE__ */ jsx("div", { className: "ens-names-register-cost-breakdown", children: /* @__PURE__ */ jsx(
|
|
126736
|
+
CostSummary,
|
|
126663
126737
|
{
|
|
126664
|
-
|
|
126665
|
-
|
|
126666
|
-
|
|
126738
|
+
duration,
|
|
126739
|
+
registrationCost,
|
|
126740
|
+
networkFee,
|
|
126741
|
+
total,
|
|
126742
|
+
isLoading: isLoadingPrice,
|
|
126743
|
+
priceError
|
|
126667
126744
|
}
|
|
126668
|
-
)
|
|
126745
|
+
) })
|
|
126669
126746
|
] }),
|
|
126670
|
-
|
|
126671
|
-
|
|
126747
|
+
/* @__PURE__ */ jsxs(
|
|
126748
|
+
"div",
|
|
126672
126749
|
{
|
|
126673
|
-
|
|
126674
|
-
|
|
126675
|
-
|
|
126676
|
-
|
|
126677
|
-
|
|
126678
|
-
|
|
126750
|
+
className: "ens-names-register-profile-card",
|
|
126751
|
+
onClick: handleAddProfile,
|
|
126752
|
+
children: [
|
|
126753
|
+
/* @__PURE__ */ jsx("div", { className: "ens-names-register-profile-icon", children: /* @__PURE__ */ jsx("img", { src: img$2, alt: "Profile Icon" }) }),
|
|
126754
|
+
/* @__PURE__ */ jsxs("div", { className: "ens-names-register-profile-text", children: [
|
|
126755
|
+
/* @__PURE__ */ jsx(Text$1, { size: "md", weight: "bold", children: "Complete your profile" }),
|
|
126756
|
+
/* @__PURE__ */ jsx(Text$1, { size: "sm", color: "grey", children: "Make your ENS more discoverable" })
|
|
126757
|
+
] }),
|
|
126758
|
+
/* @__PURE__ */ jsx("button", { className: "ens-names-register-profile-arrow", children: /* @__PURE__ */ jsx(ChevronRight, { size: 20 }) })
|
|
126759
|
+
]
|
|
126679
126760
|
}
|
|
126680
|
-
)
|
|
126761
|
+
),
|
|
126762
|
+
/* @__PURE__ */ jsx(
|
|
126763
|
+
Button,
|
|
126764
|
+
{
|
|
126765
|
+
className: "ens-names-register-next-btn",
|
|
126766
|
+
variant: "solid",
|
|
126767
|
+
size: "lg",
|
|
126768
|
+
onClick: onNext,
|
|
126769
|
+
disabled: !canProceed,
|
|
126770
|
+
children: "Next"
|
|
126771
|
+
}
|
|
126772
|
+
)
|
|
126681
126773
|
] }),
|
|
126682
|
-
/* @__PURE__ */ jsxs(
|
|
126683
|
-
"div",
|
|
126684
|
-
{
|
|
126685
|
-
className: "ens-names-register-profile-card",
|
|
126686
|
-
onClick: onCompleteProfile,
|
|
126687
|
-
children: [
|
|
126688
|
-
/* @__PURE__ */ jsx("div", { className: "ens-names-register-profile-icon", children: /* @__PURE__ */ jsx("img", { src: img$2, alt: "Profile Icon" }) }),
|
|
126689
|
-
/* @__PURE__ */ jsxs("div", { className: "ens-names-register-profile-text", children: [
|
|
126690
|
-
/* @__PURE__ */ jsx(Text$1, { size: "md", weight: "bold", children: "Complete your profile" }),
|
|
126691
|
-
/* @__PURE__ */ jsx(Text$1, { size: "sm", color: "grey", children: "Make your ENS more discoverable" })
|
|
126692
|
-
] }),
|
|
126693
|
-
/* @__PURE__ */ jsx("button", { className: "ens-names-register-profile-arrow", children: /* @__PURE__ */ jsx(ChevronRight, { size: 20 }) })
|
|
126694
|
-
]
|
|
126695
|
-
}
|
|
126696
|
-
),
|
|
126697
126774
|
/* @__PURE__ */ jsx(
|
|
126698
|
-
|
|
126775
|
+
Modal,
|
|
126699
126776
|
{
|
|
126700
|
-
|
|
126701
|
-
|
|
126702
|
-
size: "
|
|
126703
|
-
|
|
126704
|
-
|
|
126705
|
-
|
|
126777
|
+
isOpen: isModalOpen,
|
|
126778
|
+
onClose: () => setIsModalOpen(false),
|
|
126779
|
+
size: "md",
|
|
126780
|
+
footer: null,
|
|
126781
|
+
isDismissDisabled: true,
|
|
126782
|
+
style: { maxWidth: "500px" },
|
|
126783
|
+
children: /* @__PURE__ */ jsxs("div", { style: { margin: "-20px" }, children: [
|
|
126784
|
+
/* @__PURE__ */ jsx(
|
|
126785
|
+
SelectRecordsForm,
|
|
126786
|
+
{
|
|
126787
|
+
records,
|
|
126788
|
+
onRecordsUpdated: (updatedRecords) => {
|
|
126789
|
+
setRecords(updatedRecords);
|
|
126790
|
+
}
|
|
126791
|
+
}
|
|
126792
|
+
),
|
|
126793
|
+
/* @__PURE__ */ jsxs(
|
|
126794
|
+
"div",
|
|
126795
|
+
{
|
|
126796
|
+
style: {
|
|
126797
|
+
background: "#f4f4f4",
|
|
126798
|
+
gap: "7px",
|
|
126799
|
+
display: "flex",
|
|
126800
|
+
padding: "8px",
|
|
126801
|
+
paddingTop: "0"
|
|
126802
|
+
},
|
|
126803
|
+
children: [
|
|
126804
|
+
/* @__PURE__ */ jsx(
|
|
126805
|
+
Button,
|
|
126806
|
+
{
|
|
126807
|
+
onClick: handleRecordsCancel,
|
|
126808
|
+
variant: "outline",
|
|
126809
|
+
style: { width: "50%" },
|
|
126810
|
+
size: "lg",
|
|
126811
|
+
children: "Cancel"
|
|
126812
|
+
}
|
|
126813
|
+
),
|
|
126814
|
+
/* @__PURE__ */ jsxs(
|
|
126815
|
+
Button,
|
|
126816
|
+
{
|
|
126817
|
+
onClick: handleRecordsAdded,
|
|
126818
|
+
size: "lg",
|
|
126819
|
+
style: { width: "50%" },
|
|
126820
|
+
children: [
|
|
126821
|
+
"Add (",
|
|
126822
|
+
recordsToAdd,
|
|
126823
|
+
")"
|
|
126824
|
+
]
|
|
126825
|
+
}
|
|
126826
|
+
)
|
|
126827
|
+
]
|
|
126828
|
+
}
|
|
126829
|
+
)
|
|
126830
|
+
] })
|
|
126706
126831
|
}
|
|
126707
126832
|
)
|
|
126708
|
-
] })
|
|
126833
|
+
] });
|
|
126709
126834
|
}
|
|
126710
126835
|
|
|
126711
126836
|
function StepItem({
|
|
@@ -127566,7 +127691,6 @@ function ENSNamesRegistrarComponent({
|
|
|
127566
127691
|
}
|
|
127567
127692
|
}, []);
|
|
127568
127693
|
const handleNameSearchNext = () => {
|
|
127569
|
-
console.log("[ENS Registration] handleNameSearchNext called - Moving to RegistrationBegin");
|
|
127570
127694
|
if (ensName && ensName.length >= 3 && duration > 0) {
|
|
127571
127695
|
const normalizedName = normalise(ensName.trim());
|
|
127572
127696
|
if (normalizedName !== lastFetchedName || duration !== lastFetchedDuration) {
|
|
@@ -127644,6 +127768,13 @@ function ENSNamesRegistrarComponent({
|
|
|
127644
127768
|
}
|
|
127645
127769
|
if (currentStep === EnsRegistrationSteps.RegistrationBegin) {
|
|
127646
127770
|
const canProceed = nameAvailability.isAvailable && !nameAvailability.isChecking && ensName.length >= 3;
|
|
127771
|
+
const normalizedName = normalise(ensName.trim());
|
|
127772
|
+
const handleRecordsChange = (records) => {
|
|
127773
|
+
setRecordsPerName({
|
|
127774
|
+
...recordsPerName,
|
|
127775
|
+
[normalizedName]: records
|
|
127776
|
+
});
|
|
127777
|
+
};
|
|
127647
127778
|
return /* @__PURE__ */ jsx(
|
|
127648
127779
|
RegistrationForm,
|
|
127649
127780
|
{
|
|
@@ -127658,6 +127789,7 @@ function ENSNamesRegistrarComponent({
|
|
|
127658
127789
|
onClose,
|
|
127659
127790
|
onNext: handleNext,
|
|
127660
127791
|
onCompleteProfile,
|
|
127792
|
+
onRecordsChange: handleRecordsChange,
|
|
127661
127793
|
isLoadingPrice,
|
|
127662
127794
|
priceError,
|
|
127663
127795
|
nameAvailability,
|