nucypher icon indicating copy to clipboard operation
nucypher copied to clipboard

feat(conditions): add :nullAddress protected context variable

Open theref opened this issue 2 months ago • 4 comments

Summary

Adds a new protected context variable :nullAddress that resolves to the Ethereum null address (0x0000000000000000000000000000000000000000) without requiring any context data.

Motivation

This allows conditions to reference the null address directly, which is useful for:

  • Checking token burns (balanceOf null address)
  • Ownership validation against the zero address
  • Any condition that needs to reference the standard null/zero address

Changes

  • Add NULL_ADDRESS_CONTEXT = ":nullAddress" constant
  • Implement _resolve_null_address() function that returns the checksummed null address
  • Register :nullAddress in _DIRECTIVES dictionary as a protected variable
  • Add comprehensive unit test including usage in ContractCondition

Usage Example

condition = ContractCondition(
    contract_address="0x...",
    method="balanceOf",
    standard_contract_type="ERC20",
    chain=TESTERCHAIN_CHAIN_ID,
    return_value_test=ReturnValueTest(">=", 0),
    parameters=[":nullAddress"],  # Resolves to 0x0000...0000
)

Testing

  • All existing context tests pass (28 tests)
  • New test verifies :nullAddress works correctly in all contexts:
    • Direct resolution
    • In lists with other context variables
    • In ReturnValueTest
    • In ContractCondition parameters

theref avatar Nov 05 '25 11:11 theref