Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/components/Wallet/modals/DisconnectModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ const WalletDropdownMenu = ({
<Dropdown.Menu className="right-0 mt-2 min-w-[240px] border border-base-300 bg-base-200 p-3 text-center shadow-lg">
<div className="text-sm text-neutral-400">{walletAccount?.name}</div>
<div className="text-neutral-500">
<CopyablePublicKey
publicKey={ss58Format ? getAddressForFormat(address, ss58Format) : address}
variant="short"
inline={true}
/>
<CopyablePublicKey publicKey={getAddressForFormat(address, ss58Format)} variant="short" inline={true} />
</div>
<p className="my-6 truncate text-center text-2xl font-bold" title={`${balance} ${tokenSymbol}`}>
{balance && prettyNumbers(balance)} {tokenSymbol}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/addressFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Keyring } from '@polkadot/api';

export function getAddressForFormat(address: string, ss58Format: number | string) {
export function getAddressForFormat(address: string, ss58Format: number | string = 0) {
if (typeof ss58Format === 'string') {
ss58Format = parseInt(ss58Format, 10);
}
Expand All @@ -9,7 +9,7 @@ export function getAddressForFormat(address: string, ss58Format: number | string
return keyring.encodeAddress(address, ss58Format);
}

export function getAddressKeyring(address: string, ss58Format: number | string = 57) {
export function getAddressKeyring(address: string, ss58Format: number | string = 0) {
const keyring = new Keyring({ type: 'sr25519', ss58Format: Number(ss58Format) });
return keyring.addFromAddress(address);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/staking/useStakingPallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function useStakingPallet() {

const fetchEstimatedReward = useCallback(async () => {
if (!api || !walletAccount?.address) return '0';
const formattedAddr = ss58Format ? getAddressForFormat(walletAccount.address, ss58Format) : walletAccount.address;
const formattedAddr = getAddressForFormat(walletAccount.address, ss58Format);
return (await api.query.parachainStaking.rewards(formattedAddr)).toString();
}, [api, ss58Format, walletAccount?.address]);

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function useBalances() {
if (!walletAccount) return Promise.resolve();

const assets = getAllAssetsMetadata();
const walletAddress = ss58Format ? getAddressForFormat(walletAccount.address, ss58Format) : walletAccount.address;
const walletAddress = getAddressForFormat(walletAccount.address, ss58Format);

const getFree = (tokenBalanceRaw: unknown, asset: OrmlTraitsAssetRegistryAssetMetadata) => {
const isNativeToken = asset.currencyId.toHuman() === 'Native';
Expand Down
22 changes: 11 additions & 11 deletions src/pages/staking/CollatorRewards/CollatorRewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function CollatorRewards() {
}, [getTransactionFee, unlockUnstaked, walletAccount?.address]);

const userAccountAddress = useMemo(() => {
return walletAccount && ss58Format ? getAddressForFormat(walletAccount?.address, ss58Format) : '';
return walletAccount ? getAddressForFormat(walletAccount?.address, ss58Format) : '';
}, [walletAccount, ss58Format]);

useEffect(() => {
Expand Down Expand Up @@ -186,9 +186,9 @@ export function CollatorRewards() {
if (loadingToken) {
return (
<>
<Skeleton className="w-full h-8 mb-2" />
<Skeleton className="w-full h-8 mb-2" />
<Skeleton className="w-full h-8 mb-2" />
<Skeleton className="mb-2 h-8 w-full" />
<Skeleton className="mb-2 h-8 w-full" />
<Skeleton className="mb-2 h-8 w-full" />
</>
);
}
Expand All @@ -198,10 +198,10 @@ export function CollatorRewards() {

return (
<>
<div className="flex flex-col justify-between mb-8 md:flex-row">
<div className="mb-3 rounded-lg collators-box card bg-base-200 md:mb-0 md:mr-5 md:w-1/2">
<div className="px-4 py-6 card-body xs:px-8">
<h2 className="font-normal card-title">Staking</h2>
<div className="mb-8 flex flex-col justify-between md:flex-row">
<div className="collators-box card mb-3 rounded-lg bg-base-200 md:mb-0 md:mr-5 md:w-1/2">
<div className="card-body px-4 py-6 xs:px-8">
<h2 className="card-title font-normal">Staking</h2>
{renderContentWithLoading(
<StakingContent
userStakingAmount={userStaking?.amount}
Expand All @@ -215,9 +215,9 @@ export function CollatorRewards() {
)}
</div>
</div>
<div className="rounded-lg collators-box card bg-base-200 md:w-1/2">
<div className="px-4 py-6 card-body xs:px-8">
<h2 className="mb-2 font-normal card-title">Staking Rewards</h2>
<div className="collators-box card rounded-lg bg-base-200 md:w-1/2">
<div className="card-body px-4 py-6 xs:px-8">
<h2 className="card-title mb-2 font-normal">Staking Rewards</h2>
{renderContentWithLoading(
<StakingRewardsContent
updateButton={{
Expand Down
2 changes: 1 addition & 1 deletion src/pages/staking/CollatorsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function CollatorsTable() {
const [data, setData] = useState<TCollator[] | undefined>();

const userAccountAddress = useMemo(() => {
return walletAccount && ss58Format ? getAddressForFormat(walletAccount?.address, ss58Format) : '';
return walletAccount ? getAddressForFormat(walletAccount?.address, ss58Format) : '';
}, [walletAccount, ss58Format]);

useEffect(() => {
Expand Down
Loading