Shared
Contains interfaces and contracts used across the project.
Contracts
INftOwnable 
import "@etherisc/gif-next/contracts/shared/INftOwnable.sol";
- 
[
linkToRegisteredNftId()] - 
[
getNftId()] - 
[
getOwner()] 
- 
[
getRegistry()] 
- 
[
supportsInterface(interfaceId)] 
- 
[
LogNftOwnableNftLinkedToAddress(nftId, owner)] 
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
- 
[
policyActivated(policyNftId, activatedAt)] - 
[
policyExpired(policyNftId, expiredAt)] - 
[
claimConfirmed(policyNftId, claimId, amount)] - 
[
payoutExecuted(policyNftId, payoutId, amount, beneficiary)] 
- 
[
getRegistry()] 
- 
[
onERC721Received(operator, from, tokenId, data)] 
- 
[
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.
IRegisterable 
import "@etherisc/gif-next/contracts/shared/IRegisterable.sol";
Marks contracts that are intended to be registered in the registry.
- 
[
isActive()] - 
[
getInitialInfo()] 
- 
[
getRelease()] 
- 
[
linkToRegisteredNftId()] - 
[
getNftId()] - 
[
getOwner()] 
- 
[
getRegistry()] 
- 
[
supportsInterface(interfaceId)] 
- 
[
authority()] - 
[
setAuthority()] - 
[
isConsumingScheduledOp()] 
- 
[
LogNftOwnableNftLinkedToAddress(nftId, owner)] 
- 
[
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";
- 
[
getRegistry()] 
IService 
import "@etherisc/gif-next/contracts/shared/IService.sol";
- 
[
getDomain()] - 
[
getRoleId()] 
- 
[
initializeVersionable(activatedBy, activationData)] - 
[
upgradeVersionable(upgradeData)] - 
[
getVersion()] 
- 
[
isActive()] - 
[
getInitialInfo()] 
- 
[
getRelease()] 
- 
[
linkToRegisteredNftId()] - 
[
getNftId()] - 
[
getOwner()] 
- 
[
getRegistry()] 
- 
[
supportsInterface(interfaceId)] 
- 
[
authority()] - 
[
setAuthority()] - 
[
isConsumingScheduledOp()] 
- 
[
LogNftOwnableNftLinkedToAddress(nftId, owner)] 
- 
[
AuthorityUpdated(authority)] 
NftOwnable 
import "@etherisc/gif-next/contracts/shared/NftOwnable.sol";
- 
[
_checkNftType(nftId, expectedObjectType)] - 
[
__NftOwnable_init(registry, initialOwner)] - 
[
linkToRegisteredNftId()] - 
[
getNftId()] - 
[
getOwner()] - 
[
_linkToNftOwnable(nftOwnableAddress)] 
- 
[
__RegistryLinked_init(registry)] - 
[
getRegistry()] 
- 
[
__ERC165_init()] - 
[
_initializeERC165()] - 
[
_registerInterface(interfaceId)] - 
[
_registerInterfaceNotInitializing(interfaceId)] - 
[
supportsInterface(interfaceId)] 
- 
[
_checkInitializing()] - 
[
_disableInitializers()] - 
[
_getInitializedVersion()] - 
[
_isInitializing()] 
- 
[
LogNftOwnableNftLinkedToAddress(nftId, owner)] 
- 
[
Initialized(version)] 
PolicyHolder 
import "@etherisc/gif-next/contracts/shared/PolicyHolder.sol";
template implementation for IPolicyHolder
- 
[
_initializePolicyHolder(registryAddress)] - 
[
policyActivated(policyNftId, activatedAt)] - 
[
policyExpired(policyNftId, expiredAt)] - 
[
claimConfirmed(policyNftId, claimId, amount)] - 
[
payoutExecuted(policyNftId, payoutId, amount, beneficiary)] - 
[
onERC721Received(, , , )] 
- 
[
__RegistryLinked_init(registry)] - 
[
getRegistry()] 
- 
[
__ERC165_init()] - 
[
_initializeERC165()] - 
[
_registerInterface(interfaceId)] - 
[
_registerInterfaceNotInitializing(interfaceId)] - 
[
supportsInterface(interfaceId)] 
- 
[
_checkInitializing()] - 
[
_disableInitializers()] - 
[
_getInitializedVersion()] - 
[
_isInitializing()] 
- 
[
Initialized(version)] 
claimConfirmed(NftId policyNftId, ClaimId claimId, Amount amount) external
empty default implementation
Registerable 
import "@etherisc/gif-next/contracts/shared/Registerable.sol";
- 
[
__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)] - 
[
isActive()] - 
[
getRelease()] - 
[
getInitialInfo()] 
- 
[
_checkNftType(nftId, expectedObjectType)] - 
[
__NftOwnable_init(registry, initialOwner)] - 
[
linkToRegisteredNftId()] - 
[
getNftId()] - 
[
getOwner()] - 
[
_linkToNftOwnable(nftOwnableAddress)] 
- 
[
__RegistryLinked_init(registry)] - 
[
getRegistry()] 
- 
[
__ERC165_init()] - 
[
_initializeERC165()] - 
[
_registerInterface(interfaceId)] - 
[
_registerInterfaceNotInitializing(interfaceId)] - 
[
supportsInterface(interfaceId)] 
- 
[
__AccessManaged_init(initialAuthority)] - 
[
__AccessManaged_init_unchained(initialAuthority)] - 
[
authority()] - 
[
setAuthority(newAuthority)] - 
[
isConsumingScheduledOp()] - 
[
_setAuthority(newAuthority)] - 
[
_checkCanCall(caller, data)] 
- 
[
__Context_init()] - 
[
__Context_init_unchained()] - 
[
_msgSender()] - 
[
_msgData()] - 
[
_contextSuffixLength()] 
- 
[
_checkInitializing()] - 
[
_disableInitializers()] - 
[
_getInitializedVersion()] - 
[
_isInitializing()] 
- 
[
LogNftOwnableNftLinkedToAddress(nftId, owner)] 
- 
[
AuthorityUpdated(authority)] 
- 
[
Initialized(version)] 
__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";
- 
[
__RegistryLinked_init(registry)] - 
[
getRegistry()] 
- 
[
_checkInitializing()] - 
[
_disableInitializers()] - 
[
_getInitializedVersion()] - 
[
_isInitializing()] 
- 
[
Initialized(version)] 
Service 
import "@etherisc/gif-next/contracts/shared/Service.sol";
service base contract
- 
[
__Service_init(authority, registry, initialOwner)] - 
[
getDomain()] - 
[
getVersion()] - 
[
getRoleId()] - 
[
_getDomain()] - 
[
_getServiceAddress(domain)] 
- 
[
__ReentrancyGuard_init()] - 
[
__ReentrancyGuard_init_unchained()] - 
[
_reentrancyGuardEntered()] 
- 
[
initializeVersionable(activatedBy, data)] - 
[
upgradeVersionable(data)] - 
[
_initialize(, )] - 
[
_upgrade(data)] 
- 
[
__Registerable_init(authority, registry, parentNftId, objectType, isInterceptor, initialOwner, data)] - 
[
isActive()] - 
[
getRelease()] - 
[
getInitialInfo()] 
- 
[
_checkNftType(nftId, expectedObjectType)] - 
[
__NftOwnable_init(registry, initialOwner)] - 
[
linkToRegisteredNftId()] - 
[
getNftId()] - 
[
getOwner()] - 
[
_linkToNftOwnable(nftOwnableAddress)] 
- 
[
__RegistryLinked_init(registry)] - 
[
getRegistry()] 
- 
[
__ERC165_init()] - 
[
_initializeERC165()] - 
[
_registerInterface(interfaceId)] - 
[
_registerInterfaceNotInitializing(interfaceId)] - 
[
supportsInterface(interfaceId)] 
- 
[
__AccessManaged_init(initialAuthority)] - 
[
__AccessManaged_init_unchained(initialAuthority)] - 
[
authority()] - 
[
setAuthority(newAuthority)] - 
[
isConsumingScheduledOp()] - 
[
_setAuthority(newAuthority)] - 
[
_checkCanCall(caller, data)] 
- 
[
__Context_init()] - 
[
__Context_init_unchained()] - 
[
_msgSender()] - 
[
_msgData()] - 
[
_contextSuffixLength()] 
- 
[
_checkInitializing()] - 
[
_disableInitializers()] - 
[
_getInitializedVersion()] - 
[
_isInitializing()] 
- 
[
LogNftOwnableNftLinkedToAddress(nftId, owner)] 
- 
[
AuthorityUpdated(authority)] 
- 
[
Initialized(version)] 
getDomain() → ObjectType serviceDomain external
returns the domain for this service. In any GIF release only one service for any given domain may be deployed.
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.
- 
[
constructor(registry, component, token, authority)] - 
[
setWallet(newWallet)] - 
[
approve(token, amount)] - 
[
pullToken(from, amount)] - 
[
pushToken(to, amount)] - 
[
pushFeeToken(to, amount)] 
- 
[
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)] 
- 
[
authority()] - 
[
setAuthority(newAuthority)] - 
[
isConsumingScheduledOp()] - 
[
_setAuthority(newAuthority)] - 
[
_checkCanCall(caller, data)] 
- 
[
LogTokenHandlerWalletAddressChanged(componentNftId, oldWallet, newWallet)] - 
[
LogTokenHandlerWalletTokensTransferred(componentNftId, oldWallet, newWallet, amount)] - 
[
LogTokenHandlerTokenApproved(nftId, tokenHandler, token, amount, isMaxAmount)] - 
[
LogTokenHandlerTokenTransferred(token, from, to, amount)] 
- 
[
AuthorityUpdated(authority)] 
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.