Skip to content

Commit

Permalink
Display account addresses in vara format (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov authored Jul 1, 2024
1 parent 5ee1f64 commit ed7dfa0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getVaraAddress } from '@gear-js/react-hooks';
import { Identicon } from '@polkadot/react-identicon';
import { Link, generatePath } from 'react-router-dom';

Expand Down Expand Up @@ -47,7 +48,7 @@ function CollectionCard({ id, name, collectionBanner, collectionLogo, admin, tok

<div className={styles.user}>
<Identicon value={admin} size={14} theme="polkadot" />
<span className={styles.address}>{admin}</span>
<span className={styles.address}>{getVaraAddress(admin)}</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useBalanceFormat } from '@gear-js/react-hooks';
import { getVaraAddress, useBalanceFormat } from '@gear-js/react-hooks';
import { Link, generatePath } from 'react-router-dom';

import { PriceInfoCard, InfoCard } from '@/components';
Expand Down Expand Up @@ -35,7 +35,7 @@ function NFTCard({ sales, auctions, ...nft }: Props) {
<h3 className={styles.name}>{name}</h3>

<p className={styles.owner}>
Owned by <span className={styles.address}>{owner}</span>
Owned by <span className={styles.address}>{getVaraAddress(owner)}</span>
</p>
</div>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getVaraAddress } from '@gear-js/react-hooks';
import { Button, ButtonProps } from '@gear-js/vara-ui';
import { Identicon } from '@polkadot/react-identicon';

Expand All @@ -15,7 +16,7 @@ type Props = {
function AccountButton({ address, name, color, size, block, onClick }: Props) {
return (
<Button onClick={onClick} color={color} size={size} block={block} className={styles.button}>
<Identicon value={address} size={16} theme="polkadot" /> <span>{name || address}</span>
<Identicon value={address} size={16} theme="polkadot" /> <span>{name || getVaraAddress(address)}</span>
</Button>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { decodeAddress } from '@gear-js/api';
import { useAccount, useAlert } from '@gear-js/react-hooks';
import { getVaraAddress, useAccount, useAlert } from '@gear-js/react-hooks';
import { Button, Modal } from '@gear-js/vara-ui';

import CopySVG from '../../assets/copy.svg?react';
Expand Down Expand Up @@ -66,10 +65,10 @@ function WalletModal({ close }: Props) {
};

const handleCopyClick = () => {
const decodedAddress = decodeAddress(address);
const encodedAddress = getVaraAddress(address);

navigator.clipboard
.writeText(decodedAddress)
.writeText(encodedAddress)
.then(() => {
close();
alert.success('Copied');
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/nft/nft.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useAccount } from '@gear-js/react-hooks';
import { getVaraAddress, useAccount } from '@gear-js/react-hooks';
import { Identicon } from '@polkadot/react-identicon';
import { useState } from 'react';
import { generatePath, useParams } from 'react-router-dom';
Expand Down Expand Up @@ -91,7 +91,7 @@ function NFT() {

{owner ? (
<p className={styles.ownerText}>
Owned by <span className={styles.ownerAddress}>{owner}</span>
Owned by <span className={styles.ownerAddress}>{getVaraAddress(owner)}</span>
</p>
) : (
<Skeleton width="100%" borderRadius="4px" />
Expand Down

0 comments on commit ed7dfa0

Please sign in to comment.