add operator-model to contexts + local-chain test harness#2
Merged
Conversation
contexts: - add operator mapping with add_operator/remove_operator/transfer_owner; is_authorized + back-compat is_owner returns true for owner OR operator - register_context now takes (context_id, owner, operator) - README documents the new owner/operator split and migration recipe test harness (src/, all bun scripts): - test-contexts.ts: 38 assertions against a locally-deployed contexts - deploy-contexts.ts: directly instantiates contexts via Revive on a chopsticks local chain, bypassing cdm deploy (which requires an IPFS gateway) - setup-local.ts: queries the on-chain Contract Registry for deployed addresses and writes them into cdm.json under the local target - package.json: adds setup:local / deploy:contexts / test:contexts scripts and the supporting dev dependencies
Disputes Deployment Failed
|
|
|
||
| #[pvm::storage] | ||
| struct Storage { | ||
| context_owners: Mapping<ContextId, Address>, |
Collaborator
There was a problem hiding this comment.
unrelated cleanup: lets update variable name to context_owner
| #[pvm::storage] | ||
| struct Storage { | ||
| context_owners: Mapping<ContextId, Address>, | ||
| context_operators: Mapping<(ContextId, Address), bool>, |
Collaborator
There was a problem hiding this comment.
NIT: micro optimization, but I wonder if we can have this mapping to a "phantom" value to save the boolean space (since we only need to check the value exists and can delete the entry on delete instead of setting bool to false)
| } | ||
|
|
||
| #[pvm::method] | ||
| pub fn add_operator(context_id: ContextId, operator: Address) { |
Collaborator
There was a problem hiding this comment.
lets support batching
add_operator-->add_operators,- make
operatorsa vec
same for remove_operator
charlesHetterich
approved these changes
May 15, 2026
charlesHetterich
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, please address contract changes before merging (feel free to ignore NIT)
Nit: map to () instead of bool
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.
contexts:
test harness (src/, all bun scripts):