Skip to content

refactor: extract typed boolean-flag storage accessors - #55

Merged
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
Jagadeeshftw:refactor/contracts-bool-flag-accessors
Jun 24, 2026
Merged

refactor: extract typed boolean-flag storage accessors#55
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
Jagadeeshftw:refactor/contracts-bool-flag-accessors

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

Pure refactor — behaviour is byte-for-byte identical. Adds two private free functions, read_flag (centralising the unwrap_or(false) default) and write_flag, and routes every persistent boolean read/write through them: the Paused checks in record_usage/settle; the RequireServiceRegistration/ServiceRegistered/ServiceDisabled/AllowlistEnabled/AgentAllowed reads in record_usage; the bool getters; and the bool writes in set_allowlist_enabled, set_agent_allowed, set_require_service_registration, register_service, pause/unpause, and set_service_disabled. u32/i128/u64 slots (including the u32::MAX-defaulting MaxRequestsPerCall) are untouched, and the ordering of checks is preserved.

Closes #47

Test output

test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Security notes

Centralising unwrap_or(false) ensures a new boolean flag can never accidentally default to true or skip its gate; the full existing suite passes unchanged, confirming no behavioural drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Jagadeeshftw
Jagadeeshftw force-pushed the refactor/contracts-bool-flag-accessors branch from ebe883f to a00c6a7 Compare June 24, 2026 02:29
@mikewheeleer

Copy link
Copy Markdown
Contributor

nice refactor — the typed flag accessors cut a lot of unwrap_or(false) noise. lgtm

@mikewheeleer
mikewheeleer merged commit 584e71d into Agentpay-Org:main Jun 24, 2026
1 check failed
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.

Extract typed boolean-flag storage accessors to remove unwrap_or(false) duplication

2 participants