Skip to content

Commit

Permalink
Fixes getStorageAt undeployed contract response
Browse files Browse the repository at this point in the history
fix

Revert "Fixes getStorageAt undeployed contract response"

This reverts commit bd44ef2d79ace6abe9358c053ea3b640dc389bb0.

fix
  • Loading branch information
weiihann committed Nov 4, 2024
1 parent e4240ac commit 47b8084
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rpc/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func (h *Handler) StorageAt(address, key felt.Felt, id BlockID) (*felt.Felt, *js
}
defer h.callAndLogErr(stateCloser, "Error closing state reader in getStorageAt")

// This checks if the contract exists because if a key doesn't exist in contract storage,
// the returned value is always zero and error is nil.
_, err := stateReader.ContractNonce(&address)
if err != nil {
return nil, ErrContractNotFound
}

value, err := stateReader.ContractStorage(&address, &key)
if err != nil {
return nil, ErrContractNotFound
Expand Down

0 comments on commit 47b8084

Please sign in to comment.