mirror of
https://github.com/logos-storage/logos-storage-marketplace-ui.git
synced 2026-01-02 13:33:06 +00:00
1- Add the total collateral in the availability table
2- Define the min price per byte as 1 3- Use `0.1` step for the availability size 4- Round the total size number 5- Use the total size value (= 1 token per byte) by default for the total collateral 6- Do not allow negative numbers when creating the storage requests 7- Reduce the default reward and collateral for the storage request
This commit is contained in:
parent
d44a8dc95f
commit
19d045e714
@ -49,8 +49,11 @@ export function AvailabilitiesTable({ availabilities, space }: Props) {
|
||||
const onSortByPrice = (state: TabSortState) =>
|
||||
setSortFn(() => AvailabilityUtils.sortByPrice(state));
|
||||
|
||||
const onSortByCollateral = (state: TabSortState) =>
|
||||
setSortFn(() => AvailabilityUtils.sortByCollateral(state));
|
||||
const onSortByRemainingCollateral = (state: TabSortState) =>
|
||||
setSortFn(() => AvailabilityUtils.sortByRemainingCollateral(state));
|
||||
|
||||
const onSortByTotalCollateral = (state: TabSortState) =>
|
||||
setSortFn(() => AvailabilityUtils.sortByTotalCollateral(state));
|
||||
|
||||
const headers = [
|
||||
[""],
|
||||
@ -58,7 +61,8 @@ export function AvailabilitiesTable({ availabilities, space }: Props) {
|
||||
["total size", onSortBySize],
|
||||
["duration", onSortByDuration],
|
||||
["min price per byte", onSortByPrice],
|
||||
["remaining collateral", onSortByCollateral],
|
||||
["remaining collateral", onSortByRemainingCollateral],
|
||||
["total collateral", onSortByTotalCollateral],
|
||||
["actions"],
|
||||
] satisfies [string, ((state: TabSortState) => void)?][];
|
||||
|
||||
@ -90,6 +94,7 @@ export function AvailabilitiesTable({ availabilities, space }: Props) {
|
||||
<Cell>{Times.pretty(a.duration)}</Cell>,
|
||||
<Cell>{a.minPricePerBytePerSecond.toString()}</Cell>,
|
||||
<Cell>{a.totalRemainingCollateral.toString()}</Cell>,
|
||||
<Cell>{a.totalCollateral.toString()}</Cell>,
|
||||
<AvailabilityActionsCell availability={a} />,
|
||||
]}></Row>
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ const CONFIRM_STATE = 2;
|
||||
const defaultAvailabilityData: AvailabilityState = {
|
||||
totalSize: 0.5,
|
||||
duration: 1,
|
||||
minPricePerBytePerSecond: 0,
|
||||
minPricePerBytePerSecond: 1,
|
||||
totalCollateral: 0,
|
||||
totalSizeUnit: "gb",
|
||||
durationUnit: "days",
|
||||
|
||||
@ -11,6 +11,7 @@ import NodesIcon from "../../assets/icons/nodes.svg?react";
|
||||
import InfoIcon from "../../assets/icons/info.svg?react";
|
||||
import { attributes } from "../../utils/attributes";
|
||||
import { AvailabilityUtils } from "./availability.utils";
|
||||
import { GB } from "../../utils/constants";
|
||||
|
||||
export function AvailabilityForm({
|
||||
dispatch,
|
||||
@ -144,12 +145,13 @@ export function AvailabilityForm({
|
||||
max={available.toFixed(2)}
|
||||
onChange={onAvailablityChange}
|
||||
onGroupChange={onTotalSizeUnitChange}
|
||||
value={availability.totalSize.toString()}
|
||||
value={availability.totalSize.toFixed(2)}
|
||||
min={"0"}
|
||||
group={[
|
||||
["gb", "GB"],
|
||||
// ["tb", "TB"],
|
||||
]}
|
||||
step="0.1"
|
||||
groupValue={availability.totalSizeUnit}
|
||||
extra={<a onClick={onMaxSize}>Use max size</a>}
|
||||
/>
|
||||
@ -208,7 +210,10 @@ export function AvailabilityForm({
|
||||
label="Total collateral"
|
||||
min={0}
|
||||
onChange={onInputChange}
|
||||
value={availability.totalCollateral.toString()}
|
||||
value={(
|
||||
availability.totalCollateral ||
|
||||
Math.round(availability.totalSize * GB)
|
||||
).toString()}
|
||||
/>
|
||||
<Tooltip
|
||||
message={
|
||||
|
||||
@ -179,13 +179,13 @@ describe("files", () => {
|
||||
|
||||
const descSorted = items
|
||||
.slice()
|
||||
.sort(AvailabilityUtils.sortByCollateral("desc"));
|
||||
.sort(AvailabilityUtils.sortByRemainingCollateral("desc"));
|
||||
|
||||
assert.deepEqual(descSorted, [b, a]);
|
||||
|
||||
const ascSorted = items
|
||||
.slice()
|
||||
.sort(AvailabilityUtils.sortByCollateral("asc"));
|
||||
.sort(AvailabilityUtils.sortByRemainingCollateral("asc"));
|
||||
|
||||
assert.deepEqual(ascSorted, [a, b]);
|
||||
});
|
||||
|
||||
@ -25,12 +25,18 @@ export const AvailabilityUtils = {
|
||||
state === "desc"
|
||||
? b.minPricePerBytePerSecond - a.minPricePerBytePerSecond
|
||||
: a.minPricePerBytePerSecond - b.minPricePerBytePerSecond,
|
||||
sortByCollateral:
|
||||
sortByRemainingCollateral:
|
||||
(state: TabSortState) =>
|
||||
(a: AvailabilityWithSlots, b: AvailabilityWithSlots) =>
|
||||
state === "desc"
|
||||
? b.totalRemainingCollateral - a.totalRemainingCollateral
|
||||
: a.totalRemainingCollateral - b.totalRemainingCollateral,
|
||||
sortByTotalCollateral:
|
||||
(state: TabSortState) =>
|
||||
(a: AvailabilityWithSlots, b: AvailabilityWithSlots) =>
|
||||
state === "desc"
|
||||
? b.totalCollateral - a.totalCollateral
|
||||
: a.totalCollateral - b.totalCollateral,
|
||||
toUnit(bytes: number, unit: "gb" | "tb") {
|
||||
return bytes / this.unitValue(unit || "gb");
|
||||
},
|
||||
|
||||
@ -52,6 +52,7 @@ export function CardNumbers({
|
||||
value={value}
|
||||
type="number"
|
||||
isInvalid={!!error}
|
||||
min={0}
|
||||
onChange={onInternalChange}></Input>
|
||||
|
||||
<Tooltip message={error || helper}>
|
||||
|
||||
@ -27,8 +27,8 @@ const defaultStorageRequest: StorageRequest = {
|
||||
tolerance: 1,
|
||||
proofProbability: 1,
|
||||
nodes: 3,
|
||||
reward: 10,
|
||||
collateral: 10,
|
||||
reward: 1,
|
||||
collateral: 1,
|
||||
expiration: 5,
|
||||
};
|
||||
|
||||
|
||||
@ -288,7 +288,7 @@ export function StorageRequestReview({
|
||||
value={storageRequest.collateral.toString()}
|
||||
onChange={onCollateralChange}
|
||||
onValidation={isInvalidNumber}
|
||||
title="Penality tokens"></CardNumbers>
|
||||
title="Penality tokens per byte"></CardNumbers>
|
||||
<CardNumbers
|
||||
helper="The maximum amount of tokens paid per second per byte to hosts the client is willing to pay."
|
||||
id="reward"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user