Skip to content

Commit

Permalink
fix: remove redundant struct
Browse files Browse the repository at this point in the history
  • Loading branch information
amarinkovic committed Apr 26, 2023
1 parent 2e27613 commit b39aacb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 32 deletions.
17 changes: 3 additions & 14 deletions src/diamonds/nayms/facets/SimplePolicyFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.17;

import { Modifiers } from "../Modifiers.sol";
import { Entity, SimplePolicy, SimplePolicyInfo, PolicyCommissionsBasisPoints } from "../AppStorage.sol";
import { Entity, SimplePolicy, PolicyCommissionsBasisPoints } from "../AppStorage.sol";
import { LibObject } from "../libs/LibObject.sol";
import { LibHelpers } from "../libs/LibHelpers.sol";
import { LibSimplePolicy } from "../libs/LibSimplePolicy.sol";
Expand Down Expand Up @@ -48,19 +48,8 @@ contract SimplePolicyFacet is ISimplePolicyFacet, Modifiers {
* @param _policyId Id of the simple policy
* @return Simple policy metadata
*/
function getSimplePolicyInfo(bytes32 _policyId) external view returns (SimplePolicyInfo memory) {
SimplePolicy memory p = LibSimplePolicy._getSimplePolicyInfo(_policyId);
return
SimplePolicyInfo({
startDate: p.startDate,
maturationDate: p.maturationDate,
asset: p.asset,
limit: p.limit,
fundsLocked: p.fundsLocked,
cancelled: p.cancelled,
claimsPaid: p.claimsPaid,
premiumsPaid: p.premiumsPaid
});
function getSimplePolicyInfo(bytes32 _policyId) external view returns (SimplePolicy memory) {
return LibSimplePolicy._getSimplePolicyInfo(_policyId);
}

function getPremiumCommissionBasisPoints() external view returns (PolicyCommissionsBasisPoints memory bp) {
Expand Down
11 changes: 0 additions & 11 deletions src/diamonds/nayms/interfaces/FreeStructs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ struct SimplePolicy {
uint256[] commissionBasisPoints;
}

struct SimplePolicyInfo {
uint256 startDate;
uint256 maturationDate;
bytes32 asset;
uint256 limit;
bool fundsLocked;
bool cancelled;
uint256 claimsPaid;
uint256 premiumsPaid;
}

struct PolicyCommissionsBasisPoints {
uint16 premiumCommissionNaymsLtdBP;
uint16 premiumCommissionNDFBP;
Expand Down
4 changes: 2 additions & 2 deletions src/diamonds/nayms/interfaces/ISimplePolicyFacet.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { SimplePolicy, SimplePolicyInfo, PolicyCommissionsBasisPoints } from "./FreeStructs.sol";
import { SimplePolicy, PolicyCommissionsBasisPoints } from "./FreeStructs.sol";

/**
* @title Simple Policies
Expand Down Expand Up @@ -52,7 +52,7 @@ interface ISimplePolicyFacet {
* @param _id Id of the simple policy
* @return Simple policy metadata
*/
function getSimplePolicyInfo(bytes32 _id) external view returns (SimplePolicyInfo memory);
function getSimplePolicyInfo(bytes32 _id) external view returns (SimplePolicy memory);

/**
* @notice Get the policy premium commissions basis points.
Expand Down
8 changes: 5 additions & 3 deletions test/T04Entity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ pragma solidity 0.8.17;
import { Vm } from "forge-std/Vm.sol";

import { D03ProtocolDefaults, console2, LibConstants, LibHelpers, LibObject } from "./defaults/D03ProtocolDefaults.sol";
import { Entity, MarketInfo, SimplePolicy, SimplePolicyInfo, Stakeholders } from "src/diamonds/nayms/interfaces/FreeStructs.sol";
import { Entity, MarketInfo, SimplePolicy, Stakeholders } from "src/diamonds/nayms/interfaces/FreeStructs.sol";
import { INayms, IDiamondCut } from "src/diamonds/nayms/INayms.sol";

import { LibACL } from "src/diamonds/nayms/libs/LibACL.sol";
import { LibTokenizedVault } from "src/diamonds/nayms/libs/LibTokenizedVault.sol";
import { LibFeeRouterFixture } from "test/fixtures/LibFeeRouterFixture.sol";
import { SimplePolicyFixture } from "test/fixtures/SimplePolicyFixture.sol";

// solhint-disable no-global-import
import "src/diamonds/nayms/interfaces/CustomErrors.sol";

// solhint-disable no-console
Expand Down Expand Up @@ -460,7 +462,7 @@ contract T04EntityTest is D03ProtocolDefaults {
// create it successfully
nayms.createSimplePolicy(policyId1, entityId1, stakeholders, simplePolicy, testPolicyDataHash);

SimplePolicyInfo memory simplePolicyInfo = nayms.getSimplePolicyInfo(policyId1);
SimplePolicy memory simplePolicyInfo = nayms.getSimplePolicyInfo(policyId1);
assertEq(simplePolicyInfo.startDate, simplePolicy.startDate, "Start dates should match");
assertEq(simplePolicyInfo.maturationDate, simplePolicy.maturationDate, "Maturation dates should match");
assertEq(simplePolicyInfo.asset, simplePolicy.asset, "Assets should match");
Expand Down Expand Up @@ -972,7 +974,7 @@ contract T04EntityTest is D03ProtocolDefaults {
"utilized capacity should change"
);

SimplePolicyInfo memory simplePolicyInfo = nayms.getSimplePolicyInfo(policyId1);
SimplePolicy memory simplePolicyInfo = nayms.getSimplePolicyInfo(policyId1);
assertEq(simplePolicyInfo.cancelled, true, "Simple policy should be cancelled");

vm.expectRevert("Policy already cancelled");
Expand Down
2 changes: 1 addition & 1 deletion test/T04Market.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Vm } from "forge-std/Vm.sol";

import { MockAccounts } from "./utils/users/MockAccounts.sol";

import { Entity, FeeRatio, MarketInfo, TradingCommissions, SimplePolicy, SimplePolicyInfo, Stakeholders } from "src/diamonds/nayms/interfaces/FreeStructs.sol";
import { Entity, FeeRatio, MarketInfo, TradingCommissions, SimplePolicy, Stakeholders } from "src/diamonds/nayms/interfaces/FreeStructs.sol";
import { INayms, IDiamondCut } from "src/diamonds/nayms/INayms.sol";
import { IERC20 } from "src/erc20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/defaults/D03ProtocolDefaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.17;

import { D02TestSetup, console2, LibHelpers, LibConstants, LibAdmin, LibObject, LibSimplePolicy } from "./D02TestSetup.sol";
import { ERC20 } from "solmate/tokens/ERC20.sol";
import { Entity, SimplePolicy, SimplePolicyInfo, Stakeholders } from "src/diamonds/nayms/interfaces/FreeStructs.sol";
import { Entity, SimplePolicy, Stakeholders } from "src/diamonds/nayms/interfaces/FreeStructs.sol";

import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

Expand Down

0 comments on commit b39aacb

Please sign in to comment.