-
Notifications
You must be signed in to change notification settings - Fork 341
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(examples): Gnofundme #2085
base: master
Are you sure you want to change the base?
Conversation
…n getters, reshaped testfiles
…cussion about the project
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2085 +/- ##
==========================================
- Coverage 54.95% 54.31% -0.65%
==========================================
Files 481 434 -47
Lines 67407 64242 -3165
==========================================
- Hits 37044 34891 -2153
+ Misses 27341 26534 -807
+ Partials 3022 2817 -205 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. If you need some help please comment on the comment and we can check it :-)
contributors []*Contributor | ||
} | ||
|
||
func NewCampaign(title string, description string, goal uint, begin time.Time, deadline time.Time, owner *User, beneficiary *User) *Campaign { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will you check if the string variables aren't empty? I think it would be great if you add some conditionals to avoid this issue. Maybe a minimum of 5 chars for the title, 10 for description, a goal of more than 0, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I was wondering if I add my checks on the realm (can cost more gas) or in the front (react), is it secure to do it on the front?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have a safe testing of your front, it should be ok :-)
current: 0, | ||
begin: begin, | ||
deadline: deadline, | ||
owner: owner, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't be the owner the same as the caller? If not, shouldn't we add an extra requirement to avoid people requesting funds in the name of others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can see here the different types of campaigns I found on the net. So for some campaigns, someone car create a campaign for another person or organism. But I still need to figure out how do some verification on that cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you about campaigns for 3p, but you should have a mechanism to avoid people to abuse about the image of others to exploit a campaign.
users = avl.NewTree() | ||
} | ||
|
||
func NewUser(name string, email string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happen if the variables are empty? Also you can change the input part from
(name string, email string)
to (name, email string)
since both are strings (but that's a matter of taste)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here for verification, the other issue is as we're talking about web3, a user is supposed to be identified only by his address, but I may use profile pkg, who is a work in progress, to identify people. I'll need a bunch of people's opinions to take decision on how to handle this.
"time" | ||
|
||
"gno.land/p/demo/avl" | ||
pkg "gno.land/p/demo/gnofundme" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this name pkg
could be better called to avoid confusion since it's not the only package you're calling. This would help the readability of your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the advise, I'll modify it before the final version.
// the avl.tree key will be address to simplify the fetching | ||
users.Set(caller.String(), user) | ||
|
||
user = pkg.NewUser("user2", "email2", beneficiary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as previous with the other user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
} | ||
|
||
// verify that the benefeciary exists | ||
b, ok := users.Get(beneficiary.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will exist because you created it in line 49, but you're doing the order in reverse. You should first check the user exists, and if it doesn't, create a user for that beneficiary. Same as with the owner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.
// get the user if he exists | ||
user, ok := users.Get(userAddress.String()) | ||
if !ok { | ||
panic("user is not registered") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why panic
here but not in line 84? I think it would be better if you add panic
in all the possible errors that could happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, didn't pay attention. (modified)
parts := strings.Split(path, "/") | ||
switch { | ||
case len(parts) == 2 && parts[0] == "campaign": | ||
return renderCampaign(parts[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a good practice (and a better customer experience) if you first check if that campaign exists before rendering something that couldn't even be an id for a campaign. (Imagine someone puts campaign/foo
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad. This is correct then.
var b bytes.Buffer | ||
c := campaign.(*pkg.Campaign) | ||
b.WriteString( | ||
ufmt.Sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe changing this ufmt.Sprintf into 1 line instead of 3? To avoid a long path of 42 lines doing the same and reduce it into 18 (less than the half)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean the new lines after "ufmt.Sprintf(", I understand. It's because I copied a code as it is from another example. But I'll make the modifications.
GnoFundMe is a fundraising/crowdfunding platform built with React, TypeScript and Tailwind CSS.
It allows you to connect your Adena Wallet to identify and make actions/transactions.
I created this PR to open a space for discussion/suggestions from anyone that wants to participate and give ideas about this project, the repo of the project with the front is here.
I have this miro where I put my ideas, anyone is welcome to modify and suggest things. Feel free to participate.
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description