Skip to content

Commit

Permalink
make ApplicationService inherit from Service (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
doerfli committed Sep 3, 2024
1 parent a469883 commit 7ce66d9
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions contracts/product/ApplicationService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {IPricingService} from "./IPricingService.sol";
import {IRegistryService} from "../registry/IRegistryService.sol";

import {AmountLib} from "../type/Amount.sol";
import {ContractLib} from "../shared/ContractLib.sol";
import {Seconds} from "../type/Seconds.sol";
import {zeroTimestamp} from "../type/Timestamp.sol";
import {ObjectType, BUNDLE, DISTRIBUTION, PRODUCT, REGISTRY, APPLICATION, POLICY, PRICE} from "../type/ObjectType.sol";
Expand All @@ -19,13 +20,13 @@ import {NftId, NftIdLib} from "../type/NftId.sol";
import {ReferralId} from "../type/Referral.sol";
import {RiskId} from "../type/RiskId.sol";
import {Amount, AmountLib} from "../type/Amount.sol";
import {ComponentVerifyingService} from "../shared/ComponentVerifyingService.sol";
import {Service} from "../shared/Service.sol";
import {InstanceReader} from "../instance/InstanceReader.sol";



contract ApplicationService is
ComponentVerifyingService,
Service,
IApplicationService
{
IDistributionService private _distributionService;
Expand Down Expand Up @@ -155,7 +156,7 @@ contract ApplicationService is
{
_checkNftType(bundleNftId, BUNDLE());

(NftId productNftId,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
(NftId productNftId, IInstance instance) = _getAndVerifyActiveProduct();

// check if provided references are valid and linked to calling product contract
InstanceReader instanceReader = instance.getInstanceReader();
Expand Down Expand Up @@ -265,12 +266,33 @@ contract ApplicationService is
{
_checkNftType(applicationNftId, POLICY());

(,, IInstance instance) = _getAndVerifyActiveComponent(PRODUCT());
(, IInstance instance) = _getAndVerifyActiveProduct();
instance.getInstanceStore().updateApplicationState(applicationNftId, REVOKED());
}

// internal functions

function _getAndVerifyActiveProduct()
internal
view
returns (
NftId productNftId,
IInstance instance
)
{
(
IRegistry.ObjectInfo memory info,
address instanceAddress
) = ContractLib.getAndVerifyComponent(
getRegistry(),
msg.sender,
PRODUCT(),
true); // only active pools

productNftId = info.nftId;
instance = IInstance(instanceAddress);
}


function _getDomain() internal pure override returns(ObjectType) {
return APPLICATION();
Expand Down

0 comments on commit 7ce66d9

Please sign in to comment.