-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nullable Storage.Get; refactor TokenContract #1214
base: master
Are you sure you want to change the base?
Changes from 14 commits
f25d26d
dc46908
4faf6ed
903fb62
5bac102
8d6ccba
141f507
36d7715
e030734
479f63e
1c31a70
0fbd2ac
0672337
33ae8d4
067b70a
4618e31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,13 @@ public extern bool IsValid | |
{ | ||
[OpCode(OpCode.DUP)] | ||
[OpCode(OpCode.ISTYPE, "0x28")] //ByteString | ||
[OpCode(OpCode.SWAP)] | ||
[OpCode(OpCode.JMPIF, "06")] // to SIZE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is cheaper? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and better for NZ/ISNULL and folding NOT in optimization There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this avoids executing SIZE on a possibly null input, and further saves There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be in a different PR |
||
[OpCode(OpCode.DROP)] | ||
[OpCode(OpCode.PUSHF)] | ||
[OpCode(OpCode.JMP, "06")] // to the end | ||
[OpCode(OpCode.SIZE)] | ||
[OpCode(OpCode.PUSHINT8, "20")] // 0x20 == 32 bytes expected array size | ||
[OpCode(OpCode.NUMEQUAL)] | ||
[OpCode(OpCode.BOOLAND)] | ||
get; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ private static bool IsOwner() => | |
|
||
public static void SetOwner(UInt160 newOwner) | ||
{ | ||
if (IsOwner() == false) | ||
if (!IsOwner()) | ||
throw new InvalidOperationException("No Authorization!"); | ||
|
||
ExecutionEngine.Assert(newOwner.IsValid && !newOwner.IsZero, "owner must be valid"); | ||
|
@@ -60,14 +60,14 @@ public static void SetOwner(UInt160 newOwner) | |
|
||
public static new void Burn(UInt160 account, BigInteger amount) | ||
{ | ||
if (IsOwner() == false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually |
||
if (!IsOwner()) | ||
throw new InvalidOperationException("No Authorization!"); | ||
Nep17Token.Burn(account, amount); | ||
} | ||
|
||
public static new void Mint(UInt160 to, BigInteger amount) | ||
{ | ||
if (IsOwner() == false) | ||
if (!IsOwner()) | ||
throw new InvalidOperationException("No Authorization!"); | ||
Nep17Token.Mint(to, amount); | ||
} | ||
|
@@ -109,7 +109,7 @@ public static void _deploy(object data, bool update) | |
|
||
public static void Update(ByteString nefFile, string manifest, object? data = null) | ||
{ | ||
if (IsOwner() == false) | ||
if (!IsOwner()) | ||
throw new InvalidOperationException("No authorization."); | ||
ContractManagement.Update(nefFile, manifest, data); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ByteString is really cheaper when used for storage.get/put. Also static readonly ByteString can be optimized to const now.