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

tBTC minting redesign - Phase I - part 1/4 #651

Merged
merged 58 commits into from
Dec 12, 2023

Conversation

kpyszkowski
Copy link
Contributor

Ref: #590

I've accomplished the first part of ongoing changes in Phase I. The current progress status and PR scope are presented in this objectives checklist.
I've also left some comments on Figma to inform and explain about the unapplied changes I will implement in future parts/phases.

Rebuilt and restyled component according to latest design updates
Added checkbox, implemented download logic and disabled modal
Implemented useToast hook with spawner function and root element, hook
supports multiple instances handled by Redux store, implemented more
performant setTimeout alternative utility function using
requestAnimationFrame API
Implemented component, added RangeOperatorType type definition, added
utility functions: getRangeSign, getDurationByAmount and
getNumberOfConfirmationsAmount. Placed component into MakeDeposit step.
Removed redundant UI, fixed toast Icon alignment, added Step heading
Badge, updated Timeline heading
Added appropriate toast message when deposit is received, implemented
toasts identifier generation and introduced removeToasts method, renamed
method: toast -> addToast, improved toasts positioning
Refactored useToast hook: divided structure into separate components,
improved typings
Implemented DurationWidget component, applied minor UI improvements for
MintingTimeline and BridgeLayoutAsideSection components
Reorganized types related with DurationTiers and DurationWidget
components, removed unused import.
Redesigned Step 3: integrated modal contents into step, disabled modal,
removed unused imports.
NOTE: Transaction details will be updated with Phase II. It's corelated
with Solana integration. (?)
Since current Chakra version uses deprecated version of animation
library, mount/unmount animations seems to glitch between rerenders. I
couldn't fix it so I revert changes for now.
@github-actions
Copy link

1 similar comment
@github-actions
Copy link

@michalsmiarowski michalsmiarowski added this to the v1.13.0 milestone Oct 30, 2023
@mhluongo
Copy link
Member

@michalsmiarowski can we get a review here?

Copy link

@michalsmiarowski michalsmiarowski modified the milestones: v1.13.0, v1.14.0 Nov 23, 2023
Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

Did an initial review here. It's only a beginning so more comments will probably come.

src/components/DurationTiers/DurationTiers.tsx Outdated Show resolved Hide resolved
src/utils/tBTC.ts Outdated Show resolved Hide resolved
src/utils/tBTC.ts Outdated Show resolved Hide resolved
src/components/DurationTiers/DurationTiers.tsx Outdated Show resolved Hide resolved
src/components/DurationTiers/DurationTiers.tsx Outdated Show resolved Hide resolved
src/components/DurationTiers/DurationTiers.types.ts Outdated Show resolved Hide resolved
src/components/DurationTiers/DurationTiers.tsx Outdated Show resolved Hide resolved
src/components/DurationWidget/DurationWidget.types.ts Outdated Show resolved Hide resolved
src/components/DurationWidget/DurationWidget.tsx Outdated Show resolved Hide resolved
src/components/DurationWidget/DurationWidget.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

Left some more comments below:

Comment on lines 154 to 173
<DurationTiers
mt="6"
items={[
{
amount: 0.1,
rangeOperator: "less",
currency: "BTC",
},
{
amount: 1,
rangeOperator: "less",
currency: "BTC",
},
{
amount: 1,
rangeOperator: "greaterOrEqual",
currency: "BTC",
},
]}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is a good way to pass the items to the DurationTiers. The way you wrote the component is that it displays the duration times for confirmations for bitcoin transactions - you put the logic for that inside the component, which in result makes the component less reusable. This is not bad, because not every component have to be super reusable, but I believe we should pass less arguments to the component and let the component handle the rest of the logic.

