Skip to content

Commit d743fb0

Browse files
refactor: extract instruction from solana-program
1 parent ae3ca97 commit d743fb0

File tree

112 files changed

+404
-30904
lines changed

Some content is hidden

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

112 files changed

+404
-30904
lines changed

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
@@ -19,6 +19,7 @@ num-traits = "^0.2"
1919
serde = { version = "^1.0", features = ["derive"], optional = true }
2020
serde_with = { version = "^3.0", optional = true }
2121
solana-program = "2.2.1"
22+
solana-instruction = "2.2.1"
2223
solana-pubkey = { version = "2.2.1", features = ["curve25519"] }
2324
solana-client = { version = "~1.18", optional = true }
2425
solana-sdk = { version = "~1.18", optional = true }

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

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,46 +32,37 @@ pub struct CreateGuard {
3232
}
3333

3434
impl CreateGuard {
35-
pub fn instruction(
36-
&self,
37-
args: CreateGuardInstructionArgs,
38-
) -> solana_program::instruction::Instruction {
35+
pub fn instruction(&self, args: CreateGuardInstructionArgs) -> solana_instruction::Instruction {
3936
self.instruction_with_remaining_accounts(args, &[])
4037
}
4138
#[allow(clippy::arithmetic_side_effects)]
4239
#[allow(clippy::vec_init_then_push)]
4340
pub fn instruction_with_remaining_accounts(
4441
&self,
4542
args: CreateGuardInstructionArgs,
46-
remaining_accounts: &[solana_program::instruction::AccountMeta],
47-
) -> solana_program::instruction::Instruction {
43+
remaining_accounts: &[solana_instruction::AccountMeta],
44+
) -> solana_instruction::Instruction {
4845
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
49-
accounts.push(solana_program::instruction::AccountMeta::new(
50-
self.guard, false,
51-
));
52-
accounts.push(solana_program::instruction::AccountMeta::new(
53-
self.mint, true,
54-
));
55-
accounts.push(solana_program::instruction::AccountMeta::new(
46+
accounts.push(solana_instruction::AccountMeta::new(self.guard, false));
47+
accounts.push(solana_instruction::AccountMeta::new(self.mint, true));
48+
accounts.push(solana_instruction::AccountMeta::new(
5649
self.mint_token_account,
5750
false,
5851
));
59-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52+
accounts.push(solana_instruction::AccountMeta::new_readonly(
6053
self.guard_authority,
6154
true,
6255
));
63-
accounts.push(solana_program::instruction::AccountMeta::new(
64-
self.payer, true,
65-
));
66-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
56+
accounts.push(solana_instruction::AccountMeta::new(self.payer, true));
57+
accounts.push(solana_instruction::AccountMeta::new_readonly(
6758
self.associated_token_program,
6859
false,
6960
));
70-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
61+
accounts.push(solana_instruction::AccountMeta::new_readonly(
7162
self.token_program,
7263
false,
7364
));
74-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
65+
accounts.push(solana_instruction::AccountMeta::new_readonly(
7566
self.system_program,
7667
false,
7768
));
@@ -80,7 +71,7 @@ impl CreateGuard {
8071
let mut args = borsh::to_vec(&args).unwrap();
8172
data.append(&mut args);
8273

83-
solana_program::instruction::Instruction {
74+
solana_instruction::Instruction {
8475
program_id: crate::WEN_TRANSFER_GUARD_ID,
8576
accounts,
8677
data,
@@ -147,7 +138,7 @@ pub struct CreateGuardBuilder {
147138
cpi_rule: Option<CpiRule>,
148139
transfer_amount_rule: Option<TransferAmountRule>,
149140
additional_fields_rule: Option<Vec<MetadataAdditionalFieldRule>>,
150-
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
141+
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
151142
}
152143

153144
impl CreateGuardBuilder {
@@ -237,24 +228,21 @@ impl CreateGuardBuilder {
237228
}
238229
/// Add an additional account to the instruction.
239230
#[inline(always)]
240-
pub fn add_remaining_account(
241-
&mut self,
242-
account: solana_program::instruction::AccountMeta,
243-
) -> &mut Self {
231+
pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
244232
self.__remaining_accounts.push(account);
245233
self
246234
}
247235
/// Add additional accounts to the instruction.
248236
#[inline(always)]
249237
pub fn add_remaining_accounts(
250238
&mut self,
251-
accounts: &[solana_program::instruction::AccountMeta],
239+
accounts: &[solana_instruction::AccountMeta],
252240
) -> &mut Self {
253241
self.__remaining_accounts.extend_from_slice(accounts);
254242
self
255243
}
256244
#[allow(clippy::clone_on_copy)]
257-
pub fn instruction(&self) -> solana_program::instruction::Instruction {
245+
pub fn instruction(&self) -> solana_instruction::Instruction {
258246
let accounts = CreateGuard {
259247
guard: self.guard.expect("guard is not set"),
260248
mint: self.mint.expect("mint is not set"),
@@ -386,40 +374,31 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
386374
)],
387375
) -> solana_program::entrypoint::ProgramResult {
388376
let mut accounts = Vec::with_capacity(8 + remaining_accounts.len());
389-
accounts.push(solana_program::instruction::AccountMeta::new(
390-
*self.guard.key,
391-
false,
392-
));
393-
accounts.push(solana_program::instruction::AccountMeta::new(
394-
*self.mint.key,
395-
true,
396-
));
397-
accounts.push(solana_program::instruction::AccountMeta::new(
377+
accounts.push(solana_instruction::AccountMeta::new(*self.guard.key, false));
378+
accounts.push(solana_instruction::AccountMeta::new(*self.mint.key, true));
379+
accounts.push(solana_instruction::AccountMeta::new(
398380
*self.mint_token_account.key,
399381
false,
400382
));
401-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
383+
accounts.push(solana_instruction::AccountMeta::new_readonly(
402384
*self.guard_authority.key,
403385
true,
404386
));
405-
accounts.push(solana_program::instruction::AccountMeta::new(
406-
*self.payer.key,
407-
true,
408-
));
409-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
387+
accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true));
388+
accounts.push(solana_instruction::AccountMeta::new_readonly(
410389
*self.associated_token_program.key,
411390
false,
412391
));
413-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
392+
accounts.push(solana_instruction::AccountMeta::new_readonly(
414393
*self.token_program.key,
415394
false,
416395
));
417-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
396+
accounts.push(solana_instruction::AccountMeta::new_readonly(
418397
*self.system_program.key,
419398
false,
420399
));
421400
remaining_accounts.iter().for_each(|remaining_account| {
422-
accounts.push(solana_program::instruction::AccountMeta {
401+
accounts.push(solana_instruction::AccountMeta {
423402
pubkey: *remaining_account.0.key,
424403
is_signer: remaining_account.1,
425404
is_writable: remaining_account.2,
@@ -429,7 +408,7 @@ impl<'a, 'b> CreateGuardCpi<'a, 'b> {
429408
let mut args = borsh::to_vec(&self.__args).unwrap();
430409
data.append(&mut args);
431410

432-
let instruction = solana_program::instruction::Instruction {
411+
let instruction = solana_instruction::Instruction {
433412
program_id: crate::WEN_TRANSFER_GUARD_ID,
434413
accounts,
435414
data,

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

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,40 @@ pub struct Execute {
2727
}
2828

2929
impl Execute {
30-
pub fn instruction(
31-
&self,
32-
args: ExecuteInstructionArgs,
33-
) -> solana_program::instruction::Instruction {
30+
pub fn instruction(&self, args: ExecuteInstructionArgs) -> solana_instruction::Instruction {
3431
self.instruction_with_remaining_accounts(args, &[])
3532
}
3633
#[allow(clippy::arithmetic_side_effects)]
3734
#[allow(clippy::vec_init_then_push)]
3835
pub fn instruction_with_remaining_accounts(
3936
&self,
4037
args: ExecuteInstructionArgs,
41-
remaining_accounts: &[solana_program::instruction::AccountMeta],
42-
) -> solana_program::instruction::Instruction {
38+
remaining_accounts: &[solana_instruction::AccountMeta],
39+
) -> solana_instruction::Instruction {
4340
let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
44-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
41+
accounts.push(solana_instruction::AccountMeta::new_readonly(
4542
self.source_account,
4643
false,
4744
));
48-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
45+
accounts.push(solana_instruction::AccountMeta::new_readonly(
4946
self.mint, false,
5047
));
51-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
48+
accounts.push(solana_instruction::AccountMeta::new_readonly(
5249
self.destination_account,
5350
false,
5451
));
55-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
52+
accounts.push(solana_instruction::AccountMeta::new_readonly(
5653
self.owner_delegate,
5754
false,
5855
));
59-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
56+
accounts.push(solana_instruction::AccountMeta::new_readonly(
6057
self.extra_metas_account,
6158
false,
6259
));
63-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
60+
accounts.push(solana_instruction::AccountMeta::new_readonly(
6461
self.guard, false,
6562
));
66-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
63+
accounts.push(solana_instruction::AccountMeta::new_readonly(
6764
self.instruction_sysvar_account,
6865
false,
6966
));
@@ -72,7 +69,7 @@ impl Execute {
7269
let mut args = borsh::to_vec(&args).unwrap();
7370
data.append(&mut args);
7471

75-
solana_program::instruction::Instruction {
72+
solana_instruction::Instruction {
7673
program_id: crate::WEN_TRANSFER_GUARD_ID,
7774
accounts,
7875
data,
@@ -127,7 +124,7 @@ pub struct ExecuteBuilder {
127124
guard: Option<solana_pubkey::Pubkey>,
128125
instruction_sysvar_account: Option<solana_pubkey::Pubkey>,
129126
amount: Option<u64>,
130-
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
127+
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
131128
}
132129

133130
impl ExecuteBuilder {
@@ -180,24 +177,21 @@ impl ExecuteBuilder {
180177
}
181178
/// Add an additional account to the instruction.
182179
#[inline(always)]
183-
pub fn add_remaining_account(
184-
&mut self,
185-
account: solana_program::instruction::AccountMeta,
186-
) -> &mut Self {
180+
pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
187181
self.__remaining_accounts.push(account);
188182
self
189183
}
190184
/// Add additional accounts to the instruction.
191185
#[inline(always)]
192186
pub fn add_remaining_accounts(
193187
&mut self,
194-
accounts: &[solana_program::instruction::AccountMeta],
188+
accounts: &[solana_instruction::AccountMeta],
195189
) -> &mut Self {
196190
self.__remaining_accounts.extend_from_slice(accounts);
197191
self
198192
}
199193
#[allow(clippy::clone_on_copy)]
200-
pub fn instruction(&self) -> solana_program::instruction::Instruction {
194+
pub fn instruction(&self) -> solana_instruction::Instruction {
201195
let accounts = Execute {
202196
source_account: self.source_account.expect("source_account is not set"),
203197
mint: self.mint.expect("mint is not set"),
@@ -313,36 +307,36 @@ impl<'a, 'b> ExecuteCpi<'a, 'b> {
313307
)],
314308
) -> solana_program::entrypoint::ProgramResult {
315309
let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
316-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
310+
accounts.push(solana_instruction::AccountMeta::new_readonly(
317311
*self.source_account.key,
318312
false,
319313
));
320-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
314+
accounts.push(solana_instruction::AccountMeta::new_readonly(
321315
*self.mint.key,
322316
false,
323317
));
324-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
318+
accounts.push(solana_instruction::AccountMeta::new_readonly(
325319
*self.destination_account.key,
326320
false,
327321
));
328-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
322+
accounts.push(solana_instruction::AccountMeta::new_readonly(
329323
*self.owner_delegate.key,
330324
false,
331325
));
332-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
326+
accounts.push(solana_instruction::AccountMeta::new_readonly(
333327
*self.extra_metas_account.key,
334328
false,
335329
));
336-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
330+
accounts.push(solana_instruction::AccountMeta::new_readonly(
337331
*self.guard.key,
338332
false,
339333
));
340-
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
334+
accounts.push(solana_instruction::AccountMeta::new_readonly(
341335
*self.instruction_sysvar_account.key,
342336
false,
343337
));
344338
remaining_accounts.iter().for_each(|remaining_account| {
345-
accounts.push(solana_program::instruction::AccountMeta {
339+
accounts.push(solana_instruction::AccountMeta {
346340
pubkey: *remaining_account.0.key,
347341
is_signer: remaining_account.1,
348342
is_writable: remaining_account.2,
@@ -352,7 +346,7 @@ impl<'a, 'b> ExecuteCpi<'a, 'b> {
352346
let mut args = borsh::to_vec(&self.__args).unwrap();
353347
data.append(&mut args);
354348

355-
let instruction = solana_program::instruction::Instruction {
349+
let instruction = solana_instruction::Instruction {
356350
program_id: crate::WEN_TRANSFER_GUARD_ID,
357351
accounts,
358352
data,

0 commit comments

Comments
 (0)