feat(vault): add capabilities() bitmap for client feature detection#582
Open
Ajibose wants to merge 1 commit into
Open
feat(vault): add capabilities() bitmap for client feature detection#582Ajibose wants to merge 1 commit into
Ajibose wants to merge 1 commit into
Conversation
Exposes a pure-view `capabilities() -> u64` function on CalloraVault that returns a stable bitmask of every feature the contract supports. Each of the 18 assigned bits maps to a specific capability (deposit, withdraw, deduct, batch_deduct, pause, authorized_caller, offering_metadata, price_registry, request_idempotency, two_step_ownership, two_step_admin, settlement, revenue_pool, rate_limit, admin_broadcast, depositor_allowlist, slippage_guard, upgrade). Bits 18-63 are reserved and always zero. - contracts/vault/src/capabilities.rs: bit constants and capabilities() - contracts/vault/src/lib.rs: expose CalloraVault::capabilities(), wire module - contracts/vault/src/test_capabilities.rs: 25 tests covering every bit, stability, reserved-bits-zero, idempotency, and no-init availability - docs/CAPABILITIES.md: full bit registry with integration examples
|
@Ajibose Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #504
Summary
capabilities() -> u64pure-view function toCalloraVaultthat returns a stable bitmask of every feature the contract supportsdocs/CAPABILITIES.mdwith a full bit registry, stability guarantees, and integration examples for TypeScript and Rust clientsChanges
contracts/vault/src/capabilities.rsCAP_*constants,ALL_CAPABILITIESaggregate, andcapabilities()functioncontracts/vault/src/lib.rspub mod capabilities, exposesCalloraVault::capabilities(), registersmod test_capabilitiescontracts/vault/src/test_capabilities.rsdocs/CAPABILITIES.mdCapability bit registry
CAP_DEPOSITdeposit()CAP_WITHDRAWwithdraw()/withdraw_to()CAP_DEDUCTdeduct()CAP_BATCH_DEDUCTbatch_deduct()CAP_PAUSEpause()/unpause()CAP_AUTHORIZED_CALLERset_authorized_caller()CAP_OFFERING_METADATACAP_PRICE_REGISTRYCAP_REQUEST_IDEMPOTENCYrequest_iddedupCAP_TWO_STEP_OWNERSHIPCAP_TWO_STEP_ADMINCAP_SETTLEMENTCAP_REVENUE_POOLCAP_RATE_LIMITCAP_ADMIN_BROADCASTbroadcast()CAP_DEPOSITOR_ALLOWLISTCAP_SLIPPAGE_GUARDmax_fee_bpsguardCAP_UPGRADEupgrade()Test plan
25 tests in
test_capabilities.rscover:capabilities()returnsALL_CAPABILITIESconstantCAP_*bits is individually setCAP_*constants share a bit (no-overlap invariant)ALL_CAPABILITIES(no gaps)Note: The upstream repository has pre-existing compilation errors in
contracts/vault/src/lib.rs(duplicatebroadcastandget_max_deductfunction definitions) andcontracts/settlement/src/lib.rsthat preventcargo testfrom executing. None of these errors are in the new capabilities code — verified bygrep capabilitiesreturning no hits in the compiler error output. The capability module itself is correct and self-consistent.