Shared

Contains interfaces and contracts used across the project.

Contracts

INftOwnable

import "@etherisc/gif-next/contracts/shared/INftOwnable.sol";
Functions
  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

IRegistryLinked
  • [getRegistry()]

IERC165
  • [supportsInterface(interfaceId)]

Events
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

linkToRegisteredNftId() → NftId external

getNftId() → NftId external

getOwner() → address external

LogNftOwnableNftLinkedToAddress(NftId nftId, address owner) event

IPolicyHolder

import "@etherisc/gif-next/contracts/shared/IPolicyHolder.sol";

Generic interface for contracts that need to hold policies and receive payouts. The framework notifies policy holder contracts for policy creation/expiry, claim confirmation and payout execution

Functions
  • [policyActivated(policyNftId, activatedAt)]

  • [policyExpired(policyNftId, expiredAt)]

  • [claimConfirmed(policyNftId, claimId, amount)]

  • [payoutExecuted(policyNftId, payoutId, amount, beneficiary)]

IRegistryLinked
  • [getRegistry()]

IERC721Receiver
  • [onERC721Received(operator, from, tokenId, data)]

IERC165
  • [supportsInterface(interfaceId)]

policyActivated(NftId policyNftId, Timestamp activatedAt) external

Callback function that will be called after successful policy activation. Active policies may open claims under the activated policy.

policyExpired(NftId policyNftId, Timestamp expiredAt) external

Callback function to indicate the specified policy has expired. expired policies no longer accept new claims.

claimConfirmed(NftId policyNftId, ClaimId claimId, Amount amount) external

Callback function to notify the confirmation of the specified claim.

payoutExecuted(NftId policyNftId, PayoutId payoutId, Amount amount, address beneficiary) external

Callback function to notify the successful payout.

IRegisterable

import "@etherisc/gif-next/contracts/shared/IRegisterable.sol";

Marks contracts that are intended to be registered in the registry.

Functions
  • [isActive()]

  • [getInitialInfo()]

IRelease
  • [getRelease()]

INftOwnable
  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

IRegistryLinked
  • [getRegistry()]

IERC165
  • [supportsInterface(interfaceId)]

IAccessManaged
  • [authority()]

  • [setAuthority()]

  • [isConsumingScheduledOp()]

Events
INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

isActive() → bool active external

Returns true iff this contract managed by its authority is active. Queries the IAccessManaged.authority().

getInitialInfo() → struct IRegistry.ObjectInfo external

retuns the object info relevant for registering for this contract IMPORTANT information returned by this function may only be used before the contract is registered in the registry. Once registered this information MUST only be accessed via the registry.

IRegistryLinked

import "@etherisc/gif-next/contracts/shared/IRegistryLinked.sol";
Functions
  • [getRegistry()]

getRegistry() → contract IRegistry external

IService

import "@etherisc/gif-next/contracts/shared/IService.sol";
Functions
  • [getDomain()]

  • [getRoleId()]

IVersionable
  • [initializeVersionable(activatedBy, activationData)]

  • [upgradeVersionable(upgradeData)]

  • [getVersion()]

IRegisterable
  • [isActive()]

  • [getInitialInfo()]

IRelease
  • [getRelease()]

INftOwnable
  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

IRegistryLinked
  • [getRegistry()]

IERC165
  • [supportsInterface(interfaceId)]

IAccessManaged
  • [authority()]

  • [setAuthority()]

  • [isConsumingScheduledOp()]

Events
INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

getDomain() → ObjectType serviceDomain external

returns the domain for this service. In any GIF release only one service for any given domain may be deployed.

getRoleId() → RoleId serviceRoleId external

returns the GIF release specific role id. These role ids are used to authorize service to service communication.

NftOwnable

import "@etherisc/gif-next/contracts/shared/NftOwnable.sol";
Functions
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

Initializable
  • [Initialized(version)]

onlyOwner() modifier

enforces msg.sender is owner of nft (or initial owner of nft ownable)

onlyNftOwner(NftId nftId) modifier

onlyNftOfType(NftId nftId, ObjectType expectedObjectType) modifier

_checkNftType(NftId nftId, ObjectType expectedObjectType) internal

__NftOwnable_init(address registry, address initialOwner) internal

Initialization for upgradable contracts.

linkToRegisteredNftId() → NftId nftId public

links this contract to nft after registration

getNftId() → NftId public

getOwner() → address public

_linkToNftOwnable(address nftOwnableAddress) → NftId internal

used in constructor of registry service manager

PolicyHolder

import "@etherisc/gif-next/contracts/shared/PolicyHolder.sol";

template implementation for IPolicyHolder

Functions
  • [_initializePolicyHolder(registryAddress)]

  • [policyActivated(policyNftId, activatedAt)]

  • [policyExpired(policyNftId, expiredAt)]

  • [claimConfirmed(policyNftId, claimId, amount)]

  • [payoutExecuted(policyNftId, payoutId, amount, beneficiary)]

  • [onERC721Received(, , , )]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
Initializable
  • [Initialized(version)]

_initializePolicyHolder(address registryAddress) internal

policyActivated(NftId policyNftId, Timestamp activatedAt) external

empty default implementation

policyExpired(NftId policyNftId, Timestamp expiredAt) external

empty default implementation

claimConfirmed(NftId policyNftId, ClaimId claimId, Amount amount) external

empty default implementation

payoutExecuted(NftId policyNftId, PayoutId payoutId, Amount amount, address beneficiary) external

empty default implementation

onERC721Received(address, address, uint256, bytes) → bytes4 external

Registerable

import "@etherisc/gif-next/contracts/shared/Registerable.sol";
Modifiers
Functions
  • [__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)]

  • [isActive()]

  • [getRelease()]

  • [getInitialInfo()]

NftOwnable
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

AccessManagedUpgradeable
  • [__AccessManaged_init(initialAuthority)]

  • [__AccessManaged_init_unchained(initialAuthority)]

  • [authority()]

  • [setAuthority(newAuthority)]

  • [isConsumingScheduledOp()]

  • [_setAuthority(newAuthority)]

  • [_checkCanCall(caller, data)]

ContextUpgradeable
  • [__Context_init()]

  • [__Context_init_unchained()]

  • [_msgSender()]

  • [_msgData()]

  • [_contextSuffixLength()]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

onlyActive() modifier

__Registerable_init(address authority, address registry, NftId parentNftId, ObjectType objectType, bool isInterceptor, address initialOwner, bytes data) internal

isActive() → bool active public

Returns true iff this contract managed by its authority is active. Queries the IAccessManaged.authority().

getRelease() → VersionPart release public

Registers a registry contract for a specified chain. Only one chain registry may be registered per chain

getInitialInfo() → struct IRegistry.ObjectInfo info public

retuns the object info relevant for registering for this contract IMPORTANT information returned by this function may only be used before the contract is registered in the registry. Once registered this information MUST only be accessed via the registry.

RegistryLinked

import "@etherisc/gif-next/contracts/shared/RegistryLinked.sol";
Functions
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
Initializable
  • [Initialized(version)]

__RegistryLinked_init(address registry) internal

initialization for upgradable contracts

getRegistry() → contract IRegistry public

Service

import "@etherisc/gif-next/contracts/shared/Service.sol";

service base contract

Functions
  • [__Service_init(authority, registry, initialOwner)]

  • [getDomain()]

  • [getVersion()]

  • [getRoleId()]

  • [_getDomain()]

  • [_getServiceAddress(domain)]

ReentrancyGuardUpgradeable
  • [__ReentrancyGuard_init()]

  • [__ReentrancyGuard_init_unchained()]

  • [_reentrancyGuardEntered()]

Versionable
  • [initializeVersionable(activatedBy, data)]

  • [upgradeVersionable(data)]

  • [_initialize(, )]

  • [_upgrade(data)]

Registerable
  • [__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)]

  • [isActive()]

  • [getRelease()]

  • [getInitialInfo()]

