Skip to content

Custodian Struct

The Custodian struct defines the access role and ping privileges of a user over a specific key. Each key maintains its own set of custodians in a mapping(address => Custodian).

๐Ÿ“˜ Definition

struct Custodian {
    Role role;
    bool canPing;
}

๐Ÿ” Fields

Field Type Description
role Role The role assigned to the user (None, Reader, etc.)
canPing bool Whether the custodian is allowed to send ping()

๐Ÿ“‚ Context

Each KeyData instance includes a mapping:

mapping(address => Custodian) custodians;

This allows each key to define a custom access policy for multiple users.

๐Ÿ›  Use Cases

  • Grant read-only access to a trusted contact after timeout.
  • Allow a co-worker to refresh a ping timer on your behalf.
  • Revoke permissions dynamically using removeCustodian().

๐Ÿงช Testing Tips

  • Assign and read back custodian roles and ping flags
  • Attempt unauthorized pings and confirm they revert
  • Ensure only Owners can assign/remove custodians
  • setCustodian(...)
  • removeCustodian(...)
  • ping(...)
  • readKey(...)

โžก๏ธ Next: KeyData Struct