-
Notifications
You must be signed in to change notification settings - Fork 11
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
[CNft] CNft Collection Offer #107
[CNft] CNft Collection Offer #107
Conversation
fix cnft_fulfill_buy integration test, add canopy truncation
} | ||
|
||
#[derive(AnchorSerialize, AnchorDeserialize, Clone)] | ||
pub struct MetadataArgs { |
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.
look into if we can pass in serialized data
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.
tried with serialize and deserialize, the deserilized data has some unknown issue that I couldn't figure out in short time (it fails allowlist check, means the deserialization had some issue). will keep the metadata args as it is for now to unblock this PR
@@ -1124,6 +1231,152 @@ pub fn create_core_metadata_core(royalties: &Royalties) -> MplCoreMetadata { | |||
} | |||
} | |||
|
|||
#[allow(clippy::too_many_arguments)] | |||
pub fn transfer_compressed_nft<'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.
nitpick: you can use the mpl-bubblegum TransferCpiBuilder
for the CPI call here
https://github.com/metaplex-foundation/mpl-bubblegum/blob/4d35cec5ac6e72690e164725b6106d4ef610ebe0/clients/rust/src/generated/instructions/transfer.rs#L433
used something similar in the CMX mint_nft_core ix if you want to look at that for reference
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.
yeah I'm aware of that, just try to save time reuse the code from m3, added a todo though
return Err(MMMErrorCode::InvalidRequestedPrice.into()); | ||
} | ||
|
||
anchor_lang::solana_program::program::invoke_signed( |
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.
anchor 0.29 added support for transferring from PDAs
you can do the following
let buyside_sol_escrow_account = &ctx.accounts.buyside_sol_escrow_account;
buyside_sol_escrow_account.sub_lamports(payment_amount)?;
payer.add_lamports(payment_amount)?;
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.
seems like we can't change lamports for payer in this case since we don't own it?
Message: Transaction simulation failed: Error processing Instruction 0: instruction spent from the balance of an account it does not own.
Logs:
[
"Program cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK consumed 41544 of 113844 compute units",
"Program cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK success",
"Program BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY consumed 58978 of 130619 compute units",
"Program BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY success",
"Program 11111111111111111111111111111111 invoke [2]",
"Program 11111111111111111111111111111111 success",
"Program 11111111111111111111111111111111 invoke [2]",
"Program 11111111111111111111111111111111 success",
"Program mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc consumed 139097 of 200000 compute units",
"Program mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc failed: instruction spent from the balance of an account it does not own"
].
Catch the `SendTransactionError` and call `getLogs()` on it for full details.
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.
you can't subtract lamports from the payer since it's not owned by the program. you can subtract it from the pda
system_program, | ||
buyside_sol_escrow_account_seeds, | ||
)?; | ||
try_close_sell_state(sell_state, payer.to_account_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.
not related to your PR but just FYI
if the accounts are actually typed, (e.g. the Pool
and SellState
), you can use the anchor close() method from the AccountsClose
trait
fn try_close_sell_state(sell_state: Account<'info, SellState>, payer: AccountInfo<'info>) -> Result<()> {
sell_state.close(payer)?
}
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.
that's very nice, we should do a full refactor with all new optimizations
Implemented
sol_cnft_fulfill_buy
It's