Skip to content

Commit 8caf59d

Browse files
refactor(renderers-rust): extract solana-account-info from solana-program & solana-account from solana-sdk (#645)
* refactor: extract account-info from solana-program & account from solana-sdk * chore: add changeset
1 parent dbeea53 commit 8caf59d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+503
-902
lines changed

.changeset/whole-poets-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@codama/renderers-rust': minor
3+
---
4+
5+
extract `solana-account-info` from `solana-program` & `solana-account` from `solana-sdk`

packages/renderers-rust/e2e/anchor/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/renderers-rust/e2e/anchor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ num-derive = "^0.3"
1818
num-traits = "^0.2"
1919
serde = { version = "^1.0", features = ["derive"], optional = true }
2020
serde_with = { version = "^3.0", optional = true }
21+
solana-account-info = "2.2.1"
2122
solana-program = "2.2.1"
2223
solana-instruction = "2.2.1"
2324
solana-pubkey = { version = "2.2.1", features = ["curve25519"] }

packages/renderers-rust/e2e/anchor/src/generated/accounts/guard_v1.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ impl GuardV1 {
4040
}
4141
}
4242

43-
impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for GuardV1 {
43+
impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for GuardV1 {
4444
type Error = std::io::Error;
4545

46-
fn try_from(
47-
account_info: &solana_program::account_info::AccountInfo<'a>,
48-
) -> Result<Self, Self::Error> {
46+
fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result<Self, Self::Error> {
4947
let mut data: &[u8] = &(*account_info.data).borrow();
5048
Self::deserialize(&mut data)
5149
}

packages/renderers-rust/e2e/anchor/src/generated/instructions/create_guard.rs

Lines changed: 41 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -279,50 +279,50 @@ impl CreateGuardBuilder {
279279

280280
/// `create_guard` CPI accounts.
281281
pub struct CreateGuardCpiAccounts<'a, 'b> {
282-
pub guard: &'b solana_program::account_info::AccountInfo<'a>,
282+
pub guard: &'b solana_account_info::AccountInfo<'a>,
283283

284-
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
284+
pub mint: &'b solana_account_info::AccountInfo<'a>,
285285

286-
pub mint_token_account: &'b solana_program::account_info::AccountInfo<'a>,
286+
pub mint_token_account: &'b solana_account_info::AccountInfo<'a>,
287287

288-
pub guard_authority: &'b solana_program::account_info::AccountInfo<'a>,
288+
pub guard_authority: &'b solana_account_info::AccountInfo<'a>,
289289

290-
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
290+
pub payer: &'b solana_account_info::AccountInfo<'a>,
291291

292-
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
292+
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
293293

294-
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
294+
pub token_program: &'b solana_account_info::AccountInfo<'a>,
295295

296-
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
296+
pub system_program: &'b solana_account_info::AccountInfo<'a>,
297297
}
298298

299299
/// `create_guard` CPI instruction.
300300
pub struct CreateGuardCpi<'a, 'b> {
301301
/// The program to invoke.
302-
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
302+
pub __program: &'b solana_account_info::AccountInfo<'a>,
303303

304-
pub guard: &'b solana_program::account_info::AccountInfo<'a>,
304+
pub guard: &'b solana_account_info::AccountInfo<'a>,
305305

306-
pub mint: &'b solana_program::account_info::AccountInfo<'a>,
306+
pub mint: &'b solana_account_info::AccountInfo<'a>,
307307

308-
pub mint_token_account: &'b solana_program::account_info::AccountInfo<'a>,
308+
pub mint_token_account: &'b solana_account_info::AccountInfo<'a>,
309309

310-
pub guard_authority: &'b solana_program::account_info::AccountInfo<'a>,
310+
pub guard_authority: &'b solana_account_info::AccountInfo<'a>,
311311

312-
pub payer: &'b solana_program::account_info::AccountInfo<'a>,
312+
pub payer: &'b solana_account_info::AccountInfo<'a>,
313313

314-
pub associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
314+
pub associated_token_program: &'b solana_account_info::AccountInfo<'a>,
315315

316-
pub token_program: &'b solana_program::account_info::AccountInfo<'a>,
316+
pub token_program: &'b solana_account_info::AccountInfo<'a>,
317317

318-
pub system_program: &'b solana_program::account_info::AccountInfo<'a>,
318+
pub system_program: &'b solana_account_info::AccountInfo<'a>,
319319
/// The arguments for the instruction.
320320
pub __args: CreateGuardInstructionArgs,
321321
}
322322

323323
impl<'a, 'b> CreateGuardCpi<'a, 'b> {
324324
pub fn new(
325-
program: &'b solana_program::account_info::AccountInfo<'a>,
325+
program: &'b solana_account_info::AccountInfo<'a>,
326326
accounts: CreateGuardCpiAccounts<'a, 'b>,
327327
args: CreateGuardInstructionArgs,
328328
) -> Self {
@@ -346,11 +346,7 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
346346
#[inline(always)]
347347
pub fn invoke_with_remaining_accounts(
348348
&self,
349-
remaining_accounts: &[(
350-
&'b solana_program::account_info::AccountInfo<'a>,
351-
bool,
352-
bool,
353-
)],
349+
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
354350
) -> solana_program::entrypoint::ProgramResult {
355351
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
356352
}
@@ -367,11 +363,7 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
367363
pub fn invoke_signed_with_remaining_accounts(
368364
&self,
369365
signers_seeds: &[&[&[u8]]],
370-
remaining_accounts: &[(
371-
&'b solana_program::account_info::AccountInfo<'a>,
372-
bool,
373-
bool,
374-
)],
366+
remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
375367
) -> solana_program::entrypoint::ProgramResult {
376368
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
377369
accounts.push(solana_instruction::AccountMeta::new(*self.guard.key, false));
@@ -453,7 +445,7 @@ pub struct CreateGuardCpiBuilder<'a, 'b> {
453445
}
454446

455447
impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
456-
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
448+
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
457449
let instruction = Box::new(CreateGuardCpiBuilderInstruction {
458450
__program: program,
459451
guard: None,
@@ -475,56 +467,56 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
475467
Self { instruction }
476468
}
477469
#[inline(always)]
478-
pub fn guard(&mut self, guard: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
470+
pub fn guard(&mut self, guard: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
479471
self.instruction.guard = Some(guard);
480472
self
481473
}
482474
#[inline(always)]
483-
pub fn mint(&mut self, mint: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
475+
pub fn mint(&mut self, mint: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
484476
self.instruction.mint = Some(mint);
485477
self
486478
}
487479
#[inline(always)]
488480
pub fn mint_token_account(
489481
&mut self,
490-
mint_token_account: &'b solana_program::account_info::AccountInfo<'a>,
482+
mint_token_account: &'b solana_account_info::AccountInfo<'a>,
491483
) -> &mut Self {
492484
self.instruction.mint_token_account = Some(mint_token_account);
493485
self
494486
}
495487
#[inline(always)]
496488
pub fn guard_authority(
497489
&mut self,
498-
guard_authority: &'b solana_program::account_info::AccountInfo<'a>,
490+
guard_authority: &'b solana_account_info::AccountInfo<'a>,
499491
) -> &mut Self {
500492
self.instruction.guard_authority = Some(guard_authority);
501493
self
502494
}
503495
#[inline(always)]
504-
pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
496+
pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
505497
self.instruction.payer = Some(payer);
506498
self
507499
}
508500
#[inline(always)]
509501
pub fn associated_token_program(
510502
&mut self,
511-
associated_token_program: &'b solana_program::account_info::AccountInfo<'a>,
503+
associated_token_program: &'b solana_account_info::AccountInfo<'a>,
512504
) -> &mut Self {
513505
self.instruction.associated_token_program = Some(associated_token_program);
514506
self
515507
}
516508
#[inline(always)]
517509
pub fn token_program(
518510
&mut self,
519-
token_program: &'b solana_program::account_info::AccountInfo<'a>,
511+
token_program: &'b solana_account_info::AccountInfo<'a>,
520512
) -> &mut Self {
521513
self.instruction.token_program = Some(token_program);
522514
self
523515
}
524516
#[inline(always)]
525517
pub fn system_program(
526518
&mut self,
527-
system_program: &'b solana_program::account_info::AccountInfo<'a>,
519+
system_program: &'b solana_account_info::AccountInfo<'a>,
528520
) -> &mut Self {
529521
self.instruction.system_program = Some(system_program);
530522
self
@@ -568,7 +560,7 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
568560
#[inline(always)]
569561
pub fn add_remaining_account(
570562
&mut self,
571-
account: &'b solana_program::account_info::AccountInfo<'a>,
563+
account: &'b solana_account_info::AccountInfo<'a>,
572564
is_writable: bool,
573565
is_signer: bool,
574566
) -> &mut Self {
@@ -584,11 +576,7 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
584576
#[inline(always)]
585577
pub fn add_remaining_accounts(
586578
&mut self,
587-
accounts: &[(
588-
&'b solana_program::account_info::AccountInfo<'a>,
589-
bool,
590-
bool,
591-
)],
579+
accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)],
592580
) -> &mut Self {
593581
self.instruction
594582
.__remaining_accounts
@@ -661,25 +649,21 @@ impl<'a, 'b> CreateGuardCpiBuilder<'a, 'b> {
661649

662650
#[derive(Clone, Debug)]
663651
struct CreateGuardCpiBuilderInstruction<'a, 'b> {
664-
__program: &'b solana_program::account_info::AccountInfo<'a>,
665-
guard: Option<&'b solana_program::account_info::AccountInfo<'a>>,
666-
mint: Option<&'b solana_program::account_info::AccountInfo<'a>>,
667-
mint_token_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
668-
guard_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
669-
payer: Option<&'b solana_program::account_info::AccountInfo<'a>>,
670-
associated_token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
671-
token_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
672-
system_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
652+
__program: &'b solana_account_info::AccountInfo<'a>,
653+
guard: Option<&'b solana_account_info::AccountInfo<'a>>,
654+
mint: Option<&'b solana_account_info::AccountInfo<'a>>,
655+
mint_token_account: Option<&'b solana_account_info::AccountInfo<'a>>,
656+
guard_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
657+
payer: Option<&'b solana_account_info::AccountInfo<'a>>,
658+
associated_token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
659+
token_program: Option<&'b solana_account_info::AccountInfo<'a>>,
660+
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
673661
name: Option<String>,
674662
symbol: Option<String>,
675663
uri: Option<String>,
676664
cpi_rule: Option<CpiRule>,
677665
transfer_amount_rule: Option<TransferAmountRule>,
678666
additional_fields_rule: Option<Vec<MetadataAdditionalFieldRule>>,
679667
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
680-
__remaining_accounts: Vec<(
681-
&'b solana_program::account_info::AccountInfo<'a>,
682-
bool,
683-
bool,
684-
)>,
668+
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
685669
}

0 commit comments

Comments
 (0)