Skip to content

pickGrant

pickGrant<T>(grants, target, options): T | undefined

Defined in: claims.ts:412

The narrowest held grant that reaches target: a piece grant before a group grant, a deeper group before a shallower one, the group key last; on a tie, the one that expires last. Grants for another network or group key, or expired ones, or whose node does not parse, are skipped. Undefined when none reaches it: ask for a grant to that group or piece.

Takes anything carrying a verified claim, such as what openDelivery returns.

Grants are matched to one owner, never to any owner: a grant’s owner and group key id are public, so anyone can root a grant under another wallet’s group key id. A group target names its owner. A piece target takes it from the piece’s foc/own; a piece without one (not gated) needs options.owner. When both are present they must match.

Type Parameter
T extends object
Parameter Type
grants readonly T[]
target GrantTarget
options { chainId: bigint; now?: number; owner?: `0x${string}`; }
options.chainId bigint
options.now? number
options.owner? `0x${string}`

T | undefined

If no owner can be fixed, options.owner contradicts the piece’s foc/own, or a label is malformed.