Skip to content

Commit

Permalink
account identicon in callInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Oct 9, 2023
1 parent 7ed6e70 commit 3eafe70
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
13 changes: 3 additions & 10 deletions packages/ui/src/components/CallInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { usePjsLinks } from '../hooks/usePjsLinks'
import { Alert } from '@mui/material'
import { ApiPromise } from '@polkadot/api'
import { isTypeBalance } from '../utils/isTypeBalance'
import { isTypeAccount } from '../utils/isTypeAccount'

interface Props {
aggregatedData: Omit<AggregatedData, 'from' | 'timestamp'>
Expand Down Expand Up @@ -100,9 +101,6 @@ const createUlTree = ({ name, args, decimals, unit, api, typeName }: CreateTreeP
if (!args) return
if (!name) return

const isBalancesTransferAlike = ['balances.transfer', 'balances.transferKeepAlive'].includes(name)
const isProxyCreationDeletion = ['proxy.addProxy', 'proxy.removeProxy'].includes(name)

return (
<ul className="params">
{Object.entries(args).map(([key, value], index) => {
Expand All @@ -113,17 +111,12 @@ const createUlTree = ({ name, args, decimals, unit, api, typeName }: CreateTreeP
}

// generically show nice value for Balance type
if (!!_typeName && isTypeBalance(_typeName)) {
if (isTypeBalance(_typeName)) {
return handleBalanceDisplay({ value, decimals, unit, key })
}

const destAddress = value?.Id || value
// show nice dest
if (
((isBalancesTransferAlike && key === 'dest') ||
(isProxyCreationDeletion && key === 'delegate')) &&
typeof destAddress === 'string'
) {
if (isTypeAccount(_typeName) && typeof destAddress === 'string') {
return (
<li key={key}>
{key}: {<MultisigCompactDisplay address={destAddress} />}
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/utils/isTypeAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const isTypeAccount = (typeName?: string) =>
!!typeName && ['AccountIdLookupOf'].includes(typeName)
4 changes: 2 additions & 2 deletions packages/ui/src/utils/isTypeBalance.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const isTypeBalance = (typeName: string) =>
['Balance', 'BalanceOf', 'Amount'].includes(typeName)
export const isTypeBalance = (typeName?: string) =>
!!typeName && ['Balance', 'BalanceOf', 'Amount'].includes(typeName)

0 comments on commit 3eafe70

Please sign in to comment.