@@ -33,24 +33,6 @@ pub mod cnft_vault {
33
33
index : u32 , ) -> Result < ( ) > {
34
34
msg ! ( "attempting to send nft {} from tree {}" , index, ctx. accounts. merkle_tree. key( ) ) ;
35
35
36
- // CPI to bubblegum
37
- // //attempt 1
38
- // mpl_bubblegum::cpi::transfer(
39
- // CpiContext::new_with_signer(
40
- // ctx.accounts.bubblegum_program.to_account_info(),
41
- // mpl_bubblegum::cpi::accounts::Transfer{
42
- // tree_authority: ctx.accounts.tree_authority.to_account_info(),
43
- // leaf_owner: ctx.accounts.leaf_owner.to_account_info(),
44
- // leaf_delegate: ctx.accounts.leaf_owner.to_account_info(),
45
- // new_leaf_owner: ctx.accounts.new_leaf_owner.to_account_info(),
46
- // merkle_tree: ctx.accounts.merkle_tree.to_account_info(),
47
- // log_wrapper: ctx.accounts.log_wrapper.to_account_info(),
48
- // compression_program: ctx.accounts.compression_program.to_account_info(),
49
- // system_program: ctx.accounts.system_program.to_account_info(),
50
- // }, &[&[b"cNFT-vault", &[*ctx.bumps.get("vault").unwrap()]]]),
51
- // root, data_hash, creator_hash, nonce, index)
52
-
53
- //attempt 2
54
36
let mut accounts: Vec < solana_program:: instruction:: AccountMeta > = vec ! [
55
37
AccountMeta :: new_readonly( ctx. accounts. tree_authority. key( ) , false ) ,
56
38
AccountMeta :: new_readonly( ctx. accounts. leaf_owner. key( ) , true ) ,
@@ -98,10 +80,8 @@ pub mod cnft_vault {
98
80
& [ & [ b"cNFT-vault" , & [ * ctx. bumps . get ( "leaf_owner" ) . unwrap ( ) ] ] ] )
99
81
. map_err ( Into :: into)
100
82
101
-
102
83
}
103
84
104
-
105
85
pub fn withdraw_two_cnfts < ' info > ( ctx : Context < ' _ , ' _ , ' _ , ' info , WithdrawTwo < ' info > > ,
106
86
root1 : [ u8 ; 32 ] ,
107
87
data_hash1 : [ u8 ; 32 ] ,
@@ -120,8 +100,9 @@ pub mod cnft_vault {
120
100
let merkle_tree2 = ctx. accounts . merkle_tree2 . key ( ) ;
121
101
msg ! ( "attempting to send nfts from trees {} and {}" , merkle_tree1, merkle_tree2) ;
122
102
123
- // TODO check if nft transfers are even valid (correct NFT, correct authority)
124
- // in this example anyone can withdraw any NFT from the vault
103
+
104
+ // Note: in this example anyone can withdraw any NFT from the vault
105
+ // in productions you should check if nft transfers are valid (correct NFT, correct authority)
125
106
126
107
let mut accounts1: Vec < solana_program:: instruction:: AccountMeta > = vec ! [
127
108
AccountMeta :: new_readonly( ctx. accounts. tree_authority1. key( ) , false ) ,
@@ -181,7 +162,6 @@ pub mod cnft_vault {
181
162
ctx. accounts. system_program. to_account_info( ) ,
182
163
] ;
183
164
184
- // add "accounts" (hashes) that make up the merkle proof
185
165
let mut i = 0u8 ;
186
166
for acc in ctx. remaining_accounts . iter ( ) {
187
167
if i < proof_1_length {
@@ -217,7 +197,6 @@ pub mod cnft_vault {
217
197
msg ! ( "successfully sent cNFTs" ) ;
218
198
Ok ( ( ) )
219
199
220
-
221
200
}
222
201
223
202
}
0 commit comments