Skip to content

Commit f93f31c

Browse files
authored
system: Fix instruction helpers (#217)
* Remove unnecessary invoke_signed * Fix instruction name
1 parent 55ecb47 commit f93f31c

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

programs/system/src/instructions/initialize_nonce_account.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
use pinocchio::{
22
account_info::AccountInfo,
3-
instruction::{AccountMeta, Instruction, Signer},
4-
program::invoke_signed,
3+
cpi::invoke,
4+
instruction::{AccountMeta, Instruction},
55
pubkey::Pubkey,
66
ProgramResult,
77
};
88

99
/// Drive state of Uninitialized nonce account to Initialized, setting the nonce value.
1010
///
11-
/// The `Pubkey` parameter specifies the entity authorized to execute nonce
12-
/// instruction on the account
13-
///
1411
/// No signatures are required to execute this instruction, enabling derived
1512
/// nonce account addresses.
1613
///
@@ -28,21 +25,14 @@ pub struct InitializeNonceAccount<'a, 'b> {
2825
/// Rent sysvar.
2926
pub rent_sysvar: &'a AccountInfo,
3027

31-
/// Lamports to withdraw.
32-
///
33-
/// The account balance must be left above the rent exempt reserve
34-
/// or at zero.
28+
/// Indicates the entity authorized to execute nonce
29+
/// instruction on the account
3530
pub authority: &'b Pubkey,
3631
}
3732

3833
impl InitializeNonceAccount<'_, '_> {
3934
#[inline(always)]
4035
pub fn invoke(&self) -> ProgramResult {
41-
self.invoke_signed(&[])
42-
}
43-
44-
#[inline(always)]
45-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
4636
// account metadata
4737
let account_metas: [AccountMeta; 3] = [
4838
AccountMeta::writable(self.account.key()),
@@ -63,14 +53,13 @@ impl InitializeNonceAccount<'_, '_> {
6353
data: &instruction_data,
6454
};
6555

66-
invoke_signed(
56+
invoke(
6757
&instruction,
6858
&[
6959
self.account,
7060
self.recent_blockhashes_sysvar,
7161
self.rent_sysvar,
7262
],
73-
signers,
7463
)
7564
}
7665
}

programs/system/src/instructions/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod create_account_with_seed;
99
mod initialize_nonce_account;
1010
mod transfer;
1111
mod transfer_with_seed;
12-
mod update_nonce_account;
12+
mod upgrade_nonce_account;
1313
mod withdraw_nonce_account;
1414

1515
pub use advance_nonce_account::*;
@@ -23,5 +23,5 @@ pub use create_account_with_seed::*;
2323
pub use initialize_nonce_account::*;
2424
pub use transfer::*;
2525
pub use transfer_with_seed::*;
26-
pub use update_nonce_account::*;
26+
pub use upgrade_nonce_account::*;
2727
pub use withdraw_nonce_account::*;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pinocchio::{
22
account_info::AccountInfo,
3-
instruction::{AccountMeta, Instruction, Signer},
4-
program::invoke_signed,
3+
cpi::invoke,
4+
instruction::{AccountMeta, Instruction},
55
ProgramResult,
66
};
77

@@ -10,19 +10,14 @@ use pinocchio::{
1010
///
1111
/// ### Accounts:
1212
/// 0. `[WRITE]` Nonce account
13-
pub struct UpdateNonceAccount<'a> {
13+
pub struct UpgradeNonceAccount<'a> {
1414
/// Nonce account.
1515
pub account: &'a AccountInfo,
1616
}
1717

18-
impl UpdateNonceAccount<'_> {
18+
impl UpgradeNonceAccount<'_> {
1919
#[inline(always)]
2020
pub fn invoke(&self) -> ProgramResult {
21-
self.invoke_signed(&[])
22-
}
23-
24-
#[inline(always)]
25-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
2621
// account metadata
2722
let account_metas: [AccountMeta; 1] = [AccountMeta::writable(self.account.key())];
2823

@@ -33,6 +28,6 @@ impl UpdateNonceAccount<'_> {
3328
data: &[12],
3429
};
3530

36-
invoke_signed(&instruction, &[self.account], signers)
31+
invoke(&instruction, &[self.account])
3732
}
3833
}

0 commit comments

Comments
 (0)