SafeHarborAdopterLib
Title: SafeHarborAdopterLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Integrates the SEAL Whitehat Safe Harbor (https://github.com/security-alliance/safe-harbor)
Library letting a diamond adopt the SEAL Whitehat Safe Harbor agreement on-chain — the legal half of incident response, complementing the EmergencyStop technical half.
Three-layer pattern: this library holds the logic + namespaced storage; the stateless
SafeHarborAdopter facet forwards to it. The diamond calls the registry itself
(msg.sender == diamond), so it is recorded as the adopter. All state-changing functions are
gated on SAFE_HARBOR_ADMIN_ROLE because the agreement designates the asset-recovery address.
Functions
safeHarborAdopterStorage
function safeHarborAdopterStorage() internal pure returns (SafeHarborAdopterStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | SafeHarborAdopterStorage |
__SafeHarborAdopter_init
Initializes the SafeHarborAdopter module.
Must be called inside a pre/postInitializer block. Reverts SafeHarborAdopterZeroRegistry
for a zero registry; the factory may be zero (set later to enable createAndAdopt).
Registers ISafeHarborAdopter for ERC-165 discovery.
function __SafeHarborAdopter_init(address _registry, address _factory) internal;Parameters
| Name | Type | Description |
|---|---|---|
| _registry | address | The SEAL SafeHarborRegistry for this chain. |
| _factory | address | The SEAL AgreementFactory for this chain (zero allowed). |
registerInterface
Registers support for the ISafeHarborAdopter interface via ERC-165.
function registerInterface() internal;adoptSafeHarbor
Adopts a pre-deployed agreement for this diamond. Gated on SAFE_HARBOR_ADMIN_ROLE.
function adoptSafeHarbor(address agreement) internal;Parameters
| Name | Type | Description |
|---|---|---|
| agreement | address | The agreement contract to adopt. |
createAndAdopt
Creates an agreement via the factory and adopts it. Gated on SAFE_HARBOR_ADMIN_ROLE.
function createAndAdopt(AgreementDetails calldata details, address chainValidator, address owner, bytes32 salt)
internal
returns (address agreement);Parameters
| Name | Type | Description |
|---|---|---|
| details | AgreementDetails | The agreement details (recovery addresses, accounts, bounty terms). |
| chainValidator | address | The SEAL ChainValidator contract for this chain. |
| owner | address | The owner of the new agreement. |
| salt | bytes32 | A caller-provided salt for CREATE2 uniqueness. |
Returns
| Name | Type | Description |
|---|---|---|
| agreement | address | The newly created and adopted agreement address. |
setSafeHarborRegistry
Sets or rotates the Safe Harbor registry. Gated on SAFE_HARBOR_ADMIN_ROLE.
function setSafeHarborRegistry(address _registry) internal;Parameters
| Name | Type | Description |
|---|---|---|
| _registry | address | The Safe Harbor registry to use. |
setAgreementFactory
Sets or rotates the agreement factory. Gated on SAFE_HARBOR_ADMIN_ROLE.
function setAgreementFactory(address _factory) internal;Parameters
| Name | Type | Description |
|---|---|---|
| _factory | address | The agreement factory to use. |
safeHarborRegistry
Returns the configured Safe Harbor registry.
function safeHarborRegistry() internal view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
agreementFactory
Returns the configured agreement factory.
function agreementFactory() internal view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
safeHarborAgreement
Returns the agreement currently adopted by this diamond (zero if none).
The SEAL registry reverts SafeHarborRegistry__NoAgreement when this diamond has not
adopted — that case is treated as "none" (zero). Any OTHER revert (e.g. a mis-set registry)
is re-surfaced rather than silently masked.
function safeHarborAgreement() internal view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |