pub struct CapabilityGrant {
pub pool_id: B256,
pub signer: Address,
pub spending_cap: u64,
pub expiry: u64,
pub owner_signature: Vec<u8>,
}Expand description
A pool owner’s SignedCapability in its transferable, self-contained form.
Postcard-encoded and base64url-wrapped by Self::to_token. The owner
signature is held as raw bytes (65-byte r‖s‖v, exactly
Signature::as_bytes) rather than an alloy Signature so the wire shape
is a plain byte string that postcard round-trips without a human-readable
branch.
Fields§
§pool_id: B256The on-chain pool the grant draws from.
signer: AddressThe delegate voucher-signing key the owner authorizes.
spending_cap: u64Cumulative spend ceiling (token base units) for signer under this
grant. A u64, matching Capability::spending_cap and the
PaymentPool.spendingCap on-chain width.
expiry: u64Unix-seconds expiry after which vouchers under this grant stop being redeemable.
owner_signature: Vec<u8>The owner’s raw EIP-712 signature over the capability (65 bytes,
r‖s‖v).
Implementations§
Source§impl CapabilityGrant
impl CapabilityGrant
Sourcepub fn from_signed_capability(signed: &SignedCapability) -> Self
pub fn from_signed_capability(signed: &SignedCapability) -> Self
Build a grant from an already-signed capability, copying its owner signature into the token’s raw-bytes field.
Sourcepub fn to_token(&self) -> String
pub fn to_token(&self) -> String
Encode the grant as a dcap1: token: the prefix followed by the
base64url (no padding) of its postcard encoding.
§Panics
Never — postcard encoding of a fixed-shape struct into a growable Vec
does not fail, so the Result is unwrapped to an empty body on the
unreachable error rather than propagated.
Sourcepub fn from_token(s: &str) -> Result<Self, GrantError>
pub fn from_token(s: &str) -> Result<Self, GrantError>
Parse and validate a dcap1: token back into a grant.
§Errors
GrantError::BadPrefix— thedcap1:prefix is absent.GrantError::BadBase64— the body is not valid base64url.GrantError::BadPayload— the decoded bytes are not a postcardCapabilityGrant.
Sourcepub fn to_signed_capability(&self) -> Result<SignedCapability, GrantError>
pub fn to_signed_capability(&self) -> Result<SignedCapability, GrantError>
Reconstruct the SignedCapability this grant carries, ready for
PoolContext::with_capability.
§Errors
GrantError::BadSignature when owner_signature is not a well-formed
65-byte ECDSA signature.
Sourcepub fn owner(&self, domain: &Eip712Domain) -> Result<Address, GrantOwnerError>
pub fn owner(&self, domain: &Eip712Domain) -> Result<Address, GrantOwnerError>
Recover the pool owner that signed this grant under domain, for display
and validation.
§Errors
GrantError::BadSignature— the embedded signature is malformed.CapabilityError::InvalidSignatureviaGrantOwnerError— the signature is non-canonical (high-s) or unrecoverable.
Trait Implementations§
Source§impl Clone for CapabilityGrant
impl Clone for CapabilityGrant
Source§impl Debug for CapabilityGrant
impl Debug for CapabilityGrant
Source§impl<'de> Deserialize<'de> for CapabilityGrant
impl<'de> Deserialize<'de> for CapabilityGrant
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for CapabilityGrant
Source§impl PartialEq for CapabilityGrant
impl PartialEq for CapabilityGrant
Source§impl Serialize for CapabilityGrant
impl Serialize for CapabilityGrant
impl StructuralPartialEq for CapabilityGrant
Auto Trait Implementations§
impl Freeze for CapabilityGrant
impl RefUnwindSafe for CapabilityGrant
impl Send for CapabilityGrant
impl Sync for CapabilityGrant
impl Unpin for CapabilityGrant
impl UnsafeUnpin for CapabilityGrant
impl UnwindSafe for CapabilityGrant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<'de, T> BorrowedRpcObject<'de> for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more