Distribution

Contains interfaces and contracts related to distribution.

Contracts

IDistributionComponent

import "@etherisc/gif-next/contracts/distribution/IDistributionComponent.sol";
Functions
  • [getDiscountPercentage(referralCode)]

  • [getReferralId(referralCode)]

  • [calculateRenewalFeeAmount(referralId, netPremiumAmount)]

  • [processRenewal(referralId, feeAmount)]

  • [isVerifying()]

  • [withdrawCommission(distributorNftId, amount)]

IInstanceLinkedComponent
  • [withdrawFees(amount)]

  • [getInstance()]

IAuthorizedComponent
  • [getAuthorization()]

IComponent
  • [getName()]

  • [getToken()]

  • [getTokenHandler()]

  • [getWallet()]

  • [isNftInterceptor()]

  • [isRegistered()]

  • [getComponentInfo()]

  • [getInitialComponentInfo()]

ITransferInterceptor
  • [nftTransferFrom(from, to, tokenId, operator)]

IRegisterable
  • [isActive()]

  • [getInitialInfo()]

IRelease
  • [getRelease()]

INftOwnable
  • [linkToRegisteredNftId()]

  • [getNftId()]

  • [getOwner()]

IRegistryLinked
  • [getRegistry()]

IERC165
  • [supportsInterface(interfaceId)]

IAccessManaged
  • [authority()]

  • [setAuthority()]

  • [isConsumingScheduledOp()]

Events
  • [LogDistributorUpdated(to, operator)]

