Skip to content

Commit

Permalink
fix(storage): contract class hash query by hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirko-von-Leipzig committed Aug 14, 2023
1 parent 1177574 commit b6a2f35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Querying `starknet_getClassAt` and `starknet_getClassHashAt` by block hash incorrectly returns contract not found

## [0.7.1] - 2023-08-08

### Fixed
Expand Down
10 changes: 4 additions & 6 deletions crates/storage/src/connection/state_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,11 @@ pub(super) fn contract_class_hash(
),
BlockId::Hash(hash) => tx.inner().query_row(
r"SELECT class_hash FROM contract_updates
JOIN canonical_blocks ON canonical_blocks.number = contract_updates.block_number
WHERE
canonical_blocks.hash = ? AND
block_number <= contract_updates.block_number AND
contract_address = ?
WHERE contract_address = ? AND block_number <= (
SELECT number FROM canonical_blocks WHERE hash = ?
)
ORDER BY block_number DESC LIMIT 1",
params![&hash, &contract_address],
params![&contract_address, &hash],
|row| row.get_class_hash(0),
),
}
Expand Down

0 comments on commit b6a2f35

Please sign in to comment.