neo-devpack-dotnet icon indicating copy to clipboard operation
neo-devpack-dotnet copied to clipboard

nullable Storage.Get; refactor TokenContract

Open Hecate2 opened this issue 1 year ago • 2 comments

This PR is a bit risky and may affect existing contract codes. I do not mind abandoning it if not good. Storage.Get may actually return null. Ignoring it without generating any warning for the contract developer is not good. Also it is not the best to blindly translate null to BigInteger 0. And it costs GAS to check whether a ByteString is null, when converting it to BigInteger. Judging null increases contract size, but can be optimized by https://github.com/neo-project/neo-devpack-dotnet/pull/1213 .

Hecate2 avatar Oct 24 '24 07:10 Hecate2

This will not affect existing contract, unless they compile it again.... so, not really a big deal, we can add a warning to the contract when they build it. But the behavior should be properly commented. Such that developers can see how it works when they use it.

Jim8y avatar Oct 24 '24 07:10 Jim8y

NUMEQUAL can be used in TokenContract

Hecate2 avatar Oct 25 '24 16:10 Hecate2

@shargon please review

Jim8y avatar Nov 08 '24 06:11 Jim8y

I prefer to move the uint optimizations in a different PR

Ok I am on it. is null will be still used in TokenContract for this PR.

Hecate2 avatar Nov 08 '24 07:11 Hecate2