Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PE-7068): reassign name #624

Merged
merged 10 commits into from
Dec 18, 2024
8 changes: 1 addition & 7 deletions src/components/cards/WarningCard/WarningCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ function WarningCard({
}}
>
{showIcon || customIcon ? (
<span
style={{
height: '100%',
display: 'flex',
lineHeight: '150%',
}}
>
<span className="flex items-center justify-center h-full pt-[2px]">
{customIcon ? (
customIcon
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/DomainSettings/DescriptionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useEffect, useState } from 'react';
import DomainSettingsRow from './DomainSettingsRow';

export default function DescriptionRow({
description,
description = '',
confirm,
editable = false,
}: {
Expand Down
8 changes: 4 additions & 4 deletions src/components/forms/DomainSettings/DomainSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function DomainSettings({
editable={isAuthorized}
action={
<div className="flex flex-row gap-1" style={{ gap: '10px' }}>
{data?.arnsRecord?.type == 'permabuy' ? (
{data?.arnsRecord?.type == 'permabuy' && isOwner ? (
<Tooltip
message={
!antHandlers.includes('releaseName')
Expand Down Expand Up @@ -329,7 +329,7 @@ function DomainSettings({
<Skeleton.Input active />
)
}
editable={isAuthorized}
editable={isOwner}
action={
<Tooltip
message={
Expand Down Expand Up @@ -500,7 +500,7 @@ function DomainSettings({
[DomainSettingsRowTypes.DESCRIPTION]: (
<DescriptionRow
key={DomainSettingsRowTypes.DESCRIPTION}
description={data?.info.Description}
description={data?.info?.Description}
editable={isAuthorized}
confirm={(description: string) =>
dispatchANTInteraction({
Expand All @@ -520,7 +520,7 @@ function DomainSettings({
[DomainSettingsRowTypes.KEYWORDS]: (
<KeywordsRow
key={DomainSettingsRowTypes.KEYWORDS}
keywords={data?.info.Keywords}
keywords={data?.info?.Keywords}
editable={isAuthorized}
confirm={(keywords: string[]) =>
dispatchANTInteraction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export function ReassignNameModal({
<XIcon className="text-white" width={'24px'} height={'24px'} />
</button>
</div>
<span className="text-[14px]">
<span className="">
You are about to reassign your name registration from one ANT
(Arweave Name Token) to another.
</span>
Expand Down Expand Up @@ -208,16 +208,14 @@ export function ReassignNameModal({
<div className="flex flex-col gap-8 w-[32rem] pb-8">
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">Name</span>
<span className="text-[14px] text-white">
<span className=" text-grey">Name</span>
<span className=" text-white">
{encodeDomainToASCII(name)}
</span>
</div>
<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">
Old ANT Process ID
</span>
<span className="text-[14px] text-white">
<span className=" text-grey">Old ANT Process ID</span>
<span className=" text-white">
{domainData?.processId ? (
<ArweaveID
id={new ArweaveTransactionID(domainData.processId)}
Expand All @@ -231,17 +229,15 @@ export function ReassignNameModal({
</div>

<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">New ANT Type</span>
<span className="text-[14px] text-white">{antType}</span>
<span className=" text-grey">New ANT Type</span>
<span className=" text-white">{antType}</span>
</div>

{antType === REASSIGN_NAME_WORKFLOWS.EXISTING && (
<>
<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">
Destination Process ID
</span>
<span className="text-[14px] text-white">
<span className=" text-grey">Destination Process ID</span>
<span className=" text-white">
<ArweaveID
id={new ArweaveTransactionID(newAntProcessId)}
type={ArweaveIdTypes.CONTRACT}
Expand All @@ -250,9 +246,7 @@ export function ReassignNameModal({
</span>
</div>
<div className="flex flex-col gap-1 w-full">
<span className="text-[14px] text-grey">
Destination ANT Owner
</span>
<span className=" text-grey">Destination ANT Owner</span>
{loadingNewAntInfo ? (
<Skeleton.Input
size="small"
Expand All @@ -263,7 +257,7 @@ export function ReassignNameModal({
}}
/>
) : (
<span className="text-[14px] text-white">
<span className=" text-white">
{isValidAoAddress(newAntInfo?.owner) ? (
<ArweaveID
id={new ArweaveTransactionID(newAntInfo.owner)}
Expand Down Expand Up @@ -299,8 +293,8 @@ export function ReassignNameModal({
{antType === REASSIGN_NAME_WORKFLOWS.NEW_EXISTING && (
<>
<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">Controllers</span>
<div className="flex gap-3 text-[14px] text-white">
<span className=" text-grey">Controllers</span>
<div className="flex gap-3 text-white">
{domainData.controllers ? (
domainData.controllers.map((c, index) => {
if (isValidAoAddress(c)) {
Expand Down Expand Up @@ -340,8 +334,8 @@ export function ReassignNameModal({
</div>
</div>
<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">Target ID</span>
<span className="text-[14px] text-white">
<span className="text-grey">Target ID</span>
<span className="text-white">
{domainData?.apexRecord.transactionId ? (
<ArweaveID
id={
Expand All @@ -365,8 +359,8 @@ export function ReassignNameModal({
</span>
</div>
<div className="flex flex-col gap-1">
<span className="text-[14px] text-grey">Undernames</span>
<span className="text-[14px] text-white">
<span className=" text-grey">Undernames</span>
<span className=" text-white">
{domainData?.undernameCount ?? (
<Skeleton.Input
size="small"
Expand Down
81 changes: 44 additions & 37 deletions src/components/pages/ManageDomain/ManageDomain.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TransactionSuccessCard from '@src/components/cards/TransactionSuccessCard/TransactionSuccessCard';
import DomainSettings from '@src/components/forms/DomainSettings/DomainSettings';
import { usePrimaryName } from '@src/hooks/usePrimaryName';
import { useGlobalState, useModalState } from '@src/state';
import { useGlobalState, useModalState, useWalletState } from '@src/state';
import { useTransactionState } from '@src/state/contexts/TransactionState';
import { Star } from 'lucide-react';
import { ReactNode, useEffect, useRef, useState } from 'react';
Expand Down Expand Up @@ -68,6 +68,9 @@ function ManageDomain() {
useTransactionState();
const [, dispatchModalState] = useModalState();
const { data: primaryNameData } = usePrimaryName();
const [{ walletAddress }] = useWalletState();

const isOwner = walletAddress?.toString() === primaryNameData?.owner;

const [logoId, setLogoId] = useState<string | undefined>();

Expand Down Expand Up @@ -119,44 +122,48 @@ function ManageDomain() {
}
/>
</h2>
<button
className={
'flex text-primary bg-primary-thin max-w-fit rounded border border-primary px-3 py-1 gap-3 text-[16px] items-center'
}
onClick={() => {
if (!name) return;
if (primaryNameData?.name === name) {
// remove primary name payload
dispatchTransactionState({
type: 'setTransactionData',
payload: {
names: [name],
arioProcessId,
assetId: '',
functionName: 'removePrimaryNames',
},
});
} else {
dispatchTransactionState({
type: 'setTransactionData',
payload: {
name,
arioProcessId,
assetId: arioProcessId,
functionName: 'primaryNameRequest',
},
});
{isOwner && (
<button
className={
'flex text-primary bg-primary-thin max-w-fit rounded border border-primary px-3 py-1 gap-3 text-[16px] items-center'
}
onClick={() => {
if (!name) return;
if (primaryNameData?.name === name) {
// remove primary name payload
dispatchTransactionState({
type: 'setTransactionData',
payload: {
names: [name],
arioProcessId,
assetId: '',
functionName: 'removePrimaryNames',
},
});
} else {
dispatchTransactionState({
type: 'setTransactionData',
payload: {
name,
arioProcessId,
assetId: arioProcessId,
functionName: 'primaryNameRequest',
},
});
}

dispatchModalState({
type: 'setModalOpen',
payload: { showPrimaryNameModal: true },
});
}}
>
<Star className={`w-[16px]`} />{' '}
{name == primaryNameData?.name ? 'Remove Primary' : 'Make Primary'}
</button>
dispatchModalState({
type: 'setModalOpen',
payload: { showPrimaryNameModal: true },
});
}}
>
<Star className={`w-[16px]`} />{' '}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use rem

{name == primaryNameData?.name
? 'Remove Primary'
: 'Make Primary'}
</button>
)}
</div>
<DomainSettings
domain={name}
Expand Down
Loading