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: r/demo/foo20airdrop - Merkle Airdrop contract example #906

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

Conversation

albttx
Copy link
Member

@albttx albttx commented Jun 16, 2023

Description

This PR bring an example for a merkle airdrop contract.

  • the package p/demo/airdrop
  • the realm r/demo/foo20airdrop

How it's works ?

A merkle airdrop contract works by saving off-chain the elements of the merkle tree. ONLY the Merkle root is saved on the realm.

To confirm an element is present, we just need to send to the contract a merkle proof.

@albttx albttx requested review from jaekwon, moul and a team as code owners June 16, 2023 13:00
@albttx albttx self-assigned this Jun 16, 2023
@albttx albttx marked this pull request as draft June 16, 2023 13:01
@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages. labels Jun 16, 2023
@albttx
Copy link
Member Author

albttx commented Jun 16, 2023

waiting for: #893 and #895 to undraft

@albttx albttx force-pushed the r/foo20-airdrop branch 2 times, most recently from 2060eff to 2675ea9 Compare July 23, 2023 12:42
@github-actions github-actions bot removed the 📦 🤖 gnovm Issues or PRs gnovm related label Jul 23, 2023
@albttx albttx changed the title r/demo/foo20airdrop - Merkle Airdrop contract example feat: r/demo/foo20airdrop - Merkle Airdrop contract example Jul 23, 2023
@albttx albttx marked this pull request as ready for review July 26, 2023 15:18
type AirdropData struct {
Address std.Address
// TODO: use std.Coin
Amount uint64
Copy link
Member

Choose a reason for hiding this comment

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

For better control and data integrity, keep the fields in the Airdrop struct unexported.

To maintain easy marshaling with the Bytes helper, consider this approach:

type Airdrop struct {
    data struct {
        Address std.Address
        Amount  uint64
    }
}

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Looks good 💯

Please see @moul's comments, otherwise we should be good to go

examples/gno.land/p/demo/airdrop/merkle-airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/airdrop/merkle-airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

Just blocking since there are several changes. Let’s make an additional round of reviews.

@albttx
Copy link
Member Author

albttx commented Aug 9, 2023

There is tests issue once rebased with master.

There is a situation to figure out, with grc20.IGRC20, because it return a grc20.UserToken .

When user1.gno -> r/foo20-airdrop get foo20.GRC20() and then from r/foo20-airdrop exec foo20.GRC20().Transfert, std.PrevRealm isn't the realm but the user ...

Possible fix could be to update in user_token.gno to use CurrentRealm rather than PrevRealm

@moul
Copy link
Member

moul commented Aug 9, 2023

Related (and depending?) on #952

@zivkovicmilos
Copy link
Member

Hey @albttx,

What's the status of this PR?

@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 8, 2023
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Oct 18, 2023
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.95%. Comparing base (628f965) to head (245b432).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #906      +/-   ##
==========================================
- Coverage   60.96%   60.95%   -0.02%     
==========================================
  Files         564      564              
  Lines       75273    75273              
==========================================
- Hits        45893    45885       -8     
- Misses      26009    26019      +10     
+ Partials     3371     3369       -2     
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
gno.land 67.92% <ø> (ø)
gnovm 65.78% <ø> (ø)
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (ø)
tm2 62.04% <ø> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thinhnx-var
Copy link
Contributor

Excuse me, can you let me know the current status of this idea @albttx ?

@albttx
Copy link
Member Author

albttx commented Oct 4, 2024

It was blocked by #1257 for a long time, i just realized it has been merged!

I'll fixup this PR :)

@albttx albttx marked this pull request as ready for review October 4, 2024 11:24
@albttx albttx requested a review from a team as a code owner October 4, 2024 11:24
@albttx albttx requested a review from moul October 4, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: 🌟 Wanted for Launch
Development

Successfully merging this pull request may close these issues.

6 participants