Skip to content

Commit 467c7e6

Browse files
committed
cleanup
1 parent 631710a commit 467c7e6

14 files changed

Lines changed: 417 additions & 271 deletions

File tree

program-libs/compressed-account/src/pubkey.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pub trait AsPubkey {
210210
fn to_pubkey_bytes(&self) -> [u8; 32];
211211
#[cfg(feature = "anchor")]
212212
fn to_anchor_pubkey(&self) -> anchor_lang::prelude::Pubkey;
213+
fn to_light_pubkey(&self) -> Pubkey;
213214
}
214215

215216
impl AsPubkey for Pubkey {
@@ -220,6 +221,9 @@ impl AsPubkey for Pubkey {
220221
fn to_anchor_pubkey(&self) -> anchor_lang::prelude::Pubkey {
221222
self.into()
222223
}
224+
fn to_light_pubkey(&self) -> Pubkey {
225+
*self
226+
}
223227
}
224228

225229
#[cfg(feature = "anchor")]
@@ -232,6 +236,9 @@ impl AsPubkey for anchor_lang::prelude::Pubkey {
232236
fn to_anchor_pubkey(&self) -> Self {
233237
*self
234238
}
239+
fn to_light_pubkey(&self) -> Pubkey {
240+
self.to_bytes().into()
241+
}
235242
}
236243

237244
#[cfg(all(feature = "solana", not(feature = "anchor")))]
@@ -249,4 +256,7 @@ impl AsPubkey for [u8; 32] {
249256
fn to_anchor_pubkey(&self) -> anchor_lang::prelude::Pubkey {
250257
(*self).into()
251258
}
259+
fn to_light_pubkey(&self) -> Pubkey {
260+
self.into()
261+
}
252262
}

program-libs/ctoken-types/src/instructions/mint_action/builder.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ impl MintActionCompressedInstructionData {
171171
ctx.set_context = false;
172172
} else {
173173
// Create default CPI context with first_set_context enabled
174-
let mut ctx = CpiContext::default();
175-
ctx.first_set_context = true;
176-
self.cpi_context = Some(ctx);
174+
self.cpi_context = Some(CpiContext {
175+
first_set_context: true,
176+
..Default::default()
177+
});
177178
}
178179
self
179180
}
@@ -187,9 +188,10 @@ impl MintActionCompressedInstructionData {
187188
ctx.first_set_context = false;
188189
} else {
189190
// Create default CPI context with set_context enabled
190-
let mut ctx = CpiContext::default();
191-
ctx.set_context = true;
192-
self.cpi_context = Some(ctx);
191+
self.cpi_context = Some(CpiContext {
192+
set_context: true,
193+
..Default::default()
194+
});
193195
}
194196
self
195197
}

program-libs/ctoken-types/src/instructions/mint_action/mint_to_compressed.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use light_compressed_account::Pubkey;
1+
use light_compressed_account::{pubkey::AsPubkey, Pubkey};
22
use light_zero_copy::ZeroCopy;
33

44
use crate::{AnchorDeserialize, AnchorSerialize};
@@ -10,9 +10,27 @@ pub struct Recipient {
1010
pub amount: u64,
1111
}
1212

13+
impl Recipient {
14+
pub fn new(recipient: impl AsPubkey, amount: u64) -> Self {
15+
Self {
16+
recipient: recipient.to_light_pubkey(),
17+
amount,
18+
}
19+
}
20+
}
21+
1322
#[repr(C)]
1423
#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize, ZeroCopy)]
1524
pub struct MintToCompressedAction {
1625
pub token_account_version: u8,
1726
pub recipients: Vec<Recipient>,
1827
}
28+
29+
impl MintToCompressedAction {
30+
pub fn new(recipients: Vec<Recipient>) -> Self {
31+
Self {
32+
token_account_version: 3,
33+
recipients,
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)