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 21 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 force-pushed the r/foo20-airdrop branch from 2675ea9 to 08a8ac6 Compare July 23, 2023 12:44
@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 force-pushed the r/foo20-airdrop branch from 08a8ac6 to 7c384db Compare July 23, 2023 12:53
@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.

@moul moul marked this pull request as draft August 6, 2023 23:07
@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
@albttx
Copy link
Member Author

albttx commented Nov 18, 2024

(sorry force-pushed, missed the --no-rebase )

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 convo; I don't think we need to add the js tooling in misc

misc/js-merkletree/package.json Outdated Show resolved Hide resolved
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 convo; I don't think we need to add the js tooling in misc

yarn.lock Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@leohhhn
Copy link
Contributor

leohhhn commented Nov 28, 2024

@moul

Want to take a final look? Cannot merge without your approval.

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: In Progress
Status: 🌟 Wanted for Launch
Development

Successfully merging this pull request may close these issues.

7 participants