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

feat: improve delegation list header #8155

Merged
merged 12 commits into from
Mar 12, 2024

Conversation

cpl121
Copy link
Member

@cpl121 cpl121 commented Mar 7, 2024

Closes #8148
Closes #8106

Summary

Please summarize your changes, describing what they are and why they were made.

...

Changelog

- Please write a list of changes

Testing

Platforms

Please select any platforms where your changes have been tested.

  • Desktop
    • MacOS
    • Linux
    • Windows

Instructions

Please describe the specific instructions, configurations, and/or test cases necessary to test and verify that your changes work as intended.

...

Checklist

Please tick the following boxes that are relevant to your changes.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or modified tests that prove my changes work as intended
  • I have verified that new and existing unit tests pass locally with my changes
  • I have verified that my latest changes pass CI workflows for testing and linting
  • I have made corresponding changes to the documentation

@cpl121 cpl121 linked an issue Mar 7, 2024 that may be closed by this pull request
…a2.0' of github.com:iotaledger/firefly into feat/improve-delegation-list-header
…a2.0' of github.com:iotaledger/firefly into feat/improve-delegation-list-header
…a2.0' of github.com:iotaledger/firefly into feat/improve-delegation-list-header
@cpl121 cpl121 marked this pull request as ready for review March 11, 2024 12:52
@cpl121 cpl121 linked an issue Mar 11, 2024 that may be closed by this pull request
@cpl121 cpl121 requested a review from marc2332 March 11, 2024 13:03
Copy link
Member

@begonaalvarezd begonaalvarezd left a comment

Choose a reason for hiding this comment

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

code looks great, just added some minor coding convention comments 🙏🏼

$: delegationOutputs =
$selectedWallet?.walletUnspentOutputs?.filter((output) => output?.output?.type === OutputType.Delegation) || []
$: delegationOutputs?.length > 0 && mappedDelegationData(delegationOutputs)
Copy link
Member

Choose a reason for hiding this comment

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

mappedDelegationData looks like its a variable, this should be renamed to a getter or a setter or something

delegationOutputs?.map(async (output) => {
const delegationOutput = output.output as DelegationOutput
// Until the first epoch in which it was delegated ends, no rewards are obtained
const epochsDelegating = currentEpoch - delegationOutput.startEpoch
Copy link
Member

Choose a reason for hiding this comment

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

shouldnt it be currentEpoch - delegationOutput.startEpoch - 1

Copy link
Member Author

Choose a reason for hiding this comment

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

I also thought like this, but when a delegation output is created, the startEpoch is currentEpoch + 1
In the tests I did, the currentEpoch was 3 and the startEpoch of the newly created delegation output was 4

return {
[Header.Name]: `Delegation ${index + 1}`,
[Header.DelegationId]: delegationOutput.delegationId,
[Header.DelegatedFunds]: Number(delegationOutput.delegatedAmount),
[Header.Rewards]: await getOutputRewards(output.outputId),
Copy link
Member

Choose a reason for hiding this comment

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

getOutputRewards should not live in this component, i would move that logic out so its reusable somewhere else, these types of logics dont make sense in a svelte component

return Number(rewards)
}

async function getCurrentEpoch(): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

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

this should be moved somewhere else outside of this component too

@cpl121 cpl121 requested a review from marc2332 March 12, 2024 16:00
Copy link
Collaborator

@marc2332 marc2332 left a comment

Choose a reason for hiding this comment

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

🏇

@cpl121 cpl121 merged commit 110c8d6 into develop-iota2.0 Mar 12, 2024
3 of 4 checks passed
@cpl121 cpl121 deleted the feat/improve-delegation-list-header branch March 12, 2024 16:40
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.

[Task]: improve delegation list header [Task]: update DelegationOutputTemp
3 participants