8000 Fix: Coretime sale page -> purchase transactions subscan url is constructred with start and end blocks = 0 by piggydoughnut · Pull Request #11360 · polkadot-js/apps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Coretime sale page -> purchase transactions subscan url is constructred with start and end blocks = 0 #11360

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

Merged
merged 2 commits into from
Mar 6, 2025
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
61 changes: 34 additions & 27 deletions packages/page-coretime/src/Sale/SaleDetailsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import type { ChainName, SaleParameters } from '../types.js';

import React, { useCallback } from 'react';
import React, { useMemo } from 'react';

import { Button, styled } from '@polkadot/react-components';
import { styled } from '@polkadot/react-components';

import { PhaseName } from '../constants.js';
import { useTranslation } from '../translate.js';
import PhaseTable from './PhaseTable.js';
import { SubScanButton } from './SubScanButton.js';
import { SubscanModuleCallUrl } from './SubscanModuleCallUrl.js';

const ResponsiveContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -78,16 +78,14 @@ const phases = {
}
};

const dotLakeUrl = 'https://data.parity.io/coretime';

const SaleDetailsView = ({ chainName, chosenSaleNumber, saleParams }: { saleParams: SaleParameters, chosenSaleNumber: number, chainName: ChainName }) => {
const { t } = useTranslation();

const openCoretimeDashboard = useCallback(() => {
window.open('https://data.parity.io/coretime');
}, []);

const openSubscanSalePriceGraph = useCallback(() => {
window.open(`https://coretime-${chainName}.subscan.io/coretime_dashboard`);
}, [chainName]);
const subscanPriceGraphUrl = useMemo(() =>
`https://coretime-${chainName}.subscan.io/coretime_dashboard`
, [chainName]);

if (chosenSaleNumber === -1 || !saleParams) {
return null;
Expand Down Expand Up @@ -121,24 +119,33 @@ const SaleDetailsView = ({ chainName, chosenSaleNumber, saleParams }: { salePara
<Title>{t('Region for sale ')}</Title>
<p style={{ maxWidth: '600px', opacity: '0.8' }}>{t('Region is an asset of Coretime. It signifies the upcoming sales period within which a core can be secured by purchasing coretime. Acquiring coretime grants access to a core for the duration of that specific region.')}</p>
{saleParams?.regionForSale && <PhaseTable phaseInfo={saleParams?.regionForSale} />}
<Title>Price graph</Title>
<Button
isBasic
label={t('Open Subscan Sale Price graph')}
>
/>
<Title>{t('Core Purchase Transactions')}</Title>
<SubScanButton
chainName={chainName}
chosenSaleNumber={chosenSaleNumber}
currentRegion={saleParams.currentRegion}
/>
<Title>{t('Subscan Links')}</Title>
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
<a
href={subscanPriceGraphUrl}
rel='noopener noreferrer'
target='_blank'
>Sale Purchase Graph</a>
<SubscanModuleCallUrl
chainName={chainName}
chosenSaleNumber={chosenSaleNumber}
currentRegion={saleParams.currentRegion}
urlTitle='Sale Purchase Transactions'
/>
<SubscanModuleCallUrl
call={'renew'}
chainName={chainName}
chosenSaleNumber={chosenSaleNumber}
currentRegion={saleParams.currentRegion}
urlTitle='Sale Renewal Transactions'
/>
</div>
<Title>{t('DotLake Coretime Dashboard')}</Title>
<Button
isBasic
label={t('DotLake Coretime Dashboard')}
>
/>
<a
href={dotLakeUrl}
rel='noopener noreferrer'
target='_blank'
>Dot Lake</a>
<Title>{t('Coretime providers')}</Title>
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
{Object.entries(providers).map(([provider, { alt, href, logo }]) => (
Expand Down
32 changes: 0 additions & 32 deletions packages/page-coretime/src/Sale/SubScanButton.tsx

This file was deleted.

30 changes: 30 additions & 0 deletions packages/page-coretime/src/Sale/SubscanModuleCallUrl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2017-2025 @polkadot/app-coretime authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { SaleParameters } from '../types.js';

import React, { useMemo } from 'react';

import { constructSubscanQuery } from '../utils/index.js';

function formatDate (input: string) {
const date = new Date(input + ' UTC');

return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
}

export const SubscanModuleCallUrl = ({ call = 'purchase', chainName, chosenSaleNumber, currentRegion, module = 'broker', urlTitle }: { chosenSaleNumber: number, currentRegion: SaleParameters['currentRegion'], chainName: string, urlTitle: string, module?: string, call?: string }) => {
const url = useMemo(() => constructSubscanQuery(formatDate(currentRegion.start.date), formatDate(currentRegion.end.date), chainName, module, call), [currentRegion, chainName, module, call]);

if (chosenSaleNumber === -1 || !currentRegion) {
return null;
}

return (
<a
href={url}
rel='noopener noreferrer'
target='_blank'
>{urlTitle}</a>
);
};
2 changes: 1 addition & 1 deletion packages/page-coretime/src/Sale/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function Sale ({ chainName }: Props): React.ReactElement<Props> {
saleParams={saleParams}
/>}
<div style={{ backgroundColor: 'white', borderRadius: '4px', gridColumn: '1 / -1', justifySelf: 'center', padding: '24px', width: '100%' }}>
<p style={{ fontSize: '16px', fontWeight: 'bold', marginBottom: '1rem' }}>{t('Sale information')}</p>
<p style={{ fontSize: '16px', fontWeight: 'bold', marginBottom: '1rem' }}>{t('Sale history information')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
<div style={{ maxWidth: '300px' }}>
<Dropdown
Expand Down
4 changes: 2 additions & 2 deletions packages/page-coretime/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ export const getCurrentRegionStartEndTs = (saleInfo: RegionInfo, regionLength: n
export const getAvailableNumberOfCores = (coretimeInfo: CoretimeInformation) =>
Number(coretimeInfo?.salesInfo?.coresOffered) - Number(coretimeInfo?.salesInfo.coresSold);

export const constructSubscanQuery = (blockStart: number, blockEnd: number, chainName: string, module = 'broker', call = 'purchase') => {
export const constructSubscanQuery = (dateStart: string, dateEnd: string, chainName: string, module = 'broker', call = 'purchase') => {
const page = 1;
const pageSize = 25;
const signed = 'all';
const baseURL = `https://coretime-${chainName}.subscan.io/extrinsic`;

return `${baseURL}?page=${page}&time_dimension=block&page_size=${pageSize}&module=${module}&signed=${signed}&call=${call}&block_start=${blockStart}&block_end=${blockEnd}`;
return `${baseURL}?page=${page}&time_dimension=date&page_size=${pageSize}&module=${module}&signed=${signed}&call=${call}&date_start=${dateStart}&date_end=${dateEnd}`;
};
0