Skip to content

Commit

Permalink
fix: update navbar + fee units + add proposer name
Browse files Browse the repository at this point in the history
  • Loading branch information
Tien Nam Dao committed Oct 19, 2022
1 parent 990e1d6 commit 2947669
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 44 deletions.
60 changes: 31 additions & 29 deletions components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,41 @@ export const items: MenuItem[] = [
{
id: '1',
label: 'Blocks',
submenus: [
{
id: '1.1',
label: 'Blocks',
link: '/blocks'
},
{
id: '1.2',
label: 'Uncle',
link: '/uncle'
},
{
id: '1.3',
label: 'Forked Blocks (Reorgs)',
link: '/reorgs'
}
]
link: '/blocks'
// submenus: [
// {
// id: '1.1',
// label: 'Blocks',
// link: '/blocks'
// },
// {
// id: '1.2',
// label: 'Uncle',
// link: '/uncle'
// },
// {
// id: '1.3',
// label: 'Forked Blocks (Reorgs)',
// link: '/reorgs'
// }
// ]
},
{
id: '2',
label: 'Transactions',
submenus: [
{
id: '2.1',
label: 'Validated',
link: '/tx'
},
{
id: '2.2',
label: 'Pending',
link: '/pending'
}
]
link: '/tx'
// submenus: [
// {
// id: '2.1',
// label: 'Validated',
// link: '/tx'
// },
// {
// id: '2.2',
// label: 'Pending',
// link: '/pending'
// }
// ]
},
{
id: '3',
Expand Down
2 changes: 1 addition & 1 deletion pages/blocks/[block].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const BlockDetailPage: React.FC<Props> = ({ blockDetail, blockHeight, transactio
blockNumber={item.blockHeight}
updatedAt={item.blockTime}
fee={fee.amount}
feeToken={fee.denom}
feeToken={'asa'}
status={item.success}
hash={item.hash}
from={''}
Expand Down
2 changes: 1 addition & 1 deletion pages/tx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const BlockDetailPage: React.FC<NextPage> = _ => {
blockNumber={item.blockHeight}
updatedAt={item.blockTime}
fee={fee.amount}
feeToken={fee.denom}
feeToken={'asa'}
status={item.success}
hash={item.hash}
from={''}
Expand Down
12 changes: 12 additions & 0 deletions utils/address.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ethToAstra } from '@astradefi/address-converter'
import { sha256 } from '@cosmjs/crypto'
import { fromBase64, fromBech32, fromHex, toHex } from '@cosmjs/encoding'
import RIPEMD160 from 'ripemd160'
Expand Down Expand Up @@ -38,6 +39,17 @@ export function getStakingValidatorByHex(hex): Proposer | string {
return hex
}

export function getStakingValidatorByAstraAddress(astraAddress: string): Proposer {
const locals = localStorage.getItem(`validators`)
if (locals && locals !== 'undefined') {
const val = JSON.parse(locals).find((x: Proposer) => x.initialDelegatorAddress === ethToAstra(astraAddress))
if (val) {
return val as Proposer
}
}
return null
}

export function abbr(string, length = 6, suffix = '...'): string {
if (string && string.length > length) {
return `${string.substring(0, length)}${suffix}`
Expand Down
2 changes: 1 addition & 1 deletion utils/cosmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getTransactionType = (type: TransacionTypeEnum) => type?.split('.')
* @returns TokenAmount
*/
export const caculateCosmosAmount = (amounts: TokenAmount[]): TokenAmount => {
if (!amounts) {
if (!amounts || amounts.length == 0) {
return { amount: undefined, denom: undefined }
}
let totalAmount = BigNumber.from('0')
Expand Down
28 changes: 17 additions & 11 deletions views/block/BlockRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import DotSpace from 'components/DotSpace'
import Timer from 'components/Timer'
import Typography from 'components/Typography'
import Image from 'next/image'
import { ellipseRightText, LinkMaker } from 'utils/helper'
import { getStakingValidatorByAstraAddress } from 'utils/address'
import { ellipseBetweenText, LinkMaker } from 'utils/helper'
import styles from './style.module.scss'

type BlockRowProps = {
Expand Down Expand Up @@ -39,6 +40,11 @@ export default function BlockRow({
}: BlockRowProps) {
const { isMobile } = useMobileLayout('medium')
const { isMobile: isSmallDevice } = useMobileLayout('small')
const proposer = getStakingValidatorByAstraAddress(proposerAddress)
const proposerName = proposer?.moniker
const proposerDisplay = proposerName
? `${proposerName} (${ellipseBetweenText(proposerAddress, 10, 10)})`
: proposerAddress
return (
<RowShowAnimation action={newBlock}>
<div
Expand All @@ -54,14 +60,15 @@ export default function BlockRow({
>
<div className={clsx(styles.iconCetner, 'margin-right-sm md-flex-justify-space-between')}>
<div className="block-ver-center">
<Image src={'/images/icons/blockchain.png'} height={24} width={24} />
<Image alt="nothing" src={'/images/icons/blockchain.png'} height={24} width={24} />
{isMobile && (
<div className="col-2 block-ver-center md-padding-left-xs">
<Typography.LinkText
href={LinkMaker.block(blockNumber)}
children={`#${blockNumber}`}
classes={clsx('money', 'money-sm')}
/>
>
{`#${blockNumber}`}
</Typography.LinkText>
</div>
)}
</div>
Expand All @@ -73,11 +80,9 @@ export default function BlockRow({
</div>
{!isMobile && (
<div className="col-2 block-ver-center">
<Typography.LinkText
href={LinkMaker.block(blockNumber)}
children={`#${blockNumber}`}
classes={clsx('money', 'money-sm')}
/>
<Typography.LinkText href={LinkMaker.block(blockNumber)} classes={clsx('money', 'money-sm')}>
{`#${blockNumber}`}
</Typography.LinkText>
</div>
)}
<div
Expand All @@ -86,9 +91,10 @@ export default function BlockRow({
<div>
<Typography.LinkText
href={LinkMaker.address(proposerAddress)}
children={isSmallDevice ? ellipseRightText(proposerAddress, 20) : proposerAddress}
classes={clsx('money', 'money-sm')}
/>
>
{proposerDisplay}
</Typography.LinkText>
</div>
<div className={clsx('block-ver-center', styles.info)}>
<div className="block-ver-center">
Expand Down
2 changes: 1 addition & 1 deletion views/transactions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export const cosmsTransactionDetail = async (result: TransactionItem): Promise<T
// data.tokenTransfer = []
// data.value = undefined
data.fee = formatEther(fee.amount)
data.feeToken = fee.denom
data.feeToken = 'asa'
// data.gasPrice = undefined
// data.gasLimit = result.gasLimit
data.gasUsed = `${result.gasUsed}`
Expand Down

0 comments on commit 2947669

Please sign in to comment.