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(examples): Gnofundme #2085

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

Conversation

MalekLahbib
Copy link
Contributor

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...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

MalekLahbib and others added 30 commits March 21, 2024 18:23
@MalekLahbib MalekLahbib requested a review from leohhhn October 11, 2024 16:26
@leohhhn
Copy link
Contributor

leohhhn commented Nov 6, 2024

Hey @MalekLahbib,

Can you please move your code to your personal namespace in this PR? Also, if the PR is ready for review, change it from draft to ready for review.

I'll take a look after that.

@MalekLahbib MalekLahbib marked this pull request as ready for review November 8, 2024 15:35
Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

LGTM after resolving comments 👍

return string(value)
}

func FormatBool(b bool) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function now exists in the strconv package

Comment on lines +18 to +24
uassert.Equal(t, contributor.GetUser().Address, user.Address)

uassert.False(t, contributor.Date.IsZero())

uassert.Equal(t, contributor.Amount, amount)

uassert.Equal(t, contributor.GetDisplay(), display)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for these newlines

wal/cs.wal/wal Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this file

Comment on lines +46 to +53
if beneficiary != caller {
beneficiaryU = users.GetUserByAddress(beneficiary)
if beneficiaryU == nil {
panic("beneficiary not registered in 'gno.land/r/demo/users'")
}
} else {
beneficiaryU = owner
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're forcing the beneficiary to be registered in r/demo/users, why not just have the username as the input to the function?

campaign := camp.(*gfm.Campaign)
// Verfiy that the dates are correct
if time.Now().Unix() < campaign.Begin.Unix() {
panic(ufmt.Sprintf("The campaign didn't start yet. Begin: %d,", campaign.Begin.Unix()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra , here. Also, do you think it would be practical to display a user-friendly begin time here, instead of unix seconds?

Comment on lines +113 to +123
if campaigns.Size() == 0 {
return "[]"
}
campaignsArray := make([]*gfm.Campaign, 0, campaigns.Size())
campaigns.Iterate("", "", func(key string, value interface{}) bool {
c := value.(*gfm.Campaign)
campaignsArray = append(campaignsArray, c)
return false
})
return gfm.CampaignsToJSONString(campaignsArray)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Newlines

Suggested change
if campaigns.Size() == 0 {
return "[]"
}
campaignsArray := make([]*gfm.Campaign, 0, campaigns.Size())
campaigns.Iterate("", "", func(key string, value interface{}) bool {
c := value.(*gfm.Campaign)
campaignsArray = append(campaignsArray, c)
return false
})
return gfm.CampaignsToJSONString(campaignsArray)
}
if campaigns.Size() == 0 {
return "[]"
}
campaignsArray := make([]*gfm.Campaign, 0, campaigns.Size())
campaigns.Iterate("", "", func(key string, value interface{}) bool {
c := value.(*gfm.Campaign)
campaignsArray = append(campaignsArray, c)
return false
})
return gfm.CampaignsToJSONString(campaignsArray)
}

Comment on lines +152 to +156
// XXX TO BE DISCUSSED: the funds can be withdrawn even if the goal is not reached or not?
// verify that the campaign is successful
// if campaign.Current < campaign.Goal {
// panic("the campaign is not successful")
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Decide on this and remove the comment :)

campaignsTotal[campaignId] = 0
// transfer the amount to the beneficiary
banker.SendCoins(std.CurrentRealm().Addr(), beneficiaryAddress, std.Coins{std.NewCoin("ugnot", amount)})
std.Emit("Withdraw", "withdraw", "withdrawn successfully")
Copy link
Contributor

Choose a reason for hiding this comment

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

Better add some more useful information; like, how much was withdrawn.

Comment on lines +205 to +206
b.WriteString("\n")
return b.String()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
b.WriteString("\n")
return b.String()
b.WriteString("\n")
return b.String()


func TestWithdraw(t *testing.T) {
banktestAddr := std.DerivePkgAddr("gno.land/r/demo/gnofundme")
mainaddr := std.DerivePkgAddr("main")
Copy link
Contributor

Choose a reason for hiding this comment

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

Better use testutils.TestAddress("main")

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

LGTM after resolving comments 👍

@leohhhn
Copy link
Contributor

leohhhn commented Nov 12, 2024

Also, think about how the user interface will look like in gnoweb; maybe try utilizing p/moul/txlink or similar libraries to create a nicer user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants