Skip to content

Commit fda718e

Browse files
committed
fix: borsh token account deserialization throw error on invalid account type
1 parent 64bd461 commit fda718e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • program-libs/token-interface/src/state/token

program-libs/token-interface/src/state/token/borsh.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,10 @@ impl AnchorDeserialize for Token {
135135
Option::<Vec<ExtensionStruct>>::deserialize_reader(buf).unwrap_or_default();
136136
(account_type, extensions)
137137
} else {
138-
// Account type byte present but not Token - store it but no extensions
139-
(account_type, None)
138+
return Err(std::io::Error::new(
139+
std::io::ErrorKind::InvalidData,
140+
"Account type does not match Token account",
141+
));
140142
}
141143
} else {
142144
// No account_type byte - base SPL token account without extensions

0 commit comments

Comments
 (0)