Skip to content

Commit

Permalink
amend CropProduct functions
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaszimmermann committed Dec 24, 2024
1 parent 33ce3e4 commit abf5fc9
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 209,598 deletions.
2 changes: 1 addition & 1 deletion app/abi/AccountingToken.sol/AccountingToken.json

Large diffs are not rendered by default.

49,875 changes: 0 additions & 49,875 deletions app/abi/ArcModel.json

This file was deleted.

59,074 changes: 0 additions & 59,074 deletions app/abi/ArcPool.json

This file was deleted.

78,169 changes: 0 additions & 78,169 deletions app/abi/ArcProduct.json

This file was deleted.

2 changes: 1 addition & 1 deletion app/abi/CropProduct.sol/CropProduct.json

Large diffs are not rendered by default.

10,422 changes: 0 additions & 10,422 deletions app/abi/EXOF.json

This file was deleted.

6,249 changes: 0 additions & 6,249 deletions app/abi/InstanceServiceV2.json

This file was deleted.

5,757 changes: 0 additions & 5,757 deletions app/abi/Mapper.json

This file was deleted.

6 changes: 3 additions & 3 deletions app/server/model/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
"riskId": "t4FcP75uGHHc",
"externalId": "ABC123",
"subscriptionDate": "2025-01-01",
"sumInsuredAmount": 1000000.0,
"premiumAmount": 200000.0,
"sumInsuredAmount": 600000.0,
"premiumAmount": 40000.0,
}

EXAMPLE_OUT = deepcopy(EXAMPLE_IN)
EXAMPLE_OUT["id"] = "cwNCXQfypiTg"
EXAMPLE_OUT["nft"] = "2689313703"

# https://www.xe.com/currencyconverter/convert/?Amount=300&From=USD&To=UGX
MAX_MONETARY_AMOUNT = 5000000.0
MAX_MONETARY_AMOUNT = 5000000.0 # 5 million ugandan shillings

MIN_DATE = Date.create_from("2024-01-01")
MAX_DATE = Date.create_from("2025-12-31")
Expand Down
5 changes: 2 additions & 3 deletions app/server/model/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
from util.nanoid import is_valid_nanoid
import time


EXAMPLE_IN = {
"isValid": True,
"configId": "7Zv4TZoBLxUi",
"locationId": "kDho7606IRdr",
"crop": "coffee",
"startOfSeason": "2024-08-01",
"endOfSeason": "2024-11-30",
"startOfSeason": "2025-01-20",
"endOfSeason": "2025-06-15",
"deductible": 0.0,
}

Expand Down
2 changes: 1 addition & 1 deletion cache/solidity-files-cache.json

Large diffs are not rendered by default.

43 changes: 42 additions & 1 deletion src/CropProduct.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.20;

import {Amount, Location, NftId, RiskId, Str, Timestamp} from "./Types.sol";
import {Amount, Location, NftId, RiskId, Str, Timestamp, UFixed} from "./Types.sol";

contract CropProduct {
event LogCropPolicyCreated(NftId policyNftId);

error StringTooLong(string str);
error InvalidShortString();

struct Season {
uint16 year;
Str name;
Str seasonStart; // ISO 8601 date
Str seasonEnd; // ISO 8601 date
uint16 seasonDays;
}

struct CropRisk {
Str seasonId;
Str locationId;
Str crop;
Timestamp seasonEndAt;
UFixed payoutFactor;
bool payoutDefined;
}

// solhint-disable var-name-mixedcase
Amount public MIN_PREMIUM;
Amount public MAX_PREMIUM;
Amount public MIN_SUM_INSURED;
Amount public MAX_SUM_INSURED;
uint8 public MAX_POLICIES_TO_PROCESS = 1;
// solhint-enable var-name-mixedcase

uint256 public riskCounter;
uint96 public policyNftCounter = 100;

Expand Down Expand Up @@ -54,6 +79,22 @@ contract CropProduct {
return _riskId[id];
}

function setConstants(
Amount minPremium,
Amount maxPremium,
Amount minSumInsured,
Amount maxSumInsured,
uint8 maxPoliciesToProcess
) external {}

//--- view functions ----------------------------------------------------//

function crops() public view returns (Str[] memory) {}
function seasons() public view returns (Str[] memory) {}
function getSeason(Str seasonId) public view returns (Season memory season) {}
function getLocation(Str locationId) public view returns (Location location) {}
function getRisk(RiskId riskId) public view returns (bool exists, CropRisk memory cropRisk) {}

/// @dev converts the provided string into a short string.
/// code from OZ ShortStrings.toShortString
function toStr(string memory str) public pure returns (Str) {
Expand Down
42 changes: 0 additions & 42 deletions src/StrHelper.sol

This file was deleted.

2 changes: 2 additions & 0 deletions src/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ type RiskId is bytes8;
type Str is bytes32;

type Timestamp is uint40;

type UFixed is uint160;

0 comments on commit abf5fc9

Please sign in to comment.