Skip to content

Commit 62bb9a5

Browse files
committed
Remove unnecessary invoke_signed
1 parent 55ecb47 commit 62bb9a5

File tree

6 files changed

+18
-53
lines changed

6 files changed

+18
-53
lines changed

programs/token-2022/src/instructions/initialize_account.rs

Lines changed: 3 additions & 9 deletions
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
pubkey::Pubkey,
66
ProgramResult,
77
};
@@ -29,11 +29,6 @@ pub struct InitializeAccount<'a, 'b> {
2929
impl InitializeAccount<'_, '_> {
3030
#[inline(always)]
3131
pub fn invoke(&self) -> ProgramResult {
32-
self.invoke_signed(&[])
33-
}
34-
35-
#[inline(always)]
36-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
3732
// account metadata
3833
let account_metas: [AccountMeta; 4] = [
3934
AccountMeta::writable(self.account.key()),
@@ -48,10 +43,9 @@ impl InitializeAccount<'_, '_> {
4843
data: &[1],
4944
};
5045

51-
invoke_signed(
46+
invoke(
5247
&instruction,
5348
&[self.account, self.mint, self.owner, self.rent_sysvar],
54-
signers,
5549
)
5650
}
5751
}

programs/token-2022/src/instructions/initialize_account_2.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use core::slice::from_raw_parts;
22

33
use pinocchio::{
44
account_info::AccountInfo,
5-
instruction::{AccountMeta, Instruction, Signer},
6-
program::invoke_signed,
5+
cpi::invoke,
6+
instruction::{AccountMeta, Instruction},
77
pubkey::Pubkey,
88
ProgramResult,
99
};
@@ -32,11 +32,6 @@ pub struct InitializeAccount2<'a, 'b> {
3232
impl InitializeAccount2<'_, '_> {
3333
#[inline(always)]
3434
pub fn invoke(&self) -> ProgramResult {
35-
self.invoke_signed(&[])
36-
}
37-
38-
#[inline(always)]
39-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
4035
// account metadata
4136
let account_metas: [AccountMeta; 3] = [
4237
AccountMeta::writable(self.account.key()),
@@ -60,10 +55,6 @@ impl InitializeAccount2<'_, '_> {
6055
data: unsafe { from_raw_parts(instruction_data.as_ptr() as _, 33) },
6156
};
6257

63-
invoke_signed(
64-
&instruction,
65-
&[self.account, self.mint, self.rent_sysvar],
66-
signers,
67-
)
58+
invoke(&instruction, &[self.account, self.mint, self.rent_sysvar])
6859
}
6960
}

programs/token-2022/src/instructions/initialize_account_3.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use core::slice::from_raw_parts;
22

33
use pinocchio::{
44
account_info::AccountInfo,
5-
instruction::{AccountMeta, Instruction, Signer},
6-
program::invoke_signed,
5+
cpi::invoke,
6+
instruction::{AccountMeta, Instruction},
77
pubkey::Pubkey,
88
ProgramResult,
99
};
@@ -29,11 +29,6 @@ pub struct InitializeAccount3<'a, 'b> {
2929
impl InitializeAccount3<'_, '_> {
3030
#[inline(always)]
3131
pub fn invoke(&self) -> ProgramResult {
32-
self.invoke_signed(&[])
33-
}
34-
35-
#[inline(always)]
36-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
3732
// account metadata
3833
let account_metas: [AccountMeta; 2] = [
3934
AccountMeta::writable(self.account.key()),
@@ -56,6 +51,6 @@ impl InitializeAccount3<'_, '_> {
5651
data: unsafe { from_raw_parts(instruction_data.as_ptr() as _, 33) },
5752
};
5853

59-
invoke_signed(&instruction, &[self.account, self.mint], signers)
54+
invoke(&instruction, &[self.account, self.mint])
6055
}
6156
}

programs/token-2022/src/instructions/initialize_mint.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use core::slice::from_raw_parts;
22

33
use pinocchio::{
44
account_info::AccountInfo,
5-
instruction::{AccountMeta, Instruction, Signer},
6-
program::invoke_signed,
5+
cpi::invoke,
6+
instruction::{AccountMeta, Instruction},
77
pubkey::Pubkey,
88
ProgramResult,
99
};
@@ -33,11 +33,6 @@ pub struct InitializeMint<'a, 'b> {
3333
impl InitializeMint<'_, '_> {
3434
#[inline(always)]
3535
pub fn invoke(&self) -> ProgramResult {
36-
self.invoke_signed(&[])
37-
}
38-
39-
#[inline(always)]
40-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
4136
// Account metadata
4237
let account_metas: [AccountMeta; 2] = [
4338
AccountMeta::writable(self.mint.key()),
@@ -77,6 +72,6 @@ impl InitializeMint<'_, '_> {
7772
data: unsafe { from_raw_parts(instruction_data.as_ptr() as _, length) },
7873
};
7974

80-
invoke_signed(&instruction, &[self.mint, self.rent_sysvar], signers)
75+
invoke(&instruction, &[self.mint, self.rent_sysvar])
8176
}
8277
}

programs/token-2022/src/instructions/initialize_mint_2.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use core::slice::from_raw_parts;
22

33
use pinocchio::{
44
account_info::AccountInfo,
5-
instruction::{AccountMeta, Instruction, Signer},
6-
program::invoke_signed,
5+
cpi::invoke,
6+
instruction::{AccountMeta, Instruction},
77
pubkey::Pubkey,
88
ProgramResult,
99
};
@@ -30,11 +30,6 @@ pub struct InitializeMint2<'a, 'b> {
3030
impl InitializeMint2<'_, '_> {
3131
#[inline(always)]
3232
pub fn invoke(&self) -> ProgramResult {
33-
self.invoke_signed(&[])
34-
}
35-
36-
#[inline(always)]
37-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
3833
// Account metadata
3934
let account_metas: [AccountMeta; 1] = [AccountMeta::writable(self.mint.key())];
4035

@@ -71,6 +66,6 @@ impl InitializeMint2<'_, '_> {
7166
data: unsafe { from_raw_parts(instruction_data.as_ptr() as _, length) },
7267
};
7368

74-
invoke_signed(&instruction, &[self.mint], signers)
69+
invoke(&instruction, &[self.mint])
7570
}
7671
}

programs/token-2022/src/instructions/sync_native.rs

Lines changed: 3 additions & 8 deletions
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
pubkey::Pubkey,
66
ProgramResult,
77
};
@@ -22,11 +22,6 @@ pub struct SyncNative<'a, 'b> {
2222
impl SyncNative<'_, '_> {
2323
#[inline(always)]
2424
pub fn invoke(&self) -> ProgramResult {
25-
self.invoke_signed(&[])
26-
}
27-
28-
#[inline(always)]
29-
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
3025
// account metadata
3126
let account_metas: [AccountMeta; 1] = [AccountMeta::writable(self.native_token.key())];
3227

@@ -36,6 +31,6 @@ impl SyncNative<'_, '_> {
3631
data: &[17],
3732
};
3833

39-
invoke_signed(&instruction, &[self.native_token], signers)
34+
invoke(&instruction, &[self.native_token])
4035
}
4136
}

0 commit comments

Comments
 (0)