IComponent
  • [LogComponentWalletAddressChanged(oldWallet, newWallet)]

  • [LogComponentWalletTokensTransferred(from, to, amount)]

  • [LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

getDiscountPercentage(string referralCode) → UFixed discountPercentage, ReferralStatus status external

getReferralId(string referralCode) → ReferralId referralId external

calculateRenewalFeeAmount(ReferralId referralId, uint256 netPremiumAmount) → uint256 feeAmount external

processRenewal(ReferralId referralId, uint256 feeAmount) external

Callback function to process a renewal of a policy. The default implementation is empty. Overwrite this function to implement a use case specific behaviour.

isVerifying() → bool verifying external

Returns true to ensure component is called when transferring distributor Nft Ids.

withdrawCommission(NftId distributorNftId, Amount amount) → Amount withdrawnAmount external

Withdraw commission for the distributor

LogDistributorUpdated(address to, address operator) event

IDistributionService

import "@etherisc/gif-next/contracts/distribution/IDistributionService.sol";
Functions
  • [createDistributorType(name, minDiscountPercentage, maxDiscountPercentage, commissionPercentage, maxReferralCount, maxReferralLifetime, allowSelfReferrals, allowRenewals, data)]

  • [createDistributor(distributor, distributorType, data)]

  • [changeDistributorType(distributorNftId, newDistributorType, data)]

  • [createReferral(distributorNftId, code, discountPercentage, maxReferrals, expiryAt, data)]

  • [processReferral(distributionNftId, referralId)]

  • [processSale(distributionNftId, referralId, premium)]

  • [referralIsValid(distributorNftId, referralId)]

  • [withdrawCommission(distributorNftId, amount)]

  • [getDiscountPercentage(instanceReader, referralId)]

IService
  • [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
  • [LogDistributionServiceCommissionWithdrawn(distributorNftId, recipient, tokenAddress, amount)]

  • [LogDistributionServiceDistributorTypeCreated(distributionNftId, name)]

  • [LogDistributionServiceDistributorCreated(distributionNftId, distributorNftId, distributorType, distributor)]

  • [LogDistributionServiceDistributorTypeChanged(distributorNftId, oldDistributorType, newDistributorType)]

  • [LogDistributionServiceReferralCreated(distributionNftId, distributorNftId, referralId, code)]

  • [LogDistributionServiceReferralProcessed(distributionNftId, distributorNftId, referralId, usedReferrals)]

  • [LogDistributionServiceSaleProcessed(distributionNftId, referralId)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

createDistributorType(string name, UFixed minDiscountPercentage, UFixed maxDiscountPercentage, UFixed commissionPercentage, uint32 maxReferralCount, Seconds maxReferralLifetime, bool allowSelfReferrals, bool allowRenewals, bytes data) → DistributorType distributorType external

createDistributor(address distributor, DistributorType distributorType, bytes data) → NftId distributorNftId external

changeDistributorType(NftId distributorNftId, DistributorType newDistributorType, bytes data) external

createReferral(NftId distributorNftId, string code, UFixed discountPercentage, uint32 maxReferrals, Timestamp expiryAt, bytes data) → ReferralId referralId external

processReferral(NftId distributionNftId, ReferralId referralId) external

callback from product service when a referral is used. Calling this will increment the referral usage counter.

processSale(NftId distributionNftId, ReferralId referralId, struct IPolicy.PremiumInfo premium) external

callback from product service when selling a policy for a specific referralId

referralIsValid(NftId distributorNftId, ReferralId referralId) → bool isValid external

withdrawCommission(NftId distributorNftId, Amount amount) → Amount withdrawnAmount external

Withdraw commission for the distributor

getDiscountPercentage(contract InstanceReader instanceReader, ReferralId referralId) → UFixed discountPercentage, ReferralStatus status external

Returns the discount percentage for the provided referral code. The function retuns both the percentage and the status of the referral code.

LogDistributionServiceCommissionWithdrawn(NftId distributorNftId, address recipient, address tokenAddress, Amount amount) event

LogDistributionServiceDistributorTypeCreated(NftId distributionNftId, string name) event

LogDistributionServiceDistributorCreated(NftId distributionNftId, NftId distributorNftId, DistributorType distributorType, address distributor) event

LogDistributionServiceDistributorTypeChanged(NftId distributorNftId, DistributorType oldDistributorType, DistributorType newDistributorType) event

LogDistributionServiceReferralCreated(NftId distributionNftId, NftId distributorNftId, ReferralId referralId, string code) event

LogDistributionServiceReferralProcessed(NftId distributionNftId, NftId distributorNftId, ReferralId referralId, uint32 usedReferrals) event

LogDistributionServiceSaleProcessed(NftId distributionNftId, ReferralId referralId) event

Distribution

import "@etherisc/gif-next/contracts/distribution/Distribution.sol";
Functions
  • [processRenewal(referralId, feeAmount)]

  • [withdrawCommission(distributorNftId, amount)]

  • [getDiscountPercentage(referralCode)]

  • [getReferralId(referralCode)]

  • [calculateRenewalFeeAmount(, netPremiumAmount)]

  • [isVerifying()]

  • [__Distribution_init(registry, productNftId, authorization, isInterceptor, initialOwner, name)]

  • [_setFees(distributionFee, minDistributionOwnerFee)]

  • [_createDistributorType(name, minDiscountPercentage, maxDiscountPercentage, commissionPercentage, maxReferralCount, maxReferralLifetime, allowSelfReferrals, allowRenewals, data)]

  • [_createDistributor(distributor, distributorType, data)]

  • [_changeDistributorType(distributorNftId, distributorType, data)]

  • [_createReferral(distributorNftId, code, discountPercentage, maxReferrals, expiryAt, data)]

  • [_withdrawCommission(distributorNftId, amount)]

InstanceLinkedComponent
  • [getInstance()]

  • [getAuthorization()]

  • [withdrawFees(amount)]

  • [_sendRequest(oracleNftId, requestData, expiryAt, callbackMethod)]

  • [_cancelRequest(requestId)]

  • [_resendRequest(requestId)]

  • [__InstanceLinkedComponent_init(registry, parentNftId, name, componentType, authorization, isInterceptor, initialOwner)]

  • [_checkAndGetInstanceNftId(registryAddress, parentNftId, componentType)]

  • [_checkAndGetRegistry(registryAddress, objectNftId, requiredType)]

  • [_setWallet(newWallet)]

  • [_getComponentInfo()]

  • [_getInstanceReader()]

  • [_withdrawFees(amount)]

Component
  • [__Component_init(authority, registry, parentNftId, name, componentType, isInterceptor, initialOwner, registryData)]

  • [nftTransferFrom(from, to, tokenId, operator)]

  • [getWallet()]

  • [getTokenHandler()]

  • [getToken()]

  • [getName()]

  • [getVersion()]

  • [getComponentInfo()]

  • [getInitialComponentInfo()]

  • [isNftInterceptor()]

  • [isRegistered()]

  • [_approveTokenHandler(token, amount)]

  • [_nftTransferFrom(from, to, tokenId, operator)]

  • [_setLocked(locked)]

  • [_getServiceAddress(domain)]

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
IDistributionComponent
  • [LogDistributorUpdated(to, operator)]

IComponent
  • [LogComponentWalletAddressChanged(oldWallet, newWallet)]

  • [LogComponentWalletTokensTransferred(from, to, amount)]

  • [LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

processRenewal(ReferralId referralId, uint256 feeAmount) external

Callback function to process a renewal of a policy. The default implementation is empty. Overwrite this function to implement a use case specific behaviour.

withdrawCommission(NftId distributorNftId, Amount amount) → Amount withdrawnAmount external

Withdraw commission for the distributor

getDiscountPercentage(string referralCode) → UFixed discountPercentage, ReferralStatus status external

getReferralId(string referralCode) → ReferralId referralId public

calculateRenewalFeeAmount(ReferralId, uint256 netPremiumAmount) → uint256 feeAmount external

isVerifying() → bool verifying external

Returns true iff the component needs to be called when selling/renewing policis

__Distribution_init(address registry, NftId productNftId, contract IAuthorization authorization, bool isInterceptor, address initialOwner, string name) internal

_setFees(struct Fee distributionFee, struct Fee minDistributionOwnerFee) internal

Sets the distribution fees to the provided values.

_createDistributorType(string name, UFixed minDiscountPercentage, UFixed maxDiscountPercentage, UFixed commissionPercentage, uint32 maxReferralCount, Seconds maxReferralLifetime, bool allowSelfReferrals, bool allowRenewals, bytes data) → DistributorType distributorType internal

Creates a new distributor type using the provided parameters.

_createDistributor(address distributor, DistributorType distributorType, bytes data) → NftId distributorNftId internal

Turns the provided account into a new distributor of the specified type.

_changeDistributorType(NftId distributorNftId, DistributorType distributorType, bytes data) internal

Uptates the distributor type for the specified distributor.

_createReferral(NftId distributorNftId, string code, UFixed discountPercentage, uint32 maxReferrals, Timestamp expiryAt, bytes data) → ReferralId referralId internal

Create a new referral code for the provided distributor.

_withdrawCommission(NftId distributorNftId, Amount amount) → Amount withdrawnAmount internal

BasicDistribution

import "@etherisc/gif-next/contracts/distribution/BasicDistribution.sol";
Functions
  • [setFees(distributionFee, minDistributionOwnerFee)]

  • [createDistributorType(name, minDiscountPercentage, maxDiscountPercentage, commissionPercentage, maxReferralCount, maxReferralLifetime, allowSelfReferrals, allowRenewals, data)]

  • [createDistributor(distributor, distributorType, data)]

  • [changeDistributorType(distributorNftId, distributorType, data)]

  • [createReferral(distributorNftId, code, discountPercentage, maxReferrals, expiryAt, data)]

  • [_initializeBasicDistribution(registry, instanceNftId, authorization, initialOwner, name)]

Distribution
  • [processRenewal(referralId, feeAmount)]

  • [withdrawCommission(distributorNftId, amount)]

  • [getDiscountPercentage(referralCode)]

  • [getReferralId(referralCode)]

  • [calculateRenewalFeeAmount(, netPremiumAmount)]

  • [isVerifying()]

  • [__Distribution_init(registry, productNftId, authorization, isInterceptor, initialOwner, name)]

  • [_setFees(distributionFee, minDistributionOwnerFee)]

  • [_createDistributorType(name, minDiscountPercentage, maxDiscountPercentage, commissionPercentage, maxReferralCount, maxReferralLifetime, allowSelfReferrals, allowRenewals, data)]

  • [_createDistributor(distributor, distributorType, data)]

  • [_changeDistributorType(distributorNftId, distributorType, data)]

  • [_createReferral(distributorNftId, code, discountPercentage, maxReferrals, expiryAt, data)]

  • [_withdrawCommission(distributorNftId, amount)]

InstanceLinkedComponent
  • [getInstance()]

  • [getAuthorization()]

  • [withdrawFees(amount)]

  • [_sendRequest(oracleNftId, requestData, expiryAt, callbackMethod)]

  • [_cancelRequest(requestId)]

  • [_resendRequest(requestId)]

  • [__InstanceLinkedComponent_init(registry, parentNftId, name, componentType, authorization, isInterceptor, initialOwner)]

  • [_checkAndGetInstanceNftId(registryAddress, parentNftId, componentType)]

  • [_checkAndGetRegistry(registryAddress, objectNftId, requiredType)]

  • [_setWallet(newWallet)]

  • [_getComponentInfo()]

  • [_getInstanceReader()]

  • [_withdrawFees(amount)]

Component
  • [__Component_init(authority, registry, parentNftId, name, componentType, isInterceptor, initialOwner, registryData)]

  • [nftTransferFrom(from, to, tokenId, operator)]

  • [getWallet()]

  • [getTokenHandler()]

  • [getToken()]

  • [getName()]

  • [getVersion()]

  • [getComponentInfo()]

  • [getInitialComponentInfo()]

  • [isNftInterceptor()]

  • [isRegistered()]

  • [_approveTokenHandler(token, amount)]

  • [_nftTransferFrom(from, to, tokenId, operator)]

  • [_setLocked(locked)]

  • [_getServiceAddress(domain)]

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
IDistributionComponent
  • [LogDistributorUpdated(to, operator)]

IComponent
  • [LogComponentWalletAddressChanged(oldWallet, newWallet)]

  • [LogComponentWalletTokensTransferred(from, to, amount)]

  • [LogComponentTokenHandlerApproved(tokenHandler, token, limit, isMaxAmount)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

setFees(struct Fee distributionFee, struct Fee minDistributionOwnerFee) external

createDistributorType(string name, UFixed minDiscountPercentage, UFixed maxDiscountPercentage, UFixed commissionPercentage, uint32 maxReferralCount, Seconds maxReferralLifetime, bool allowSelfReferrals, bool allowRenewals, bytes data) → DistributorType distributorType external

createDistributor(address distributor, DistributorType distributorType, bytes data) → NftId distributorNftId external

changeDistributorType(NftId distributorNftId, DistributorType distributorType, bytes data) external

createReferral(NftId distributorNftId, string code, UFixed discountPercentage, uint32 maxReferrals, Timestamp expiryAt, bytes data) → ReferralId referralId external

lets distributors create referral codes. referral codes need to be unique

_initializeBasicDistribution(address registry, NftId instanceNftId, contract IAuthorization authorization, address initialOwner, string name) internal

BasicDistributionAuthorization

import "@etherisc/gif-next/contracts/distribution/BasicDistributionAuthorization.sol";
Functions
  • [constructor(distributionName)]

  • [_setupServiceTargets()]

  • [_setupTokenHandlerAuthorizations()]

  • [_setupTargetAuthorizations()]

Authorization
  • [getTokenHandlerName()]

  • [getTokenHandlerTarget()]

  • [getTarget(targetName)]

  • [getTargets()]

  • [targetExists(target)]

  • [_setupTargets()]

  • [_setupRoles()]

  • [_addCustomRole(roleId, adminRoleId, maxMemberCount, name)]

  • [_addGifTarget(contractName)]

  • [_addInstanceTarget(contractName)]

  • [_addTarget(name)]

  • [_toTargetRoleId(targetDomain)]

  • [_toTargetRoleName(targetName)]

ServiceAuthorization
  • [getDomain()]

  • [getRelease()]

  • [getCommitHash()]

  • [getMainTargetName()]

  • [getMainTarget()]

  • [getServiceDomains()]

  • [getServiceDomain(idx)]

  • [getServiceTarget(serviceDomain)]

  • [getServiceRole(serviceDomain)]

  • [getServiceAddress(serviceDomain)]

  • [getTargetRole(target)]

  • [roleExists(roleId)]

  • [getRoles()]

  • [getRoleInfo(roleId)]

  • [getRoleName(roleId)]

  • [getAuthorizedRoles(target)]

  • [getAuthorizedFunctions(target, roleId)]

  • [_setupDomains()]

  • [_setupDomainAuthorizations()]

  • [_authorizeServiceDomain(serviceDomain, serviceAddress)]

  • [_addTargetWithRole(targetName, roleId, roleName)]

  • [_addRole(roleId, info)]

  • [_authorizeForService(serviceDomain, authorizedDomain)]

  • [_authorizeForTarget(target, authorizedRoleId)]

  • [_authorize(functions, selector, name)]

InitializableERC165
  • [__ERC165_init()]

  • [_initializeERC165()]

  • [_registerInterface(interfaceId)]

  • [_registerInterfaceNotInitializing(interfaceId)]

  • [supportsInterface(interfaceId)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
Initializable
  • [Initialized(version)]

constructor(string distributionName) public

_setupServiceTargets() internal

Sets up the relevant service targets for the component. Overwrite this function for use case specific authorizations.

_setupTokenHandlerAuthorizations() internal

Sets up the relevant component’s token handler authorizations. Overwrite this function for use case specific authorizations.

_setupTargetAuthorizations() internal

Sets up the relevant target authorizations for the component. Overwrite this function for use case specific authorizations.

DistributionService

import "@etherisc/gif-next/contracts/distribution/DistributionService.sol";
Functions
  • [_initialize(owner, data)]

  • [createDistributorType(name, minDiscountPercentage, maxDiscountPercentage, commissionPercentage, maxReferralCount, maxReferralLifetime, allowSelfReferrals, allowRenewals, data)]

  • [createDistributor(distributor, distributorType, data)]

  • [changeDistributorType(distributorNftId, newDistributorType, data)]

  • [createReferral(distributorNftId, code, discountPercentage, maxReferrals, expiryAt, data)]

  • [processReferral(distributionNftId, referralId)]

  • [processSale(distributionNftId, referralId, premium)]

  • [withdrawCommission(distributorNftId, amount)]

  • [referralIsValid(distributionNftId, referralId)]

  • [getDiscountPercentage(instanceReader, referralId)]

  • [_checkDistributionType(instanceReader, distributorType, expectedDistributionNftId)]

  • [_getAndVerifyActiveDistribution()]

  • [_getDomain()]

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

  • [getDomain()]

  • [getVersion()]

  • [getRoleId()]

  • [_getServiceAddress(domain)]

ReentrancyGuardUpgradeable
  • [__ReentrancyGuard_init()]

  • [__ReentrancyGuard_init_unchained()]

  • [_reentrancyGuardEntered()]

Versionable
  • [initializeVersionable(activatedBy, data)]

  • [upgradeVersionable(data)]

  • [_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
IDistributionService
  • [LogDistributionServiceCommissionWithdrawn(distributorNftId, recipient, tokenAddress, amount)]

  • [LogDistributionServiceDistributorTypeCreated(distributionNftId, name)]

  • [LogDistributionServiceDistributorCreated(distributionNftId, distributorNftId, distributorType, distributor)]

  • [LogDistributionServiceDistributorTypeChanged(distributorNftId, oldDistributorType, newDistributorType)]

  • [LogDistributionServiceReferralCreated(distributionNftId, distributorNftId, referralId, code)]

  • [LogDistributionServiceReferralProcessed(distributionNftId, distributorNftId, referralId, usedReferrals)]

  • [LogDistributionServiceSaleProcessed(distributionNftId, referralId)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

IAccessManaged
  • [AuthorityUpdated(authority)]

Initializable
  • [Initialized(version)]

_initialize(address owner, bytes data) internal

createDistributorType(string name, UFixed minDiscountPercentage, UFixed maxDiscountPercentage, UFixed commissionPercentage, uint32 maxReferralCount, Seconds maxReferralLifetime, bool allowSelfReferrals, bool allowRenewals, bytes data) → DistributorType distributorType external

createDistributor(address distributor, DistributorType distributorType, bytes data) → NftId distributorNftId external

changeDistributorType(NftId distributorNftId, DistributorType newDistributorType, bytes data) external

createReferral(NftId distributorNftId, string code, UFixed discountPercentage, uint32 maxReferrals, Timestamp expiryAt, bytes data) → ReferralId referralId external

processReferral(NftId distributionNftId, ReferralId referralId) external

callback from product service when a referral is used. Calling this will increment the referral usage counter.

processSale(NftId distributionNftId, ReferralId referralId, struct IPolicy.PremiumInfo premium) external

callback from product service when selling a policy for a specific referralId

withdrawCommission(NftId distributorNftId, Amount amount) → Amount withdrawnAmount public

Withdraw commission for the distributor

referralIsValid(NftId distributionNftId, ReferralId referralId) → bool isValid public

getDiscountPercentage(contract InstanceReader instanceReader, ReferralId referralId) → UFixed discountPercentage, ReferralStatus status external

Returns the discount percentage for the provided referral code. The function retuns both the percentage and the status of the referral code.

_checkDistributionType(contract InstanceReader instanceReader, DistributorType distributorType, NftId expectedDistributionNftId) internal

_getAndVerifyActiveDistribution() → NftId poolNftId, contract IInstance instance internal

_getDomain() → ObjectType internal

DistributionServiceManager

import "@etherisc/gif-next/contracts/distribution/DistributionServiceManager.sol";
Functions
  • [constructor(authority, registry, salt)]

  • [getDistributionService()]

ProxyManager
  • [initialize(registry, implementation, data, salt)]

  • [deploy(registry, initialImplementation, initializationData)]

  • [deployDetermenistic(registry, initialImplementation, initializationData, salt)]

  • [upgrade(newImplementation)]

  • [upgrade(newImplementation, upgradeData)]

  • [linkToProxy()]

  • [getDeployData(proxyOwner, deployData)]

  • [getUpgradeData(upgradeData)]

  • [getProxy()]

  • [getVersion()]

  • [getVersionCount()]

  • [getVersion(idx)]

  • [getVersionInfo(_version)]

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)]

Initializable
  • [_checkInitializing()]

  • [_disableInitializers()]

  • [_getInitializedVersion()]

  • [_isInitializing()]

Events
ProxyManager
  • [LogProxyManagerVersionableDeployed(proxy, initialImplementation)]

  • [LogProxyManagerVersionableUpgraded(proxy, upgradedImplementation)]

INftOwnable
  • [LogNftOwnableNftLinkedToAddress(nftId, owner)]

Initializable
  • [Initialized(version)]

constructor(address authority, address registry, bytes32 salt) public

initializes proxy manager with distribution service implementation and deploys instance

getDistributionService() → contract DistributionService distributionService external