Skip to content

Commit

Permalink
fix: fixing fee render logic
Browse files Browse the repository at this point in the history
  • Loading branch information
wainola committed Feb 6, 2024
1 parent 82aac26 commit e99ff8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/ExplorerTable/ExplorerTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ExplorerTable: React.FC<ExplorerTable> = ({ state, sharedConfig }: Explore
const fromDomainInfo = getDomainData(fromDomainId, sharedConfig)
const toDomainInfo = getDomainData(toDomainId, sharedConfig)

const formatedFee = getFormatedFee(fee, fromDomainInfo!)
const formatedFee = getFormatedFee(fee, resourceID, fromDomainInfo!)

const fromDomainType = fromDomainInfo?.type

Expand Down
14 changes: 9 additions & 5 deletions src/utils/Helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,21 @@ export const formatDistanceDate = (timestamp: string): string => {
}
}

export const getFormatedFee = (fee: Transfer["fee"] | string, domain: SharedConfigDomain): string => {
export const getFormatedFee = (fee: Transfer["fee"] | string, resourceID: string, domain: SharedConfigDomain): string => {
let formatedFee = "No fee"
const { type } = domain
const { type, resources } = domain

if (type === DomainTypes.SUBSTRATE) {
formatedFee = "50 PHA"
}

if (typeof fee !== "string" && domain) {
const { nativeTokenDecimals, nativeTokenSymbol } = domain
formatedFee = `${ethers.formatUnits(fee.amount, nativeTokenDecimals).toString()} ${nativeTokenSymbol.toUpperCase()}`
const resource = resources.find(resource => {
return resource.resourceId === resourceID
})

if (typeof fee !== "string" && domain && resource) {
const { decimals, symbol } = resource
formatedFee = `${ethers.formatUnits(fee.amount, decimals).toString()} ${symbol.toUpperCase()}`
}

return formatedFee
Expand Down

0 comments on commit e99ff8b

Please sign in to comment.