-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add airdrop support via Gumdrop #73
base: main
Are you sure you want to change the base?
Conversation
programs/gumdrop/src/lib.rs
Outdated
} | ||
|
||
// Claim a compressed NFT | ||
pub fn claim_bubblegum<'info>( |
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 does seem like there's some repeated code in all these claim_xxx
type methods and maybe it could be refactored to do all the similar stuff in a helper function and then call issue_mint_nft
, issue_compressed_nft
, etc.
But that is fine if that is out of scope. I understand this is not a gumdrop specific PR but just adding using similar established paradigms.
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.
Unless @austbot or @jarry-xiao say otherwise, I'll assume this structure will be reviewed more in depth upon merging back into mpl
programs/gumdrop/src/lib.rs
Outdated
/// Creates a new [MerkleDistributor]. | ||
/// After creating this [MerkleDistributor], the account should be seeded with tokens via | ||
/// delegates | ||
pub fn new_distributor_compressed( |
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.
Should there be a comment that says something like "tree is created here to make sure more NFTs cannot be added after the airdrop"?
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. I prefer being explicit about the pros and cons of using the tree authorities in this way. It made sense to me to limit append permissions to instructions issued via gumdrop, but I would like to open a discussion.
programs/gumdrop/src/lib.rs
Outdated
@@ -0,0 +1,1815 @@ | |||
//! Program for distributing tokens efficiently via uploading a Merkle root. |
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.
Overall I'm mostly looking at the new functions added to support bubblegum, not doing detailed review of gumdrop program. I also assume if anyone wants to be very detail oriented about the new instruction handler APIs, those details can be discussed when this is back ported to the metaplex program library.
tests/gumdrop-test.ts
Outdated
creator: PublicKey, | ||
share: number, | ||
}; | ||
type Metadata = { |
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.
Ultra nit: Should this be TokenMetadata
?
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.
Good idea. I'll rename
tests/gumdrop-test.ts
Outdated
creators: Creator[], | ||
}; | ||
|
||
const METADATA = [ |
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.
Ultra nit: Should this be TOKEN_METADATA
or something slightly more than just metadata?
tests/gumdropTree.ts
Outdated
@@ -0,0 +1,77 @@ | |||
import { keccak_256 } from 'js-sha3'; | |||
|
|||
export class MerkleTree { |
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 really like this class and how it seems to define how the test is built. If the test were able to be written without this object, I think the test wouldn't have been as clean.
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.
All credit to @lwus
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.
Looks great! Added some nits about the test
tests/gumdrop-test.ts
Outdated
} | ||
|
||
|
||
function getMerkleRollAccountSize(maxDepth: number, maxBufferSize: number): number { |
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.
We can probably just import this from ./merkle-roll-serde
like the bubblegum test
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.
Good catch. Fixed
tests/gumdrop-test.ts
Outdated
const txId = await gumdrop.provider.send(tx, [merkleRollKeypair, payer], { | ||
skipPreflight: true | ||
}); | ||
console.log(`${txId} sent`); |
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.
console.log(`${txId} sent`); |
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.
fixed
tests/gumdrop-test.ts
Outdated
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
|
||
async function succeedOrThrow(txId: string, connection: Connection) { |
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.
This is great. Maybe we can move it to ./utils.ts
to be reused?
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.
fixed
tests/gumdrop-test.ts
Outdated
import { MerkleTree } from './gumdropTree'; | ||
import { BinaryWriter } from 'borsh' | ||
|
||
async function delay(ms: number) { |
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.
move to ./utils.ts
?
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.
fixed
Waiting to merge this in until #77 is addressed |
Closes #71