@etherisc/gif-next 0.0.2-da06f3b-803 → 0.0.2-da0f894-204
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +73 -1
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +1 -1
- package/artifacts/contracts/components/Component.sol/Component.json +212 -94
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +1 -1
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +552 -122
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IComponent.sol/IComponent.json +64 -72
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +279 -98
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +406 -90
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +1 -1
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +68 -144
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +1 -1
- package/artifacts/contracts/components/Pool.sol/Pool.json +654 -117
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +1 -1
- package/artifacts/contracts/components/Product.sol/Product.json +316 -166
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +1 -1
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +2 -2
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +765 -323
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +97 -180
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +841 -574
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +134 -231
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +98 -124
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +265 -269
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +319 -99
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +1 -1
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +2 -2
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +118 -169
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +2 -2
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +1 -1
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +2 -2
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +62 -36
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +1 -1
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +1 -1
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationService.sol/ApplicationService.json +947 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +665 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +261 -267
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +305 -93
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimService.sol/ClaimService.json +754 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ClaimServiceManager.sol/ClaimServiceManager.json +637 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1031 -250
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +441 -85
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +535 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +130 -212
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IClaimService.sol/IClaimService.json +409 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +552 -135
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +40 -287
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +22 -169
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +22 -169
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +164 -391
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +311 -127
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +142 -221
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +302 -90
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +142 -221
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +1 -1
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +302 -90
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +15 -21
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +83 -174
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +1 -1
- package/artifacts/contracts/registry/Registry.sol/Registry.json +28 -34
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +2 -2
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +193 -216
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +300 -94
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +1 -1
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +11 -11
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +141 -37
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +1 -1
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +41 -3
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +40 -29
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/IPolicyHolder.sol/IPolicyHolder.json +129 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +1 -1
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +21 -29
- package/artifacts/contracts/shared/IRegistryLinked.sol/IRegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/{experiment/inheritance/IB.sol/IB.json → shared/IRegistryLinked.sol/IRegistryLinked.json} +18 -20
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +1 -1
- package/artifacts/contracts/shared/IService.sol/IService.json +22 -169
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +1 -1
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +2 -152
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +1 -1
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +113 -33
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.dbg.json +4 -0
- package/artifacts/contracts/shared/PolicyHolder.sol/PolicyHolder.json +248 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +1 -1
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +294 -74
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +125 -55
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.dbg.json +4 -0
- package/artifacts/contracts/shared/RegistryLinked.sol/RegistryLinked.json +84 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +1 -1
- package/artifacts/contracts/shared/Service.sol/Service.json +113 -164
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +1 -1
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +2 -2
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +1 -1
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +2 -152
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +125 -55
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +6 -6
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +134 -221
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +8 -190
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +1 -1
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +1 -1
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +1 -1
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ClaimId.sol/ClaimIdLib.json +100 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +2 -2
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +1 -1
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +2 -2
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +2 -2
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +1 -1
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +2 -2
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +1 -1
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +2 -2
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/PayoutId.sol/PayoutIdLib.json +100 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +1 -1
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +2 -2
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +2 -2
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +2 -2
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.dbg.json +4 -0
- package/artifacts/contracts/types/Seconds.sol/SecondsLib.json +124 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +25 -7
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/contracts/components/Component.sol +82 -77
- package/contracts/components/Distribution.sol +188 -48
- package/contracts/components/IComponent.sol +42 -17
- package/contracts/components/IDistributionComponent.sol +39 -7
- package/contracts/components/IPoolComponent.sol +121 -21
- package/contracts/components/IProductComponent.sol +3 -2
- package/contracts/components/Pool.sol +290 -120
- package/contracts/components/Product.sol +92 -69
- package/contracts/instance/BundleManager.sol +1 -1
- package/contracts/instance/IInstance.sol +21 -1
- package/contracts/instance/IInstanceService.sol +19 -2
- package/contracts/instance/Instance.sol +58 -36
- package/contracts/instance/InstanceAccessManager.sol +136 -253
- package/contracts/instance/InstanceService.sol +154 -137
- package/contracts/instance/InstanceServiceManager.sol +1 -1
- package/contracts/instance/base/ComponentService.sol +1 -1
- package/contracts/instance/module/IAccess.sol +10 -11
- package/contracts/instance/module/IBundle.sol +2 -1
- package/contracts/instance/module/IDistribution.sol +2 -0
- package/contracts/instance/module/IPolicy.sol +30 -3
- package/contracts/instance/module/ISetup.sol +10 -10
- package/contracts/instance/service/ApplicationService.sol +346 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +15 -9
- package/contracts/instance/service/BundleServiceManager.sol +1 -1
- package/contracts/instance/service/ClaimService.sol +151 -0
- package/contracts/instance/service/ClaimServiceManager.sol +35 -0
- package/contracts/instance/service/DistributionService.sol +303 -15
- package/contracts/instance/service/DistributionServiceManager.sol +1 -1
- package/contracts/instance/service/IApplicationService.sol +81 -0
- package/contracts/instance/service/IBundleService.sol +14 -3
- package/contracts/instance/service/IClaimService.sol +61 -0
- package/contracts/instance/service/IDistributionService.sol +74 -0
- package/contracts/instance/service/IPolicyService.sol +26 -50
- package/contracts/instance/service/PolicyService.sol +126 -260
- package/contracts/instance/service/PolicyServiceManager.sol +2 -2
- package/contracts/instance/service/PoolService.sol +2 -3
- package/contracts/instance/service/PoolServiceManager.sol +1 -1
- package/contracts/instance/service/ProductService.sol +9 -9
- package/contracts/instance/service/ProductServiceManager.sol +2 -2
- package/contracts/registry/IRegistry.sol +3 -4
- package/contracts/registry/IRegistryService.sol +10 -8
- package/contracts/registry/Registry.sol +28 -21
- package/contracts/registry/RegistryService.sol +69 -48
- package/contracts/registry/RegistryServiceManager.sol +13 -13
- package/contracts/registry/ReleaseManager.sol +18 -28
- package/contracts/registry/TokenRegistry.sol +16 -12
- package/contracts/shared/ERC165.sol +14 -12
- package/contracts/shared/INftOwnable.sol +11 -10
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +3 -3
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IService.sol +2 -0
- package/contracts/shared/IVersionable.sol +4 -47
- package/contracts/shared/NftOwnable.sol +66 -85
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +100 -25
- package/contracts/shared/Registerable.sol +7 -19
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +15 -17
- package/contracts/shared/Versionable.sol +4 -92
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestService.sol +1 -1
- package/contracts/types/ClaimId.sol +52 -0
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/ObjectType.sol +9 -5
- package/contracts/types/PayoutId.sol +54 -0
- package/contracts/types/RoleId.sol +14 -12
- package/contracts/types/Seconds.sol +54 -0
- package/contracts/types/Timestamp.sol +12 -13
- package/package.json +1 -1
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +0 -66
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +0 -24
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +0 -4
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +0 -42
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +0 -4
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +0 -105
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +0 -4
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +0 -105
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +0 -128
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +0 -42
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/B.sol/B.json +0 -76
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/C.sol/C.json +0 -89
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +0 -128
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +0 -37
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +0 -4
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +0 -63
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +0 -59
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +0 -124
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +0 -74
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +0 -124
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +0 -4
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +0 -207
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +0 -4
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +0 -10
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +0 -4
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +0 -10
- package/contracts/experiment/cloning/Cloner.sol +0 -47
- package/contracts/experiment/errors/Require.sol +0 -38
- package/contracts/experiment/errors/Revert.sol +0 -44
- package/contracts/experiment/inheritance/A.sol +0 -53
- package/contracts/experiment/inheritance/B.sol +0 -28
- package/contracts/experiment/inheritance/C.sol +0 -34
- package/contracts/experiment/inheritance/IA.sol +0 -13
- package/contracts/experiment/inheritance/IB.sol +0 -10
- package/contracts/experiment/inheritance/IC.sol +0 -12
- package/contracts/experiment/statemachine/Dummy.sol +0 -27
- package/contracts/experiment/statemachine/ISM.sol +0 -25
- package/contracts/experiment/statemachine/SM.sol +0 -57
- package/contracts/experiment/statemachine/SimpleStateMachine.sol +0 -31
- package/contracts/experiment/types/TypeA.sol +0 -47
- package/contracts/experiment/types/TypeB.sol +0 -29
@@ -10,6 +10,7 @@ import {IProductService} from "../instance/service/IProductService.sol";
|
|
10
10
|
import {IInstanceService} from "../instance/IInstanceService.sol";
|
11
11
|
import {IInstance} from "../instance/IInstance.sol";
|
12
12
|
import {InstanceAccessManager} from "../instance/InstanceAccessManager.sol";
|
13
|
+
import {InstanceReader} from "../instance/InstanceReader.sol";
|
13
14
|
import {IRegistry} from "../registry/IRegistry.sol";
|
14
15
|
import {NftId} from "../types/NftId.sol";
|
15
16
|
import {ObjectType, INSTANCE, PRODUCT} from "../types/ObjectType.sol";
|
@@ -17,9 +18,9 @@ import {VersionPart} from "../types/Version.sol";
|
|
17
18
|
import {Registerable} from "../shared/Registerable.sol";
|
18
19
|
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
19
20
|
import {IAccess} from "../instance/module/IAccess.sol";
|
21
|
+
import {VersionPart} from "../types/Version.sol";
|
20
22
|
|
21
23
|
// TODO discuss to inherit from oz accessmanaged
|
22
|
-
// TODO make contract upgradeable
|
23
24
|
// then add (Distribution|Pool|Product)Upradeable that also intherit from Versionable
|
24
25
|
// same pattern as for Service which is also upgradeable
|
25
26
|
abstract contract Component is
|
@@ -28,47 +29,25 @@ abstract contract Component is
|
|
28
29
|
AccessManagedUpgradeable
|
29
30
|
{
|
30
31
|
// keccak256(abi.encode(uint256(keccak256("gif-next.contracts.component.Component.sol")) - 1)) & ~bytes32(uint256(0xff));
|
31
|
-
bytes32 public constant
|
32
|
+
bytes32 public constant COMPONENT_LOCATION_V1 = 0xffe8d4462baed26a47154f4b8f6db497d2f772496965791d25bd456e342b7f00;
|
32
33
|
|
33
34
|
struct ComponentStorage {
|
34
|
-
IInstance _instance; // instance for this component
|
35
35
|
string _name; // unique (per instance) component name
|
36
36
|
IERC20Metadata _token; // token for this component
|
37
|
+
IInstance _instance; // instance for this component
|
37
38
|
address _wallet; // wallet for this component (default = component contract itself)
|
38
|
-
|
39
|
-
|
39
|
+
InstanceReader _instanceReader; // instance reader for this component
|
40
|
+
bool _isNftInterceptor; // declares if component is involved in nft transfers
|
40
41
|
NftId _productNftId; // only relevant for components that are linked to a aproduct
|
41
|
-
IProductService _productService; // product service for component, might not be relevant for some component types (eg oracles)
|
42
|
-
}
|
43
|
-
|
44
|
-
|
45
|
-
modifier onlyProductService() {
|
46
|
-
if(msg.sender != address(_getComponentStorage()._productService)) {
|
47
|
-
revert ErrorComponentNotProductService(msg.sender);
|
48
|
-
}
|
49
|
-
_;
|
50
|
-
}
|
51
|
-
|
52
|
-
constructor(
|
53
|
-
address registry,
|
54
|
-
NftId instanceNftId,
|
55
|
-
string memory name,
|
56
|
-
address token,
|
57
|
-
ObjectType componentType,
|
58
|
-
bool isInterceptor,
|
59
|
-
address initialOwner,
|
60
|
-
bytes memory data
|
61
|
-
) {
|
62
|
-
_initializeComponent(registry, instanceNftId, name, token, componentType, isInterceptor, initialOwner, data);
|
63
42
|
}
|
64
43
|
|
65
44
|
function _getComponentStorage() private pure returns (ComponentStorage storage $) {
|
66
45
|
assembly {
|
67
|
-
$.slot :=
|
46
|
+
$.slot := COMPONENT_LOCATION_V1
|
68
47
|
}
|
69
48
|
}
|
70
49
|
|
71
|
-
function
|
50
|
+
function initializeComponent(
|
72
51
|
address registry,
|
73
52
|
NftId instanceNftId,
|
74
53
|
string memory name,
|
@@ -76,70 +55,51 @@ abstract contract Component is
|
|
76
55
|
ObjectType componentType,
|
77
56
|
bool isInterceptor,
|
78
57
|
address initialOwner,
|
79
|
-
bytes memory data
|
58
|
+
bytes memory registryData // writeonly data that will saved in the object info record of the registry
|
80
59
|
)
|
81
|
-
|
82
|
-
initializer
|
60
|
+
public
|
83
61
|
virtual
|
62
|
+
onlyInitializing()
|
84
63
|
{
|
85
|
-
|
86
|
-
_initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, data);
|
87
|
-
|
88
|
-
// set unique name of component
|
89
|
-
$._name = name;
|
64
|
+
initializeRegisterable(registry, instanceNftId, componentType, isInterceptor, initialOwner, registryData);
|
90
65
|
|
91
66
|
// set and check linked instance
|
92
|
-
|
93
|
-
$._instance = IInstance(
|
67
|
+
ComponentStorage storage $ = _getComponentStorage();
|
68
|
+
$._instance = IInstance(
|
69
|
+
getRegistry().getObjectInfo(instanceNftId).objectAddress);
|
70
|
+
|
94
71
|
if(!$._instance.supportsInterface(type(IInstance).interfaceId)) {
|
95
|
-
revert ErrorComponentNotInstance(instanceNftId
|
72
|
+
revert ErrorComponentNotInstance(instanceNftId);
|
96
73
|
}
|
97
74
|
|
98
75
|
// initialize AccessManagedUpgradeable
|
99
76
|
__AccessManaged_init($._instance.authority());
|
100
77
|
|
101
|
-
// set
|
102
|
-
|
103
|
-
$.
|
104
|
-
$.
|
105
|
-
|
106
|
-
// set wallet and token
|
78
|
+
// set component state
|
79
|
+
$._name = name;
|
80
|
+
$._isNftInterceptor = isInterceptor;
|
81
|
+
$._instanceReader = $._instance.getInstanceReader();
|
107
82
|
$._wallet = address(this);
|
108
83
|
$._token = IERC20Metadata(token);
|
109
84
|
|
110
|
-
|
85
|
+
registerInterface(type(IComponent).interfaceId);
|
111
86
|
}
|
112
87
|
|
113
88
|
function lock() external onlyOwner override {
|
114
|
-
|
89
|
+
IInstanceService(_getServiceAddress(INSTANCE())).setTargetLocked(getName(), true);
|
115
90
|
}
|
116
91
|
|
117
92
|
function unlock() external onlyOwner override {
|
118
|
-
|
93
|
+
IInstanceService(_getServiceAddress(INSTANCE())).setTargetLocked(getName(), false);
|
119
94
|
}
|
120
95
|
|
121
|
-
|
122
|
-
function setProductNftId(NftId productNftId)
|
96
|
+
function setWallet(address newWallet)
|
123
97
|
external
|
124
98
|
override
|
125
|
-
|
99
|
+
onlyOwner
|
126
100
|
{
|
127
101
|
ComponentStorage storage $ = _getComponentStorage();
|
128
102
|
|
129
|
-
if($._productNftId.gtz()) {
|
130
|
-
revert ErrorComponentProductNftAlreadySet();
|
131
|
-
}
|
132
|
-
|
133
|
-
$._productNftId = productNftId;
|
134
|
-
}
|
135
|
-
|
136
|
-
/// @dev Sets the wallet address for the component.
|
137
|
-
/// if the current wallet has tokens, these will be transferred.
|
138
|
-
/// if the new wallet address is externally owned, an approval from the
|
139
|
-
/// owner of the external wallet for the component to move all tokens must exist.
|
140
|
-
function setWallet(address newWallet) external override onlyOwner {
|
141
|
-
ComponentStorage storage $ = _getComponentStorage();
|
142
|
-
|
143
103
|
address currentWallet = $._wallet;
|
144
104
|
uint256 currentBalance = $._token.balanceOf(currentWallet);
|
145
105
|
|
@@ -147,8 +107,9 @@ abstract contract Component is
|
|
147
107
|
if (newWallet == address(0)) {
|
148
108
|
revert ErrorComponentWalletAddressZero();
|
149
109
|
}
|
110
|
+
|
150
111
|
if (newWallet == currentWallet) {
|
151
|
-
revert ErrorComponentWalletAddressIsSameAsCurrent(
|
112
|
+
revert ErrorComponentWalletAddressIsSameAsCurrent();
|
152
113
|
}
|
153
114
|
|
154
115
|
if (currentBalance > 0) {
|
@@ -165,7 +126,7 @@ abstract contract Component is
|
|
165
126
|
|
166
127
|
// effects
|
167
128
|
$._wallet = newWallet;
|
168
|
-
emit LogComponentWalletAddressChanged(newWallet);
|
129
|
+
emit LogComponentWalletAddressChanged(currentWallet, newWallet);
|
169
130
|
|
170
131
|
// interactions
|
171
132
|
if (currentBalance > 0) {
|
@@ -180,11 +141,41 @@ abstract contract Component is
|
|
180
141
|
}
|
181
142
|
}
|
182
143
|
|
183
|
-
function
|
184
|
-
|
185
|
-
view
|
144
|
+
function setProductNftId(NftId productNftId)
|
145
|
+
external
|
186
146
|
override
|
187
|
-
|
147
|
+
{
|
148
|
+
ComponentStorage storage $ = _getComponentStorage();
|
149
|
+
|
150
|
+
// verify caller is product service
|
151
|
+
if(msg.sender != _getServiceAddress(PRODUCT())) {
|
152
|
+
revert ErrorComponentNotProductService(msg.sender);
|
153
|
+
}
|
154
|
+
|
155
|
+
// verify component is not yet linked to a product
|
156
|
+
if($._productNftId.gtz()) {
|
157
|
+
revert ErrorComponentProductNftAlreadySet();
|
158
|
+
}
|
159
|
+
|
160
|
+
$._productNftId = productNftId;
|
161
|
+
}
|
162
|
+
|
163
|
+
/// @dev callback function for nft transfers
|
164
|
+
/// may only be called by chain nft contract.
|
165
|
+
/// do not override this function to implement business logic for handling transfers
|
166
|
+
/// override internal function _nftTransferFrom instead
|
167
|
+
function nftTransferFrom(address from, address to, uint256 tokenId)
|
168
|
+
external
|
169
|
+
virtual override
|
170
|
+
{
|
171
|
+
if(msg.sender != getRegistry().getChainNftAddress()) {
|
172
|
+
revert ErrorComponentNotChainNft(msg.sender);
|
173
|
+
}
|
174
|
+
|
175
|
+
_nftTransferFrom(from, to, tokenId);
|
176
|
+
}
|
177
|
+
|
178
|
+
function getWallet() public view override returns (address walletAddress)
|
188
179
|
{
|
189
180
|
return _getComponentStorage()._wallet;
|
190
181
|
}
|
@@ -193,6 +184,10 @@ abstract contract Component is
|
|
193
184
|
return _getComponentStorage()._token;
|
194
185
|
}
|
195
186
|
|
187
|
+
function isNftInterceptor() public view override returns(bool isInterceptor) {
|
188
|
+
return _getComponentStorage()._isNftInterceptor;
|
189
|
+
}
|
190
|
+
|
196
191
|
function getInstance() public view override returns (IInstance instance) {
|
197
192
|
return _getComponentStorage()._instance;
|
198
193
|
}
|
@@ -205,12 +200,22 @@ abstract contract Component is
|
|
205
200
|
return _getComponentStorage()._productNftId;
|
206
201
|
}
|
207
202
|
|
208
|
-
|
209
|
-
|
210
|
-
|
203
|
+
/// @dev internal function for nft transfers.
|
204
|
+
/// handling logic that deals with nft transfers need to overwrite this function
|
205
|
+
function _nftTransferFrom(address from, address to, uint256 tokenId)
|
206
|
+
internal
|
207
|
+
virtual
|
208
|
+
{ }
|
211
209
|
|
212
|
-
|
213
|
-
|
210
|
+
/// @dev returns reader for linked instance
|
211
|
+
function _getInstanceReader() internal view returns (InstanceReader reader) {
|
212
|
+
return _getComponentStorage()._instanceReader;
|
214
213
|
}
|
215
214
|
|
215
|
+
/// @dev returns the service address for the specified domain
|
216
|
+
/// gets address via lookup from registry using the major version form the linked instance
|
217
|
+
function _getServiceAddress(ObjectType domain) internal view returns (address service) {
|
218
|
+
VersionPart majorVersion = _getComponentStorage()._instance.getMajorVersion();
|
219
|
+
return getRegistry().getServiceAddress(domain, majorVersion);
|
220
|
+
}
|
216
221
|
}
|
@@ -4,10 +4,11 @@ pragma solidity ^0.8.19;
|
|
4
4
|
import {DISTRIBUTION} from "../types/ObjectType.sol";
|
5
5
|
import {IDistributionService} from "../instance/service/IDistributionService.sol";
|
6
6
|
import {IProductService} from "../instance/service/IProductService.sol";
|
7
|
-
import {NftId, zeroNftId, NftIdLib} from "../types/NftId.sol";
|
8
|
-
import {ReferralId} from "../types/Referral.sol";
|
7
|
+
import {NftId, zeroNftId, NftIdLib, toNftId} from "../types/NftId.sol";
|
8
|
+
import {ReferralId, ReferralStatus, ReferralLib} from "../types/Referral.sol";
|
9
9
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
10
10
|
import {Component} from "./Component.sol";
|
11
|
+
import {IDistribution} from "../instance/module/IDistribution.sol";
|
11
12
|
import {IDistributionComponent} from "./IDistributionComponent.sol";
|
12
13
|
import {IRegistry} from "../registry/IRegistry.sol";
|
13
14
|
import {IRegisterable} from "../shared/IRegisterable.sol";
|
@@ -15,49 +16,55 @@ import {ISetup} from "../instance/module/ISetup.sol";
|
|
15
16
|
import {Registerable} from "../shared/Registerable.sol";
|
16
17
|
import {TokenHandler} from "../shared/TokenHandler.sol";
|
17
18
|
import {InstanceReader} from "../instance/InstanceReader.sol";
|
19
|
+
import {UFixed} from "../types/UFixed.sol";
|
20
|
+
import {DistributorType} from "../types/DistributorType.sol";
|
21
|
+
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
22
|
+
import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
|
23
|
+
|
18
24
|
|
19
25
|
abstract contract Distribution is
|
20
26
|
Component,
|
21
27
|
IDistributionComponent
|
22
28
|
{
|
23
|
-
|
24
|
-
|
25
|
-
bool internal _isVerifying;
|
26
|
-
Fee internal _initialDistributionFee;
|
29
|
+
// keccak256(abi.encode(uint256(keccak256("etherisc.storage.Distribution")) - 1)) & ~bytes32(uint256(0xff));
|
30
|
+
bytes32 public constant DISTRIBUTION_STORAGE_LOCATION_V1 = 0xaab7c5ea03d290056d6c060e0833d3ebcbe647f7694616a2ec52738a64b2f900;
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
struct DistributionStorage {
|
33
|
+
Fee _minDistributionOwnerFee;
|
34
|
+
Fee _distributionFee;
|
35
|
+
TokenHandler _tokenHandler;
|
36
|
+
IDistributionService _distributionService;
|
37
|
+
mapping(address distributor => NftId distributorNftId) _distributorNftId;
|
38
|
+
}
|
31
39
|
|
32
|
-
|
40
|
+
function initializeDistribution(
|
33
41
|
address registry,
|
34
42
|
NftId instanceNftId,
|
35
|
-
// TODO refactor into tokenNftId
|
36
43
|
string memory name,
|
37
44
|
address token,
|
38
|
-
|
45
|
+
Fee memory minDistributionOwnerFee,
|
39
46
|
Fee memory distributionFee,
|
40
47
|
address initialOwner,
|
41
|
-
bytes memory data
|
42
|
-
)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
true,
|
48
|
-
initialOwner,
|
49
|
-
data
|
50
|
-
) {
|
51
|
-
_isVerifying = verifying;
|
52
|
-
_initialDistributionFee = distributionFee;
|
48
|
+
bytes memory registryData // writeonly data that will saved in the object info record of the registry
|
49
|
+
)
|
50
|
+
public
|
51
|
+
virtual
|
52
|
+
onlyInitializing()
|
53
|
+
{
|
54
|
+
initializeComponent(registry, instanceNftId, name, token, DISTRIBUTION(), true, initialOwner, registryData);
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
57
|
+
// TODO add validation
|
58
|
+
$._minDistributionOwnerFee = minDistributionOwnerFee;
|
59
|
+
$._distributionFee = distributionFee;
|
60
|
+
$._tokenHandler = new TokenHandler(token);
|
61
|
+
$._distributionService = getInstance().getDistributionService();
|
56
62
|
|
57
|
-
|
63
|
+
registerInterface(type(IDistributionComponent).interfaceId);
|
58
64
|
}
|
59
65
|
|
60
66
|
function setFees(
|
67
|
+
Fee memory minDistributionOwnerFee,
|
61
68
|
Fee memory distributionFee
|
62
69
|
)
|
63
70
|
external
|
@@ -65,24 +72,144 @@ abstract contract Distribution is
|
|
65
72
|
onlyOwner
|
66
73
|
restricted()
|
67
74
|
{
|
68
|
-
_distributionService.setFees(distributionFee);
|
75
|
+
_getDistributionStorage()._distributionService.setFees(minDistributionOwnerFee, distributionFee);
|
69
76
|
}
|
70
77
|
|
71
|
-
function
|
72
|
-
|
73
|
-
|
78
|
+
function getDistributionFee() external view returns (Fee memory distributionFee) {
|
79
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
80
|
+
return $._distributionFee;
|
81
|
+
}
|
82
|
+
|
83
|
+
function createDistributorType(
|
84
|
+
string memory name,
|
85
|
+
UFixed minDiscountPercentage,
|
86
|
+
UFixed maxDiscountPercentage,
|
87
|
+
UFixed commissionPercentage,
|
88
|
+
uint32 maxReferralCount,
|
89
|
+
uint32 maxReferralLifetime,
|
90
|
+
bool allowSelfReferrals,
|
91
|
+
bool allowRenewals,
|
92
|
+
bytes memory data
|
74
93
|
)
|
94
|
+
public
|
95
|
+
returns (DistributorType distributorType)
|
96
|
+
{
|
97
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
98
|
+
distributorType = $._distributionService.createDistributorType(
|
99
|
+
name,
|
100
|
+
minDiscountPercentage,
|
101
|
+
maxDiscountPercentage,
|
102
|
+
commissionPercentage,
|
103
|
+
maxReferralCount,
|
104
|
+
maxReferralLifetime,
|
105
|
+
allowSelfReferrals,
|
106
|
+
allowRenewals,
|
107
|
+
data);
|
108
|
+
}
|
109
|
+
|
110
|
+
function createDistributor(
|
111
|
+
address distributor,
|
112
|
+
DistributorType distributorType,
|
113
|
+
bytes memory data
|
114
|
+
)
|
115
|
+
public
|
116
|
+
returns(NftId distributorNftId)
|
117
|
+
{
|
118
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
119
|
+
require($._distributorNftId[distributor].eqz(), "ERROR:DST-030:ALREADY_DISTRIBUTOR");
|
120
|
+
|
121
|
+
distributorNftId = $._distributionService.createDistributor(
|
122
|
+
distributor,
|
123
|
+
distributorType,
|
124
|
+
data);
|
125
|
+
|
126
|
+
$._distributorNftId[distributor] = distributorNftId;
|
127
|
+
}
|
128
|
+
|
129
|
+
function updateDistributorType(
|
130
|
+
NftId distributorNftId,
|
131
|
+
DistributorType distributorType,
|
132
|
+
bytes memory data
|
133
|
+
)
|
134
|
+
public
|
135
|
+
// TODO figure out what we need for authz
|
136
|
+
// and add it
|
137
|
+
{
|
138
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
139
|
+
$._distributionService.updateDistributorType(
|
140
|
+
distributorNftId,
|
141
|
+
distributorType,
|
142
|
+
data);
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* @dev lets distributors create referral codes.
|
147
|
+
* referral codes need to be unique
|
148
|
+
*/
|
149
|
+
function _createReferral(
|
150
|
+
NftId distributorNftId,
|
151
|
+
string memory code,
|
152
|
+
UFixed discountPercentage,
|
153
|
+
uint32 maxReferrals,
|
154
|
+
Timestamp expiryAt,
|
155
|
+
bytes memory data
|
156
|
+
)
|
157
|
+
internal
|
158
|
+
returns (ReferralId referralId)
|
159
|
+
{
|
160
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
161
|
+
referralId = $._distributionService.createReferral(
|
162
|
+
distributorNftId,
|
163
|
+
code,
|
164
|
+
discountPercentage,
|
165
|
+
maxReferrals,
|
166
|
+
expiryAt,
|
167
|
+
data);
|
168
|
+
}
|
169
|
+
|
170
|
+
function isDistributor(address candidate)
|
171
|
+
public
|
172
|
+
view
|
173
|
+
returns (bool)
|
174
|
+
{
|
175
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
176
|
+
return $._distributorNftId[candidate].gtz();
|
177
|
+
}
|
178
|
+
|
179
|
+
function getDistributorNftId(address distributor)
|
180
|
+
public
|
181
|
+
view
|
182
|
+
returns (NftId distributorNftId)
|
183
|
+
{
|
184
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
185
|
+
return $._distributorNftId[distributor];
|
186
|
+
}
|
187
|
+
|
188
|
+
function getDiscountPercentage(string memory referralCode)
|
75
189
|
external
|
76
190
|
view
|
77
|
-
|
78
|
-
|
191
|
+
returns (
|
192
|
+
UFixed discountPercentage,
|
193
|
+
ReferralStatus status
|
194
|
+
)
|
79
195
|
{
|
80
|
-
|
81
|
-
|
82
|
-
(feeAmount,) = FeeLib.calculateFee(fee, netPremiumAmount);
|
196
|
+
ReferralId referralId = getReferralId(referralCode);
|
197
|
+
return _getInstanceReader().getDiscountPercentage(referralId);
|
83
198
|
}
|
84
199
|
|
85
200
|
|
201
|
+
function getReferralId(
|
202
|
+
string memory referralCode
|
203
|
+
)
|
204
|
+
public
|
205
|
+
view
|
206
|
+
returns (ReferralId referralId)
|
207
|
+
{
|
208
|
+
return ReferralLib.toReferralId(
|
209
|
+
getNftId(),
|
210
|
+
referralCode);
|
211
|
+
}
|
212
|
+
|
86
213
|
function calculateRenewalFeeAmount(
|
87
214
|
ReferralId referralId,
|
88
215
|
uint256 netPremiumAmount
|
@@ -98,14 +225,15 @@ abstract contract Distribution is
|
|
98
225
|
|
99
226
|
function processSale(
|
100
227
|
ReferralId referralId,
|
101
|
-
uint256
|
228
|
+
uint256 premiumAmount
|
102
229
|
)
|
103
230
|
external
|
104
231
|
onlyOwner
|
105
232
|
restricted()
|
106
233
|
virtual override
|
107
234
|
{
|
108
|
-
|
235
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
236
|
+
$._distributionService.processSale(referralId, premiumAmount);
|
109
237
|
}
|
110
238
|
|
111
239
|
function processRenewal(
|
@@ -120,11 +248,6 @@ abstract contract Distribution is
|
|
120
248
|
// default is no action
|
121
249
|
}
|
122
250
|
|
123
|
-
function referralIsValid(ReferralId referralId) external view returns (bool isValid) {
|
124
|
-
// default is invalid
|
125
|
-
return false;
|
126
|
-
}
|
127
|
-
|
128
251
|
function getSetupInfo() public view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
129
252
|
InstanceReader reader = getInstance().getInstanceReader();
|
130
253
|
setupInfo = reader.getDistributionSetupInfo(getNftId());
|
@@ -136,18 +259,35 @@ abstract contract Distribution is
|
|
136
259
|
}
|
137
260
|
|
138
261
|
function _getInitialSetupInfo() internal view returns (ISetup.DistributionSetupInfo memory setupInfo) {
|
262
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
139
263
|
return ISetup.DistributionSetupInfo(
|
140
264
|
zeroNftId(),
|
141
|
-
_tokenHandler,
|
142
|
-
|
143
|
-
|
144
|
-
address(this)
|
265
|
+
$._tokenHandler,
|
266
|
+
$._minDistributionOwnerFee,
|
267
|
+
$._distributionFee,
|
268
|
+
address(this),
|
269
|
+
0
|
145
270
|
);
|
146
271
|
}
|
272
|
+
|
273
|
+
|
274
|
+
function _nftTransferFrom(address from, address to, uint256 tokenId) internal virtual override {
|
275
|
+
// keep track of distributor nft owner
|
276
|
+
emit LogDistributorUpdated(to, msg.sender);
|
277
|
+
DistributionStorage storage $ = _getDistributionStorage();
|
278
|
+
$._distributorNftId[from] = zeroNftId();
|
279
|
+
$._distributorNftId[to] = toNftId(tokenId);
|
280
|
+
}
|
147
281
|
|
148
282
|
|
149
283
|
/// @dev returns true iff the component needs to be called when selling/renewing policis
|
150
284
|
function isVerifying() external view returns (bool verifying) {
|
151
|
-
return
|
285
|
+
return true;
|
286
|
+
}
|
287
|
+
|
288
|
+
function _getDistributionStorage() private pure returns (DistributionStorage storage $) {
|
289
|
+
assembly {
|
290
|
+
$.slot := DISTRIBUTION_STORAGE_LOCATION_V1
|
291
|
+
}
|
152
292
|
}
|
153
293
|
}
|
@@ -3,41 +3,66 @@ pragma solidity ^0.8.20;
|
|
3
3
|
|
4
4
|
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
|
-
import {IRegisterable} from "../shared/IRegisterable.sol";
|
7
6
|
import {IInstance} from "../instance/IInstance.sol";
|
8
7
|
import {IInstanceService} from "../instance/IInstanceService.sol";
|
9
8
|
import {IProductService} from "../instance/service/IProductService.sol";
|
9
|
+
import {IRegisterable} from "../shared/IRegisterable.sol";
|
10
|
+
import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
|
10
11
|
import {NftId} from "../types/NftId.sol";
|
12
|
+
import {ObjectType} from "../types/ObjectType.sol";
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
/// @dev component base class
|
15
|
+
/// component examples are product, distribution, pool and oracle
|
16
|
+
interface IComponent is
|
17
|
+
IRegisterable,
|
18
|
+
ITransferInterceptor
|
19
|
+
{
|
20
|
+
error ErrorComponentNotChainNft(address caller);
|
21
|
+
error ErrorComponentNotProductService(address caller);
|
22
|
+
error ErrorComponentNotInstance(NftId instanceNftId);
|
15
23
|
error ErrorComponentProductNftAlreadySet();
|
24
|
+
|
16
25
|
error ErrorComponentWalletAddressZero();
|
17
|
-
error ErrorComponentWalletAddressIsSameAsCurrent(
|
26
|
+
error ErrorComponentWalletAddressIsSameAsCurrent();
|
18
27
|
error ErrorComponentWalletAllowanceTooSmall(address oldWallet, address newWallet, uint256 allowance, uint256 balance);
|
19
|
-
error ErrorComponentUnauthorized(address caller, uint64 requiredRoleIdNum);
|
20
|
-
error ErrorComponentNotProductService(address caller);
|
21
28
|
|
22
|
-
event LogComponentWalletAddressChanged(address newWallet);
|
29
|
+
event LogComponentWalletAddressChanged(address oldWallet, address newWallet);
|
23
30
|
event LogComponentWalletTokensTransferred(address from, address to, uint256 amount);
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
// TODO remove and replace with accessmanaged target locking mechanism
|
32
|
+
/// @dev locks component to disable functions that may change state related to this component, the only exception is function "unlock"
|
33
|
+
/// only component owner (nft holder) is authorizes to call this function
|
28
34
|
function lock() external;
|
29
|
-
function unlock() external;
|
30
35
|
|
31
|
-
|
36
|
+
/// @dev unlocks component to (re-)enable functions that may change state related to this component
|
37
|
+
/// only component owner (nft holder) is authorizes to call this function
|
38
|
+
function unlock() external;
|
32
39
|
|
40
|
+
/// @dev sets the wallet address for the component
|
41
|
+
/// if the current wallet has tokens, these will be transferred
|
42
|
+
/// if the new wallet address is externally owned, an approval from the
|
43
|
+
/// owner of the external wallet for the component to move all tokens must exist
|
33
44
|
function setWallet(address walletAddress) external;
|
34
|
-
function getWallet() external view returns (address walletAddress);
|
35
45
|
|
46
|
+
/// @dev only product service may set product nft id during registration of product setup
|
47
|
+
function setProductNftId(NftId productNftId) external;
|
48
|
+
|
49
|
+
/// @dev returns the name of this component
|
50
|
+
/// to successfully register the component with an instance the name MUST be unique in the linked instance
|
51
|
+
function getName() external view returns (string memory name);
|
52
|
+
|
53
|
+
/// @dev defines which ERC20 token is used by this component
|
54
|
+
function getToken() external view returns (IERC20Metadata token);
|
55
|
+
|
56
|
+
/// @dev defines the instance to which this component is linked to
|
36
57
|
function getInstance() external view returns (IInstance instance);
|
37
58
|
|
38
|
-
|
59
|
+
/// @dev defines the wallet address used to hold the ERC20 tokens related to this component
|
60
|
+
/// the default address is the component token address
|
61
|
+
function getWallet() external view returns (address walletAddress);
|
62
|
+
|
63
|
+
/// @dev defines the product to which this component is linked to
|
64
|
+
/// this is only relevant for pool and distribution components
|
39
65
|
function getProductNftId() external view returns (NftId productNftId);
|
40
66
|
|
41
|
-
function
|
42
|
-
function getProductService() external view returns (IProductService);
|
67
|
+
function isNftInterceptor() external view returns(bool isInterceptor);
|
43
68
|
}
|