Skip to content

Commit

Permalink
Show error when access to storage without deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Feb 20, 2024
1 parent 2b25580 commit 96dfad3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Neo.SmartContract.Testing/SmartContractStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ internal SmartContractStorage(SmartContract smartContract, int? contractId = nul
private int GetContractId()
{
// If it was not initialized checking the contract, we need to query the contract id
_contractId ??= _smartContract.Engine.Native.ContractManagement.GetContract(_smartContract.Hash).Id;

if (_contractId is not null) return _contractId.Value;

var state = _smartContract.Engine.Native.ContractManagement.GetContract(_smartContract.Hash)
?? throw new Exception($"The contract 0x{_smartContract.Hash} is not deployed, so it's not possible to get the storage id.");

_contractId ??= state.Id;
return _contractId.Value;
}

Expand Down

0 comments on commit 96dfad3

Please sign in to comment.