跳到主要内容

JBBuybackHookRegistry

Git Source

Inherits: IJBBuybackHookRegistry, ERC2771Context, JBPermissioned, Ownable

State Variables

PROJECTS

The project registry.

IJBProjects public immutable override PROJECTS;

defaultHook

The default hook to use.

IJBRulesetDataHook public override defaultHook;

hasLockedHook

Whether the hook for the given project is locked.

mapping(uint256 projectId => bool) public override hasLockedHook;

hookOf

The hook for the given project.

mapping(uint256 projectId => IJBRulesetDataHook) public override hookOf;

isHookAllowed

The address of each project's token.

mapping(IJBRulesetDataHook hook => bool) public override isHookAllowed;

Functions

constructor

constructor(
IJBPermissions permissions,
IJBProjects projects,
address owner,
address trustedForwarder
)
JBPermissioned(permissions)
ERC2771Context(trustedForwarder)
Ownable(owner);

Parameters

NameTypeDescription
permissionsIJBPermissionsThe permissions contract.
projectsIJBProjectsThe project registry.
owneraddressThe owner of the contract.
trustedForwarderaddressA trusted forwarder of transactions to this contract.

beforePayRecordedWith

Forward the call to the hook for the project.

function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
external
view
override
returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications);

beforeCashOutRecordedWith

To fulfill the IJBRulesetDataHook interface.

Pass cash out context back to the terminal without changes.

function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
external
pure
override
returns (uint256, uint256, uint256, JBCashOutHookSpecification[] memory hookSpecifications);

Parameters

NameTypeDescription
contextJBBeforeCashOutRecordedContextThe cash out context passed in by the terminal.

hasMintPermissionFor

Make sure the hook has mint permission.

function hasMintPermissionFor(
uint256 projectId,
JBRuleset memory,
address addr
)
external
view
override
returns (bool);

Parameters

NameTypeDescription
projectIduint256The ID of the project to check the mint permission for.
<none>JBRuleset
addraddressThe address to check the mint permission for.

Returns

NameTypeDescription
<none>boolWhether the address has mint permission.

supportsInterface

function supportsInterface(bytes4 interfaceId) public pure override returns (bool);

_contextSuffixLength

ERC-2771 specifies the context as being a single address (20 bytes).

function _contextSuffixLength() internal view override(ERC2771Context, Context) returns (uint256);

_msgData

The calldata. Preferred to use over msg.data.

function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata);

Returns

NameTypeDescription
<none>bytescalldata The msg.data of this call.

_msgSender

The message's sender. Preferred to use over msg.sender.

function _msgSender() internal view override(ERC2771Context, Context) returns (address sender);

Returns

NameTypeDescription
senderaddressThe address which sent this call.

allowHook

Allow a hook.

Only the owner can allow a hook.

function allowHook(IJBRulesetDataHook hook) external onlyOwner;

Parameters

NameTypeDescription
hookIJBRulesetDataHookThe hook to allow.

disallowHook

Disallow a hook.

Only the owner can disallow a hook.

function disallowHook(IJBRulesetDataHook hook) external onlyOwner;

Parameters

NameTypeDescription
hookIJBRulesetDataHookThe hook to disallow.

lockHookFor

Lock a hook for a project.

Only the project's owner or an address with the JBPermissionIds.SET_BUYBACK_POOL permission from the owner can lock a hook for a project.

function lockHookFor(uint256 projectId) external;

Parameters

NameTypeDescription
projectIduint256The ID of the project to lock the hook for.

setDefaultHook

Set the default hook.

Only the owner can set the default hook.

function setDefaultHook(IJBRulesetDataHook hook) external onlyOwner;

Parameters

NameTypeDescription
hookIJBRulesetDataHookThe hook to set as the default.

setHookFor

Set the hook for a project.

Only the project's owner or an address with the JBPermissionIds.SET_BUYBACK_POOL permission from the owner can set the hook for a project.

function setHookFor(uint256 projectId, IJBRulesetDataHook hook) external;

Parameters

NameTypeDescription
projectIduint256The ID of the project to set the hook for.
hookIJBRulesetDataHookThe hook to set for the project.

Errors

JBBuybackHookRegistry_HookLocked

error JBBuybackHookRegistry_HookLocked(uint256 projectId);

JBBuybackHookRegistry_HookNotAllowed

error JBBuybackHookRegistry_HookNotAllowed(IJBRulesetDataHook hook);

JBBuybackHookRegistry_HookNotSet

error JBBuybackHookRegistry_HookNotSet(uint256 projectId);