NftOwnable
  • [_checkNftType(nftId, expectedObjectType)]

  • [__NftOwnable_init(registry, initialOwner)]

  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

  • [_linkToNftOwnable(nftOwnableAddress)]

RegistryLinked
  • [__RegistryLinked_init(registry)]

  • [getRegistry()]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

AccessManagedUpgradeable
  • [__AccessManaged_init(initialAuthority)]

  • [__AccessManaged_init_unchained(initialAuthority)]

  • [authority()]

  • [setAuthority(newAuthority)]

  • [isConsumingScheduledOp()]

  • [_setAuthority(newAuthority)]

  • [_checkCanCall(caller, data)]

ContextUpgradeable
  • [__Context_init()]

  • [__Context_init_unchained()]

  • [_msgSender()]

  • [_msgData()]

  • [_contextSuffixLength()]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

__Service_init(address authority, address registry, address initialOwner) internal

getDomain() → ObjectType serviceDomain external

returns the domain for this service. In any GIF release only one service for any given domain may be deployed.

getVersion() → Version public

getRoleId() → RoleId serviceRoleId external

returns the GIF release specific role id. These role ids are used to authorize service to service communication.

_getDomain() → ObjectType internal

_getServiceAddress(ObjectType domain) → address internal

TokenHandler

import "@etherisc/gif-next/contracts/shared/TokenHandler.sol";

Token specific transfer helper. Contract is derived from TokenHandlerBase and adds authorization based on OpenZeppelin AccessManaged.

Modifiers
Functions
  • [constructor(registry, component, token, authority)]

  • [setWallet(newWallet)]

  • [approve(token, amount)]

  • [pullToken(from, amount)]

  • [pushToken(to, amount)]

  • [pushFeeToken(to, amount)]

TokenHandlerBase
  • [checkBalanceAndAllowance(from, amount, checkAmount)]

  • [getWallet()]

  • [_approve(token, amount)]

  • [_setWallet(newWallet)]

  • [_pullToken(from, amount)]

  • [_pushToken(to, amount)]

  • [_transfer(from, to, amount, checkPreconditions)]

  • [_checkBalanceAndAllowance(from, amount, checkAmount)]

AccessManaged
  • [authority()]

  • [setAuthority(newAuthority)]

  • [isConsumingScheduledOp()]

  • [_setAuthority(newAuthority)]

  • [_checkCanCall(caller, data)]

Events
TokenHandlerBase
  • [LogTokenHandlerWalletAddressChanged(componentNftId, oldWallet, newWallet)]

  • [LogTokenHandlerWalletTokensTransferred(componentNftId, oldWallet, newWallet, amount)]

  • [LogTokenHandlerTokenApproved(nftId, tokenHandler, token, amount, isMaxAmount)]

  • [LogTokenHandlerTokenTransfer(token, from, to, amount)]

IAccessManaged
  • [AuthorityUpdated(authority)]

onlyService() modifier

constructor(address registry, address component, address token, address authority) public

setWallet(address newWallet) external

Sets the wallet address for the component. Seeting the new wallet address to address(0) will set the wallet to the tokenHandler contract itself. If the current wallet has tokens, these will be transferred. If the new wallet address is externally owned, an approval from the owner of the external wallet to the tokenhandler of the component that covers the current component balance must exist.

approve(contract IERC20Metadata token, Amount amount) external

Approves token handler to spend up to the specified amount of tokens. Sets spending limit to type(uint256).max for AmountLib.max(). Reverts if component wallet is not component itself. Sets approvel using SareERC20.forceApprove internally.

pullToken(address from, Amount amount) external

Collect tokens from outside of GIF and transfer them to the wallet. This method also checks balance and allowance and makes sure the amount is greater than zero.

pushToken(address to, Amount amount) external

Distribute tokens from a wallet within the scope of gif to some address.

pushFeeToken(address to, Amount amount) external

Distribute fee tokens from a wallet within the scope of gif to some address. Separate push function for component service.