Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Nov 10, 2025

Summary

  • ensure constant folding picks up context types so string literals assigned to hash types compile to byte payloads
  • add runtime regression test covering string literal UInt160 return
  • introduce return-value analyzer that blocks implicit non-matching returns for UInt160/UInt256/ECPoint and add coverage

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be converted by the compiler to the right type?

@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 10, 2025

Should not be converted by the compiler to the right type?

its impossible, UInt160 has its own format, while string could be any value. we dont have native methods/syscall/opcode to perform the conversion, unless its constent string.

@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 10, 2025

Should not be converted by the compiler to the right type?

wait, maybe i can add a method? will update this pr later.

@Jim8y Jim8y force-pushed the fix/return-value-analyzer branch from 278c3af to 0b46a15 Compare November 11, 2025 01:38
@Jim8y Jim8y requested a review from shargon November 11, 2025 03:09
@Jim8y Jim8y marked this pull request as draft November 11, 2025 04:27
@shargon
Copy link
Member

shargon commented Nov 11, 2025

Should not be converted by the compiler to the right type?

its impossible, UInt160 has its own format, while string could be any value. we dont have native methods/syscall/opcode to perform the conversion, unless its constent string.

I know, but here the compiler knows that it's a string, and want a UInt160, so it can convert from hex directly, isn't it?

@Jim8y Jim8y changed the base branch from dev to master November 14, 2025 07:23
shargon and others added 19 commits November 14, 2025 15:38
* fix: resolve nullable reference type warnings in Neo.SmartContract.Framework

This commit fixes all nullable reference type warnings (CS8618, CS8625, CS8604, CS8602, CS8600)
in the Neo.SmartContract.Framework project to ensure clean builds with nullable reference types enabled.

Changes include:
- Added nullable annotations to method parameters accepting null values (GAS, NEO, Runtime)
- Used null-forgiving operators for fields initialized at runtime (Native classes, token states)
- Added pragma directives to suppress CS8618 for runtime-populated service classes
- Fixed nullable parameter types in delegate signatures and PostTransfer methods
- Used null-forgiving operators in storage access and Contract.Call invocations

This resolves all nullable reference warnings in the Framework project, resulting in a clean build.

* fix: remove non-existent OnNewSnapshot event from RpcStore

The RpcStore was referencing IStore.OnNewSnapshotDelegate which doesn't exist
in the IStore interface, causing compilation errors. This removes the undefined
event and its invocation from the GetSnapshot method.

This resolves build errors CS0426 and CS0066 in the Testing project.

* Fix GitHub Actions failure by implementing IStore.OnNewSnapshot event in RpcStore

- Add OnNewSnapshot event implementation to comply with IStore interface requirements
- Event is properly invoked when GetSnapshot() is called
- Resolves CS0535 compilation error in GitHub Actions CI/CD pipeline

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

* Update NEO.cs

* Update Contract.cs

* Apply suggestions from code review

* Update src/Neo.SmartContract.Framework/Nep17Token.cs

* Update src/Neo.SmartContract.Framework/Nep11Token.cs

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Shargon <[email protected]>
* Update neo

* Clean

---------

Co-authored-by: Jimmy <[email protected]>
* chore: update neo submodule to latest master

Update neo submodule reference to include latest changes from master branch

* chore: update neo submodule to latest dev branch

Update neo submodule from 9b9be473 to 257756e7 to include:
- unit-tests: Use proper 'Assert' methods
- Allow HF in syscalls
- IComparable, Casting to UInt160 & UInt256
- Clean JsonSerializer
- Fix RpcSendByHashOrIndexAsync comment
…1381)

* feat: Add GuardHelpers utility class for smart contract validation

Introduces a comprehensive validation helper library to standardize precondition
and postcondition checks in Neo smart contracts.

Features:
- Basic validation: Require(), Ensure(), Revert()
- Null checks: RequireNotNull()
- Numeric validation: RequireNonNegative(), RequirePositive(), RequireInRange()
- Address validation: RequireValidAddress(), RequireWitness()
- Security checks: RequireCaller(), RequireEquals()
- String validation: RequireNotEmpty()

Benefits:
- Reduces boilerplate validation code
- Standardizes error messages with short codes for gas efficiency
- Improves contract security and reliability
- Makes smart contracts more readable and maintainable

* feat: add GuardHelpers utility class for smart contract validation

Introduces a new GuardHelpers static class that provides common validation
patterns for Neo smart contracts with gas-efficient error codes.

Features:
- Require/Ensure methods for preconditions and postconditions
- Common validation helpers (RequireNotNull, RequirePositive, etc.)
- Address validation (RequireValidAddress, RequireWitness)
- Range and equality checks (RequireInRange, RequireEquals)
- Caller verification (RequireCaller)
- String validation (RequireNotEmpty)

All methods use short error codes to minimize GAS consumption while
maintaining clear error identification.

* test: add comprehensive unit tests for GuardHelpers

Adds test contract and unit tests covering all GuardHelpers methods:
- Basic validation tests (Require, Ensure, Revert)
- Type validation tests (RequireNotNull, RequireNonNegative, RequirePositive)
- Address validation tests (RequireValidAddress, RequireWitness)
- Range and equality tests (RequireInRange, RequireEquals)
- Caller verification tests (RequireCaller)
- String validation tests (RequireNotEmpty)
- Real-world Transfer scenario test

All tests verify both success and failure cases with appropriate error messages.

* style: fix formatting and remove duplicate generated file

- Remove duplicate Contract_GuardHelpers_Inline.cs from TestingArtifacts
- Fix minor formatting issues in source files
- Ensure no file conflicts during build

* fix: resolve GitHub Actions build failure for GuardHelpers tests

- Remove duplicate and conflicting artifact files
- Keep only the generated wrapper (Contract_GuardHelpers_Inline.cs)
- Follow existing test artifact pattern used by other test contracts
- Binary artifacts (.nef, .manifest.json, etc.) are generated during build

* Revert "fix: resolve GitHub Actions build failure for GuardHelpers tests"

This reverts commit 47b7336.

* fix: resolve artifact naming conflict for GuardHelpers tests

- Rename Contract_GuardHelpers_Inline.artifacts.cs to Contract_GuardHelpers_Inline.cs
- Keep all test artifacts (.nef, .manifest.json, .nefdbgnfo) as required
- This follows the consistent naming pattern and avoids build conflicts

* Update tests/Neo.SmartContract.Framework.UnitTests/GuardHelpersTest.cs

* Update src/Neo.SmartContract.Framework/Helpers/GuardHelpers.cs

Co-authored-by: Will <[email protected]>

* Update src/Neo.SmartContract.Framework/Helpers/GuardHelpers.cs

Co-authored-by: Will <[email protected]>

---------

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Will <[email protected]>
* #4148

* change summary

* Update submodule

* Template

* fix artifacts

---------

Co-authored-by: Alvaro <[email protected]>
* Update WriteInTry artifact and ensure temp projects target net9

* Refresh WriteInTry artifacts and include local storage syscalls
@Jim8y Jim8y force-pushed the fix/return-value-analyzer branch from b71fe37 to 5a7b477 Compare November 14, 2025 07:41
@Jim8y
Copy link
Contributor Author

Jim8y commented Nov 20, 2025

will create a new one based on master to replace this one

@Jim8y Jim8y closed this Nov 20, 2025
@shargon shargon deleted the fix/return-value-analyzer branch November 20, 2025 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UInt160 type method in smart contract can return String, can be compiled, but can't be executed.

4 participants