Skip to content

Commit

Permalink
fix: nft address calculation and typo in function naming
Browse files Browse the repository at this point in the history
  • Loading branch information
brancoder committed Feb 28, 2024
1 parent d5bca2a commit 004cd07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client/src/app/components/nova/OutputView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const OutputView: React.FC<OutputViewProps> = ({ outputId, output, showCopyAmoun
const [isFormattedBalance, setIsFormattedBalance] = useState(true);
const { bech32Hrp, name: network } = useNetworkInfoNova((s) => s.networkInfo);

const aliasOrNftBech32 = buildAddressForAliasOrNft(outputId, output, bech32Hrp);
const aliasOrNftBech32 = buildAddressForAccountOrNft(outputId, output, bech32Hrp);
const outputIdTransactionPart = `${outputId.slice(0, 8)}....${outputId.slice(-8, -4)}`;
const outputIdIndexPart = outputId.slice(-4);
const manaEntries = getManaKeyValueEntries(manaDetails);
Expand Down Expand Up @@ -217,7 +217,7 @@ const OutputView: React.FC<OutputViewProps> = ({ outputId, output, showCopyAmoun
);
};

function buildAddressForAliasOrNft(outputId: string, output: Output, bech32Hrp: string): string {
function buildAddressForAccountOrNft(outputId: string, output: Output, bech32Hrp: string): string {
let bech32: string = "";

if (output.type === OutputType.Account) {
Expand Down
9 changes: 5 additions & 4 deletions client/src/app/components/nova/address/section/nft/Nft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { tryParseMetadata } from "~helpers/stardust/metadataUtils";
import { INftImmutableMetadata } from "~models/api/stardust/nft/INftImmutableMetadata";
import "./Nft.scss";
import { useNetworkInfoNova } from "~/helpers/nova/networkInfo";
import { MetadataFeature, NftOutput, Utils } from "@iota/sdk-wasm-nova/web";
import { MetadataFeature, NftAddress, NftOutput, Utils } from "@iota/sdk-wasm-nova/web";
import TruncatedId from "~/app/components/stardust/TruncatedId";
import { TransactionsHelper } from "~/helpers/nova/transactionsHelper";

Expand All @@ -32,7 +32,8 @@ const Nft: React.FC<NftProps> = ({ nftOutput }) => {
const [metadata, setMetadata] = useState<MetadataFeature | null>(null);
const [issuerId, setIssuerId] = useState<string | null>(null);
const [standardMetadata, setStandardMetadata] = useState<INftImmutableMetadata | null>();
const nftAddress = Utils.hexToBech32(nftOutput.nftId, bech32Hrp);
const nftAddress = new NftAddress(nftOutput.nftId);
const nftBech32Address = Utils.addressToBech32(nftAddress, bech32Hrp);
const [isWhitelisted] = useTokenRegistryNftCheck(issuerId, nftOutput.nftId);
const [name, setName] = useState<string | null>();
const [uri, isNftUriLoading] = useNftMetadataUri(standardMetadata?.uri);
Expand Down Expand Up @@ -75,9 +76,9 @@ const Nft: React.FC<NftProps> = ({ nftOutput }) => {
return (
<div className="nft-card">
<div className="nft-card__metadata">
<Link to={`/${network}/addr/${nftAddress}`}>{nftImageContent}</Link>
<Link to={`/${network}/addr/${nftBech32Address}`}>{nftImageContent}</Link>
<span className="nft-card__id">
<TruncatedId id={nftOutput.nftId} link={`/${network}/addr/${nftAddress}`} />
<TruncatedId id={nftOutput.nftId} link={`/${network}/addr/${nftBech32Address}`} />
</span>
</div>
{name && isWhitelisted && <span className="nft-card__name truncate">{name}</span>}
Expand Down

0 comments on commit 004cd07

Please sign in to comment.