-
Notifications
You must be signed in to change notification settings - Fork 67
feat: compressed token sdk #1826
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
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
8c97cf0
to
1f49556
Compare
let instruction = | ||
create_compressed_token_instruction(cpi_inputs, &light_cpi_accounts).unwrap(); |
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.
think cleanest to just have dedicated function for each type of cpi instruction (decompress, compress, transfer,..)
example for verbose case:
let instruction = sdk::decompress_with_amount(
&mint, // mint
claimant.key, // owner
vec![compressed_token_account],
proof,
&light_cpi_accounts,
None, // amount for partial decompression
None, // lamport amount
None, // cpi_context
)?;
this would then also look very similar to SPL cpis and remove the need for cpiInputs
, token_account.decompress(10).unwrap()
, and probably even the cTokenAccount
abstraction (InputTokenDataWithContext
is probably all you need). Another nice effect of this is that it clearly separates all the input_token_account-related info from the action/output. this makes it all semantically intuitive to grok.
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 iteration is closer to that.
output_tree_index: u8, | ||
mint: Pubkey, | ||
) -> Result<()> { | ||
let sender_account = light_compressed_token_sdk::account::CTokenAccount::new( |
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.
add decompress
or new_close
4d012c3
to
96a5e0e
Compare
pub cpi_context_pubkey: Option<Pubkey>, | ||
pub cpi_context: Option<CompressedCpiContext>, | ||
pub with_transaction_hash: bool, | ||
pub filter_zero_amount_outputs: bool, |
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.
todo default should be true
// TODO: test | ||
/// Filter packed accounts for accounts necessary for token accounts. | ||
/// Note accounts still need to be in the correct order. | ||
pub fn filter_packed_accounts<'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.
remove, too expensive
|
||
msg!("account metas {:?}", ix.accounts); | ||
msg!("account infos {:?}", account_infos); | ||
panic!("account info and meta don't match."); |
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.
throw error
mint to spl works compress works token transfer works decompress works batch compress works refactor: sdk-token-test ixs into files with cpi context works fix: get_validity_proof order fix: process_update_deposit typo
96a5e0e
to
3f2b1e8
Compare
See
program-tests/sdk-token-test/src/lib.rs
for how thecompressed-token-sdk
currently looks like in a program forcompress
,transfer
anddecompress
.For other token program instructions we would add custom
CpiInputs
andCpiAccounts
.(Maybe that already makes sense for
Compress
,Decompress
, andTransfer
, although that might be confusing since you can compress or decompress and transfer in the same cpi to the ctoken program.TODO:
light-client