Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorganize instance contracts #299

Merged
merged 9 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 16 additions & 54 deletions contracts/instance/IInstance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {StateId} from "../types/StateId.sol";
import {RiskId} from "../types/RiskId.sol";
import {VersionPart} from "../types/Version.sol";
import {Key32} from "../types/Key32.sol";
import {RoleId} from "../types/RoleId.sol";

import {IRegisterable} from "../shared/IRegisterable.sol";

Expand All @@ -16,83 +17,44 @@ import {ITransferInterceptor} from "../registry/ITransferInterceptor.sol";
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
import {BundleManager} from "./BundleManager.sol";
import {InstanceReader} from "./InstanceReader.sol";
import {InstanceStore} from "./InstanceStore.sol";

import {IKeyValueStore} from "./base/IKeyValueStore.sol";

import {IAccess} from "./module/IAccess.sol";

import {IBundle} from "./module/IBundle.sol";
import {IBundleService} from "./service/IBundleService.sol";
import {IComponents} from "./module/IComponents.sol";
import {IDistributionService} from "./service/IDistributionService.sol";
import {InstanceAccessManager} from "./InstanceAccessManager.sol";
import {IKeyValueStore} from "./base/IKeyValueStore.sol";
import {IPolicy} from "./module/IPolicy.sol";
import {IDistribution} from "./module/IDistribution.sol";
import {IPolicyService} from "./service/IPolicyService.sol";
import {IPoolService} from "./service/IPoolService.sol";
import {IProductService} from "./service/IProductService.sol";
import {IPolicyService} from "./service/IPolicyService.sol";
import {IBundleService} from "./service/IBundleService.sol";
import {IRisk} from "./module/IRisk.sol";
import {ISetup} from "./module/ISetup.sol";



interface IInstance is
IRegisterable,
ITransferInterceptor,
IAccessManaged,
IKeyValueStore
IAccessManaged
{
function createRole(string memory roleName, string memory adminName) external returns (RoleId roleId, RoleId admin);
function grantRole(RoleId roleId, address account) external;
function revokeRole(RoleId roleId, address account) external;

function createTarget(address target, string memory name) external;
function setTargetFunctionRole(string memory targetName, bytes4[] calldata selectors, RoleId roleId) external;
function setTargetLocked(address target, bool locked) external;

function getDistributionService() external view returns (IDistributionService);
function getProductService() external view returns (IProductService);
function getPoolService() external view returns (IPoolService);
function getPolicyService() external view returns (IPolicyService);
function getBundleService() external view returns (IBundleService);

function createDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup) external;
function updateDistributionSetup(NftId distributionNftId, ISetup.DistributionSetupInfo memory setup, StateId newState) external;
function updateDistributionSetupState(NftId distributionNftId, StateId newState) external;

function createPoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info) external;
function updatePoolSetup(NftId poolNftId, IComponents.ComponentInfo memory info, StateId newState) external;
function updatePoolSetupState(NftId poolNftId, StateId newState) external;

function createBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle) external;
function updateBundle(NftId bundleNftId, IBundle.BundleInfo memory bundle, StateId newState) external;
function updateBundleState(NftId bundleNftId, StateId newState) external;

function createProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup) external;
function updateProductSetup(NftId productNftId, ISetup.ProductSetupInfo memory setup, StateId newState) external;
function updateProductSetupState(NftId productNftId, StateId newState) external;

function createDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info) external;
function updateDistributorType(Key32 distributorKey, IDistribution.DistributorTypeInfo memory info, StateId newState) external;
function updateDistributorTypeState(Key32 distributorKey, StateId newState) external;

function createDistributor(NftId nftId, IDistribution.DistributorInfo memory info) external;
function updateDistributor(NftId nftId, IDistribution.DistributorInfo memory info, StateId newState) external;
function updateDistributorState(NftId nftId, StateId newState) external;

function createReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo) external;
function updateReferral(Key32 referralKey, IDistribution.ReferralInfo memory referralInfo, StateId newState) external;
function updateReferralState(Key32 referralKey, StateId newState) external;

function createRisk(RiskId riskId, IRisk.RiskInfo memory risk) external;
function updateRisk(RiskId riskId, IRisk.RiskInfo memory risk, StateId newState) external;
function updateRiskState(RiskId riskId, StateId newState) external;

function createApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy) external;
function updateApplication(NftId applicationNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
function updateApplicationState(NftId applicationNftId, StateId newState) external;

function updatePolicy(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;
function updatePolicyState(NftId policyNftId, StateId newState) external;

// TODO add claims/payouts function to instance
// function updateClaims(NftId policyNftId, IPolicy.PolicyInfo memory policy, StateId newState) external;

function getMajorVersion() external pure returns (VersionPart majorVersion);
function getInstanceReader() external view returns (InstanceReader);
function getBundleManager() external view returns (BundleManager);

function setInstanceAccessManager(InstanceAccessManager accessManager) external;
function getInstanceAccessManager() external view returns (InstanceAccessManager);
function getInstanceStore() external view returns (InstanceStore);
}
16 changes: 14 additions & 2 deletions contracts/instance/IInstanceService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {InstanceAccessManager} from "./InstanceAccessManager.sol";
import {Instance} from "./Instance.sol";
import {InstanceReader} from "./InstanceReader.sol";
import {BundleManager} from "./BundleManager.sol";
import {InstanceStore} from "./InstanceStore.sol";

interface IInstanceService is IService {

Expand All @@ -33,11 +34,13 @@ interface IInstanceService is IService {
error ErrorInstanceServiceInstanceAccessManagerZero();
error ErrorInstanceServiceInstanceReaderZero();
error ErrorInstanceServiceBundleManagerZero();
error ErrorInstanceServiceInstanceStoreZero();

error ErrorInstanceServiceInstanceAuthorityMismatch();
error ErrorInstanceServiceBundleManagerAuthorityMismatch();
error ErrorInstanceServiceInstanceReaderInstanceMismatch2();
error ErrorInstanceServiceBundleMangerInstanceMismatch();
error ErrorInstanceServiceInstanceStoreAuthorityMismatch();

error ErrorInstanceServiceRequestUnauhorized(address caller);
error ErrorInstanceServiceNotInstanceOwner(address caller, NftId instanceNftId);
Expand All @@ -46,7 +49,15 @@ interface IInstanceService is IService {
error ErrorInstanceServiceInstanceComponentMismatch(NftId instanceNftId, NftId componentNftId);
error ErrorInstanceServiceInvalidComponentType(address componentAddress, ObjectType expectedType, ObjectType componentType);

event LogInstanceCloned(address clonedOzAccessManager, address clonedInstanceAccessManager, address clonedInstance, address clonedBundleManager, address clonedInstanceReader, NftId clonedInstanceNftId);
event LogInstanceCloned(
address clonedOzAccessManager,
address clonedInstanceAccessManager,
address clonedInstance,
address clonedInstanceStore,
address clonedBundleManager,
address clonedInstanceReader,
NftId clonedInstanceNftId
);

function createInstanceClone()
external
Expand All @@ -56,7 +67,8 @@ interface IInstanceService is IService {
Instance clonedInstance,
NftId instanceNftId,
InstanceReader clonedInstanceReader,
BundleManager clonedBundleManager
BundleManager clonedBundleManager,
InstanceStore clonedInstanceStore
);

function createGifTarget(
Expand Down
Loading
Loading