Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing data to Consensus tx list #1462

Merged
merged 2 commits into from
Jun 28, 2024
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
1 change: 1 addition & 0 deletions .changelog/1462.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show missing columns in Consensus transactions list
135 changes: 72 additions & 63 deletions src/app/components/Transactions/ConsensusTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,73 +56,82 @@ export const ConsensusTransactions: FC<ConsensusTransactionsProps> = ({
]
: []),
]
const tableRows = transactions?.map(transaction => ({
key: `${transaction.hash}${transaction.index}`,
data: [
{
content: <StatusIcon success={transaction.success} error={transaction.error} />,
key: 'success',
},
{
content: <TransactionLink scope={transaction} alwaysTrim hash={transaction.hash} />,
key: 'hash',
},
{
content: <BlockLink scope={transaction} height={transaction.block} />,
key: 'round',
},
{
content: <Age sinceTimestamp={transaction.timestamp} />,
key: 'timestamp',
},
...(verbose
? [
{
content: <ConsensusTransactionMethod method={transaction.method} truncate />,
key: 'method',
},
{
align: TableCellAlign.Right,
content: (
<Box
sx={{
display: 'flex',
alignItems: 'center',
position: 'relative',
pr: 3,
}}
>

const tableRows = transactions?.map(transaction => {
const targetAddress = transaction.body.to || transaction.body.account
Copy link
Contributor Author

@buberdds buberdds Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transactions consensus and runtime APIs are not consistent:

runtime has props

amount?: string;
to?: Address;

where here we use body. not sure this should be unified in Nexus. Current API might work fine with new design where we will have to render different body props depends on a tx type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say it would be nice to unify, but not high priority. Let's make it work on our side, and BE can resolve it, once they find the time.

return {
key: `${transaction.hash}${transaction.index}`,
Copy link
Collaborator

@lubej lubej Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for ${transaction.index} I think. Tx hash should be unique enough, unless there is a case, where it's missing or duplicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was needed in the past #1412

data: [
{
content: <StatusIcon success={transaction.success} error={transaction.error} />,
key: 'success',
},
{
content: <TransactionLink scope={transaction} alwaysTrim hash={transaction.hash} />,
key: 'hash',
},
{
content: <BlockLink scope={transaction} height={transaction.block} />,
key: 'round',
},
{
content: <Age sinceTimestamp={transaction.timestamp} />,
key: 'timestamp',
},
...(verbose
? [
{
content: <ConsensusTransactionMethod method={transaction.method} truncate />,
key: 'method',
},
{
align: TableCellAlign.Right,
content: (
<Box
sx={{
display: 'flex',
alignItems: 'center',
position: 'relative',
pr: 3,
}}
>
<AccountLink
labelOnly={transaction.sender === ownAddress}
scope={transaction}
address={transaction.sender}
alwaysTrim
/>
</Box>
),
key: 'from',
},
{
content: targetAddress ? (
<AccountLink
labelOnly={!!ownAddress && transaction.sender === ownAddress}
labelOnly={targetAddress === ownAddress}
scope={transaction}
address={transaction.sender}
address={targetAddress}
alwaysTrim
/>
</Box>
),
key: 'from',
},
{
// TODO: show recipients address when props is added to API
content: <>-</>,
key: 'to',
},
{
align: TableCellAlign.Right,
content: <RoundedBalance value={transaction.fee} ticker={transaction.ticker} />,
key: 'fee_amount',
},
{
align: TableCellAlign.Right,
// TODO: show RoundedBalance when API returns amount prop
content: <>-</>,
key: 'value',
},
]
: []),
],
highlight: transaction.markAsNew,
}))
) : null,
key: 'to',
},
{
align: TableCellAlign.Right,
content: <RoundedBalance value={transaction.fee} ticker={transaction.ticker} />,
key: 'fee_amount',
},
{
align: TableCellAlign.Right,
content: <RoundedBalance value={transaction.body.amount} ticker={transaction.ticker} />,
key: 'value',
},
]
: []),
],
highlight: transaction.markAsNew,
}
})

return (
<Table
Expand Down
4 changes: 4 additions & 0 deletions src/oasis-nexus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export const useGetConsensusTransactions: typeof generated.useGetConsensusTransa
network,
layer: Layer.consensus,
ticker,
body: {
...tx.body,
amount: tx.body.amount ? fromBaseUnits(tx.body.amount, consensusDecimals) : undefined,
},
}
}),
}
Expand Down
Loading