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

Init coretime business, #4832 #4848

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f287c00
coretime, init page #4832 (#4844)
2nthony Oct 10, 2024
9c4835b
Merge branch 'main' into coretime-4832
wliyongfeng Oct 10, 2024
b8ba730
fix: nav menu, if back to homepage, switch back to main menu
2nthony Oct 11, 2024
be45671
fix useeffect deps
2nthony Oct 11, 2024
efcdaa3
fill overview page content
2nthony Oct 11, 2024
bf5c672
add coretime chain setting [skip ci]
2nthony Oct 14, 2024
e057e09
Merge branch 'main' into coretime-4832
2nthony Oct 16, 2024
439a6ab
revert main format [skip ci]
2nthony Oct 16, 2024
7e946c5
revert main format [skip ci]
2nthony Oct 16, 2024
7c5d7ee
coretime, overview page connect api #4832 (#4876)
2nthony Oct 16, 2024
b8d51aa
Merge branch 'main' into coretime-4832
wliyongfeng Oct 17, 2024
2107cdd
kusama coretime module
2nthony Oct 17, 2024
896b5ad
coretime, separate coretime chain settings files #4832 (#4898)
2nthony Oct 18, 2024
aa90765
coretime, sale purchases data #4832 (#4897)
2nthony Oct 18, 2024
dcb5f07
coretime, sale renewal data #4832 (#4900)
2nthony Oct 18, 2024
e4fbf6a
coretime, should check parent chain support coretime #4832 #4895 (#4902)
2nthony Oct 18, 2024
3448365
coretime, rename sales section files and components #4832 (#4903)
2nthony Oct 18, 2024
544a7a9
coretime, tweak sales history #4832 (#4913)
2nthony Oct 21, 2024
3d50dae
bump icons
2nthony Oct 21, 2024
7f18ae2
coretime, sale panel data, stage 1 #4832 (#4921)
2nthony Oct 22, 2024
51b6991
Merge remote-tracking branch 'origin/main' into coretime-4832
2nthony Oct 22, 2024
c221915
Merge branch 'main' into coretime-4832
wliyongfeng Oct 23, 2024
59863ac
Refactor the code to query current coretime sale, #4832 (#4923)
wliyongfeng Oct 23, 2024
db6fe3a
fix: refactored data #4832 (#4926)
2nthony Oct 23, 2024
6158527
Add a context to hold coretime sale data, #4832 (#4928)
wliyongfeng Oct 23, 2024
547d657
Query and subscribe configuration and status, #4832 (#4930)
wliyongfeng Oct 23, 2024
777f3a2
Add hooks to get coretime configuration and status, #4832 (#4932)
wliyongfeng Oct 23, 2024
c389e3f
Add hook to loop query coretime scan height, #4832 (#4933)
wliyongfeng Oct 23, 2024
5b8265e
fix: nav, improve UX for subspace #4833 (#4929)
2nthony Oct 23, 2024
7310ab9
bump icons [skip ci]
2nthony Oct 23, 2024
a2abdb7
fix: coretime project icon in network selector #4832 (#4935)
2nthony Oct 23, 2024
bb9ff28
Add a hook to get coretime phase data, #4832 (#4936)
wliyongfeng Oct 23, 2024
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
2 changes: 1 addition & 1 deletion packages/kintsugi-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@interlay/monetary-js": "^0.5.3",
"@next/env": "^13.3.0",
"@osn/icons": "^1.144.0",
"@osn/icons": "^1.145.0",
"@polkadot/util-crypto": "^13.1.1",
"@svgr/webpack": "^7.0.0",
"bignumber.js": "^9.0.2",
Expand Down
22 changes: 22 additions & 0 deletions packages/next-common/components/coretime/salePanel/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NeutralPanel } from "../../styled/containers/neutralPanel";
import Divider from "../../styled/layout/divider";
import CoretimeSaleSummary from "./summary";
import useCoretimeSale from "next-common/context/coretime/sale/provider";

