Skip to content

Commit

Permalink
chore: update root domain on bitname register & update empty text aft…
Browse files Browse the repository at this point in the history
…er loading on stamp detail page & some weird placed 000s in the Details dropdown & showed the error message more details
  • Loading branch information
itttm127 authored and reinamora137 committed Jan 21, 2025
1 parent fda95c5 commit 6334ee7
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 12 deletions.
2 changes: 2 additions & 0 deletions client/hooks/userSRC101Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface SRC101FormState {
file: File | null;
psbtFees?: PSBTFees;
maxAmount?: string;
root: string;
}

export function useSRC101Form(
Expand All @@ -50,6 +51,7 @@ export function useSRC101Form(
const [apiError, setApiError] = useState<string>("");

const [formState, setFormState] = useState<SRC101FormState>({
root: ".btc",
toAddress: "",
token: initialToken || "",
amt: "",
Expand Down
2 changes: 1 addition & 1 deletion components/shared/fee/FeeCalculatorBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export function FeeCalculatorBase({

{/* Sats Per Byte */}
<p className={detailsText}>
<span className={detailsTitle}>SATS PER BYTE</span> {fee}
<span className={detailsTitle}>SATS PER BYTE</span> {/* {fee} */}
</p>

{/* Miner Fee */}
Expand Down
2 changes: 1 addition & 1 deletion globals.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// General Types ---------------------------------------------------------------

export type ROOT_DOMAIN_TYPES = ".btc" | ".sats" | ".xbt" | ".x" | ".pink";
export type SUBPROTOCOLS = "STAMP" | "SRC-20" | "SRC-721" | "SRC-101";
export type STAMP_TYPES = // These just reformat to variations of SUBPROTOCOLS
| "all"
Expand Down
2 changes: 1 addition & 1 deletion islands/shared/Tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export default function Table({
</div>
<ScrollContainer class="max-h-48" onScroll={handleScroll}>
<div class="">
{renderTabContent()}
{!isLoading && renderTabContent()}
{isLoading && (
<div class={textLoader}>
<span>L</span>
Expand Down
3 changes: 1 addition & 2 deletions islands/stamp/details/StampImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export function StampImage(

useEffect(() => {
const validateContent = async () => {
if (stamp.stamp_mimetype === "image/svg+xml") {
if (stamp.stamp_mimetype === "image/svg+xml" && src) {
const { isValid, error } = await validateStampContent(src);
if (isValid) {
setValidatedContent(
Expand Down Expand Up @@ -507,7 +507,6 @@ export function StampImage(
}
}
};

validateContent();
}, [src, stamp.stamp_mimetype]);

Expand Down
55 changes: 48 additions & 7 deletions islands/stamping/src101/register/RegisterContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { ComplexFeeCalculator } from "$islands/fee/ComplexFeeCalculator.tsx";
import { StatusMessages } from "$islands/stamping/StatusMessages.tsx";
import { InputField } from "$islands/stamping/InputField.tsx";
import DetailModal from "$islands/stamping/src101/DetailModal.tsx";
import { SRC101Balance } from "$globals";
import { ROOT_DOMAIN_TYPES, SRC101Balance } from "$globals";
import { useSRC101Form } from "$client/hooks/userSRC101Form.ts";
import { SelectField } from "$islands/stamping/SelectField.tsx";
import { ROOT_DOMAINS } from "$lib/utils/constants.ts";

// CSS Class Constants
const bodyTools = "flex flex-col w-full items-center gap-3 mobileMd:gap-6";
Expand Down Expand Up @@ -79,7 +81,7 @@ export function RegisterBitnameContent({
try {
const url =
`/api/v2/src101/77fb147b72a551cf1e2f0b37dccf9982a1c25623a7fe8b4d5efaac566cf63fed/${
btoa(formState.toAddress?.toLowerCase().replace(".btc", ""))
btoa((formState.toAddress + formState.root)?.toLowerCase())
}`;
const res = await fetch(url);
const jsonData = await res.json();
Expand Down Expand Up @@ -108,8 +110,44 @@ export function RegisterBitnameContent({
<h1 className={titlePurpleLDCenter}>REGISTER</h1>

<div className={inputFieldContainer}>
<div class="relative w-full">
<div className={animatedInputContainer}>
<div class={animatedInputContainer}>
<div class="flex justify-between relative z-[2] !bg-[#100318] placeholder:!bg-[#100318] rounded-md">
<input
type="search"
id="search-dropdown"
class="h-[54px] mobileLg:h-[60px] w-full bg-transparent rounded-md pl-6 text-base mobileLg:text-lg font-bold text-stamp-grey-light placeholder:!text-stamp-grey placeholder:lowercase !outline-none focus-visible:!outline-none focus:!bg-[#100318]"
placeholder="Please input your bitname"
required
value={formState.toAddress || ""}
onChange={(e) => handleInputChange(e, "toAddress")}
/>
<select
className="h-[54px] max-w-32 mobileLg:h-[60px] px-3 rounded-md bg-transparent text-stamp-grey-light placeholder:lowercase text-base focus-visible:!outline-none appearance-none"
onChange={(e) =>
handleInputChange(
{
target: {
value: e.currentTarget.value,
},
},
"root",
)}
value={formState.root}
>
{ROOT_DOMAINS.map((item: ROOT_DOMAIN_TYPES) => (
<option
key={item}
value={item}
class="bg-[#100318]"
>
{item}
</option>
))}
</select>
</div>

{
/* <div className={animatedInputContainer}>
<InputField
type="text"
placeholder="Please input your bitname"
Expand All @@ -135,16 +173,19 @@ export function RegisterBitnameContent({
</div>
<span class="absolute z-[3] right-6 top-1/2 -translate-y-1/2 text-base mobileLg:text-lg font-black text-stamp-purple pointer-events-none">
.btc
</span>
</span> */
}
</div>
<div className="flex flex-row justify-between w-full">
<div className="flex flex-col justify-center items-start">
{/* message - default:noDisplay / display on user input & onClick - either already registered or available */}
<p className="text-sm mobileLg:text-base font-medium text-[#999999]">
{formState.toAddress && checkStatus
? isExist
? `${formState.toAddress} is already registered`
: `${formState.toAddress} is available`
? `${
formState.toAddress + formState.root
} is already registered`
: `${formState.toAddress + formState.root} is available`
: ""}
</p>
</div>
Expand Down
15 changes: 15 additions & 0 deletions islands/stamping/stamp/OlgaContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,24 @@ function extractErrorMessage(error: unknown): string {
message?: string;
};
};
response?: {
data?: {
error?: string;
};
};
message?: string;
};

// Check for direct error message
if (err.response?.data?.error) {
logger.debug("stamps", {
message: "Found direct error message",
path: "error.message",
value: err.response?.data?.error,
});
return err.response?.data?.error;
}

// Check for direct error message
if (err.error?.message) {
logger.debug("stamps", {
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ROOT_DOMAIN_TYPES } from "$globals";

export const LOGO_STAMPCHAIN = "/img/stampchain.png";
export const LOGO = LOGO_STAMPCHAIN;
export const MAX_XCP_RETRIES = 5;
Expand Down Expand Up @@ -105,3 +107,11 @@ export const ARTICLE_LINKS: ArticleLink[] = [
{ title: "REGISTER BITNAME DOMAIN", href: "/howto/registerbitname" },
{ title: "TRANSFER A BITNAME DOMAIN", href: "/howto/transferbitname" },
];

export const ROOT_DOMAINS: ROOT_DOMAIN_TYPES[] = [
".btc",
".sats",
".xbt",
".x",
".pink",
];

0 comments on commit 6334ee7

Please sign in to comment.