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/15886093 reputation cancel #3322

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

Conversation

CzarekDryl
Copy link
Contributor

Description

This PR introduces options for penalizing or not penalizing the cancellation of staked payments. It also implements a reputation method for canceling after the locked state and the handling of multiple cancellation requests.

Testing

  • Install Reputation Weighted extension
  • Create advanced payment using both permissions and staking method
  • Lock it and then cancel the payment

Main issue - #2256

@CzarekDryl CzarekDryl self-assigned this Oct 14, 2024
@CzarekDryl CzarekDryl requested review from a team as code owners October 14, 2024 11:34
@CzarekDryl CzarekDryl changed the base branch from master to feat/advanced-payments October 14, 2024 11:36
@jakubcolony jakubcolony force-pushed the feat/advanced-payments branch from c0099a8 to c60c833 Compare October 14, 2024 22:02
Base automatically changed from feat/advanced-payments to master October 14, 2024 22:14
@jakubcolony
Copy link
Collaborator

@CzarekDryl looks like it needs another rebase on master

@CzarekDryl CzarekDryl force-pushed the feat/15886093-reputation-cancel branch from 87e902e to f782dda Compare October 21, 2024 07:44
@CzarekDryl
Copy link
Contributor Author

@jakubcolony @arrenv Branch rebased and ready to review

@CzarekDryl CzarekDryl force-pushed the feat/15886093-reputation-cancel branch 2 times, most recently from 4113c5c to 255d868 Compare October 29, 2024 14:37
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 the work on this, and your patience. I have noticed a couple of things.

  1. This translation error appeared when the Advanced payment was created.
    image
    image

  2. Two cancelled pills appeared, there should be only one pill in the timeline.
    image
    image

  3. The staking decision method does not trigger the transaction to create the payment.

  4. Cancelling with Reputation after the Funding step resulted in the following, you should still be able to cancel after funding and the cancel pill should appear after the funding step.
    image

@CzarekDryl CzarekDryl force-pushed the feat/15886093-reputation-cancel branch from 255d868 to b0a6149 Compare November 12, 2024 12:32
Copy link
Contributor

@iamsamgibbs iamsamgibbs left a comment

Choose a reason for hiding this comment

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

Nice start of this, I'm able to get through the entire flow.

Screenshot 2024-11-14 at 11 22 45

There is an issue that if you reject the first motion and start another one, when the cancel step reappears it loads into the first motion rather than the staking stage of the second one, so it looks like it is in a broken state.

Screenshot 2024-11-14 at 11 21 23

And I'm experiencing the same issue as Arren when attempting to cancel after the funding stage.

Screenshot 2024-11-14 at 11 23 59

It also seemed odd that the cancel motion step completely disappears if you reject the motion, I think you should still be able to access the failed motions and the step should remain visible, especially if there are unclaimed stakes / rewards.

@CzarekDryl CzarekDryl force-pushed the feat/15886093-reputation-cancel branch 2 times, most recently from 957a3a5 to d01637e Compare November 29, 2024 12:46
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 your hard work on this. I noticed a few things while testing:

  1. Canceling with Permissions after the Review stage resulted in the first incomplete action timeline, and if after funding, the second screenshot.
    image
    image

  2. Can these have a hover state when there are multiple cancellation requests:
    image

  3. In this case I created a motion to cancel the action, then while voting I used Permissions to cancel it right away. It cancelled correctly but stayed in this view. Is it possible to remove all the following steps in the timeline and show a message in this case. Something like this Figma link.
    image

  4. I saw this error in console when revealing a vote:
    image

  5. It seems if there are any still running motions then the extra steps in the timeline persists, despite a motion already passing and being finalized and the action being cancelled. It should remove all steps if the action has been cancelled.
    image

  6. Claiming staked tokens shows this broken pending button, however, is it possible to auto return this stakes when cancelling?
    image

  7. Cancelling with permissions with no penalty showed this timeline, it should have the step label be "Cancel", as the stakes have already be returned, the text should be "The action was canceled and cannot be executed."
    image

Figma link showing expected designs

image

image

  1. While testing, I noticed that we a missing the indicator as to whether the cancellation motion is penalising or not, can we add a pill to a motion item like this design? Figma link.
    image

@CzarekDryl
Copy link
Contributor Author

@arrenv Everything should be fixed now, please check it again. Penalty badge added to cancel request item.

image

@CzarekDryl CzarekDryl requested a review from arrenv December 11, 2024 14:25
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 work on this PR @CzarekDryl, generally most of the functionality is there, but I spotted a few issues.

There appears to be regression around how cancel in review step is displayed:

