Skip to content
Lattice

SafeHarborAdopterLib

Git Source

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

NameTypeDescription
$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

NameTypeDescription
_registryaddressThe SEAL SafeHarborRegistry for this chain.
_factoryaddressThe 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

NameTypeDescription
agreementaddressThe 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

NameTypeDescription
detailsAgreementDetailsThe agreement details (recovery addresses, accounts, bounty terms).
chainValidatoraddressThe SEAL ChainValidator contract for this chain.
owneraddressThe owner of the new agreement.
saltbytes32A caller-provided salt for CREATE2 uniqueness.

Returns

NameTypeDescription
agreementaddressThe 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

NameTypeDescription
_registryaddressThe Safe Harbor registry to use.

setAgreementFactory

Sets or rotates the agreement factory. Gated on SAFE_HARBOR_ADMIN_ROLE.

function setAgreementFactory(address _factory) internal;

Parameters

NameTypeDescription
_factoryaddressThe agreement factory to use.

safeHarborRegistry

Returns the configured Safe Harbor registry.

function safeHarborRegistry() internal view returns (address);

Returns

NameTypeDescription
<none>address

agreementFactory

Returns the configured agreement factory.

function agreementFactory() internal view returns (address);

Returns

NameTypeDescription
<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

NameTypeDescription
<none>address