Skip to content

Commit

Permalink
NameService: explicitly throw an exception on unknown tokenId
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaShaleva committed Sep 9, 2022
1 parent 69c415f commit b5f7a16
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/NameService/NameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public static bool Transfer(UInt160 to, ByteString tokenId, object data)
StorageMap accountMap = new(context, Prefix_AccountToken);
StorageMap nameMap = new(context, Prefix_Name);
ByteString tokenKey = GetKey(tokenId);
NameState token = (NameState)StdLib.Deserialize(nameMap[tokenKey]);
ByteString tokenBytes = nameMap[tokenKey];
if (tokenBytes is null) throw new InvalidOperationException("Unknown token.");
NameState token = (NameState)StdLib.Deserialize(tokenBytes);
token.EnsureNotExpired();
UInt160 from = token.Owner;
if (!Runtime.CheckWitness(from)) return false;
Expand Down

0 comments on commit b5f7a16

Please sign in to comment.