image

master for comparison:
image


The note in the Cancel modal should display the actual role held by the user instead of hardcoded Payer:
image
image


I was able to get into a broken state by quickly funding or releasing a payment while the funding motion was loading. The UI should be disabled during that period:

Screen.Recording.2024-12-11.at.23.02.55.mov

When cancelling a staked expenditure with penalise option, the modal gets stuck in Pending. There are errors in the console which are most likely due to the fact the UI is trying to reclaim stake (which has been forfeited) - I commented on where I think it happens in code.
image

image

The same thing happens with cancelling via motions, on motion finalization.


Penalise badge has a border that is not in the designs:

  • Figma
image - UI image

Other flows tested which mostly work well:

Cancelling via permissions, non-staked expenditure:

  • At Funding:
image
  • At Release:
image

Cancelling via reputation, non-staked expenditure:

image image image

Cancelling via permissions, staked:

image

Cancelling via reputation, staked expenditure:

image image image

Comment on lines 142 to 147
if (penalise) {
await cancelStakedExpenditureViaMotion(stakedMotionPayload);
} else {
await cancelExpenditureViaMotion(motionPayload);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which saga to use should not depend on penalise but rather on the expenditure type - if staked, cancelStakedExpenditureViaMotion should always be used. You can pass the penalise as shouldPunish param to the saga.

Comment on lines 147 to 154
} else if (penalise) {
await cancelStakedExpenditure(stakedPayload);
await reclaimExpenditureStake(reclaimPayload);
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly here, cancelStakedExpenditure should always be used for staked expenditure regardless of penalise value.

Also, if creator was penalised, they lost their stake, so there is nothing to claim.

@@ -0,0 +1,80 @@
import clsx from 'clsx';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to reuse code from similar components? Composition via props could be used for elements specific to this type of action, e.g. the penalise badges.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakubcolony Can we do this in other issue and refactor all request items?

@jakubcolony
Copy link
Collaborator

Just a note this PR will most likely have a conflict with #3922 as the designs have been updated (as per #3776).

@CzarekDryl
Copy link
Contributor Author

@jakubcolony Everything should be fixed, please check it :)

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.

Nice one @CzarekDryl, it is looking and working really well.

I did still run into a couple of things, not sure if they should be tackled in this PR.

  1. If created using staking, and when finalizing a cancelation or using permissions to cancel I received this transaction error in the console.
    image

  2. If cancelling with Permissions and penalising, or not, it does not show which option was selected in the card, where it has been added when you use Reputation.
    image

  3. I received this error in the console when trying to stake, despite having more then enough tokens to stake.
    image
    image

@CzarekDryl
Copy link
Contributor Author

CzarekDryl commented Dec 17, 2024

@arrenv I've added badge while using permissions and it's in finalize pill
image

And I'm not able to replicate console errors:

Screen.Recording.2024-12-17.at.13.44.48.mov
Screen.Recording.2024-12-13.at.14.47.47.mov

arrenv
arrenv previously approved these changes Dec 18, 2024
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.

Thank you @CzarekDryl, looking great, tested all scenarios I could think of and all works as expected.

An active motion with a cancelled motion
image

Cancelling working correctly
image

Reputation and cancel, penalise and not
image

@arrenv
Copy link
Member

arrenv commented Dec 18, 2024

I have just seen this @CzarekDryl, is this related to this PR?

image

@CzarekDryl
Copy link
Contributor Author

@arrenv I've checked and all descriptions work fine for me
image

@CzarekDryl CzarekDryl requested a review from arrenv December 18, 2024 14:40
arrenv
arrenv previously approved these changes Dec 18, 2024
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.

Re-approving after a rebase

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 another round of changes @CzarekDryl, mostly looking good but I'm still seeing some issues with staked expenditure.

When cancelling using permissions, the cards are different depending on whether the creator was punished or not.

If punished, no label is displayed informing of this:
image
image

If not punished, an extra Finalize step is added to the stepper:

image

It appears that the UI is still trying to reclaim the stake even though the payment creator was penalised, leading to some errors in the console:
image


I am still able to click around the UI while the cancel modal is in pending state. That's how I got the "Paid" label as well as a cancellation request in progress:

image

Otherwise, things are working well:

image image image image image

fix after rebase

fix: translations, duplicated steps

fix: cancel step

fixes after rebase

fix: auto claim, stepper

Feat: Add willPunishExpenditureStaker field to colony motion

feat: add penalty badge

fix: pending buttons, penalise saga

fix: types

fix: permission badge
@CzarekDryl
Copy link
Contributor Author

@jakubcolony All fixed

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