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: added reputation method to release #3162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CzarekDryl
Copy link
Contributor

Description

  • Added reputation method to release step in advanced payment

Testing

  • Install Reputation Weighted extension
  • Create advanced payment and go to release step
  • Choose reputation method from release modal

Main issue: #2256

@iamsamgibbs
Copy link
Contributor

@CzarekDryl Can you rebase this so I can give it a review?

@CzarekDryl CzarekDryl force-pushed the feat/15886092-release-step-motion branch from 890ca7c to 0324712 Compare October 1, 2024 08:05
@CzarekDryl
Copy link
Contributor Author

@iamsamgibbs Branch rebased

Copy link
Collaborator

@jakubcolony jakubcolony left a comment

Choose a reason for hiding this comment

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

Thanks for your PR @CzarekDryl, nice to see this coming together.

The message ID for Reputation in the release modal seems incorrect and causing errors:

image image

After releasing via a motion, the UI says it was the Payment creator decision method:
image

The rest of the flow looks good, including voting and failed motions, nice work 👍

image

@CzarekDryl
Copy link
Contributor Author

@jakubcolony Payment creator box is not displaying anymore
image

And translation is added
image

@jakubcolony jakubcolony force-pushed the feat/advanced-payments branch 3 times, most recently from d78ac13 to b0d4b0a Compare October 6, 2024 21:53
@CzarekDryl CzarekDryl force-pushed the feat/15886092-release-step-motion branch from 72668b1 to 0558341 Compare October 7, 2024 13:58
Base automatically changed from feat/advanced-payments to master October 7, 2024 17:43
Copy link
Member

@arrenv arrenv left a comment

Choose a reason for hiding this comment

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

@CzarekDryl Thank you for adding this in. I picked up

  1. The text is wrong in the info callout, it should be "for releasing the payment."
    image

  2. Is there a way to not have the "Failed" show here before the "Passed"? Can we use the skeleton loader?

failed-shows.webm

@CzarekDryl CzarekDryl force-pushed the feat/15886092-release-step-motion branch from 0558341 to bfa399e Compare October 16, 2024 07:23
@CzarekDryl
Copy link
Contributor Author

CzarekDryl commented Oct 16, 2024

@arrenv

  1. Description changed to for releasing the payment.
  2. We have the values from the beginning, only over time the value of yayVotes changes. The loading of the action is set to false in this case.
{
    "nayStakes": "4426661121689491626",
    "requiredStake": "4426661121689491626",
    "yayStakes": "4426661121689491626",
    "yayVotes": "0",
    "nayVotes": "0"
} 

before

{
    "nayStakes": "4426661121689491626",
    "requiredStake": "4426661121689491626",
    "yayStakes": "4426661121689491626",
    "yayVotes": "398798442899037963861",
    "nayVotes": "0"
}

after

@arrenv
Copy link
Member

arrenv commented Oct 16, 2024

  1. We have the values from the beginning, only over time the value of yayVotes changes. The loading of the action is set to false in this case.
{
    "nayStakes": "4426661121689491626",
    "requiredStake": "4426661121689491626",
    "yayStakes": "4426661121689491626",
    "yayVotes": "0",
    "nayVotes": "0"
} 

before

{
    "nayStakes": "4426661121689491626",
    "requiredStake": "4426661121689491626",
    "yayStakes": "4426661121689491626",
    "yayVotes": "398798442899037963861",
    "nayVotes": "0"
}

after

@CzarekDryl does this need to be an arbitrary setTimeout then, maybe like 3 seconds? That way, it allows time for the loading without showing a false outcome, but will still fallback to the hopefully rare occasions where a motion that gets to a vote does not receive any votes.

Copy link
Collaborator

@jakubcolony jakubcolony left a comment

Choose a reason for hiding this comment

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

Thanks for the rebase @CzarekDryl, I appreciate this must've not been the easiest one due to the amount of changes.

It looks like there's an unfortunate name clash between the concepts of releasing a payment (finalizing expenditure on the contracts) and releasing a milestone (or stage on the contracts) in case of staged payments. I'd like to suggest we go with the contracts naming as they allow for distinction, would be great if you could rename functions and components to reflect that.

That caused some unexpected UI behaviour:

  • Timer shown in two places for staged payments:
image
  • There's a useEffect in PaymentBuilderWidget responsible for setting initially selected funding and release (milestone) actions. It's conflicting with the finalizing actions and there isn't one selected by default:
image image
  • The action under Payment step matches the action from Release step, which in this case was a motion ready to claim:
image

Comment on lines 40 to 49
const sortedReleaseActions = useMemo(
() =>
finalizingActions?.items.filter(notNull).sort((a, b) => {
if (a?.createdAt && b?.createdAt) {
return Date.parse(b.createdAt) - Date.parse(a.createdAt);
}
return 0;
}) ?? [],
[finalizingActions?.items],
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could reuse an existing sortActionsByCreatedDate util

Comment on lines +30 to +31
selectedReleaseAction: ExpenditureAction | null;
setSelectedReleaseAction: (action: ExpenditureAction | null) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This has to be separate from release milestone action

src/i18n/en.json Outdated
Comment on lines 1793 to 1811
"releaseModal.permissionsDescription": "This will use your Payer permissions to immediately make the decision and release the payment.",
"releaseModal.reputationDescription": "This will start the lazy consensus process using reputation to make the decision for releasing the payment.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The footer in the modal should show the current user's role instead of hardcoded one

@@ -0,0 +1,37 @@
import React, { type FC } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you make this (and ReleaseRequestItem) shared components that would also replace ReleaseActions and FundingRequests? They're effectively the same:

image image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added new shared component and changed FundingRequests and FinalizeRequests but left it in ReleaseActions because there is some additional logic there

Comment on lines 75 to 90
useEffect(() => {
if (!selectedReleaseAction && sortedReleaseActions.length > 0) {
setSelectedReleaseAction(sortedReleaseActions[0]);
}

if (
selectedReleaseAction &&
!sortedReleaseActions.some(
(releaseAction) =>
releaseAction.transactionHash ===
selectedReleaseAction.transactionHash,
)
) {
setSelectedReleaseAction(null);
}
}, [selectedReleaseAction, setSelectedReleaseAction, sortedReleaseActions]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This useEffect needs to work with a similar one in PaymentBuilderWidget

Comment on lines 92 to 101
useEffect(() => {
if (
!isAnyReleaseMotionInProgress &&
allReleaseMotions &&
allReleaseMotions.length > 0 &&
!allReleaseMotions[0].motionStateHistory.hasPassed
) {
setExpectedStepKey(ExpenditureStep.Release);
}
}, [allReleaseMotions, isAnyReleaseMotionInProgress, setExpectedStepKey]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this responsible for? Seems like the only thing impacted by this would be the funding button which won't be shown at this stage either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to me that I handled some case, but without it, everything also seems to work well

@jakubcolony
Copy link
Collaborator

@arrenv the explanation from @CzarekDryl made me think this must be a race condition that also affects regular motions (as it's using the same code). After 3 attempts I managed to reproduce it on a mint tokens motion:

Screen.Recording.2024-10-17.at.19.18.06.mov

Additionally the voting step shows the wrong outcome:

image

I have opened an issue #3390.

@CzarekDryl CzarekDryl force-pushed the feat/15886092-release-step-motion branch from 3d6c533 to 4d724d4 Compare October 24, 2024 12:31
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.

4 participants