@etherisc/gif-next 0.0.2-ebbe63d → 0.0.2-ec436bf-674
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +390 -2
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/BaseComponent.sol/BaseComponent.json +327 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.dbg.json +4 -0
- package/artifacts/contracts/components/Distribution.sol/Distribution.json +618 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IBaseComponent.sol/IBaseComponent.json +280 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IDistributionComponent.sol/IDistributionComponent.json +152 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IPoolComponent.sol/IPoolComponent.json +249 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.dbg.json +4 -0
- package/artifacts/contracts/components/IProductComponent.sol/IProductComponent.json +157 -0
- package/artifacts/contracts/components/Pool.sol/Pool.dbg.json +4 -0
- package/artifacts/contracts/components/Pool.sol/Pool.json +782 -0
- package/artifacts/contracts/components/Product.sol/Product.dbg.json +4 -0
- package/artifacts/contracts/components/Product.sol/Product.json +775 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Cloner.json +66 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock1.json +24 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.dbg.json +4 -0
- package/artifacts/contracts/experiment/cloning/Cloner.sol/Mock2.json +42 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Require.sol/Require.json +105 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.dbg.json +4 -0
- package/artifacts/contracts/experiment/errors/Revert.sol/Revert.json +105 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/A.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/A.json +128 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/A.sol/AShared.json +42 -0
- package/artifacts/contracts/experiment/inheritance/B.sol/B.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/B.sol/B.json +76 -0
- package/artifacts/contracts/experiment/inheritance/C.sol/C.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/C.sol/C.json +89 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/IA.json +128 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IA.sol/ISharedA.json +37 -0
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IB.sol/IB.json +50 -0
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.dbg.json +4 -0
- package/artifacts/contracts/experiment/inheritance/IC.sol/IC.json +63 -0
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/Dummy.sol/LifeCycleModule.json +59 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISM.json +124 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/ISM.sol/ISMEE.json +74 -0
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/SM.sol/SM.json +124 -0
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.dbg.json +4 -0
- package/artifacts/contracts/experiment/statemachine/SimpleStateMachine.sol/SimpleStateMachine.json +207 -0
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.dbg.json +4 -0
- package/artifacts/contracts/experiment/types/TypeA.sol/TypeALib.json +10 -0
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.dbg.json +4 -0
- package/artifacts/contracts/experiment/types/TypeB.sol/TypeBLib.json +10 -0
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagedSimple.sol/AccessManagedSimple.json +101 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/AccessManagerSimple.sol/AccessManagerSimple.json +1132 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.dbg.json +4 -0
- package/artifacts/contracts/instance/IAccessManagerSimple.sol/IAccessManagerSimple.json +1082 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstance.sol/IInstance.json +753 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/IInstanceService.sol/IInstanceService.json +480 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.dbg.json +4 -0
- package/artifacts/contracts/instance/Instance.sol/Instance.json +3539 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceAccessManager.sol/InstanceAccessManager.json +917 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceReader.sol/InstanceReader.json +1388 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceService.sol/InstanceService.json +891 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/InstanceServiceManager.sol/InstanceServiceManager.json +492 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ComponentServiceBase.sol/ComponentServiceBase.json +540 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IInstanceBase.sol/IInstanceBase.json +113 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/IKeyValueStore.sol/IKeyValueStore.json +429 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/ILifecycle.sol/ILifecycle.json +115 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.dbg.json +4 -0
- package/artifacts/contracts/instance/base/KeyValueStore.sol/KeyValueStore.json +502 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.dbg.json +4 -0
- package/artifacts/contracts/instance/base/Lifecycle.sol/Lifecycle.json +169 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IAccess.sol/IAccess.json +211 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IBundle.sol/IBundle.json +10 -0
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IDistribution.sol/IDistribution.json +10 -0
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IPolicy.sol/IPolicy.json +10 -0
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.dbg.json +4 -0
- package/artifacts/contracts/instance/module/IRisk.sol/IRisk.json +10 -0
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.dbg.json +4 -0
- package/artifacts/contracts/instance/module/ISetup.sol/ISetup.json +10 -0
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.dbg.json +4 -0
- package/artifacts/contracts/instance/module/ITreasury.sol/ITreasury.json +10 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/ComponentOwnerService.sol/ComponentOwnerService.json +827 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionService.sol/DistributionService.json +716 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/DistributionServiceManager.sol/DistributionServiceManager.json +448 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IComponentOwnerService.sol/IComponentOwnerService.json +466 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IDistributionService.sol/IDistributionService.json +446 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IPoolService.sol/IPoolService.json +561 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/IProductService.sol/IProductService.json +751 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolService.sol/PoolService.json +855 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.dbg.json +4 -0
- package/artifacts/contracts/instance/service/PoolServiceManager.sol/PoolServiceManager.json +460 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.dbg.json +4 -0
- package/artifacts/contracts/registry/ChainNft.sol/ChainNft.json +771 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistry.sol/IRegistry.json +753 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/IRegistryService.sol/IRegistryService.json +853 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.dbg.json +4 -0
- package/artifacts/contracts/registry/ITransferInterceptor.sol/ITransferInterceptor.json +34 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.dbg.json +4 -0
- package/artifacts/contracts/registry/Registry.sol/Registry.json +947 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryService.sol/RegistryService.json +1237 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.dbg.json +4 -0
- package/artifacts/contracts/registry/RegistryServiceManager.sol/RegistryServiceManager.json +525 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.dbg.json +4 -0
- package/artifacts/contracts/registry/TokenRegistry.sol/TokenRegistry.json +410 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.dbg.json +4 -0
- package/artifacts/contracts/shared/ContractDeployerLib.sol/ContractDeployerLib.json +107 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/contracts/shared/ERC165.sol/ERC165.json +35 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/INftOwnable.sol/INftOwnable.json +127 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.dbg.json +4 -0
- package/artifacts/contracts/shared/IRegisterable.sol/IRegisterable.json +201 -0
- package/artifacts/contracts/shared/IService.sol/IService.dbg.json +4 -0
- package/artifacts/contracts/shared/IService.sol/IService.json +421 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.dbg.json +4 -0
- package/artifacts/contracts/shared/IVersionable.sol/IVersionable.json +205 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.dbg.json +4 -0
- package/artifacts/contracts/shared/NftOwnable.sol/NftOwnable.json +158 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.dbg.json +4 -0
- package/artifacts/contracts/shared/ProxyManager.sol/ProxyManager.json +349 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.dbg.json +4 -0
- package/artifacts/contracts/shared/Registerable.sol/Registerable.json +274 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.dbg.json +4 -0
- package/artifacts/contracts/shared/RegisterableUpgradable.sol/RegisterableUpgradable.json +442 -0
- package/artifacts/contracts/shared/Service.sol/Service.dbg.json +4 -0
- package/artifacts/contracts/shared/Service.sol/Service.json +468 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.dbg.json +4 -0
- package/artifacts/contracts/shared/TokenHandler.sol/TokenHandler.json +96 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.dbg.json +4 -0
- package/artifacts/contracts/shared/UpgradableProxyWithAdmin.sol/UpgradableProxyWithAdmin.json +129 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.dbg.json +4 -0
- package/artifacts/contracts/shared/Versionable.sol/Versionable.json +228 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.dbg.json +4 -0
- package/artifacts/contracts/test/TestFee.sol/TestFee.json +119 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.dbg.json +4 -0
- package/artifacts/contracts/test/TestRegisterable.sol/TestRegisterable.json +305 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.dbg.json +4 -0
- package/artifacts/contracts/test/TestRoleId.sol/TestRoleId.json +116 -0
- package/artifacts/contracts/test/TestService.sol/TestService.dbg.json +4 -0
- package/artifacts/contracts/test/TestService.sol/TestService.json +600 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.dbg.json +4 -0
- package/artifacts/contracts/test/TestToken.sol/TestUsdc.json +376 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersion.sol/TestVersion.json +218 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.dbg.json +4 -0
- package/artifacts/contracts/test/TestVersionable.sol/TestVersionable.json +286 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.dbg.json +4 -0
- package/artifacts/contracts/test/Usdc.sol/USDC.json +376 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.dbg.json +4 -0
- package/artifacts/contracts/types/AddressSet.sol/LibAddressSet.json +10 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.dbg.json +4 -0
- package/artifacts/contracts/types/Blocknumber.sol/BlocknumberLib.json +174 -0
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/ChainId.sol/ChainIdLib.json +10 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/DistributorType.sol/DistributorTypeLib.json +104 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.dbg.json +4 -0
- package/artifacts/contracts/types/Fee.sol/FeeLib.json +257 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.dbg.json +4 -0
- package/artifacts/contracts/types/Key32.sol/Key32Lib.json +125 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/NftId.sol/NftIdLib.json +153 -0
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.dbg.json +4 -0
- package/artifacts/contracts/types/NftIdSet.sol/LibNftIdSet.json +10 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/NumberId.sol/NumberIdLib.json +100 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.dbg.json +4 -0
- package/artifacts/contracts/types/ObjectType.sol/ObjectTypeLib.json +92 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.dbg.json +4 -0
- package/artifacts/contracts/types/Referral.sol/ReferralLib.json +123 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RiskId.sol/RiskIdLib.json +86 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/RoleId.sol/RoleIdLib.json +156 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.dbg.json +4 -0
- package/artifacts/contracts/types/StateId.sol/StateIdLib.json +92 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.dbg.json +4 -0
- package/artifacts/contracts/types/Timestamp.sol/TimestampLib.json +249 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/MathLib.json +10 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.dbg.json +4 -0
- package/artifacts/contracts/types/UFixed.sol/UFixedLib.json +479 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionLib.json +177 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.dbg.json +4 -0
- package/artifacts/contracts/types/Version.sol/VersionPartLib.json +49 -0
- package/contracts/components/BaseComponent.sol +91 -0
- package/contracts/components/Distribution.sol +160 -0
- package/contracts/components/IBaseComponent.sol +25 -0
- package/contracts/components/IDistributionComponent.sol +44 -0
- package/contracts/components/IPoolComponent.sol +62 -0
- package/contracts/components/IProductComponent.sol +35 -0
- package/contracts/components/Pool.sol +243 -0
- package/contracts/components/Product.sol +297 -0
- package/contracts/experiment/cloning/Cloner.sol +47 -0
- package/contracts/experiment/errors/Require.sol +38 -0
- package/contracts/experiment/errors/Revert.sol +44 -0
- package/contracts/experiment/inheritance/A.sol +53 -0
- package/contracts/experiment/inheritance/B.sol +28 -0
- package/contracts/experiment/inheritance/C.sol +34 -0
- package/contracts/experiment/inheritance/IA.sol +13 -0
- package/contracts/experiment/inheritance/IB.sol +10 -0
- package/contracts/experiment/inheritance/IC.sol +12 -0
- package/contracts/experiment/statemachine/Dummy.sol +27 -0
- package/contracts/experiment/statemachine/ISM.sol +25 -0
- package/contracts/experiment/statemachine/SM.sol +57 -0
- package/contracts/experiment/statemachine/SimpleStateMachine.sol +31 -0
- package/contracts/experiment/types/TypeA.sol +47 -0
- package/contracts/experiment/types/TypeB.sol +29 -0
- package/contracts/instance/AccessManagedSimple.sol +115 -0
- package/contracts/instance/AccessManagerSimple.sol +692 -0
- package/contracts/instance/IAccessManagerSimple.sol +391 -0
- package/contracts/instance/IInstance.sol +39 -0
- package/contracts/instance/IInstanceService.sol +30 -0
- package/contracts/instance/Instance.sol +443 -0
- package/contracts/instance/InstanceAccessManager.sol +288 -0
- package/contracts/instance/InstanceReader.sol +306 -0
- package/contracts/instance/InstanceService.sol +182 -0
- package/contracts/instance/InstanceServiceManager.sol +56 -0
- package/contracts/instance/base/ComponentServiceBase.sol +118 -0
- package/contracts/instance/base/IInstanceBase.sol +23 -0
- package/contracts/instance/base/IKeyValueStore.sol +49 -0
- package/contracts/instance/base/ILifecycle.sol +30 -0
- package/contracts/instance/base/KeyValueStore.sol +172 -0
- package/contracts/instance/base/Lifecycle.sol +100 -0
- package/contracts/instance/module/IAccess.sol +38 -0
- package/contracts/instance/module/IBundle.sol +20 -0
- package/contracts/instance/module/IDistribution.sol +39 -0
- package/contracts/instance/module/IPolicy.sol +45 -0
- package/contracts/instance/module/IRisk.sol +11 -0
- package/contracts/instance/module/ISetup.sol +44 -0
- package/contracts/instance/module/ITreasury.sol +23 -0
- package/contracts/instance/service/ComponentOwnerService.sol +317 -0
- package/contracts/instance/service/DistributionService.sol +87 -0
- package/contracts/instance/service/DistributionServiceManager.sol +53 -0
- package/contracts/instance/service/IComponentOwnerService.sol +20 -0
- package/contracts/instance/service/IDistributionService.sol +12 -0
- package/contracts/instance/service/IPoolService.sol +37 -0
- package/contracts/instance/service/IProductService.sol +107 -0
- package/contracts/instance/service/PoolService.sol +193 -0
- package/contracts/instance/service/PoolServiceManager.sol +53 -0
- package/contracts/registry/ChainNft.sol +202 -0
- package/contracts/registry/IRegistry.sol +94 -0
- package/contracts/registry/IRegistryService.sol +33 -0
- package/contracts/registry/ITransferInterceptor.sol +6 -0
- package/contracts/registry/Registry.sol +489 -0
- package/contracts/registry/RegistryService.sol +399 -0
- package/contracts/registry/RegistryServiceManager.sol +80 -0
- package/contracts/registry/TokenRegistry.sol +111 -0
- package/contracts/shared/ContractDeployerLib.sol +72 -0
- package/contracts/shared/ERC165.sol +25 -0
- package/contracts/shared/INftOwnable.sol +22 -0
- package/contracts/shared/IRegisterable.sol +17 -0
- package/contracts/shared/IService.sol +15 -0
- package/contracts/shared/IVersionable.sol +96 -0
- package/contracts/shared/NftOwnable.sol +136 -0
- package/contracts/shared/ProxyManager.sol +94 -0
- package/contracts/shared/Registerable.sol +90 -0
- package/contracts/shared/RegisterableUpgradable.sol +16 -0
- package/contracts/shared/Service.sol +55 -0
- package/contracts/shared/TokenHandler.sol +27 -0
- package/contracts/shared/UpgradableProxyWithAdmin.sol +16 -0
- package/contracts/shared/Versionable.sol +147 -0
- package/contracts/test/TestFee.sol +25 -0
- package/contracts/test/TestRegisterable.sol +18 -0
- package/contracts/test/TestRoleId.sol +14 -0
- package/contracts/test/TestService.sol +24 -0
- package/contracts/{Dip.sol → test/TestToken.sol} +5 -5
- package/contracts/test/TestVersion.sol +44 -0
- package/contracts/test/TestVersionable.sol +17 -0
- package/contracts/test/Usdc.sol +26 -0
- package/contracts/types/AddressSet.sol +58 -0
- package/contracts/types/Blocknumber.sol +118 -0
- package/contracts/types/ChainId.sol +38 -0
- package/contracts/types/DistributorType.sol +55 -0
- package/contracts/types/Fee.sol +56 -0
- package/contracts/types/Key32.sol +50 -0
- package/contracts/types/NftId.sol +72 -0
- package/contracts/types/NftIdSet.sol +60 -0
- package/contracts/types/NumberId.sol +52 -0
- package/contracts/types/ObjectType.sol +152 -0
- package/contracts/types/Referral.sol +85 -0
- package/contracts/types/RiskId.sol +43 -0
- package/contracts/types/RoleId.sol +89 -0
- package/contracts/types/StateId.sol +105 -0
- package/contracts/types/Timestamp.sol +127 -0
- package/contracts/types/UFixed.sol +325 -0
- package/contracts/types/Version.sol +107 -0
- package/package.json +26 -10
- package/artifacts/contracts/Dip.sol/DIP.dbg.json +0 -4
- package/artifacts/contracts/Dip.sol/DIP.json +0 -338
- package/artifacts/contracts/Lock.sol/Lock.dbg.json +0 -4
- package/artifacts/contracts/Lock.sol/Lock.json +0 -74
- package/contracts/Lock.sol +0 -34
@@ -0,0 +1,147 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
5
|
+
|
6
|
+
import {Blocknumber, blockNumber} from "../types/Blocknumber.sol";
|
7
|
+
import {Timestamp, TimestampLib} from "../types/Timestamp.sol";
|
8
|
+
import {Version, VersionPart, VersionLib} from "../types/Version.sol";
|
9
|
+
|
10
|
+
import {IVersionable} from "./IVersionable.sol";
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
abstract contract Versionable is
|
15
|
+
Initializable,
|
16
|
+
IVersionable
|
17
|
+
{
|
18
|
+
// keccak256(abi.encode(uint256(keccak256("gif-next.contracts.shared.Versionable.sol")) - 1)) & ~bytes32(uint256(0xff))
|
19
|
+
bytes32 private constant VERSIONABLE_LOCATION_V1 = 0x4f61291a8ac3d020d0a7d919a76b8592aa88385744dee3f8b4f3873b969ed900;
|
20
|
+
|
21
|
+
|
22
|
+
/// @custom:storage-location erc7201:gif-next.contracts.shared.Versionable.sol
|
23
|
+
struct VersionableStorage {
|
24
|
+
mapping(Version version => VersionInfo info) _versionHistory;
|
25
|
+
Version [] _versions;
|
26
|
+
Version _v1;
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
constructor() {
|
31
|
+
_disableInitializers();
|
32
|
+
}
|
33
|
+
// TODO write test where new version of private _updateVersionHistory is added and used...
|
34
|
+
function initialize(
|
35
|
+
address implementation,
|
36
|
+
address activatedBy,
|
37
|
+
bytes memory data
|
38
|
+
)
|
39
|
+
public
|
40
|
+
initializer
|
41
|
+
{
|
42
|
+
_updateVersionHistory(implementation, activatedBy);
|
43
|
+
_initialize(activatedBy, data);
|
44
|
+
}
|
45
|
+
|
46
|
+
// TODO activatedBy MUST ALWAYS be an owner?
|
47
|
+
function upgrade(
|
48
|
+
address implementation,
|
49
|
+
address activatedBy,
|
50
|
+
bytes memory data
|
51
|
+
)
|
52
|
+
external
|
53
|
+
reinitializer(VersionLib.toUint64(getVersion()))
|
54
|
+
{
|
55
|
+
_updateVersionHistory(implementation, activatedBy);
|
56
|
+
_upgrade(data);
|
57
|
+
}
|
58
|
+
|
59
|
+
function isInitialized(Version _version) public override view returns(bool) {
|
60
|
+
return _getVersionableStorage()._versionHistory[_version].activatedIn.toInt() > 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
function getVersion() public pure virtual returns(Version);
|
64
|
+
|
65
|
+
function getVersionCount() public view override returns(uint256) {
|
66
|
+
return _getVersionableStorage()._versions.length;
|
67
|
+
}
|
68
|
+
|
69
|
+
function getVersion(uint256 idx) public view override returns(Version) {
|
70
|
+
return _getVersionableStorage()._versions[idx];
|
71
|
+
}
|
72
|
+
|
73
|
+
function getVersionInfo(Version _version) public override view returns(VersionInfo memory) {
|
74
|
+
return _getVersionableStorage()._versionHistory[_version];
|
75
|
+
}
|
76
|
+
|
77
|
+
function getInitializedVersion() public view returns(uint64) {
|
78
|
+
return _getInitializedVersion();
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
// IMPORTANT each version must implement this function
|
84
|
+
// each implementation MUST use onlyInitialising modifier
|
85
|
+
// each implementation MUST call intializers of all base contracts...
|
86
|
+
function _initialize(address owner, bytes memory data)
|
87
|
+
internal
|
88
|
+
onlyInitializing
|
89
|
+
virtual
|
90
|
+
{
|
91
|
+
revert();
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
// IMPORTANT each version except version "1" must implement this function
|
96
|
+
// each implementation MUST use onlyInitialising modifier
|
97
|
+
function _upgrade(bytes memory data)
|
98
|
+
internal
|
99
|
+
onlyInitializing
|
100
|
+
virtual
|
101
|
+
{
|
102
|
+
revert();
|
103
|
+
}
|
104
|
+
|
105
|
+
function _getVersionableStorage() private pure returns (VersionableStorage storage $) {
|
106
|
+
assembly {
|
107
|
+
$.slot := VERSIONABLE_LOCATION_V1
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
// can only be called once per contract
|
112
|
+
// needs to be called inside the proxy upgrade tx
|
113
|
+
// TODO run reinitializer(version().toUint64()) modifier after "version()" is checked,
|
114
|
+
function _updateVersionHistory(
|
115
|
+
address implementation,
|
116
|
+
address activatedBy
|
117
|
+
)
|
118
|
+
private
|
119
|
+
onlyInitializing
|
120
|
+
{
|
121
|
+
VersionableStorage storage $ = _getVersionableStorage();
|
122
|
+
|
123
|
+
uint64 version = _getInitializedVersion();
|
124
|
+
|
125
|
+
Version thisVersion = getVersion();
|
126
|
+
|
127
|
+
if(version == 1) {
|
128
|
+
// thisVersion is alias to version "1"
|
129
|
+
$._v1 = thisVersion;
|
130
|
+
}
|
131
|
+
else {
|
132
|
+
require(thisVersion > $._v1, "INVALID VERSION");
|
133
|
+
}
|
134
|
+
|
135
|
+
// update version history
|
136
|
+
$._versions.push(thisVersion);
|
137
|
+
$._versionHistory[thisVersion] = VersionInfo(
|
138
|
+
thisVersion,
|
139
|
+
implementation,
|
140
|
+
activatedBy,
|
141
|
+
TimestampLib.blockTimestamp(),
|
142
|
+
blockNumber()
|
143
|
+
);
|
144
|
+
|
145
|
+
emit LogVersionableInitialized(thisVersion, implementation, activatedBy);
|
146
|
+
}
|
147
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {UFixed, UFixedLib} from "../types/UFixed.sol";
|
5
|
+
import {Fee, FeeLib} from "../types/Fee.sol";
|
6
|
+
|
7
|
+
contract TestFee {
|
8
|
+
|
9
|
+
function createFee(
|
10
|
+
uint256 fractionalValue,
|
11
|
+
int8 exponent,
|
12
|
+
uint256 fixedValue
|
13
|
+
)
|
14
|
+
external
|
15
|
+
pure
|
16
|
+
returns(Fee memory fee)
|
17
|
+
{
|
18
|
+
return FeeLib.toFee(UFixedLib.toUFixed(fractionalValue, exponent), fixedValue);
|
19
|
+
}
|
20
|
+
|
21
|
+
function getZeroFee() external pure returns(Fee memory fee) {
|
22
|
+
return FeeLib.zeroFee();
|
23
|
+
}
|
24
|
+
|
25
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../contracts/types/NftId.sol";
|
5
|
+
import {ObjectType, TOKEN} from "../../contracts/types/ObjectType.sol";
|
6
|
+
import {IRegistry} from "../../contracts/registry/IRegistry.sol";
|
7
|
+
import {Registerable} from "../../contracts/shared/Registerable.sol";
|
8
|
+
|
9
|
+
contract TestRegisterable is Registerable {
|
10
|
+
|
11
|
+
constructor(address registry, NftId registryNftId, ObjectType objectType, bool isInterceptor, address initialOwner)
|
12
|
+
//Registerable(registry, registryNftId)
|
13
|
+
// solhint-disable-next-line no-empty-blocks
|
14
|
+
{
|
15
|
+
bytes memory data = "";
|
16
|
+
_initializeRegisterable(registry, registryNftId, objectType, isInterceptor, initialOwner, data);
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {RoleId, RoleIdLib, PRODUCT_OWNER_ROLE_NAME, PRODUCT_OWNER_ROLE, POOL_OWNER_ROLE_NAME, POOL_OWNER_ROLE} from "../../contracts/types/RoleId.sol";
|
5
|
+
|
6
|
+
contract TestRoleId {
|
7
|
+
function getRole(uint256 roleNum) external pure returns (RoleId) { return RoleIdLib.toRoleId(roleNum); }
|
8
|
+
|
9
|
+
function getProductOwnerRoleName() external pure returns (string memory) { return PRODUCT_OWNER_ROLE_NAME(); }
|
10
|
+
function getProductOwnerRole() external pure returns (RoleId) { return PRODUCT_OWNER_ROLE(); }
|
11
|
+
|
12
|
+
function getPoolOwnerRoleName() external pure returns (string memory) { return POOL_OWNER_ROLE_NAME(); }
|
13
|
+
function getPoolOwnerRole() external pure returns (RoleId) { return POOL_OWNER_ROLE(); }
|
14
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {NftId} from "../../contracts/types/NftId.sol";
|
5
|
+
import {Version, VersionLib} from "../../contracts/types/Version.sol";
|
6
|
+
import {Service} from "../../contracts/shared/Service.sol";
|
7
|
+
|
8
|
+
import {IVersionable} from "../../contracts/shared/IVersionable.sol";
|
9
|
+
import {Versionable} from "../../contracts/shared/Versionable.sol";
|
10
|
+
|
11
|
+
contract TestService is Service {
|
12
|
+
|
13
|
+
string public constant NAME = "TestService";
|
14
|
+
|
15
|
+
constructor(address registry, NftId registryNftId, address initialOwner)
|
16
|
+
// solhint-disable-next-line no-empty-blocks
|
17
|
+
{
|
18
|
+
_initializeService(registry, initialOwner);
|
19
|
+
}
|
20
|
+
|
21
|
+
function getName() public pure override returns(string memory name) {
|
22
|
+
return NAME;
|
23
|
+
}
|
24
|
+
}
|
@@ -1,14 +1,14 @@
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
2
|
-
pragma solidity ^0.8.
|
2
|
+
pragma solidity ^0.8.19;
|
3
3
|
|
4
4
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
5
5
|
|
6
|
-
contract
|
6
|
+
contract TestUsdc is ERC20 {
|
7
7
|
|
8
8
|
// https://etherscan.io/token/0xc719d010b63e5bbf2c0551872cd5316ed26acd83#readContract
|
9
|
-
string public constant NAME = "
|
10
|
-
string public constant SYMBOL = "
|
11
|
-
uint8 public constant DECIMALS =
|
9
|
+
string public constant NAME = "USDC - Test";
|
10
|
+
string public constant SYMBOL = "USDC";
|
11
|
+
uint8 public constant DECIMALS = 6;
|
12
12
|
uint256 public constant INITIAL_SUPPLY = 10**9 * 10**DECIMALS; // 1 Billion 1'000'000'000
|
13
13
|
// decimals == 18 (openzeppelin erc20 default)
|
14
14
|
constructor()
|
@@ -0,0 +1,44 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {Version, VersionPart, VersionLib} from "../types/Version.sol";
|
5
|
+
|
6
|
+
contract TestVersion {
|
7
|
+
|
8
|
+
function createVersion(uint major, uint minor, uint patch) external pure returns(Version) {
|
9
|
+
return VersionLib.toVersion(major, minor, patch);
|
10
|
+
}
|
11
|
+
|
12
|
+
function createVersionPart(uint versionPart) external pure returns(VersionPart) {
|
13
|
+
return VersionLib.toVersionPart(uint8(versionPart));
|
14
|
+
}
|
15
|
+
|
16
|
+
function getVersionParts(Version version)
|
17
|
+
external
|
18
|
+
pure
|
19
|
+
returns(
|
20
|
+
VersionPart major,
|
21
|
+
VersionPart minor,
|
22
|
+
VersionPart patch
|
23
|
+
)
|
24
|
+
{
|
25
|
+
return version.toVersionParts();
|
26
|
+
}
|
27
|
+
|
28
|
+
function getMajorPart(Version version) external pure returns(VersionPart major) {
|
29
|
+
return version.toMajorPart();
|
30
|
+
}
|
31
|
+
|
32
|
+
function getZeroVersion() external pure returns(Version) {
|
33
|
+
return VersionLib.zeroVersion();
|
34
|
+
}
|
35
|
+
|
36
|
+
function isSameVersion(Version a, Version b) external pure returns(bool) {
|
37
|
+
return a == b;
|
38
|
+
}
|
39
|
+
|
40
|
+
function isLargerVersion(Version a, Version b) external pure returns(bool) {
|
41
|
+
return a > b;
|
42
|
+
}
|
43
|
+
|
44
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {Version, VersionLib} from "../../contracts/types/Version.sol";
|
5
|
+
import {Versionable} from "../../contracts/shared/Versionable.sol";
|
6
|
+
|
7
|
+
contract TestVersionable is Versionable {
|
8
|
+
|
9
|
+
function getVersion()
|
10
|
+
public
|
11
|
+
pure
|
12
|
+
virtual override
|
13
|
+
returns(Version)
|
14
|
+
{
|
15
|
+
return VersionLib.toVersion(3,0,0);
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
5
|
+
|
6
|
+
contract USDC is ERC20 {
|
7
|
+
|
8
|
+
// https://etherscan.io/token/0xc719d010b63e5bbf2c0551872cd5316ed26acd83#readContract
|
9
|
+
string public constant NAME = "USDC - DUMMY";
|
10
|
+
string public constant SYMBOL = "USDC";
|
11
|
+
uint8 public constant DECIMALS = 6;
|
12
|
+
uint256 public constant INITIAL_SUPPLY = 10**9 * 10**DECIMALS; // 1 Billion 1'000'000'000
|
13
|
+
// decimals == 18 (openzeppelin erc20 default)
|
14
|
+
constructor()
|
15
|
+
ERC20(NAME, SYMBOL)
|
16
|
+
{
|
17
|
+
_mint(
|
18
|
+
_msgSender(),
|
19
|
+
INITIAL_SUPPLY
|
20
|
+
);
|
21
|
+
}
|
22
|
+
|
23
|
+
function decimals() public pure override returns(uint8) {
|
24
|
+
return DECIMALS;
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
// based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/EnumerableSet.sol
|
5
|
+
library LibAddressSet {
|
6
|
+
|
7
|
+
struct Set {
|
8
|
+
address[] elements;
|
9
|
+
mapping(address element => uint256 index) at;
|
10
|
+
}
|
11
|
+
|
12
|
+
function add(Set storage set, address element) external returns(bool added) {
|
13
|
+
if (set.at[element] == 0) {
|
14
|
+
set.elements.push(element);
|
15
|
+
set.at[element] = set.elements.length;
|
16
|
+
return true;
|
17
|
+
} else {
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
function remove(Set storage set, address element) external returns(bool removed) {
|
23
|
+
uint256 elementIndex = set.at[element];
|
24
|
+
|
25
|
+
if (elementIndex > 0) {
|
26
|
+
uint256 toDeleteIndex = elementIndex - 1;
|
27
|
+
uint256 lastIndex = set.elements.length - 1;
|
28
|
+
|
29
|
+
if (lastIndex != toDeleteIndex) {
|
30
|
+
address lastElement = set.elements[lastIndex];
|
31
|
+
set.elements[toDeleteIndex] = lastElement;
|
32
|
+
set.at[lastElement] = elementIndex; // Replace lastValue's index to valueIndex
|
33
|
+
}
|
34
|
+
|
35
|
+
set.elements.pop();
|
36
|
+
delete set.at[element];
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
|
43
|
+
function isEmpty(Set storage set) external view returns(bool empty) {
|
44
|
+
return set.elements.length == 0;
|
45
|
+
}
|
46
|
+
|
47
|
+
function contains(Set storage set, address element) external view returns(bool inSet) {
|
48
|
+
return set.at[element] > 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
function getLength(Set storage set) external view returns(uint256 length) {
|
52
|
+
return set.elements.length;
|
53
|
+
}
|
54
|
+
|
55
|
+
function getElementAt(Set storage set, uint256 index) external view returns(address element) {
|
56
|
+
return set.elements[index];
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
type Blocknumber is uint32;
|
5
|
+
|
6
|
+
using {
|
7
|
+
gtBlocknumber as >,
|
8
|
+
gteBlocknumber as >=,
|
9
|
+
ltBlocknumber as <,
|
10
|
+
lteBlocknumber as <=,
|
11
|
+
eqBlocknumber as ==,
|
12
|
+
neBlocknumber as !=,
|
13
|
+
BlocknumberLib.toInt
|
14
|
+
} for Blocknumber global;
|
15
|
+
|
16
|
+
/// @dev return true if Blocknumber a is greater than Blocknumber b
|
17
|
+
function gtBlocknumber(Blocknumber a, Blocknumber b) pure returns (bool) {
|
18
|
+
return Blocknumber.unwrap(a) > Blocknumber.unwrap(b);
|
19
|
+
}
|
20
|
+
|
21
|
+
/// @dev return true if Blocknumber a is greater than or equal to Blocknumber b
|
22
|
+
function gteBlocknumber(Blocknumber a, Blocknumber b) pure returns (bool) {
|
23
|
+
return Blocknumber.unwrap(a) >= Blocknumber.unwrap(b);
|
24
|
+
}
|
25
|
+
|
26
|
+
/// @dev return true if Blocknumber a is less than Blocknumber b
|
27
|
+
function ltBlocknumber(Blocknumber a, Blocknumber b) pure returns (bool) {
|
28
|
+
return Blocknumber.unwrap(a) < Blocknumber.unwrap(b);
|
29
|
+
}
|
30
|
+
|
31
|
+
/// @dev return true if Blocknumber a is less than or equal to Blocknumber b
|
32
|
+
function lteBlocknumber(Blocknumber a, Blocknumber b) pure returns (bool) {
|
33
|
+
return Blocknumber.unwrap(a) <= Blocknumber.unwrap(b);
|
34
|
+
}
|
35
|
+
|
36
|
+
/// @dev return true if Blocknumber a is equal to Blocknumber b
|
37
|
+
function eqBlocknumber(Blocknumber a, Blocknumber b) pure returns (bool) {
|
38
|
+
return Blocknumber.unwrap(a) == Blocknumber.unwrap(b);
|
39
|
+
}
|
40
|
+
|
41
|
+
/// @dev return true if Blocknumber a is not equal to Blocknumber b
|
42
|
+
function neBlocknumber(Blocknumber a, Blocknumber b) pure returns (bool) {
|
43
|
+
return Blocknumber.unwrap(a) != Blocknumber.unwrap(b);
|
44
|
+
}
|
45
|
+
|
46
|
+
/// @dev Converts the uint256 to a Blocknumber.
|
47
|
+
function toBlocknumber(uint256 blocknum) pure returns (Blocknumber) {
|
48
|
+
return Blocknumber.wrap(uint32(blocknum));
|
49
|
+
}
|
50
|
+
|
51
|
+
function blockBlocknumber() view returns (Blocknumber) {
|
52
|
+
return toBlocknumber(block.number);
|
53
|
+
}
|
54
|
+
|
55
|
+
/// @dev Return the Blocknumber zero (0)
|
56
|
+
function zeroBlocknumber() pure returns (Blocknumber) {
|
57
|
+
return toBlocknumber(0);
|
58
|
+
}
|
59
|
+
|
60
|
+
/// @dev Return the current block number
|
61
|
+
function blockNumber() view returns (Blocknumber) {
|
62
|
+
return toBlocknumber(block.number);
|
63
|
+
}
|
64
|
+
|
65
|
+
library BlocknumberLib {
|
66
|
+
/// @dev return true if Blocknumber a is greater than Blocknumber b
|
67
|
+
function gt(
|
68
|
+
Blocknumber a,
|
69
|
+
Blocknumber b
|
70
|
+
) public pure returns (bool isAfter) {
|
71
|
+
return gtBlocknumber(a, b);
|
72
|
+
}
|
73
|
+
|
74
|
+
/// @dev return true if Blocknumber a is greater than or equal to Blocknumber b
|
75
|
+
function gte(
|
76
|
+
Blocknumber a,
|
77
|
+
Blocknumber b
|
78
|
+
) public pure returns (bool isAfterOrSame) {
|
79
|
+
return gteBlocknumber(a, b);
|
80
|
+
}
|
81
|
+
|
82
|
+
/// @dev return true if Blocknumber a is less than Blocknumber b
|
83
|
+
function lt(
|
84
|
+
Blocknumber a,
|
85
|
+
Blocknumber b
|
86
|
+
) public pure returns (bool isBefore) {
|
87
|
+
return ltBlocknumber(a, b);
|
88
|
+
}
|
89
|
+
|
90
|
+
/// @dev return true if Blocknumber a is less than or equal to Blocknumber b
|
91
|
+
function lte(
|
92
|
+
Blocknumber a,
|
93
|
+
Blocknumber b
|
94
|
+
) public pure returns (bool isBeforeOrSame) {
|
95
|
+
return lteBlocknumber(a, b);
|
96
|
+
}
|
97
|
+
|
98
|
+
/// @dev return true if Blocknumber a is equal to Blocknumber b
|
99
|
+
function eq(
|
100
|
+
Blocknumber a,
|
101
|
+
Blocknumber b
|
102
|
+
) public pure returns (bool isSame) {
|
103
|
+
return eqBlocknumber(a, b);
|
104
|
+
}
|
105
|
+
|
106
|
+
/// @dev return true if Blocknumber a is not equal to Blocknumber b
|
107
|
+
function ne(
|
108
|
+
Blocknumber a,
|
109
|
+
Blocknumber b
|
110
|
+
) public pure returns (bool isDifferent) {
|
111
|
+
return neBlocknumber(a, b);
|
112
|
+
}
|
113
|
+
|
114
|
+
/// @dev converts the Blocknumber to a uint256
|
115
|
+
function toInt(Blocknumber blocknumber) public pure returns (uint256) {
|
116
|
+
return uint256(uint32(Blocknumber.unwrap(blocknumber)));
|
117
|
+
}
|
118
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
/// @dev bytes5 (uint40) allows for chain ids up to 13 digits
|
5
|
+
type ChainId is bytes5;
|
6
|
+
|
7
|
+
// type bindings
|
8
|
+
using {eqChainId as ==, neChainId as !=, ChainIdLib.toInt} for ChainId global;
|
9
|
+
|
10
|
+
// general pure free functions
|
11
|
+
/// @dev Converts the uint256 to a ChainId.
|
12
|
+
function toChainId(uint256 chainId) pure returns (ChainId) {
|
13
|
+
return ChainId.wrap(bytes5(uint40(chainId)));
|
14
|
+
}
|
15
|
+
|
16
|
+
/// @dev Return the ChainId for the chain the contract is deployed to
|
17
|
+
function thisChainId() view returns (ChainId) {
|
18
|
+
return toChainId(block.chainid);
|
19
|
+
}
|
20
|
+
|
21
|
+
// pure free functions for operators
|
22
|
+
/// @dev Returns true if the values are equal (==).
|
23
|
+
function eqChainId(ChainId a, ChainId b) pure returns (bool isSame) {
|
24
|
+
return ChainId.unwrap(a) == ChainId.unwrap(b);
|
25
|
+
}
|
26
|
+
|
27
|
+
/// @dev Returns true if the values are not equal (!=).
|
28
|
+
function neChainId(ChainId a, ChainId b) pure returns (bool isDifferent) {
|
29
|
+
return ChainId.unwrap(a) != ChainId.unwrap(b);
|
30
|
+
}
|
31
|
+
|
32
|
+
// library functions that operate on user defined type
|
33
|
+
library ChainIdLib {
|
34
|
+
/// @dev Converts the ChainId to a uint256.
|
35
|
+
function toInt(ChainId chainId) internal pure returns (uint256) {
|
36
|
+
return uint256(uint40(ChainId.unwrap(chainId)));
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.20;
|
3
|
+
|
4
|
+
import {Key32, KeyId, Key32Lib} from "./Key32.sol";
|
5
|
+
import {NftId} from "./NftId.sol";
|
6
|
+
import {DISTRIBUTION_TYPE} from "./ObjectType.sol";
|
7
|
+
|
8
|
+
type DistributorType is bytes8;
|
9
|
+
|
10
|
+
// type bindings
|
11
|
+
using {
|
12
|
+
eqDistributorType as ==,
|
13
|
+
neDistributorType as !=,
|
14
|
+
DistributorTypeLib.toKey32
|
15
|
+
} for DistributorType global;
|
16
|
+
|
17
|
+
// general pure free functions
|
18
|
+
|
19
|
+
// pure free functions for operators
|
20
|
+
function eqDistributorType(
|
21
|
+
DistributorType a,
|
22
|
+
DistributorType b
|
23
|
+
) pure returns (bool isSame) {
|
24
|
+
return DistributorType.unwrap(a) == DistributorType.unwrap(b);
|
25
|
+
}
|
26
|
+
|
27
|
+
function neDistributorType(
|
28
|
+
DistributorType a,
|
29
|
+
DistributorType b
|
30
|
+
) pure returns (bool isDifferent) {
|
31
|
+
return DistributorType.unwrap(a) != DistributorType.unwrap(b);
|
32
|
+
}
|
33
|
+
|
34
|
+
// library functions that operate on user defined type
|
35
|
+
library DistributorTypeLib {
|
36
|
+
|
37
|
+
function zero() public pure returns (DistributorType) {
|
38
|
+
return DistributorType.wrap(bytes8(0));
|
39
|
+
}
|
40
|
+
|
41
|
+
// @dev Converts a referral string into an id.
|
42
|
+
function toDistributorType(NftId distributionNftId, string memory name) public pure returns (DistributorType) {
|
43
|
+
return DistributorType.wrap(bytes8(keccak256(abi.encode(distributionNftId, name))));
|
44
|
+
}
|
45
|
+
|
46
|
+
/// @dev Returns the key32 value for the specified nft id and object type.
|
47
|
+
function toKey32(DistributorType id) public pure returns (Key32 key) {
|
48
|
+
return Key32Lib.toKey32(DISTRIBUTION_TYPE(), toKeyId(id));
|
49
|
+
}
|
50
|
+
|
51
|
+
/// @dev Returns the key id value for the specified nft id
|
52
|
+
function toKeyId(DistributorType id) public pure returns (KeyId keyId) {
|
53
|
+
return KeyId.wrap(bytes31(DistributorType.unwrap(id)));
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.19;
|
3
|
+
|
4
|
+
import {UFixed, UFixedLib} from "./UFixed.sol";
|
5
|
+
|
6
|
+
struct Fee {
|
7
|
+
UFixed fractionalFee;
|
8
|
+
uint256 fixedFee;
|
9
|
+
}
|
10
|
+
|
11
|
+
library FeeLib {
|
12
|
+
|
13
|
+
function calculateFee(
|
14
|
+
Fee memory fee,
|
15
|
+
uint256 amount
|
16
|
+
)
|
17
|
+
public
|
18
|
+
pure
|
19
|
+
returns (
|
20
|
+
uint256 feeAmount,
|
21
|
+
uint256 netAmount
|
22
|
+
)
|
23
|
+
{
|
24
|
+
UFixed fractionalAmount = UFixedLib.toUFixed(amount) *
|
25
|
+
fee.fractionalFee;
|
26
|
+
feeAmount = fractionalAmount.toInt() + fee.fixedFee;
|
27
|
+
netAmount = amount - feeAmount;
|
28
|
+
}
|
29
|
+
|
30
|
+
/// @dev Converts the uint256 to a fee struct.
|
31
|
+
function toFee(
|
32
|
+
UFixed fractionalFee,
|
33
|
+
uint256 fixedFee
|
34
|
+
) public pure returns (Fee memory fee) {
|
35
|
+
return Fee(fractionalFee, fixedFee);
|
36
|
+
}
|
37
|
+
|
38
|
+
/// @dev Return the percent fee struct (x%, 0)
|
39
|
+
function percentageFee(uint8 percent) public pure returns (Fee memory fee) {
|
40
|
+
return Fee(UFixedLib.toUFixed(percent, -2), 0);
|
41
|
+
}
|
42
|
+
|
43
|
+
/// @dev Return a zero fee struct (0, 0)
|
44
|
+
function zeroFee() public pure returns (Fee memory fee) {
|
45
|
+
return Fee(UFixed.wrap(0), 0);
|
46
|
+
}
|
47
|
+
|
48
|
+
// pure free functions for operators
|
49
|
+
function feeIsSame(Fee memory a, Fee memory b) public pure returns (bool isSame) {
|
50
|
+
return a.fixedFee == b.fixedFee && a.fractionalFee == b.fractionalFee;
|
51
|
+
}
|
52
|
+
|
53
|
+
function feeIsZero(Fee memory fee) public pure returns (bool) {
|
54
|
+
return fee.fixedFee == 0 && UFixed.unwrap(fee.fractionalFee) == 0;
|
55
|
+
}
|
56
|
+
}
|