Skip to content

Commit

Permalink
refactor(renterd): contract total cost initial renter funds
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Dec 2, 2024
1 parent 8cdd612 commit 48995db
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 22 deletions.
8 changes: 8 additions & 0 deletions .changeset/grumpy-badgers-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'renterd': minor
'@siafoundation/renterd-js': minor
'@siafoundation/renterd-react': minor
'@siafoundation/renterd-types': minor
---

The contract total cost value is now called initial renter funds.
14 changes: 7 additions & 7 deletions apps/renterd/contexts/contracts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,23 +376,23 @@ export const columns: ContractsTableColumn[] = [
},
},
{
id: 'totalCost',
label: 'total cost',
id: 'initialRenterFunds',
label: 'initial renter funds',
category: 'financial',
contentClassName: 'w-[120px] justify-end',
render: ({ data: { totalCost } }) => (
<ValueScFiat displayBoth size="12" value={totalCost.negated()} />
render: ({ data: { initialRenterFunds } }) => (
<ValueScFiat displayBoth size="12" value={initialRenterFunds.negated()} />
),
summary: ({ context: { filteredStats } }) => {
if (!filteredStats.totalCostTotal) {
if (!filteredStats.initialRenterFundsTotal) {
return null
}
return (
<ValueScFiat
displayBoth
size="12"
value={filteredStats.totalCostTotal.negated()}
tooltip="Total cost across the filtered set of active contracts"
value={filteredStats.initialRenterFundsTotal.negated()}
tooltip="Total initial renter funds across the filtered set of active contracts"
/>
)
},
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/contexts/contracts/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function useDataset() {
revisionHeight: c.revisionHeight,
isRenewed,
renewedFrom: c.renewedFrom,
totalCost: new BigNumber(c.totalCost),
initialRenterFunds: new BigNumber(c.initialRenterFunds),
spendingUploads: new BigNumber(c.spending.uploads),
spendingDeletions: new BigNumber(c.spending.deletions),
spendingSectorRoots: new BigNumber(c.spending.sectorRoots),
Expand Down
12 changes: 6 additions & 6 deletions apps/renterd/contexts/contracts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type ContractData = {
proofWindowHeightEnd: number
proofHeight: number
revisionHeight: number
totalCost: BigNumber
initialRenterFunds: BigNumber
spendingUploads: BigNumber
spendingDeletions: BigNumber
spendingSectorRoots: BigNumber
Expand Down Expand Up @@ -75,7 +75,7 @@ export type TableColumnId =
| 'endTime'
| 'size'
| 'prunableSize'
| 'totalCost'
| 'initialRenterFunds'
| 'spendingUploads'
| 'spendingDeletions'
| 'spendingFundAccount'
Expand All @@ -90,7 +90,7 @@ export const columnsDefaultVisible: TableColumnId[] = [
'timeline',
'size',
'prunableSize',
'totalCost',
'initialRenterFunds',
'spendingUploads',
'spendingDeletions',
'spendingFundAccount',
Expand All @@ -107,7 +107,7 @@ export type SortField =
| 'endTime'
| 'size'
| 'prunableSize'
| 'totalCost'
| 'initialRenterFunds'
| 'spendingUploads'
| 'spendingDeletions'
| 'spendingFundAccount'
Expand Down Expand Up @@ -166,8 +166,8 @@ export const sortOptions: {
category: 'general',
},
{
id: 'totalCost',
label: 'total cost',
id: 'initialRenterFunds',
label: 'initial renter funds',
category: 'financial',
},
{
Expand Down
8 changes: 4 additions & 4 deletions apps/renterd/contexts/contracts/useFilteredStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export function useFilteredStats({
}, new BigNumber(0))
}, [datasetFiltered])

const totalCostTotal = useMemo(() => {
const initialRenterFundsTotal = useMemo(() => {
if (!datasetFiltered) {
return undefined
}
return datasetFiltered.reduce((acc, datum) => {
return acc.plus(datum.totalCost)
return acc.plus(datum.initialRenterFunds)
}, new BigNumber(0))
}, [datasetFiltered])

Expand Down Expand Up @@ -77,7 +77,7 @@ export function useFilteredStats({
return {
sizeTotal,
prunableSizeTotal,
totalCostTotal,
initialRenterFundsTotal,
spendingUploadsTotal,
spendingDeletionsTotal,
spendingFundAccountTotal,
Expand All @@ -86,7 +86,7 @@ export function useFilteredStats({
}, [
sizeTotal,
prunableSizeTotal,
totalCostTotal,
initialRenterFundsTotal,
spendingUploadsTotal,
spendingDeletionsTotal,
spendingFundAccountTotal,
Expand Down
2 changes: 1 addition & 1 deletion libs/react-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function handleSubmit(values: Values) {
payload: {
contract: contractRevision
startHeight: 40000
totalCost: '2424242421223232'
initialRenterFunds: '2424242421223232'
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export type ContractsAddParams = {
export type ContractsAddPayload = {
contract: ContractRevision
startHeight: number
totalCost: Currency
initialRenterFunds: Currency
}
export type ContractsAddResponse = Contract

Expand All @@ -331,7 +331,7 @@ export type ContractRenewedPayload = {
contract: ContractRevision
renewedFrom: string
startHeight: number
totalCost: Currency
initialRenterFunds: Currency
}
export type ContractRenewedResponse = Contract

Expand Down
2 changes: 1 addition & 1 deletion libs/renterd-types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export type Contract = {
windowEnd: number
renewedFrom: string
spending: ContractSpending
totalCost: Currency
initialRenterFunds: Currency
size: number
state: ContractState
}
Expand Down

0 comments on commit 48995db

Please sign in to comment.