export default function CoretimeSalePanel() {
const coretimeSale = useCoretimeSale();

return (
<NeutralPanel className="p-6 text-textPrimary">
<h3 className="text16Bold">Coretime Sale #{coretimeSale.id}</h3>
<Divider className="my-4" />
<CoretimeSaleSummary data={coretimeSale} />

<hr className="border-dashed border-neutral300 my-4" />

<div className="h-48 bg-neutral200">
<div className="flex justify-center items-center h-full">chart</div>
</div>
</NeutralPanel>
);
}
111 changes: 111 additions & 0 deletions packages/next-common/components/coretime/salePanel/summary/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import SummaryItem from "next-common/components/summary/layout/item";
import SummaryLayout from "next-common/components/summary/layout/layout";
import ValueDisplay from "next-common/components/valueDisplay";
import { useChainSettings } from "next-common/context/chain";
import { toPrecision } from "next-common/utils";
import PhaseItem from "next-common/components/coretime/salePanel/summary/phase";

function Item({ label = "", value }) {
return (
<div className="flex items-center gap-x-1 text12Medium text-textTertiary">
<div>{label}</div>
<div className="text-textPrimary">{value}</div>
</div>
);
}

export default function CoretimeSaleSummary({ data }) {
const { decimals, symbol } = useChainSettings();

return (
<div>
<SummaryLayout>
<SummaryItem title="Current Price">
{data?.info?.price ? (
<ValueDisplay
value={toPrecision(10000000000, decimals)}
symbol={symbol}
/>
) : (
<div className="text-textTertiary">-</div>
)}
</SummaryItem>

<SummaryItem title="Available Cores">
{data?.info ? (
<div>
{data?.info?.coresSold}
<span className="text-textTertiary">
{" "}
/ {data?.info?.coresOffered}
</span>
</div>
) : (
<div className="text-textTertiary">-</div>
)}
</SummaryItem>

<PhaseItem />

<SummaryItem title="Sale Period">
<div>[time]</div>
</SummaryItem>

<SummaryItem>
<div className="space-y-1 text12Medium text-textTertiary">
<Item
label="Total Revenue"
value={
<ValueDisplay
className="text-textPrimary"
value={toPrecision(data?.totalRevenue, decimals)}
symbol={symbol}
/>
}
/>
<Item
label="↳ Renewal"
value={
<ValueDisplay
className="text-textPrimary"
value={toPrecision(data?.renewalRevenue, decimals)}
symbol={symbol}
/>
}
/>
<Item
label="↳ Sale"
value={
<ValueDisplay
className="text-textPrimary"
value={toPrecision(data?.purchaseRevenue, decimals)}
symbol={symbol}
/>
}
/>
</div>
</SummaryItem>

<SummaryItem>
<div className="space-y-1 text12Medium text-textTertiary">
<Item label="System Reserved" value="[0]" />
<Item label="Renewal" value={data?.renewalCount} />
<Item label="Sale" value={data?.purchaseCount} />
</div>
</SummaryItem>

<SummaryItem>
<div className="text12Medium">
<Item label="End in" value="[time]" />
</div>
</SummaryItem>

<SummaryItem>
<div className="space-y-1 text12Medium">
<Item label="End At" value="[time]" />
</div>
</SummaryItem>
</SummaryLayout>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import SummaryItem from "next-common/components/summary/layout/item";
import useCoretimeSalePhase from "next-common/context/coretime/hooks/useCoretimeSalePhase";
import FieldLoading from "next-common/components/icons/fieldLoading";

export default function PhaseItem() {
const {phase, isLoading} = useCoretimeSalePhase();

Check failure on line 6 in packages/next-common/components/coretime/salePanel/summary/phase.jsx

View workflow job for this annotation

GitHub Actions / ci

A space is required after '{'

Check failure on line 6 in packages/next-common/components/coretime/salePanel/summary/phase.jsx

View workflow job for this annotation

GitHub Actions / ci

A space is required before '}'

return (
<SummaryItem title="Current Phase">
<div>{isLoading ? <FieldLoading/> : phase}</div>
</SummaryItem>
)

Check failure on line 12 in packages/next-common/components/coretime/salePanel/summary/phase.jsx

View workflow job for this annotation

GitHub Actions / ci

Missing semicolon
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Tabs from "next-common/components/tabs";
import { NeutralPanel } from "../../styled/containers/neutralPanel";
import { TitleContainer } from "../../styled/containers/titleContainer";
import SalesHistoryPurchases from "./purchases";
import SalesHistoryRenewals from "./renewals";
import { useState } from "react";
import { usePageProps } from "next-common/context/page";

export default function CoretimeSalesHistorySection() {
const { coretimeSale } = usePageProps();
const [activeTabLabel, setActiveTabLabel] = useState("Purchases");

return (
<div>
<TitleContainer className="mb-4">Sales History</TitleContainer>
<NeutralPanel className="p-6">
<Tabs
activeTabLabel={activeTabLabel}
onTabClick={(tab) => {
setActiveTabLabel(tab.label);
}}
tabs={[
{
label: "Renewals",
activeCount: coretimeSale?.renewalCount,
content: <SalesHistoryRenewals />,
},
{
label: "Purchases",
activeCount: coretimeSale?.purchaseCount,
content: <SalesHistoryPurchases />,
},
]}
/>
</NeutralPanel>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import dayjs from "dayjs";
import { MapDataList } from "next-common/components/dataList";
import Duration from "next-common/components/duration";
import ExplorerLink from "next-common/components/links/explorerLink";
import Pagination from "next-common/components/pagination";
import AddressUser from "next-common/components/user/addressUser";
import ValueDisplay from "next-common/components/valueDisplay";
import { useChainSettings } from "next-common/context/chain";
import { usePageProps } from "next-common/context/page";
import { useCoretimeQuery } from "next-common/hooks/apollo";
import { toPrecision } from "next-common/utils";
import { defaultPageSize } from "next-common/utils/constants";
import { useState } from "react";
import { GET_CORETIME_SALE_PURCHASES } from "next-common/services/gql/coretime/consts";

export default function SalesHistoryPurchases() {
const { decimals, symbol } = useChainSettings();
const { coretimeSale } = usePageProps();
const [page, setPage] = useState(1);
const [isTime, setIsTime] = useState(true);

const pageSize = defaultPageSize;

const { data, loading } = useCoretimeQuery(GET_CORETIME_SALE_PURCHASES, {
variables: {
saleId: coretimeSale?.id,
offset: (page - 1) * pageSize,
limit: pageSize,
},
});

const columns = [
{
name: "Core",
className: "w-[120px]",
render(data) {
return <div>#{data?.regionId?.core}</div>;
},
},
{
name: "Purchased By",
className: "w-80",
render(data) {
return (
<div>
<AddressUser add={data?.who} />
</div>
);
},
},
{
name: (
<button
className="text-theme500"
onClick={() => {
setIsTime(!isTime);
}}
>
{isTime ? "Time" : "Age"}
</button>
),
render(data) {
const time = data?.indexer?.blockTime;

return (
<ExplorerLink indexer={data?.indexer}>
<div className="text-textTertiary hover:underline">
{isTime ? (
dayjs(time).format("YYYY-MM-DD HH:mm:ss")
) : (
<Duration time={time} />
)}
</div>
</ExplorerLink>
);
},
},
{
name: "Price",
className: "text-right w-40",
render(data) {
return (
<div>
<ValueDisplay
value={toPrecision(data?.price, decimals)}
symbol={symbol}
/>
</div>
);
},
},
];

return (
<div>
<MapDataList
loading={loading}
noDataText="No purchases history"
columnsDef={columns}
data={data?.coretimeSalePurchases?.items}
/>

<div className="mt-4">
<Pagination
page={page}
total={data?.coretimeSalePurchases?.total}
pageSize={pageSize}
onPageChange={(e, newPage) => {
e.preventDefault();
setPage(newPage);
}}
/>
</div>
</div>
);
}
Loading
Loading