Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/processor/fast/utils/requires.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ pub fn require_pda(
return Err(ProgramError::InvalidSeeds);
}

if !info.is_writable().eq(&is_writable) {
// TODO (snawaz): misleading msg
// also better use more granular error here ProgramError::InvalidPermission
if is_writable && !info.is_writable() {
log!("Account needs to be writable. Label: {}", label);
pubkey::log(info.key());
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(pda.1)
Expand Down Expand Up @@ -124,7 +122,7 @@ pub fn require_uninitialized_account(
if is_writable && !info.is_writable() {
log!("Account needs to be writable. label: {}, account: ", label);
pubkey::log(info.key());
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(())
Expand Down Expand Up @@ -176,7 +174,7 @@ pub fn require_initialized_pda(
if is_writable && !info.is_writable() {
log!("Account needs to be writable. label: {}, account: ", label);
pubkey::log(info.key());
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(pda.1)
Expand Down
12 changes: 5 additions & 7 deletions src/processor/utils/loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ pub fn load_pda(
return Err(ProgramError::InvalidSeeds);
}

if !info.is_writable.eq(&is_writable) {
// TODO (snawaz): misleading msg
// also better use more granular error here ProgramError::InvalidPermission
if is_writable && !info.is_writable {
msg!("Account {} ({}) needs to be writable", label, info.key);
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(pda.1)
Expand Down Expand Up @@ -103,7 +101,7 @@ pub fn load_initialized_pda(

if is_writable && !info.is_writable {
msg!("Account {} is not writable", info.key);
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(pda.1)
Expand Down Expand Up @@ -143,7 +141,7 @@ pub fn load_uninitialized_account(

if is_writable && !info.is_writable {
msg!("Account {} ({}) needs to be writable", label, info.key);
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(())
Expand Down Expand Up @@ -178,7 +176,7 @@ pub fn load_account(

if is_writable && !info.is_writable {
msg!("Account {} ({}) needs to be writable", label, info.key);
return Err(ProgramError::InvalidAccountData);
return Err(ProgramError::Immutable);
}

Ok(())
Expand Down