@etherisc/gif-next 0.0.2-ce8407f-016 → 0.0.2-ce87da3-250
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +243 -2
- package/artifacts/contracts/components/Component.sol/Component.dbg.json +4 -0
- package/artifacts/contracts/components/Component.sol/Component.json +853 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +1346 -0
- package/artifacts/contracts/components/IComponent.sol/IComponent.dbg.json +4 -0
- package/artifacts/contracts/{instance/base/ServiceBase.sol/ServiceBase.json → components/IComponent.sol/IComponent.json} +195 -150
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +900 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +887 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +806 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +1322 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +1246 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.dbg.json +4 -0
- package/artifacts/contracts/instance/BundleManager.sol/BundleManager.json +764 -0
- package/artifacts/contracts/instance/Cloneable.sol/Cloneable.dbg.json +4 -0
- package/artifacts/contracts/instance/{AccessManagedSimple.sol/AccessManagedSimple.json → Cloneable.sol/Cloneable.json} +86 -2
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +1 -1
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +2475 -1
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +509 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +1 -1
- package/artifacts/contracts/instance/Instance.sol/Instance.json +1051 -1183
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +211 -144
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +562 -54
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +1 -1
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +958 -29
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +693 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.dbg.json +4 -0
- package/artifacts/contracts/instance/ObjectManager.sol/ObjectManager.json +261 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentService.sol/ComponentService.json +552 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +1 -1
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +0 -77
- 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 +10 -244
- 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 +59 -16
- 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 +869 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ApplicationServiceManager.sol/ApplicationServiceManager.json +657 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleService.sol/BundleService.json +1096 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/BundleServiceManager.sol/BundleServiceManager.json +661 -0
- 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 +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +1254 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +753 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IApplicationService.sol/IApplicationService.json +473 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IBundleService.sol/IBundleService.json +633 -0
- 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 +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +639 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPolicyService.sol/IPolicyService.json +583 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +347 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +384 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyService.sol/PolicyService.json +1120 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PolicyServiceManager.sol/PolicyServiceManager.json +717 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +727 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +649 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductService.sol/ProductService.json +777 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ProductServiceManager.sol/ProductServiceManager.json +649 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +1 -1
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +47 -2
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +236 -63
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +323 -178
- 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 +210 -212
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryAccessManager.sol/RegistryAccessManager.json +285 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +432 -268
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +1 -1
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +323 -129
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.dbg.json +4 -0
- package/artifacts/contracts/registry/ReleaseManager.sol/ReleaseManager.json +547 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +498 -0
- 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 -34
- 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 +4 -0
- package/artifacts/contracts/{components/IBaseComponent.sol/IBaseComponent.json → shared/IService.sol/IService.json} +67 -39
- 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 +120 -27
- 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 -61
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +1 -1
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +129 -51
- 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 +4 -0
- package/artifacts/contracts/{instance/base/IService.sol/IService.json → shared/Service.sol/Service.json} +155 -151
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +1 -1
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +2 -2
- 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/TestFee.sol/TestFee.json +4 -4
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +1 -1
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +129 -51
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +1 -1
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +111 -5
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +1 -1
- package/artifacts/contracts/test/TestService.sol/TestService.json +147 -226
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +1 -1
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +91 -53
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +1 -1
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +2 -2
- 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/test/Usdc.sol/USDC.json +91 -53
- 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/Fee.sol/FeeLib.json +4 -4
- 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 +26 -3
- 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/StateId.sol/StateIdLib.dbg.json +1 -1
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +2 -2
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +1 -1
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/{experiment/types/TypeB.sol/TypeBLib.json → types/UFixed.sol/MathLib.json} +4 -4
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/{UFixedMathLib.json → UFixedLib.json} +3 -3
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionLib.json +2 -2
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +1 -1
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +22 -3
- package/contracts/components/Component.sol +241 -0
- package/contracts/components/Distribution.sol +287 -0
- package/contracts/components/IComponent.sol +54 -0
- package/contracts/components/IDistributionComponent.sol +92 -0
- package/contracts/components/IPoolComponent.sol +87 -0
- package/contracts/components/IProductComponent.sol +39 -0
- package/contracts/components/Pool.sol +254 -0
- package/contracts/components/Product.sol +285 -0
- package/contracts/instance/BundleManager.sol +125 -0
- package/contracts/instance/Cloneable.sol +46 -0
- package/contracts/instance/IInstance.sol +87 -1
- package/contracts/instance/IInstanceService.sol +59 -0
- package/contracts/instance/Instance.sol +137 -238
- package/contracts/instance/InstanceAccessManager.sol +90 -81
- package/contracts/instance/InstanceReader.sol +86 -28
- package/contracts/instance/InstanceService.sol +453 -22
- package/contracts/instance/InstanceServiceManager.sol +54 -0
- package/contracts/instance/ObjectManager.sol +84 -0
- package/contracts/instance/base/ComponentService.sol +134 -0
- package/contracts/instance/base/IKeyValueStore.sol +5 -4
- package/contracts/instance/base/KeyValueStore.sol +4 -20
- package/contracts/instance/module/IAccess.sol +28 -19
- package/contracts/instance/module/IBundle.sol +1 -0
- package/contracts/instance/module/IDistribution.sol +1 -0
- package/contracts/instance/module/IPolicy.sol +4 -2
- package/contracts/instance/module/ISetup.sol +10 -3
- package/contracts/instance/module/ITreasury.sol +1 -1
- package/contracts/instance/service/ApplicationService.sol +268 -0
- package/contracts/instance/service/ApplicationServiceManager.sol +35 -0
- package/contracts/instance/service/BundleService.sol +298 -0
- package/contracts/instance/service/BundleServiceManager.sol +51 -0
- package/contracts/instance/service/ClaimService.sol +151 -0
- package/contracts/instance/service/ClaimServiceManager.sol +35 -0
- package/contracts/instance/service/DistributionService.sol +366 -0
- package/contracts/instance/service/DistributionServiceManager.sol +51 -0
- package/contracts/instance/service/IApplicationService.sol +82 -0
- package/contracts/instance/service/IBundleService.sol +54 -0
- package/contracts/instance/service/IClaimService.sol +61 -0
- package/contracts/instance/service/IDistributionService.sol +81 -0
- package/contracts/instance/service/IPolicyService.sol +89 -0
- package/contracts/instance/service/IPoolService.sol +20 -0
- package/contracts/instance/service/IProductService.sol +40 -0
- package/contracts/instance/service/PolicyService.sol +476 -0
- package/contracts/instance/service/PolicyServiceManager.sol +54 -0
- package/contracts/instance/service/PoolService.sol +109 -0
- package/contracts/instance/service/PoolServiceManager.sol +51 -0
- package/contracts/instance/service/ProductService.sol +233 -0
- package/contracts/instance/service/ProductServiceManager.sol +54 -0
- package/contracts/registry/ChainNft.sol +41 -26
- package/contracts/registry/IRegistry.sol +51 -25
- package/contracts/registry/IRegistryService.sol +54 -16
- package/contracts/registry/Registry.sol +279 -306
- package/contracts/registry/RegistryAccessManager.sol +216 -0
- package/contracts/registry/RegistryService.sol +170 -256
- package/contracts/registry/RegistryServiceManager.sol +30 -11
- package/contracts/registry/ReleaseManager.sol +322 -0
- package/contracts/registry/TokenRegistry.sol +116 -0
- package/contracts/shared/ERC165.sol +15 -9
- package/contracts/shared/INftOwnable.sol +11 -10
- package/contracts/shared/IPolicyHolder.sol +26 -0
- package/contracts/shared/IRegisterable.sol +4 -6
- package/contracts/shared/IRegistryLinked.sol +12 -0
- package/contracts/shared/IService.sol +18 -0
- package/contracts/shared/IVersionable.sol +4 -47
- package/contracts/shared/NftOwnable.sol +67 -83
- package/contracts/shared/PolicyHolder.sol +81 -0
- package/contracts/shared/ProxyManager.sol +101 -26
- package/contracts/shared/Registerable.sol +15 -30
- package/contracts/shared/RegistryLinked.sol +48 -0
- package/contracts/shared/Service.sol +58 -0
- package/contracts/shared/TokenHandler.sol +2 -2
- package/contracts/shared/UpgradableProxyWithAdmin.sol +2 -2
- package/contracts/shared/Versionable.sol +5 -93
- package/contracts/test/TestFee.sol +2 -2
- package/contracts/test/TestRegisterable.sol +1 -1
- package/contracts/test/TestRoleId.sol +6 -6
- package/contracts/test/TestService.sol +6 -7
- package/contracts/types/ClaimId.sol +52 -0
- package/contracts/types/DistributorType.sol +2 -2
- package/contracts/types/Fee.sol +3 -3
- package/contracts/types/NftIdSet.sol +26 -24
- package/contracts/types/ObjectType.sol +9 -5
- package/contracts/types/PayoutId.sol +54 -0
- package/contracts/types/RoleId.sol +19 -4
- package/contracts/types/StateId.sol +4 -0
- package/contracts/types/UFixed.sol +128 -12
- package/contracts/types/Version.sol +4 -1
- package/package.json +6 -5
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +0 -4
- 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/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +0 -1119
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +0 -4
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +0 -1082
- package/artifacts/contracts/instance/base/IService.sol/IService.dbg.json +0 -4
- package/artifacts/contracts/instance/base/ServiceBase.sol/ServiceBase.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.dbg.json +0 -4
- package/artifacts/contracts/registry/IChainNft.sol/IChainNft.json +0 -457
- package/artifacts/contracts/types/UFixed.sol/UFixedMathLib.dbg.json +0 -4
- package/contracts/components/IBaseComponent.sol +0 -19
- 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
- package/contracts/instance/AccessManagedSimple.sol +0 -114
- package/contracts/instance/AccessManagerSimple.sol +0 -682
- package/contracts/instance/IAccessManagerSimple.sol +0 -391
- package/contracts/instance/base/IService.sol +0 -15
- package/contracts/instance/base/ServiceBase.sol +0 -44
- package/contracts/registry/IChainNft.sol +0 -22
@@ -1,95 +1,54 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
|
7
|
-
import {
|
8
|
-
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
12
|
-
import {ISetup} from "./module/ISetup.sol";
|
13
|
-
import {Key32, KeyId, Key32Lib} from "../types/Key32.sol";
|
14
|
-
import {KeyValueStore} from "./base/KeyValueStore.sol";
|
15
|
-
import {NftId} from "../types/NftId.sol";
|
16
|
-
import {NumberId} from "../types/NumberId.sol";
|
17
|
-
import {ObjectType, BUNDLE, DISTRIBUTION, POLICY, POOL, ROLE, PRODUCT, TARGET} from "../types/ObjectType.sol";
|
18
|
-
import {RiskId, RiskIdLib} from "../types/RiskId.sol";
|
19
|
-
import {RoleId, RoleIdLib} from "../types/RoleId.sol";
|
20
|
-
import {StateId, ACTIVE} from "../types/StateId.sol";
|
21
|
-
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
4
|
+
import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
|
5
|
+
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";
|
6
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
7
|
+
import {ShortString, ShortStrings} from "@openzeppelin/contracts/utils/ShortStrings.sol";
|
8
|
+
|
9
|
+
import {RoleId, RoleIdLib } from "../types/RoleId.sol";
|
10
|
+
import {TimestampLib} from "../types/Timestamp.sol";
|
11
|
+
import {IAccess} from "./module/IAccess.sol";
|
22
12
|
|
23
13
|
contract InstanceAccessManager is
|
24
|
-
|
14
|
+
AccessManagedUpgradeable
|
25
15
|
{
|
16
|
+
using RoleIdLib for RoleId;
|
17
|
+
|
26
18
|
string public constant ADMIN_ROLE_NAME = "AdminRole";
|
27
19
|
string public constant PUBLIC_ROLE_NAME = "PublicRole";
|
28
20
|
|
29
21
|
uint64 public constant CUSTOM_ROLE_ID_MIN = 10000;
|
30
22
|
uint32 public constant EXECUTION_DELAY = 0;
|
31
23
|
|
32
|
-
struct RoleInfo {
|
33
|
-
ShortString name;
|
34
|
-
bool isCustom;
|
35
|
-
bool isLocked;
|
36
|
-
Timestamp createdAt;
|
37
|
-
Timestamp updatedAt;
|
38
|
-
}
|
39
|
-
|
40
|
-
struct TargetInfo {
|
41
|
-
ShortString name;
|
42
|
-
bool isCustom;
|
43
|
-
bool isLocked;
|
44
|
-
Timestamp createdAt;
|
45
|
-
Timestamp updatedAt;
|
46
|
-
}
|
47
|
-
|
48
|
-
error ErrorRoleIdInvalid(RoleId roleId);
|
49
|
-
error ErrorRoleIdTooBig(RoleId roleId);
|
50
|
-
error ErrorRoleIdTooSmall(RoleId roleId);
|
51
|
-
error ErrorRoleIdAlreadyExists(RoleId roleId, ShortString name);
|
52
|
-
error ErrorRoleIdNotActive(RoleId roleId);
|
53
|
-
error ErrorRoleNameEmpty(RoleId roleId);
|
54
|
-
error ErrorRoleNameNotUnique(RoleId roleId, ShortString name);
|
55
|
-
error ErrorRoleInvalidUpdate(RoleId roleId, bool isCustom);
|
56
|
-
error ErrorRoleIsCustomIsImmutable(RoleId roleId, bool isCustom, bool isCustomExisting);
|
57
|
-
error ErrorSetLockedForNonexstentRole(RoleId roleId);
|
58
|
-
error ErrorGrantNonexstentRole(RoleId roleId);
|
59
|
-
error ErrorRevokeNonexstentRole(RoleId roleId);
|
60
|
-
error ErrorRenounceNonexstentRole(RoleId roleId);
|
61
|
-
|
62
|
-
error ErrorTargetAddressZero();
|
63
|
-
error ErrorTargetAlreadyExists(address target, ShortString name);
|
64
|
-
error ErrorTargetNameEmpty(address target);
|
65
|
-
error ErrorTargetNameExists(address target, address existingTarget, ShortString name);
|
66
|
-
error ErrorSetLockedForNonexstentTarget(address target);
|
67
|
-
|
68
24
|
// role specific state
|
69
|
-
mapping(RoleId roleId => RoleInfo info) internal _role;
|
25
|
+
mapping(RoleId roleId => IAccess.RoleInfo info) internal _role;
|
70
26
|
mapping(RoleId roleId => EnumerableSet.AddressSet roleMembers) internal _roleMembers;
|
71
27
|
mapping(ShortString name => RoleId roleId) internal _roleForName;
|
72
28
|
RoleId [] internal _roles;
|
73
29
|
|
74
30
|
// target specific state
|
75
|
-
mapping(address target => TargetInfo info) internal _target;
|
31
|
+
mapping(address target => IAccess.TargetInfo info) internal _target;
|
76
32
|
mapping(ShortString name => address target) internal _targetForName;
|
77
33
|
address [] internal _targets;
|
78
34
|
|
79
|
-
|
35
|
+
AccessManager internal _accessManager;
|
80
36
|
|
81
|
-
|
82
|
-
AccessManagedSimple(accessManager)
|
37
|
+
function initialize(address initialAdmin) external initializer
|
83
38
|
{
|
84
|
-
|
39
|
+
// if size of the contract gets too large, this can be externalized which will reduce the contract size considerably
|
40
|
+
_accessManager = new AccessManager(address(this));
|
41
|
+
// this service required admin rights to access manager to be able to grant/revoke roles
|
42
|
+
_accessManager.grantRole(_accessManager.ADMIN_ROLE(), initialAdmin, 0);
|
43
|
+
|
44
|
+
__AccessManaged_init(address(_accessManager));
|
85
45
|
|
86
46
|
_createRole(RoleIdLib.toRoleId(_accessManager.ADMIN_ROLE()), ADMIN_ROLE_NAME, false, false);
|
87
47
|
_createRole(RoleIdLib.toRoleId(_accessManager.PUBLIC_ROLE()), PUBLIC_ROLE_NAME, false, false);
|
88
48
|
}
|
89
49
|
|
90
50
|
//--- Role ------------------------------------------------------//
|
91
|
-
|
92
|
-
function createDefaultRole(RoleId roleId, string memory name) external restricted() {
|
51
|
+
function createGifRole(RoleId roleId, string memory name) external restricted() {
|
93
52
|
_createRole(roleId, name, false, true);
|
94
53
|
}
|
95
54
|
|
@@ -99,7 +58,7 @@ contract InstanceAccessManager is
|
|
99
58
|
|
100
59
|
function setRoleLocked(RoleId roleId, bool locked) external restricted() {
|
101
60
|
if (!roleExists(roleId)) {
|
102
|
-
revert
|
61
|
+
revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
|
103
62
|
}
|
104
63
|
|
105
64
|
_role[roleId].isLocked = locked;
|
@@ -112,11 +71,11 @@ contract InstanceAccessManager is
|
|
112
71
|
|
113
72
|
function grantRole(RoleId roleId, address member) external restricted() returns (bool granted) {
|
114
73
|
if (!roleExists(roleId)) {
|
115
|
-
revert
|
74
|
+
revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
|
116
75
|
}
|
117
76
|
|
118
77
|
if (_role[roleId].isLocked) {
|
119
|
-
revert
|
78
|
+
revert IAccess.ErrorIAccessRoleIdNotActive(roleId);
|
120
79
|
}
|
121
80
|
|
122
81
|
if (!EnumerableSet.contains(_roleMembers[roleId], member)) {
|
@@ -130,7 +89,7 @@ contract InstanceAccessManager is
|
|
130
89
|
|
131
90
|
function revokeRole(RoleId roleId, address member) external restricted() returns (bool revoked) {
|
132
91
|
if (!roleExists(roleId)) {
|
133
|
-
revert
|
92
|
+
revert IAccess.ErrorIAccessRevokeNonexstentRole(roleId);
|
134
93
|
}
|
135
94
|
|
136
95
|
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
@@ -148,7 +107,7 @@ contract InstanceAccessManager is
|
|
148
107
|
address member = msg.sender;
|
149
108
|
|
150
109
|
if (!roleExists(roleId)) {
|
151
|
-
revert
|
110
|
+
revert IAccess.ErrorIAccessRenounceNonexstentRole(roleId);
|
152
111
|
}
|
153
112
|
|
154
113
|
if (EnumerableSet.contains(_roleMembers[roleId], member)) {
|
@@ -173,7 +132,7 @@ contract InstanceAccessManager is
|
|
173
132
|
return _roleForName[ShortStrings.toShortString(name)];
|
174
133
|
}
|
175
134
|
|
176
|
-
function getRole(RoleId roleId) external view returns (RoleInfo memory role) {
|
135
|
+
function getRole(RoleId roleId) external view returns (IAccess.RoleInfo memory role) {
|
177
136
|
return _role[roleId];
|
178
137
|
}
|
179
138
|
|
@@ -190,13 +149,19 @@ contract InstanceAccessManager is
|
|
190
149
|
}
|
191
150
|
|
192
151
|
//--- Target ------------------------------------------------------//
|
152
|
+
function createGifTarget(address target, string memory name) external restricted() {
|
153
|
+
_createTarget(target, name, false, true);
|
154
|
+
}
|
155
|
+
|
193
156
|
function createTarget(address target, string memory name) external restricted() {
|
194
157
|
_createTarget(target, name, true, true);
|
195
158
|
}
|
196
159
|
|
197
|
-
function setTargetLocked(
|
198
|
-
|
199
|
-
|
160
|
+
function setTargetLocked(string memory targetName, bool locked) external restricted() {
|
161
|
+
address target = _targetForName[ShortStrings.toShortString(targetName)];
|
162
|
+
|
163
|
+
if (target == address(0)) {
|
164
|
+
revert IAccess.ErrorIAccessTargetDoesNotExist(ShortStrings.toShortString(targetName));
|
200
165
|
}
|
201
166
|
|
202
167
|
_target[target].isLocked = locked;
|
@@ -214,7 +179,7 @@ contract InstanceAccessManager is
|
|
214
179
|
_validateRoleParameters(roleId, name, isCustom);
|
215
180
|
}
|
216
181
|
|
217
|
-
RoleInfo memory role = RoleInfo(
|
182
|
+
IAccess.RoleInfo memory role = IAccess.RoleInfo(
|
218
183
|
ShortStrings.toShortString(name),
|
219
184
|
isCustom,
|
220
185
|
false, // role un-locked,
|
@@ -233,35 +198,35 @@ contract InstanceAccessManager is
|
|
233
198
|
)
|
234
199
|
internal
|
235
200
|
view
|
236
|
-
returns (RoleInfo memory existingRole)
|
201
|
+
returns (IAccess.RoleInfo memory existingRole)
|
237
202
|
{
|
238
203
|
// check role id
|
239
204
|
uint64 roleIdInt = RoleId.unwrap(roleId);
|
240
205
|
if(roleIdInt == _accessManager.ADMIN_ROLE() || roleIdInt == _accessManager.PUBLIC_ROLE()) {
|
241
|
-
revert
|
206
|
+
revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
|
242
207
|
}
|
243
208
|
|
244
209
|
// prevent changing isCustom for existing roles
|
245
210
|
existingRole = _role[roleId];
|
246
211
|
|
247
212
|
if (existingRole.createdAt.gtz() && isCustom != existingRole.isCustom) {
|
248
|
-
revert
|
213
|
+
revert IAccess.ErrorIAccessRoleIsCustomIsImmutable(roleId, isCustom, existingRole.isCustom);
|
249
214
|
}
|
250
215
|
|
251
216
|
if (isCustom && roleIdInt < CUSTOM_ROLE_ID_MIN) {
|
252
|
-
revert
|
217
|
+
revert IAccess.ErrorIAccessRoleIdTooSmall(roleId);
|
253
218
|
} else if (!isCustom && roleIdInt >= CUSTOM_ROLE_ID_MIN) {
|
254
|
-
revert
|
219
|
+
revert IAccess.ErrorIAccessRoleIdTooBig(roleId);
|
255
220
|
}
|
256
221
|
|
257
222
|
// role name checks
|
258
223
|
ShortString nameShort = ShortStrings.toShortString(name);
|
259
224
|
if (ShortStrings.byteLength(nameShort) == 0) {
|
260
|
-
revert
|
225
|
+
revert IAccess.ErrorIAccessRoleNameEmpty(roleId);
|
261
226
|
}
|
262
227
|
|
263
228
|
if (_roleForName[nameShort] != RoleIdLib.zero() && _roleForName[nameShort] != roleId) {
|
264
|
-
revert
|
229
|
+
revert IAccess.ErrorIAccessRoleNameNotUnique(_roleForName[nameShort], nameShort);
|
265
230
|
}
|
266
231
|
}
|
267
232
|
|
@@ -270,7 +235,14 @@ contract InstanceAccessManager is
|
|
270
235
|
_validateTargetParameters(target, name, isCustom);
|
271
236
|
}
|
272
237
|
|
273
|
-
|
238
|
+
if (_target[target].createdAt.gtz()) {
|
239
|
+
revert IAccess.ErrorIAccessTargetExists(target, _target[target].name);
|
240
|
+
}
|
241
|
+
if (_targetForName[ShortStrings.toShortString(name)] != address(0)) {
|
242
|
+
revert IAccess.ErrorIAccessTargetNameExists(target, _targetForName[ShortStrings.toShortString(name)], ShortStrings.toShortString(name));
|
243
|
+
}
|
244
|
+
|
245
|
+
IAccess.TargetInfo memory info = IAccess.TargetInfo(
|
274
246
|
ShortStrings.toShortString(name),
|
275
247
|
isCustom,
|
276
248
|
_accessManager.isTargetClosed(target), // sync with state in access manager
|
@@ -283,6 +255,43 @@ contract InstanceAccessManager is
|
|
283
255
|
}
|
284
256
|
|
285
257
|
function _validateTargetParameters(address target, string memory name, bool isCustom) internal view {
|
258
|
+
// TODO: implement
|
259
|
+
}
|
260
|
+
|
261
|
+
function setTargetFunctionRole(
|
262
|
+
string memory targetName,
|
263
|
+
bytes4[] calldata selectors,
|
264
|
+
RoleId roleId
|
265
|
+
) public virtual restricted() {
|
266
|
+
address target = _targetForName[ShortStrings.toShortString(targetName)];
|
267
|
+
|
268
|
+
if (target == address(0)) {
|
269
|
+
revert IAccess.ErrorIAccessTargetDoesNotExist(ShortStrings.toShortString(targetName));
|
270
|
+
}
|
271
|
+
if (! roleExists(roleId)) {
|
272
|
+
revert IAccess.ErrorIAccessRoleIdInvalid(roleId);
|
273
|
+
}
|
274
|
+
uint64 roleIdInt = RoleId.unwrap(roleId);
|
275
|
+
_accessManager.setTargetFunctionRole(target, selectors, roleIdInt);
|
276
|
+
}
|
277
|
+
|
278
|
+
function setTargetClosed(string memory targetName, bool closed) public restricted() {
|
279
|
+
address target = _targetForName[ShortStrings.toShortString(targetName)];
|
280
|
+
if (target == address(0)) {
|
281
|
+
revert IAccess.ErrorIAccessTargetDoesNotExist(ShortStrings.toShortString(targetName));
|
282
|
+
}
|
283
|
+
_accessManager.setTargetClosed(target, closed);
|
284
|
+
}
|
285
|
+
|
286
|
+
function isTargetLocked(address target) public view returns (bool locked) {
|
287
|
+
return _accessManager.isTargetClosed(target);
|
288
|
+
}
|
286
289
|
|
290
|
+
function canCall(
|
291
|
+
address caller,
|
292
|
+
address target,
|
293
|
+
bytes4 selector
|
294
|
+
) public view virtual returns (bool immediate, uint32 delay) {
|
295
|
+
return _accessManager.canCall(caller, target, selector);
|
287
296
|
}
|
288
297
|
}
|
@@ -1,61 +1,56 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
2
|
pragma solidity ^0.8.20;
|
3
3
|
|
4
|
-
import {IERC20Metadata} from "@
|
4
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
5
5
|
|
6
6
|
import {DistributorType} from "../types/DistributorType.sol";
|
7
7
|
import {Fee, FeeLib} from "../types/Fee.sol";
|
8
8
|
import {Key32} from "../types/Key32.sol";
|
9
9
|
import {NftId} from "../types/NftId.sol";
|
10
|
-
import {ObjectType, DISTRIBUTOR, INSTANCE, PRODUCT, POLICY, TREASURY} from "../types/ObjectType.sol";
|
10
|
+
import {ObjectType, DISTRIBUTOR, DISTRIBUTION, INSTANCE, PRODUCT, POLICY, POOL, TREASURY, BUNDLE} from "../types/ObjectType.sol";
|
11
11
|
import {ReferralId, ReferralStatus, ReferralLib, REFERRAL_OK, REFERRAL_ERROR_UNKNOWN, REFERRAL_ERROR_EXPIRED, REFERRAL_ERROR_EXHAUSTED} from "../types/Referral.sol";
|
12
12
|
import {Registerable} from "../shared/Registerable.sol";
|
13
13
|
import {RiskId} from "../types/RiskId.sol";
|
14
|
-
import {UFixed,
|
14
|
+
import {UFixed, MathLib, UFixedLib} from "../types/UFixed.sol";
|
15
15
|
import {Version} from "../types/Version.sol";
|
16
|
+
import {StateId} from "../types/StateId.sol";
|
16
17
|
|
17
18
|
import {IRegistry} from "../registry/IRegistry.sol";
|
19
|
+
import {IBundle} from "../instance/module/IBundle.sol";
|
18
20
|
import {IDistribution} from "../instance/module/IDistribution.sol";
|
19
21
|
import {IInstance} from "./IInstance.sol";
|
20
22
|
import {IKeyValueStore} from "../instance/base/IKeyValueStore.sol";
|
21
23
|
import {IPolicy} from "../instance/module/IPolicy.sol";
|
22
24
|
import {IRisk} from "../instance/module/IRisk.sol";
|
25
|
+
import {ISetup} from "../instance/module/ISetup.sol";
|
23
26
|
import {ITreasury} from "../instance/module/ITreasury.sol";
|
24
27
|
import {TimestampLib} from "../types/Timestamp.sol";
|
25
28
|
|
26
29
|
|
27
30
|
contract InstanceReader {
|
31
|
+
bool private _initialized;
|
28
32
|
|
29
33
|
IRegistry internal _registry;
|
30
|
-
NftId internal _instanceNftId;
|
31
34
|
IInstance internal _instance;
|
32
35
|
IKeyValueStore internal _store;
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
)
|
38
|
-
{
|
37
|
+
function initialize(address registry, address instance) public {
|
38
|
+
require(!_initialized, "ERROR:CRD-000:ALREADY_INITIALIZED");
|
39
|
+
|
39
40
|
require(
|
40
41
|
address(registry) != address(0),
|
41
42
|
"ERROR:CRD-001:REGISTRY_ZERO");
|
42
43
|
|
43
|
-
require(
|
44
|
-
instanceNftId.gtz(),
|
45
|
-
"ERROR:CRD-002:NFT_ID_ZERO");
|
46
44
|
|
47
45
|
_registry = IRegistry(registry);
|
48
|
-
_instanceNftId = instanceNftId;
|
49
|
-
IRegistry.ObjectInfo memory instanceInfo = _registry.getObjectInfo(_instanceNftId);
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
"ERROR:CRD-003:PARENT_NOT_INSTANCE");
|
47
|
+
_instance = IInstance(instance);
|
48
|
+
_store = IKeyValueStore(instance);
|
54
49
|
|
55
|
-
|
56
|
-
_store = IKeyValueStore(instanceInfo.objectAddress);
|
50
|
+
_initialized = true;
|
57
51
|
}
|
58
52
|
|
53
|
+
|
59
54
|
// module specific functions
|
60
55
|
|
61
56
|
function getPolicyInfo(NftId policyNftId)
|
@@ -69,6 +64,14 @@ contract InstanceReader {
|
|
69
64
|
}
|
70
65
|
}
|
71
66
|
|
67
|
+
function getPolicyState(NftId policyNftId)
|
68
|
+
public
|
69
|
+
view
|
70
|
+
returns (StateId state)
|
71
|
+
{
|
72
|
+
return _instance.getState(toPolicyKey(policyNftId));
|
73
|
+
}
|
74
|
+
|
72
75
|
function getRiskInfo(RiskId riskId)
|
73
76
|
public
|
74
77
|
view
|
@@ -103,6 +106,17 @@ contract InstanceReader {
|
|
103
106
|
return abi.decode(data, (ITreasury.TreasuryInfo));
|
104
107
|
}
|
105
108
|
}
|
109
|
+
|
110
|
+
function getBundleInfo(NftId bundleNftId)
|
111
|
+
public
|
112
|
+
view
|
113
|
+
returns (IBundle.BundleInfo memory info)
|
114
|
+
{
|
115
|
+
bytes memory data = _store.getData(toBundleKey(bundleNftId));
|
116
|
+
if (data.length > 0) {
|
117
|
+
return abi.decode(data, (IBundle.BundleInfo));
|
118
|
+
}
|
119
|
+
}
|
106
120
|
|
107
121
|
function getDistributorTypeInfo(DistributorType distributorType)
|
108
122
|
public
|
@@ -126,6 +140,38 @@ contract InstanceReader {
|
|
126
140
|
}
|
127
141
|
}
|
128
142
|
|
143
|
+
function getDistributionSetupInfo(NftId distributionNftId)
|
144
|
+
public
|
145
|
+
view
|
146
|
+
returns (ISetup.DistributionSetupInfo memory info)
|
147
|
+
{
|
148
|
+
bytes memory data = _store.getData(toDistributionKey(distributionNftId));
|
149
|
+
if (data.length > 0) {
|
150
|
+
return abi.decode(data, (ISetup.DistributionSetupInfo));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
function getPoolSetupInfo(NftId poolNftId)
|
155
|
+
public
|
156
|
+
view
|
157
|
+
returns (ISetup.PoolSetupInfo memory info)
|
158
|
+
{
|
159
|
+
bytes memory data = _store.getData(toPoolKey(poolNftId));
|
160
|
+
if (data.length > 0) {
|
161
|
+
return abi.decode(data, (ISetup.PoolSetupInfo));
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
function getProductSetupInfo(NftId productNftId)
|
166
|
+
public
|
167
|
+
view
|
168
|
+
returns (ISetup.ProductSetupInfo memory info)
|
169
|
+
{
|
170
|
+
bytes memory data = _store.getData(toProductKey(productNftId));
|
171
|
+
if (data.length > 0) {
|
172
|
+
return abi.decode(data, (ISetup.ProductSetupInfo));
|
173
|
+
}
|
174
|
+
}
|
129
175
|
|
130
176
|
function getReferralInfo(ReferralId referralId)
|
131
177
|
public
|
@@ -175,19 +221,19 @@ contract InstanceReader {
|
|
175
221
|
|
176
222
|
if (info.expiryAt.eqz()) {
|
177
223
|
return (
|
178
|
-
|
224
|
+
UFixedLib.zero(),
|
179
225
|
REFERRAL_ERROR_UNKNOWN());
|
180
226
|
}
|
181
227
|
|
182
228
|
if (info.expiryAt < TimestampLib.blockTimestamp()) {
|
183
229
|
return (
|
184
|
-
|
230
|
+
UFixedLib.zero(),
|
185
231
|
REFERRAL_ERROR_EXPIRED());
|
186
232
|
}
|
187
233
|
|
188
234
|
if (info.usedReferrals >= info.maxReferrals) {
|
189
235
|
return (
|
190
|
-
|
236
|
+
UFixedLib.zero(),
|
191
237
|
REFERRAL_ERROR_EXHAUSTED());
|
192
238
|
}
|
193
239
|
|
@@ -212,6 +258,22 @@ contract InstanceReader {
|
|
212
258
|
return distributorNftId.toKey32(DISTRIBUTOR());
|
213
259
|
}
|
214
260
|
|
261
|
+
function toDistributionKey(NftId distributionNftId) public pure returns (Key32) {
|
262
|
+
return distributionNftId.toKey32(DISTRIBUTION());
|
263
|
+
}
|
264
|
+
|
265
|
+
function toBundleKey(NftId poolNftId) public pure returns (Key32) {
|
266
|
+
return poolNftId.toKey32(BUNDLE());
|
267
|
+
}
|
268
|
+
|
269
|
+
function toPoolKey(NftId poolNftId) public pure returns (Key32) {
|
270
|
+
return poolNftId.toKey32(POOL());
|
271
|
+
}
|
272
|
+
|
273
|
+
function toProductKey(NftId productNftId) public pure returns (Key32) {
|
274
|
+
return productNftId.toKey32(PRODUCT());
|
275
|
+
}
|
276
|
+
|
215
277
|
// low level function
|
216
278
|
function getInstance() external view returns (IInstance instance) {
|
217
279
|
return _instance;
|
@@ -221,15 +283,11 @@ contract InstanceReader {
|
|
221
283
|
return _store;
|
222
284
|
}
|
223
285
|
|
224
|
-
function getInstanceNftId() external view returns (NftId nftId) {
|
225
|
-
return _instanceNftId;
|
226
|
-
}
|
227
|
-
|
228
286
|
function toUFixed(uint256 value, int8 exp) public pure returns (UFixed) {
|
229
|
-
return
|
287
|
+
return UFixedLib.toUFixed(value, exp);
|
230
288
|
}
|
231
289
|
|
232
290
|
function toInt(UFixed value) public pure returns (uint256) {
|
233
|
-
return
|
291
|
+
return UFixedLib.toInt(value);
|
234
292
|
}
|
235
293
|
}
|