Instead of the amount I would pass the txConfirmationNumbers and remove rangeOperator and currency. This is something that should be handled in the component, probably in some kind of a helper function that will return the value witt the range operator based on the txConfirmationNumber passed. Inside that helper function we would call getDuraiontByNumberOfConfimrations (see my comment here: #651 (comment)) and based on the minutes returned from there we would print a string that we want to display. We could then use that logic in DurationWidget too.

I think it would also look better if we've just change it to singular tier component instead of making it rendering all of them by passing the data as items property. So instead of doing this:

<DurationTiers
        mt="6"
        items={[
          {
            transactionConfirmations: 1
          },
          {
            transactionConfirmations: 3
          },
          {
            transactionConfirmations: 6
          },
        ]}
      />

or this:

<DurationTiers
        mt="6"
        transactionConfirmations={[1, 3, 6]}
      />

I would just extract the <Stack> and render it separately:

<Stack direction="row" spacing="6" mt="6">
  <DurationTier transactionConfirmations={1} />
  <DurationTier transactionConfirmations={3} />
  <DurationTier transactionConfirmations={6} />
</Stack>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you name component the way you requested (prefixed by 'Mint') you indicate that the component is limited to be used in correlation with minting only.
That's a good point to remove the confirmation calculations from the component itself and keep it in presentiontal role only but that way I would revert the name change. Components are reusable by definition, non-reusable component is not a component at all.

About component API - array of objects with strongly typed structure is not a dealbreaker, especially if you are using TypeScript. It's crucial to find a proper balance between reusability and overengineering. The problem is when props are eg. polymorphic or deeply nested with unspecified structure which can lead to misunderstandings when consuming component. With type safety and documentation (which I should add :D) it's not a big deal. TypeScript gives much more opportunities, so why don't use it? If it was JavaScript I wouldn't go for it.

My suggestion is:

  1. Revert name change of components.
  2. Remove duration/confirmation calculations from components so its roles will be strictly presentational (it gets data, and displays data).
  3. Calculate duration and/or confirmations one step before the render of component and pass it as props as you suggested.
  4. Add JSDoc documentation for component.

src/components/DurationTiers/DurationTiers.tsx Outdated Show resolved Hide resolved
src/components/DurationWidget/DurationWidget.tsx Outdated Show resolved Hide resolved
src/components/DurationWidget/DurationWidget.tsx Outdated Show resolved Hide resolved
src/components/Toast/Toast.tsx Show resolved Hide resolved
src/pages/tBTC/Bridge/Minting/MintingTimeline.tsx Outdated Show resolved Hide resolved
src/pages/tBTC/Bridge/Minting/MintingTimeline.tsx Outdated Show resolved Hide resolved
src/pages/tBTC/Bridge/Minting/MintingTimeline.tsx Outdated Show resolved Hide resolved
src/pages/tBTC/Bridge/Minting/MintingTimeline.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

And some more comments down below 😉

src/pages/tBTC/Bridge/Minting/ProvideData.tsx Show resolved Hide resolved
src/pages/tBTC/Bridge/Minting/ProvideData.tsx Outdated Show resolved Hide resolved
src/pages/tBTC/Bridge/index.tsx Outdated Show resolved Hide resolved
src/utils/setTimeout.ts Show resolved Hide resolved
Copy link

1 similar comment
Copy link

Copy link

src/pages/tBTC/Bridge/Mint.tsx Outdated Show resolved Hide resolved
src/pages/tBTC/Bridge/Mint.tsx Outdated Show resolved Hide resolved
Copy link

Copy link

1 similar comment
Copy link

Copy link

Improve `mintingStep` state change when deposit is resumed.
@kpyszkowski kpyszkowski force-pushed the tbtc-minting-redesign branch from 1b6e033 to 507c500 Compare December 12, 2023 14:07
Copy link

@michalsmiarowski michalsmiarowski self-requested a review December 12, 2023 14:15
Copy link

Copy link
Contributor

@michalsmiarowski michalsmiarowski left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@michalsmiarowski michalsmiarowski merged commit 13ce558 into main Dec 12, 2023
5 checks passed
@michalsmiarowski michalsmiarowski deleted the tbtc-minting-redesign branch December 12, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants