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

Relay Chain - Coretime Sale UI #11091

Merged
merged 21 commits into from
Dec 29, 2024
Merged

Relay Chain - Coretime Sale UI #11091

merged 21 commits into from
Dec 29, 2024

Conversation

piggydoughnut
Copy link
Contributor

@piggydoughnut piggydoughnut commented Nov 14, 2024

Relay Chain Coretime Sale UI

Simple UI aimed at providing useful information for people interested in an ongoing sale/ coretime cycle.

Screenshot 2024-12-12 at 1 27 50

Functionality

  • Shows current sale details
  • Porgress bar with where we are in the current cycle
  • Cycle details on where the current phase is ending
  • Ability to see the start/end dates, blocks and slices for previous dates
  • Can choose a sale number and it will prefill a subscan url query for you

Cool code things

I did a lot of calculations of coretime values in the background, which could be useful to other seeking to work with Coretime pallet.

Implemented calculations:

  • core time price
  • sale phase configuration
    • current phase
    • current phase end date
    • current phase end block
  • start/end details for each sale - dates, blocks, timeslices

@piggydoughnut piggydoughnut marked this pull request as draft November 14, 2024 20:18
@piggydoughnut piggydoughnut changed the title WIP: Relay Chain - Coretime Sale UI Relay Chain - Coretime Sale UI Dec 11, 2024
import { CoreTimeChainConsts, CoreTimeConsts } from '@polkadot/react-hooks/types';
import { BN } from '@polkadot/util';

type FirstCycleStartType = Record<
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start of the cycle, aka first sale initialization, starting with the interlude! Sale starts after the interlude.

@@ -0,0 +1,244 @@
// Copyright 2017-2024 @polkadot/app-coretime authors & contributors
Copy link
Contributor Author

@piggydoughnut piggydoughnut Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filvecchiato you might wanna check out this file. It has a bunch of useful calcs for coretime :) Maybe we can collaborate together and combine our work and make a library of sorts with these functions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be a very good example implementation for Facade as well!

@@ -0,0 +1,139 @@
// Copyright 2017-2024 @polkadot/app-coretime authors & contributors
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filvecchiato few more coretime things here :)

@piggydoughnut piggydoughnut marked this pull request as ready for review December 11, 2024 18:07
@filvecchiato
Copy link

Looks awesome!! Great work !!
/

@@ -0,0 +1,244 @@
// Copyright 2017-2024 @polkadot/app-coretime authors & contributors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be a very good example implementation for Facade as well!

@@ -384,5 +385,6 @@ export const CoreTimeConsts = {
};

export const CoreTimeChainConsts = {
BlockTime: 12000,
BlocksPerTimeslice: 40

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could get the blocksPerTimeslice value from the api.consts.broker.timeslicePeriod (number of relay chain blocks) on coretime chain, then maybe consts.babe.expectedBlockTime for relay and coretime and calculate the blocks per timeslice dynamically ? But it might not be accurate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Thank you :) I will check it out

const progressValues = useMemo(() => getSaleProgress(lastCommittedTimeslice, saleParams.currentRegion.start.ts, saleParams.interlude.ts, saleParams.leadin.ts, regionBegin),
[saleParams, lastCommittedTimeslice, regionBegin]);

// TODO: uncomment when introducing core purchase functionality
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we attach a link to this PR as reference:

ie

ref: https://github.com/polkadot-js/apps/pull/11091

Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, a really amazing job 🚀 !

Some small nits, I would also like to see those consts be transferred to a more appropriate file.

Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing to me!

@piggydoughnut piggydoughnut merged commit 5e80322 into master Dec 29, 2024
5 checks passed
@piggydoughnut piggydoughnut deleted the dm-coretime-ui-sale branch December 29, 2024 00:39
@polkadot-js-bot
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Dec 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants