Skip to content

add operator-model to contexts + local-chain test harness#2

Merged
ReinhardHatko merged 2 commits into
mainfrom
rh/transferrable-contexts
May 21, 2026
Merged

add operator-model to contexts + local-chain test harness#2
ReinhardHatko merged 2 commits into
mainfrom
rh/transferrable-contexts

Conversation

@ReinhardHatko

Copy link
Copy Markdown
Contributor

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

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
@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown

Disputes Deployment Failed

Stage Status
Build Built
Deploy Failed

View workflow run

Comment thread src/contracts/contexts/lib.rs Outdated

#[pvm::storage]
struct Storage {
context_owners: Mapping<ContextId, Address>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

unrelated cleanup: lets update variable name to context_owner

Comment thread src/contracts/contexts/lib.rs Outdated
#[pvm::storage]
struct Storage {
context_owners: Mapping<ContextId, Address>,
context_operators: Mapping<(ContextId, Address), bool>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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)

Comment thread src/contracts/contexts/lib.rs Outdated
}

#[pvm::method]
pub fn add_operator(context_id: ContextId, operator: Address) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets support batching

  • add_operator --> add_operators,
  • make operators a vec

same for remove_operator

@charlesHetterich charlesHetterich left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, please address contract changes before merging (feel free to ignore NIT)

@ReinhardHatko ReinhardHatko merged commit 453e6c9 into main May 21, 2026
5 of 6 checks passed
@ReinhardHatko ReinhardHatko deleted the rh/transferrable-contexts branch June 9, 2026 13:00
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.

2 participants