impact-graph icon indicating copy to clipboard operation
impact-graph copied to clipboard

Dont allow owner of project to donate to his/her own project

Open mohammadranjbarz opened this issue 2 years ago • 17 comments

Now we dont allow it in UI, but it's better to restrict it in backend as well

Screen Shot 1401-09-07 at 10 03 32

mohammadranjbarz avatar Nov 28 '22 07:11 mohammadranjbarz

@HrithikSampson Please implement this issue, it's a good task for start contributing You need to change createDonation in donationResolver.ts and also please add appropriate test case in donationResolver.test.ts to make sure your code works properly. (For just running tests related to donation resolver you can use test:donationResolver instead of npm run test )

mohammadranjbarz avatar Aug 07 '24 11:08 mohammadranjbarz

Hi @mohammadranjbarz ,I have made the changes in this pull request: https://github.com/Giveth/impact-graph/pull/1756

HrithikSampson avatar Aug 09 '24 11:08 HrithikSampson

@maryjaf It's ready for testing now ( If you had problem to how test it DM me please)

mohammadranjbarz avatar Aug 12 '24 09:08 mohammadranjbarz

After confirming transaction in metamask I got this error I think before this step the error message should be shown, am I right? @mohammadranjbarz

Screenshot 2024-08-12 at 2 02 58 PM

https://github.com/user-attachments/assets/e0705c2c-30a3-474f-afe7-9456b51b3d60

maryjaf avatar Aug 12 '24 10:08 maryjaf

After confirming transaction in metamask I got this error I think before this step the error message should be shown, am I right? @mohammadranjbarz

Screenshot 2024-08-12 at 2 02 58 PM Screen.Recording.2024-08-12.at.2.02.29.PM.mov

Thanks @maryjaf
@HrithikSampson You should do same restriction and write test cases for createDraftDonation as well

mohammadranjbarz avatar Aug 13 '24 09:08 mohammadranjbarz

Hi @maryjaf , I have merged the branch to staging with the restrictions added for createDraftDonation

HrithikSampson avatar Aug 16 '24 11:08 HrithikSampson

Thanks @HrithikSampson

  • [ ] 1- I think it would be good if this message in console log also be shown in UI instead of "transaction rejected"

image

  • [ ] 2- This limitation doesn't exist in recurring donation and I could set a recurring donation for my project

https://github.com/user-attachments/assets/e4ece612-6bd0-4ca5-a2fe-6b0d585d62fb

  • [ ] 3- we will have a new model for donation, donate with stellar ; this new logic also should be applied for stellar ? cc: @MoeNick @mohammadranjbarz

maryjaf avatar Aug 18 '24 07:08 maryjaf

Thanks @HrithikSampson

  • [ ] 1- I think it would be good if this message in console log also be shown in UI instead of "transaction rejected"

image

  • [ ] 2- This limitation doesn't exist in recurring donation and I could set a recurring donation for my project

Screen.Recording.2024-08-18.at.10.45.57.AM.mov

  • [ ] 3- we will have a new model for donation, donate with stellar ; this new logic also should be applied for stellar ? cc: @MoeNick @mohammadranjbarz
  1. I think we can do it. @HrithikSampson please try to to fix it and if you had problem ask from some FE devs (@MohammadPCh or @RamRamez )
  2. @HrithikSampson Please add this restriction for recurring donations as well
  3. @maryjaf I think it's better to add another issue in order to implemen it. @MoeNick WDYT?

mohammadranjbarz avatar Aug 22 '24 06:08 mohammadranjbarz

Hey guys! look like this hasn't passed QA - please let @maryjaf test this out and approve before moving it to Done @HrithikSampson

We also have https://github.com/Giveth/giveth-dapps-v2/issues/4612 which is to prevent the user from attempting to make a donation directly from the donate page of the project (the back-end still rejects it but we need to handle it on the UI)

divine-comedian avatar Aug 30 '24 14:08 divine-comedian

Sure @divine-comedian, @maryjaf I thought that Issue 4612(https://github.com/Giveth/giveth-dapps-v2/issues/4612) is the Frontend Version of this issue.

HrithikSampson avatar Aug 30 '24 15:08 HrithikSampson

Thanks @HrithikSampson

  • [ ] 1- I think it would be good if this message in console log also be shown in UI instead of "transaction rejected"

image

  • [ ] 2- This limitation doesn't exist in recurring donation and I could set a recurring donation for my project

Screen.Recording.2024-08-18.at.10.45.57.AM.mov

  • [ ] 3- we will have a new model for donation, donate with stellar ; this new logic also should be applied for stellar ? cc: @MoeNick @mohammadranjbarz

I've tested this issue and reported these items when they are ready for retesting, please let me know

maryjaf avatar Sep 01 '24 06:09 maryjaf

@maryjaf check out the FE implementation of this change - read the issue and understand the proposed changes and we can follow UI changes there. https://github.com/Giveth/giveth-dapps-v2/issues/4612

In terms of preventing it from the back-end it seems this issue is complete.

Have we also tested this for Solana and Stellar addresses?

divine-comedian avatar Sep 01 '24 17:09 divine-comedian

  • [ ] 2- This limitation doesn't exist in recurring donation and I could set a recurring donation for my project

This item hasn't been fixed @divine-comedian @mohammadranjbarz

maryjaf avatar Sep 02 '24 07:09 maryjaf

For Stellar please note that we only have the Stellar recipient address and the project owner does not have any Stellar address as a user-related address like Sol and Eth. So we can only avoid the recipient address as a source of donation in this case.

MoeNick avatar Sep 02 '24 07:09 MoeNick

Have we also tested this for Solana and Stellar addresses?

for stellar @MoeNick added some description above and for solana I got an error when I try to donate, could you please take a look ? @HrithikSampson @mohammadranjbarz

https://github.com/user-attachments/assets/4f27d8d9-f4a6-4a3c-9875-9dd346c37671

maryjaf avatar Sep 02 '24 09:09 maryjaf

Have we also tested this for Solana and Stellar addresses?

I've tested with SOL token and the correct error is shown on backend side

image

maryjaf avatar Sep 02 '24 11:09 maryjaf

https://github.com/Giveth/impact-graph/issues/743#issuecomment-2324300583

@maryjaf, I have tried to resolve it and merged it to staging.

HrithikSampson avatar Sep 03 '24 14:09 HrithikSampson