Skip to content

Commit

Permalink
add return parameters to collectPremium
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaszimmermann committed Jul 26, 2022
1 parent 20c6f16 commit 0593091
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
26 changes: 25 additions & 1 deletion contracts/components/Product.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,37 @@ abstract contract Product is
applicationData);
}

function _collectPremium(bytes32 processId)
internal
returns(
bool success,
uint256 feeAmount,
uint256 netAmount
)
{
IPolicy.Policy memory policy = _getPolicy(processId);

if (policy.premiumPaidAmount < policy.premiumExpectedAmount) {
(success, feeAmount, netAmount)
= _collectPremium(
processId,
policy.premiumExpectedAmount - policy.premiumPaidAmount
);
}
}

function _collectPremium(
bytes32 processId,
uint256 amount
)
internal
returns(
bool success,
uint256 feeAmount,
uint256 netAmount
)
{
_productService.collectPremium(processId, amount);
(success, feeAmount, netAmount) = _productService.collectPremium(processId, amount);
}

function _revoke(bytes32 processId) internal {
Expand Down
15 changes: 10 additions & 5 deletions contracts/services/IProductService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ interface IProductService {
bytes calldata applicationData
) external;

function collectPremium(bytes32 processId, uint256 amount) external;
function collectPremium(bytes32 processId, uint256 amount) external
returns(
bool success,
uint256 feeAmount,
uint256 netPremiumAmount
);

function revoke(bytes32 processId) external;
function underwrite(bytes32 processId) external returns (bool success);
function underwrite(bytes32 processId) external returns(bool success);
function decline(bytes32 processId) external;
function expire(bytes32 processId) external;
function close(bytes32 processId) external;
Expand All @@ -24,7 +29,7 @@ interface IProductService {
bytes32 processId,
uint256 claimAmount,
bytes calldata data
) external returns (uint256 claimId);
) external returns(uint256 claimId);

function declineClaim(bytes32 processId, uint256 claimId) external;

Expand All @@ -33,7 +38,7 @@ interface IProductService {
uint256 claimId,
uint256 payoutAmount,
bytes calldata data
) external returns (uint256 payoutId);
) external returns(uint256 payoutId);

function processPayout(
bytes32 processId,
Expand All @@ -48,5 +53,5 @@ interface IProductService {
string calldata callbackMethodName,
address callbackContractAddress,
uint256 responsibleOracleId
) external returns (uint256 requestId);
) external returns(uint256 requestId);
}

0 comments on commit 0593091

Please sign in to comment.