Skip to content

Commit

Permalink
fix: contract nonce by hash is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirko-von-Leipzig committed Aug 23, 2023
1 parent ff784fc commit cc01276
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- RPC v0.3 `starknet_estimateFee` example
- RPC method names could be prefixed with API version
- `starknet_getNonce` returns invalid values when queried by hash

### Added

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

0 comments on commit cc01276

Please sign in to comment.