Skip to content

Commit

Permalink
refactor: remove deprecated apis and migrate to events
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Sep 10, 2024
1 parent bc72e68 commit f537865
Show file tree
Hide file tree
Showing 11 changed files with 423 additions and 260 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-cycles-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

The transactions list is now includes more details such as specific transaction types and maturity height for locked siacoin.
7 changes: 7 additions & 0 deletions .changeset/cold-poems-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Removed wallet transactions and pending transactions APIs.
7 changes: 7 additions & 0 deletions .changeset/poor-berries-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Added wallet events and pending events APIs.
7 changes: 7 additions & 0 deletions .changeset/silent-icons-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

Removed deprecated wallet discard, fund, sign, and outputs APIs.
2 changes: 1 addition & 1 deletion apps/hostd/contexts/transactions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function useTransactionsMain() {
sortField,
sortDirection,
resetDefaultColumnVisibility,
} = useTableState('walletd/v0/events', {
} = useTableState('hostd/v0/events', {
columns,
columnsDefaultVisible,
sortOptions,
Expand Down
175 changes: 175 additions & 0 deletions apps/renterd/contexts/transactions/columns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import {
Text,
TableColumn,
ValueCopyable,
LoadingDots,
ValueScFiat,
ValueSf,
Tooltip,
Badge,
} from '@siafoundation/design-system'
import { humanDate, getTxTypeLabel } from '@siafoundation/units'
import { CellContext, EventData, TableColumnId } from './types'
import { Locked16, Unlocked16 } from '@siafoundation/react-icons'

type EventsTableColumn = TableColumn<TableColumnId, EventData, CellContext> & {
fixed?: boolean
category?: string
}

export const columns: EventsTableColumn[] = [
{
id: 'transactionId',
label: 'transaction ID',
category: 'general',
render: ({ data: { id }, context }) => {
if (!id) {
return null
}
return (
<ValueCopyable
size="12"
value={id}
label="transaction ID"
type="transaction"
siascanUrl={context.siascanUrl}
/>
)
},
},
{
id: 'type',
label: 'type',
category: 'general',
fixed: true,
render: ({ data: { txType } }) => {
return <Badge size="small">{getTxTypeLabel(txType)}</Badge>
},
},
{
id: 'height',
label: 'height',
category: 'general',
contentClassName: 'justify-end',
render: ({ data: { height, pending, maturityHeight, isMature } }) => {
if (pending) {
return (
<Text size="12" ellipsis>
<LoadingDots />
</Text>
)
}
if (!height) {
return null
}
if (height && maturityHeight && maturityHeight > height) {
return (
<Tooltip
content={
isMature
? 'The maturity height has been reached.'
: 'The maturity height has not been reached, therefore the output is still locked.'
}
>
<div className="flex flex-col gap-[5px]">
<div className="flex justify-end">
<Text
size="12"
font="mono"
ellipsis
color={isMature ? 'green' : 'red'}
className="flex gap-1 items-center"
>
{isMature ? <Unlocked16 /> : <Locked16 />}
{maturityHeight.toLocaleString()}
</Text>
</div>
<div className="flex justify-between items-end gap-1">
<div className="pl-[8px] pb-[6px]">
<div className="border-l border-b border-gray-800 dark:border-graydark-800 h-[20px] w-[7px]" />
</div>
<Text size="12" font="mono" color="subtle" ellipsis>
{height.toLocaleString()}
</Text>
</div>
</div>
</Tooltip>
)
}
return (
<Text size="12" font="mono" ellipsis>
{height.toLocaleString()}
</Text>
)
},
},
{
id: 'timestamp',
label: 'timestamp',
category: 'general',
contentClassName: 'justify-end',
render: ({ data: { timestamp, pending } }) => {
if (pending) {
return (
<Text size="12" ellipsis>
<LoadingDots />
</Text>
)
}
return (
<Text size="12" ellipsis>
{humanDate(timestamp, { timeStyle: 'short' })}
</Text>
)
},
},
{
id: 'amount',
label: 'amount',
category: 'general',
contentClassName: 'w-[120px] justify-end',
render: ({ data: { amountSc, amountSf } }) => {
if (!amountSc) {
return null
}
return (
<div className="flex flex-col gap-2 items-end">
{!amountSc.isZero() && (
<ValueScFiat displayBoth size="12" value={amountSc} />
)}
{!!amountSf && <ValueSf size="12" value={amountSf} />}
</div>
)
},
},
{
id: 'fee',
label: 'fee',
category: 'general',
contentClassName: 'w-[120px] justify-end',
render: ({ data: { fee } }) => {
if (!fee) {
return null
}
return <ValueScFiat displayBoth size="12" variant="value" value={fee} />
},
},
{
id: 'contractId',
label: 'contract ID',
category: 'general',
render: ({ data: { contractId }, context }) => {
if (!contractId) {
return null
}
return (
<ValueCopyable
size="12"
value={contractId}
label="contract ID"
siascanUrl={context.siascanUrl}
/>
)
},
},
]
Loading

0 comments on commit f537865

Please sign in to comment.