From 23d2f24d800b7beb0eee8cede9440e5abd0fd916 Mon Sep 17 00:00:00 2001 From: Marc Doerflinger Date: Mon, 30 Dec 2024 15:08:09 +0000 Subject: [PATCH] fix policy sync implementation --- app/abi/CropProduct.sol/CropProduct.json | 2 +- app/server/config.py | 4 ++++ app/server/sync/onchain.py | 2 +- app/server/sync/person.py | 22 ++++++++++++++++++--- app/server/sync/policy.py | 8 +++++--- app/web3utils/blocks.py | 15 ++++++++++++++ app/web3utils/contract.py | 21 ++++++++++++++++---- app/web3utils/send_eth.py | 25 ++++++++++++++++++++++++ src/CropProduct.sol | 1 + 9 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 app/web3utils/blocks.py create mode 100644 app/web3utils/send_eth.py diff --git a/app/abi/CropProduct.sol/CropProduct.json b/app/abi/CropProduct.sol/CropProduct.json index 9411068..4b7c48a 100644 --- a/app/abi/CropProduct.sol/CropProduct.json +++ b/app/abi/CropProduct.sol/CropProduct.json @@ -1 +1 @@ -{"abi":[{"type":"function","name":"MAX_POLICIES_TO_PROCESS","inputs":[],"outputs":[{"name":"","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"type":"function","name":"MAX_PREMIUM","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"MAX_SUM_INSURED","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"MIN_PREMIUM","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"MIN_SUM_INSURED","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"createCrop","inputs":[{"name":"crop","type":"bytes32","internalType":"Str"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"createLocation","inputs":[{"name":"locationId","type":"bytes32","internalType":"Str"},{"name":"latitude","type":"int32","internalType":"int32"},{"name":"longitude","type":"int32","internalType":"int32"}],"outputs":[{"name":"location","type":"uint64","internalType":"Location"}],"stateMutability":"nonpayable"},{"type":"function","name":"createPolicy","inputs":[{"name":"policyHolder","type":"address","internalType":"address"},{"name":"riskId","type":"bytes8","internalType":"RiskId"},{"name":"activateAt","type":"uint40","internalType":"Timestamp"},{"name":"sumInsuredAmount","type":"uint96","internalType":"Amount"},{"name":"premiumAmount","type":"uint96","internalType":"Amount"}],"outputs":[{"name":"policyNftId","type":"uint96","internalType":"NftId"}],"stateMutability":"nonpayable"},{"type":"function","name":"createRisk","inputs":[{"name":"id","type":"bytes32","internalType":"Str"},{"name":"seasonId","type":"bytes32","internalType":"Str"},{"name":"locationId","type":"bytes32","internalType":"Str"},{"name":"crop","type":"bytes32","internalType":"Str"},{"name":"seasonEndAt","type":"uint40","internalType":"Timestamp"}],"outputs":[{"name":"riskId","type":"bytes8","internalType":"RiskId"}],"stateMutability":"nonpayable"},{"type":"function","name":"createSeason","inputs":[{"name":"seasonId","type":"bytes32","internalType":"Str"},{"name":"year","type":"uint16","internalType":"uint16"},{"name":"name","type":"bytes32","internalType":"Str"},{"name":"seasonStart","type":"bytes32","internalType":"Str"},{"name":"seasonEnd","type":"bytes32","internalType":"Str"},{"name":"seasonDays","type":"uint16","internalType":"uint16"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"crops","inputs":[],"outputs":[{"name":"","type":"bytes32[]","internalType":"Str[]"}],"stateMutability":"view"},{"type":"function","name":"getLocation","inputs":[{"name":"locationId","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"location","type":"uint64","internalType":"Location"}],"stateMutability":"view"},{"type":"function","name":"getRisk","inputs":[{"name":"riskId","type":"bytes8","internalType":"RiskId"}],"outputs":[{"name":"exists","type":"bool","internalType":"bool"},{"name":"cropRisk","type":"tuple","internalType":"struct CropProduct.CropRisk","components":[{"name":"seasonId","type":"bytes32","internalType":"Str"},{"name":"locationId","type":"bytes32","internalType":"Str"},{"name":"crop","type":"bytes32","internalType":"Str"},{"name":"seasonEndAt","type":"uint40","internalType":"Timestamp"},{"name":"payoutFactor","type":"uint160","internalType":"UFixed"},{"name":"payoutDefined","type":"bool","internalType":"bool"}]}],"stateMutability":"view"},{"type":"function","name":"getRiskId","inputs":[{"name":"id","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"riskId","type":"bytes8","internalType":"RiskId"}],"stateMutability":"view"},{"type":"function","name":"getSeason","inputs":[{"name":"seasonId","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"season","type":"tuple","internalType":"struct CropProduct.Season","components":[{"name":"year","type":"uint16","internalType":"uint16"},{"name":"name","type":"bytes32","internalType":"Str"},{"name":"seasonStart","type":"bytes32","internalType":"Str"},{"name":"seasonEnd","type":"bytes32","internalType":"Str"},{"name":"seasonDays","type":"uint16","internalType":"uint16"}]}],"stateMutability":"view"},{"type":"function","name":"length","inputs":[{"name":"sstr","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"type":"function","name":"policyNftCounter","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"uint96"}],"stateMutability":"view"},{"type":"function","name":"riskCounter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"seasons","inputs":[],"outputs":[{"name":"","type":"bytes32[]","internalType":"Str[]"}],"stateMutability":"view"},{"type":"function","name":"setConstants","inputs":[{"name":"minPremium","type":"uint96","internalType":"Amount"},{"name":"maxPremium","type":"uint96","internalType":"Amount"},{"name":"minSumInsured","type":"uint96","internalType":"Amount"},{"name":"maxSumInsured","type":"uint96","internalType":"Amount"},{"name":"maxPoliciesToProcess","type":"uint8","internalType":"uint8"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"toStr","inputs":[{"name":"str","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bytes32","internalType":"Str"}],"stateMutability":"pure"},{"type":"function","name":"toString","inputs":[{"name":"sstr","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"pure"},{"type":"event","name":"LogCropPolicyCreated","inputs":[{"name":"policyNftId","type":"uint96","indexed":false,"internalType":"NftId"}],"anonymous":false},{"type":"error","name":"InvalidShortString","inputs":[]},{"type":"error","name":"StringTooLong","inputs":[{"name":"str","type":"string","internalType":"string"}]}],"bytecode":{"object":"0x60806040526001805460ff60c01b1916600160c01b179055600380546001600160601b03191660641790553480156034575f5ffd5b50610aa2806100425f395ff3fe608060405234801561000f575f5ffd5b506004361061013d575f3560e01c80637d1c5290116100b4578063bb31332111610079578063bb313321146103e7578063be5c8f44146103fa578063cdc23e691461040c578063def6aeca1461041f578063f1338cda14610432578063f44f30cd14610172575f5ffd5b80637d1c5290146103665780637f73fa9c1461037b578063a4846cbf1461038c578063a9dbaf25146103a6578063b11a19e8146103c7575f5ffd5b80634b396c4f116101055780634b396c4f1461027e5780634cdabb16146102a45780635be6405e146102bd578063694ac999146102d05780636f336d7c146102f2578063729ff16c1461030a575f5ffd5b80630228ec7b1461014157806323c9bc52146101725780632a6f8ef2146101815780633405f20c146101b0578063422e9f4114610253575b5f5ffd5b61015461014f366004610646565b61043b565b6040516001600160c01b031990911681526020015b60405180910390f35b6060604051610169919061068b565b61019761018f3660046106de565b5f9392505050565b60405167ffffffffffffffff9091168152602001610169565b6101f36101be36600461072e565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a08101829052915091565b60408051921515835281516020808501919091528201518382015281015160608084019190915281015164ffffffffff166080808401919091528101516001600160a01b031660a0808401919091520151151560c082015260e001610169565b610266610261366004610764565b6104a8565b6040516001600160601b039091168152602001610169565b60015461029290600160c01b900460ff1681565b60405160ff9091168152602001610169565b5f5461026690600160601b90046001600160601b031681565b6101976102cb3660046107c6565b505f90565b6101546102de3660046107c6565b5f9081526004602052604090205460c01b90565b6103086103003660046107ee565b505050505050565b005b61031d6103183660046107c6565b610548565b60405161016991905f60a08201905061ffff835116825260208301516020830152604083015160408301526060830151606083015261ffff608084015116608083015292915050565b610308610374366004610842565b5050505050565b6103086103893660046107c6565b50565b60015461026690600160601b90046001600160601b031681565b6103b96103b43660046107c6565b610582565b604051908152602001610169565b6103da6103d53660046107c6565b6105af565b60405161016991906108ac565b600354610266906001600160601b031681565b5f54610266906001600160601b031681565b6103b961041a3660046108f5565b6105ec565b600154610266906001600160601b031681565b6103b960025481565b600280545f918261044b836109bc565b919050555060025460405160200161046591815260200190565b60408051808303601f1901815291815281516020928301205f9889526004909252909620805467ffffffffffffffff191660c088901c1790555093949350505050565b600380545f916001600160601b0390911690826104c4836109d4565b82546101009290920a6001600160601b038181021990931691831602179091556003546104f59250166103e86109fe565b610500906065610a27565b6040516001600160601b03821681529091507fc31147b2435123798832cf3c9d8ce5cd012cb3d548b18d196793c5a8e65f57d19060200160405180910390a195945050505050565b61057d6040518060a001604052805f61ffff1681526020015f81526020015f81526020015f81526020015f61ffff1681525090565b919050565b5f60ff8216601f8111156105a957604051632cd44ac360e21b815260040160405180910390fd5b92915050565b60605f6105bb83610582565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f5f829050601f8151111561061f578260405163305a27a960e01b815260040161061691906108ac565b60405180910390fd5b805161062a82610a46565b179392505050565b803564ffffffffff8116811461057d575f5ffd5b5f5f5f5f5f60a0868803121561065a575f5ffd5b8535945060208601359350604086013592506060860135915061067f60808701610632565b90509295509295909350565b602080825282518282018190525f918401906040840190835b818110156106c25783518352602093840193909201916001016106a4565b509095945050505050565b8035600381900b811461057d575f5ffd5b5f5f5f606084860312156106f0575f5ffd5b83359250610700602085016106cd565b915061070e604085016106cd565b90509250925092565b80356001600160c01b03198116811461057d575f5ffd5b5f6020828403121561073e575f5ffd5b61074782610717565b9392505050565b80356001600160601b038116811461057d575f5ffd5b5f5f5f5f5f60a08688031215610778575f5ffd5b85356001600160a01b038116811461078e575f5ffd5b945061079c60208701610717565b93506107aa60408701610632565b92506107b86060870161074e565b915061067f6080870161074e565b5f602082840312156107d6575f5ffd5b5035919050565b803561ffff8116811461057d575f5ffd5b5f5f5f5f5f5f60c08789031215610803575f5ffd5b86359550610813602088016107dd565b945060408701359350606087013592506080870135915061083660a088016107dd565b90509295509295509295565b5f5f5f5f5f60a08688031215610856575f5ffd5b61085f8661074e565b945061086d6020870161074e565b935061087b6040870161074e565b92506108896060870161074e565b9150608086013560ff8116811461089e575f5ffd5b809150509295509295909350565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b634e487b7160e01b5f52604160045260245ffd5b5f60208284031215610905575f5ffd5b813567ffffffffffffffff81111561091b575f5ffd5b8201601f8101841361092b575f5ffd5b803567ffffffffffffffff811115610945576109456108e1565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715610974576109746108e1565b60405281815282820160200186101561098b575f5ffd5b816020840160208301375f91810160200191909152949350505050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016109cd576109cd6109a8565b5060010190565b5f6001600160601b0382166001600160601b0381036109f5576109f56109a8565b60010192915050565b6001600160601b038181168382160290811690818114610a2057610a206109a8565b5092915050565b6001600160601b0381811683821601908111156105a9576105a96109a8565b80516020808301519190811015610a66575f198160200360031b1b821691505b5091905056fea26469706673582212208a575d28cf0af91451bc9215bec1316c5249aba27cccafac383a04ca94ba70fd64736f6c634300081b0033","sourceMap":"151:3910:24:-:0;;;869:1;830:40;;-1:-1:-1;;;;830:40:24;-1:-1:-1;;;830:40:24;;;950:36;;;-1:-1:-1;;;;;;950:36:24;983:3;950:36;;;151:3910;;;;;;;;;;;;;;;;","linkReferences":{}},"deployedBytecode":{"object":"0x608060405234801561000f575f5ffd5b506004361061013d575f3560e01c80637d1c5290116100b4578063bb31332111610079578063bb313321146103e7578063be5c8f44146103fa578063cdc23e691461040c578063def6aeca1461041f578063f1338cda14610432578063f44f30cd14610172575f5ffd5b80637d1c5290146103665780637f73fa9c1461037b578063a4846cbf1461038c578063a9dbaf25146103a6578063b11a19e8146103c7575f5ffd5b80634b396c4f116101055780634b396c4f1461027e5780634cdabb16146102a45780635be6405e146102bd578063694ac999146102d05780636f336d7c146102f2578063729ff16c1461030a575f5ffd5b80630228ec7b1461014157806323c9bc52146101725780632a6f8ef2146101815780633405f20c146101b0578063422e9f4114610253575b5f5ffd5b61015461014f366004610646565b61043b565b6040516001600160c01b031990911681526020015b60405180910390f35b6060604051610169919061068b565b61019761018f3660046106de565b5f9392505050565b60405167ffffffffffffffff9091168152602001610169565b6101f36101be36600461072e565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a08101829052915091565b60408051921515835281516020808501919091528201518382015281015160608084019190915281015164ffffffffff166080808401919091528101516001600160a01b031660a0808401919091520151151560c082015260e001610169565b610266610261366004610764565b6104a8565b6040516001600160601b039091168152602001610169565b60015461029290600160c01b900460ff1681565b60405160ff9091168152602001610169565b5f5461026690600160601b90046001600160601b031681565b6101976102cb3660046107c6565b505f90565b6101546102de3660046107c6565b5f9081526004602052604090205460c01b90565b6103086103003660046107ee565b505050505050565b005b61031d6103183660046107c6565b610548565b60405161016991905f60a08201905061ffff835116825260208301516020830152604083015160408301526060830151606083015261ffff608084015116608083015292915050565b610308610374366004610842565b5050505050565b6103086103893660046107c6565b50565b60015461026690600160601b90046001600160601b031681565b6103b96103b43660046107c6565b610582565b604051908152602001610169565b6103da6103d53660046107c6565b6105af565b60405161016991906108ac565b600354610266906001600160601b031681565b5f54610266906001600160601b031681565b6103b961041a3660046108f5565b6105ec565b600154610266906001600160601b031681565b6103b960025481565b600280545f918261044b836109bc565b919050555060025460405160200161046591815260200190565b60408051808303601f1901815291815281516020928301205f9889526004909252909620805467ffffffffffffffff191660c088901c1790555093949350505050565b600380545f916001600160601b0390911690826104c4836109d4565b82546101009290920a6001600160601b038181021990931691831602179091556003546104f59250166103e86109fe565b610500906065610a27565b6040516001600160601b03821681529091507fc31147b2435123798832cf3c9d8ce5cd012cb3d548b18d196793c5a8e65f57d19060200160405180910390a195945050505050565b61057d6040518060a001604052805f61ffff1681526020015f81526020015f81526020015f81526020015f61ffff1681525090565b919050565b5f60ff8216601f8111156105a957604051632cd44ac360e21b815260040160405180910390fd5b92915050565b60605f6105bb83610582565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f5f829050601f8151111561061f578260405163305a27a960e01b815260040161061691906108ac565b60405180910390fd5b805161062a82610a46565b179392505050565b803564ffffffffff8116811461057d575f5ffd5b5f5f5f5f5f60a0868803121561065a575f5ffd5b8535945060208601359350604086013592506060860135915061067f60808701610632565b90509295509295909350565b602080825282518282018190525f918401906040840190835b818110156106c25783518352602093840193909201916001016106a4565b509095945050505050565b8035600381900b811461057d575f5ffd5b5f5f5f606084860312156106f0575f5ffd5b83359250610700602085016106cd565b915061070e604085016106cd565b90509250925092565b80356001600160c01b03198116811461057d575f5ffd5b5f6020828403121561073e575f5ffd5b61074782610717565b9392505050565b80356001600160601b038116811461057d575f5ffd5b5f5f5f5f5f60a08688031215610778575f5ffd5b85356001600160a01b038116811461078e575f5ffd5b945061079c60208701610717565b93506107aa60408701610632565b92506107b86060870161074e565b915061067f6080870161074e565b5f602082840312156107d6575f5ffd5b5035919050565b803561ffff8116811461057d575f5ffd5b5f5f5f5f5f5f60c08789031215610803575f5ffd5b86359550610813602088016107dd565b945060408701359350606087013592506080870135915061083660a088016107dd565b90509295509295509295565b5f5f5f5f5f60a08688031215610856575f5ffd5b61085f8661074e565b945061086d6020870161074e565b935061087b6040870161074e565b92506108896060870161074e565b9150608086013560ff8116811461089e575f5ffd5b809150509295509295909350565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b634e487b7160e01b5f52604160045260245ffd5b5f60208284031215610905575f5ffd5b813567ffffffffffffffff81111561091b575f5ffd5b8201601f8101841361092b575f5ffd5b803567ffffffffffffffff811115610945576109456108e1565b604051601f8201601f19908116603f0116810167ffffffffffffffff81118282101715610974576109746108e1565b60405281815282820160200186101561098b575f5ffd5b816020840160208301375f91810160200191909152949350505050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016109cd576109cd6109a8565b5060010190565b5f6001600160601b0382166001600160601b0381036109f5576109f56109a8565b60010192915050565b6001600160601b038181168382160290811690818114610a2057610a206109a8565b5092915050565b6001600160601b0381811683821601908111156105a9576105a96109a8565b80516020808301519190811015610a66575f198160200360031b1b821691505b5091905056fea26469706673582212208a575d28cf0af91451bc9215bec1316c5249aba27cccafac383a04ca94ba70fd64736f6c634300081b0033","sourceMap":"151:3910:24:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1429:278;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;;1220:41:29;;;1202:60;;1190:2;1175:18;1429:278:24;;;;;;;;2489:54;2527:12;2489:54;;;;;;:::i;1264:112::-;;;;;;:::i;:::-;1355:17;1264:112;;;;;;;;;2680:18:29;2668:31;;;2650:50;;2638:2;2623:18;1264:112:24;2475:231:29;2776:94:24;;;;;;:::i;:::-;-1:-1:-1;;;;;;;;2829:11:24;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2776:94:24;;;;;;;;3405:14:29;;3398:22;3380:41;;3457:13;;3452:2;3437:18;;;3430:41;;;;3513:15;;3507:22;3487:18;;;3480:50;3572:15;;3566:22;3561:2;3546:18;;;3539:50;;;;3636:15;;3630:22;3654:12;3626:41;3620:3;3605:19;;;3598:70;;;;3715:16;;3709:23;-1:-1:-1;;;;;3705:49:29;3742:3;3684:19;;;3677:78;;;;3812:16;3806:23;3799:31;3792:39;3786:3;3771:19;;3764:68;3367:3;3352:19;2776:94:24;3157:681:29;1713:388:24;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;5025:39:29;;;5007:58;;4995:2;4980:18;1713:388:24;4835:236:29;830:40:24;;;;;-1:-1:-1;;;830:40:24;;;;;;;;;5248:4:29;5236:17;;;5218:36;;5206:2;5191:18;830:40:24;5076:184:29;729:25:24;;;;;-1:-1:-1;;;729:25:24;;-1:-1:-1;;;;;729:25:24;;;2692:79;;;;;;:::i;:::-;-1:-1:-1;2750:17:24;;2692:79;2107:100;;;;;;:::i;:::-;2157:13;2189:11;;;:7;:11;;;;;;;;;2107:100;1049:209;;;;;;:::i;:::-;;;;;;;;;;2609:78;;;;;;:::i;:::-;;:::i;:::-;;;;;;6907:4:29;6949:3;6938:9;6934:19;6926:27;;6999:6;6990;6984:13;6980:26;6969:9;6962:45;7063:4;7055:6;7051:17;7045:24;7038:4;7027:9;7023:20;7016:54;7126:4;7118:6;7114:17;7108:24;7101:4;7090:9;7086:20;7079:54;7189:4;7181:6;7177:17;7171:24;7164:4;7153:9;7149:20;7142:54;7264:6;7256:4;7248:6;7244:17;7238:24;7234:37;7227:4;7216:9;7212:20;7205:67;6765:513;;;;;2213:189:24;;;;;;:::i;:::-;;;;;;;1382:41;;;;;;:::i;:::-;;;795:29;;;;;-1:-1:-1;;;795:29:24;;-1:-1:-1;;;;;795:29:24;;;3836:223;;;;;;:::i;:::-;;:::i;:::-;;;8193:25:29;;;8181:2;8166:18;3836:223:24;8047:177:29;3359:364:24;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;950:36::-;;;;;-1:-1:-1;;;;;950:36:24;;;698:25;;;;;-1:-1:-1;;;;;698:25:24;;;2987:260;;;;;;:::i;:::-;;:::i;760:29::-;;;;;-1:-1:-1;;;;;760:29:24;;;918:26;;;;;;1429:278;1583:11;:13;;1554;;;1583;;;:::i;:::-;;;;;;1655:11;;1644:23;;;;;;8193:25:29;;8181:2;8166:18;;8047:177;1644:23:24;;;;;;;-1:-1:-1;;1644:23:24;;;;;;1634:34;;1644:23;1634:34;;;;1680:11;;;;:7;:11;;;;;;:20;;-1:-1:-1;;1680:20:24;;;;;;;;-1:-1:-1;1634:34:24;;;-1:-1:-1;;;;1429:278:24:o;1713:388::-;1934:16;:18;;1905:17;;-1:-1:-1;;;;;1934:18:24;;;;1905:17;1934:18;;;:::i;:::-;;;;;;;;-1:-1:-1;;;;;1934:18:24;;;;;;;;;;;;;;;1994:16;;1987:23;;-1:-1:-1;1994:16:24;1987:4;:23;:::i;:::-;:29;;2013:3;1987:29;:::i;:::-;2032:33;;-1:-1:-1;;;;;5025:39:29;;5007:58;;1962:55:24;;-1:-1:-1;2032:33:24;;4995:2:29;4980:18;2032:33:24;;;;;;;1713:388;;;;;;;:::o;2609:78::-;2663:20;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2663:20:24;2609:78;;;:::o;3836:223::-;3883:7;3947:4;3919:32;;3974:2;3965:11;;3961:69;;;3999:20;;-1:-1:-1;;;3999:20:24;;;;;;;;;;;3961:69;4046:6;3836:223;-1:-1:-1;;3836:223:24:o;3359:364::-;3408:13;3433:11;3447:12;3454:4;3447:6;:12::i;:::-;3567:14;;;3578:2;3567:14;;;;;;;;;3433:26;;-1:-1:-1;3547:17:24;;3567:14;;;;;;;;;-1:-1:-1;;;3630:16:24;;;-1:-1:-1;3675:4:24;3666:14;;3659:28;;;;-1:-1:-1;3630:16:24;3359:364::o;2987:260::-;3042:3;3057:17;3083:3;3057:30;;3115:2;3101:4;:11;:16;3097:72;;;3154:3;3140:18;;-1:-1:-1;;;3140:18:24;;;;;;;;:::i;:::-;;;;;;;;3097:72;3227:11;;3210:13;3227:4;3210:13;:::i;:::-;3202:36;;2987:260;-1:-1:-1;;;2987:260:24:o;14:189:29:-;105:20;;165:12;154:24;;144:35;;134:63;;193:1;190;183:12;208:816;434:6;442;450;458;466;519:3;507:9;498:7;494:23;490:33;487:53;;;536:1;533;526:12;487:53;581:23;;;-1:-1:-1;701:2:29;686:18;;673:32;;-1:-1:-1;804:2:29;789:18;;776:32;;-1:-1:-1;907:2:29;892:18;;879:32;;-1:-1:-1;956:62:29;1013:3;998:19;;956:62;:::i;:::-;946:72;;208:816;;;;;;;;:::o;1273:636::-;1488:2;1500:21;;;1570:13;;1473:18;;;1592:22;;;1440:4;;1671:15;;;1645:2;1630:18;;;1440:4;1714:169;1728:6;1725:1;1722:13;1714:169;;;1789:13;;1777:26;;1832:2;1858:15;;;;1823:12;;;;1750:1;1743:9;1714:169;;;-1:-1:-1;1900:3:29;;1273:636;-1:-1:-1;;;;;1273:636:29:o;1914:160::-;1980:20;;2040:1;2029:20;;;2019:31;;2009:59;;2064:1;2061;2054:12;2079:391;2177:6;2185;2193;2246:2;2234:9;2225:7;2221:23;2217:32;2214:52;;;2262:1;2259;2252:12;2214:52;2307:23;;;-1:-1:-1;2373:36:29;2405:2;2390:18;;2373:36;:::i;:::-;2363:46;;2428:36;2460:2;2449:9;2445:18;2428:36;:::i;:::-;2418:46;;2079:391;;;;;:::o;2711:202::-;2799:20;;-1:-1:-1;;;;;;2848:40:29;;2838:51;;2828:79;;2903:1;2900;2893:12;2918:234;3005:6;3058:2;3046:9;3037:7;3033:23;3029:32;3026:52;;;3074:1;3071;3064:12;3026:52;3097:49;3136:9;3097:49;:::i;:::-;3087:59;2918:234;-1:-1:-1;;;2918:234:29:o;3843:200::-;3931:20;;-1:-1:-1;;;;;3980:38:29;;3970:49;;3960:77;;4033:1;4030;4023:12;4048:782;4258:6;4266;4274;4282;4290;4343:3;4331:9;4322:7;4318:23;4314:33;4311:53;;;4360:1;4357;4350:12;4311:53;4386:23;;-1:-1:-1;;;;;4438:31:29;;4428:42;;4418:70;;4484:1;4481;4474:12;4418:70;4507:5;-1:-1:-1;4531:58:29;4585:2;4570:18;;4531:58;:::i;:::-;4521:68;;4608:61;4665:2;4654:9;4650:18;4608:61;:::i;:::-;4598:71;;4688:58;4742:2;4731:9;4727:18;4688:58;:::i;:::-;4678:68;;4765:59;4819:3;4808:9;4804:19;4765:59;:::i;5507:251::-;5591:6;5644:2;5632:9;5623:7;5619:23;5615:32;5612:52;;;5660:1;5657;5650:12;5612:52;-1:-1:-1;5705:23:29;;5507:251;-1:-1:-1;5507:251:29:o;5763:159::-;5830:20;;5890:6;5879:18;;5869:29;;5859:57;;5912:1;5909;5902:12;5927:833;6129:6;6137;6145;6153;6161;6169;6222:3;6210:9;6201:7;6197:23;6193:33;6190:53;;;6239:1;6236;6229:12;6190:53;6284:23;;;-1:-1:-1;6350:37:29;6383:2;6368:18;;6350:37;:::i;:::-;6340:47;-1:-1:-1;6460:2:29;6445:18;;6432:32;;-1:-1:-1;6563:2:29;6548:18;;6535:32;;-1:-1:-1;6666:3:29;6651:19;;6638:33;;-1:-1:-1;6716:38:29;6749:3;6734:19;;6716:38;:::i;:::-;6706:48;;5927:833;;;;;;;;:::o;7283:759::-;7488:6;7496;7504;7512;7520;7573:3;7561:9;7552:7;7548:23;7544:33;7541:53;;;7590:1;7587;7580:12;7541:53;7613:49;7652:9;7613:49;:::i;:::-;7603:59;;7681:58;7735:2;7724:9;7720:18;7681:58;:::i;:::-;7671:68;;7758:58;7812:2;7801:9;7797:18;7758:58;:::i;:::-;7748:68;;7835:58;7889:2;7878:9;7874:18;7835:58;:::i;:::-;7825:68;;7943:3;7932:9;7928:19;7915:33;7988:4;7981:5;7977:16;7970:5;7967:27;7957:55;;8008:1;8005;7998:12;7957:55;8031:5;8021:15;;;7283:759;;;;;;;;:::o;8229:418::-;8378:2;8367:9;8360:21;8341:4;8410:6;8404:13;8453:6;8448:2;8437:9;8433:18;8426:34;8512:6;8507:2;8499:6;8495:15;8490:2;8479:9;8475:18;8469:50;8568:1;8563:2;8554:6;8543:9;8539:22;8535:31;8528:42;8638:2;8631;8627:7;8622:2;8614:6;8610:15;8606:29;8595:9;8591:45;8587:54;8579:62;;;8229:418;;;;:::o;8865:127::-;8926:10;8921:3;8917:20;8914:1;8907:31;8957:4;8954:1;8947:15;8981:4;8978:1;8971:15;8997:945;9066:6;9119:2;9107:9;9098:7;9094:23;9090:32;9087:52;;;9135:1;9132;9125:12;9087:52;9175:9;9162:23;9208:18;9200:6;9197:30;9194:50;;;9240:1;9237;9230:12;9194:50;9263:22;;9316:4;9308:13;;9304:27;-1:-1:-1;9294:55:29;;9345:1;9342;9335:12;9294:55;9385:2;9372:16;9411:18;9403:6;9400:30;9397:56;;;9433:18;;:::i;:::-;9482:2;9476:9;9574:2;9536:17;;-1:-1:-1;;9532:31:29;;;9565:2;9528:40;9524:54;9512:67;;9609:18;9594:34;;9630:22;;;9591:62;9588:88;;;9656:18;;:::i;:::-;9692:2;9685:22;9716;;;9757:15;;;9774:2;9753:24;9750:37;-1:-1:-1;9747:57:29;;;9800:1;9797;9790:12;9747:57;9856:6;9851:2;9847;9843:11;9838:2;9830:6;9826:15;9813:50;9909:1;9883:19;;;9904:2;9879:28;9872:39;;;;9887:6;8997:945;-1:-1:-1;;;;8997:945:29:o;10154:127::-;10215:10;10210:3;10206:20;10203:1;10196:31;10246:4;10243:1;10236:15;10270:4;10267:1;10260:15;10286:135;10325:3;10346:17;;;10343:43;;10366:18;;:::i;:::-;-1:-1:-1;10413:1:29;10402:13;;10286:135::o;10426:220::-;10464:3;-1:-1:-1;;;;;10501:5:29;10497:38;-1:-1:-1;;;;;10550:7:29;10547:39;10544:65;;10589:18;;:::i;:::-;10638:1;10625:15;;10426:220;-1:-1:-1;;10426:220:29:o;10651:292::-;-1:-1:-1;;;;;10735:34:29;;;10771;;;10731:75;10826:44;;;;10889:24;;;10879:58;;10917:18;;:::i;:::-;10879:58;10651:292;;;;:::o;10948:215::-;-1:-1:-1;;;;;11016:34:29;;;11052;;;11012:75;;11099:35;;11096:61;;;11137:18;;:::i;11168:297::-;11286:12;;11333:4;11322:16;;;11316:23;;11286:12;11351:16;;11348:111;;;11445:1;11441:6;11431;11425:4;11421:17;11418:1;11414:25;11410:38;11403:5;11399:50;11390:59;;11348:111;;11168:297;;;:::o","linkReferences":{}},"methodIdentifiers":{"MAX_POLICIES_TO_PROCESS()":"4b396c4f","MAX_PREMIUM()":"4cdabb16","MAX_SUM_INSURED()":"a4846cbf","MIN_PREMIUM()":"be5c8f44","MIN_SUM_INSURED()":"def6aeca","createCrop(bytes32)":"7f73fa9c","createLocation(bytes32,int32,int32)":"2a6f8ef2","createPolicy(address,bytes8,uint40,uint96,uint96)":"422e9f41","createRisk(bytes32,bytes32,bytes32,bytes32,uint40)":"0228ec7b","createSeason(bytes32,uint16,bytes32,bytes32,bytes32,uint16)":"6f336d7c","crops()":"23c9bc52","getLocation(bytes32)":"5be6405e","getRisk(bytes8)":"3405f20c","getRiskId(bytes32)":"694ac999","getSeason(bytes32)":"729ff16c","length(bytes32)":"a9dbaf25","policyNftCounter()":"bb313321","riskCounter()":"f1338cda","seasons()":"f44f30cd","setConstants(uint96,uint96,uint96,uint96,uint8)":"7d1c5290","toStr(string)":"cdc23e69","toString(bytes32)":"b11a19e8"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.27+commit.40a35a09\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidShortString\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"}],\"name\":\"StringTooLong\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"NftId\",\"name\":\"policyNftId\",\"type\":\"uint96\"}],\"name\":\"LogCropPolicyCreated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_POLICIES_TO_PROCESS\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_PREMIUM\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_SUM_INSURED\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_PREMIUM\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_SUM_INSURED\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"crop\",\"type\":\"bytes32\"}],\"name\":\"createCrop\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"},{\"internalType\":\"int32\",\"name\":\"latitude\",\"type\":\"int32\"},{\"internalType\":\"int32\",\"name\":\"longitude\",\"type\":\"int32\"}],\"name\":\"createLocation\",\"outputs\":[{\"internalType\":\"Location\",\"name\":\"location\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"policyHolder\",\"type\":\"address\"},{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"},{\"internalType\":\"Timestamp\",\"name\":\"activateAt\",\"type\":\"uint40\"},{\"internalType\":\"Amount\",\"name\":\"sumInsuredAmount\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"premiumAmount\",\"type\":\"uint96\"}],\"name\":\"createPolicy\",\"outputs\":[{\"internalType\":\"NftId\",\"name\":\"policyNftId\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"id\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"crop\",\"type\":\"bytes32\"},{\"internalType\":\"Timestamp\",\"name\":\"seasonEndAt\",\"type\":\"uint40\"}],\"name\":\"createRisk\",\"outputs\":[{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"},{\"internalType\":\"uint16\",\"name\":\"year\",\"type\":\"uint16\"},{\"internalType\":\"Str\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonStart\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonEnd\",\"type\":\"bytes32\"},{\"internalType\":\"uint16\",\"name\":\"seasonDays\",\"type\":\"uint16\"}],\"name\":\"createSeason\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"crops\",\"outputs\":[{\"internalType\":\"Str[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"}],\"name\":\"getLocation\",\"outputs\":[{\"internalType\":\"Location\",\"name\":\"location\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"}],\"name\":\"getRisk\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"crop\",\"type\":\"bytes32\"},{\"internalType\":\"Timestamp\",\"name\":\"seasonEndAt\",\"type\":\"uint40\"},{\"internalType\":\"UFixed\",\"name\":\"payoutFactor\",\"type\":\"uint160\"},{\"internalType\":\"bool\",\"name\":\"payoutDefined\",\"type\":\"bool\"}],\"internalType\":\"struct CropProduct.CropRisk\",\"name\":\"cropRisk\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"getRiskId\",\"outputs\":[{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"}],\"name\":\"getSeason\",\"outputs\":[{\"components\":[{\"internalType\":\"uint16\",\"name\":\"year\",\"type\":\"uint16\"},{\"internalType\":\"Str\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonStart\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonEnd\",\"type\":\"bytes32\"},{\"internalType\":\"uint16\",\"name\":\"seasonDays\",\"type\":\"uint16\"}],\"internalType\":\"struct CropProduct.Season\",\"name\":\"season\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"sstr\",\"type\":\"bytes32\"}],\"name\":\"length\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"policyNftCounter\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"riskCounter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"seasons\",\"outputs\":[{\"internalType\":\"Str[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Amount\",\"name\":\"minPremium\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"maxPremium\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"minSumInsured\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"maxSumInsured\",\"type\":\"uint96\"},{\"internalType\":\"uint8\",\"name\":\"maxPoliciesToProcess\",\"type\":\"uint8\"}],\"name\":\"setConstants\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"}],\"name\":\"toStr\",\"outputs\":[{\"internalType\":\"Str\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"sstr\",\"type\":\"bytes32\"}],\"name\":\"toString\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"length(bytes32)\":{\"details\":\"returns the length of the provided short string. code from OZ ShortStrings.byteLength\"},\"toStr(string)\":{\"details\":\"converts the provided string into a short string. code from OZ ShortStrings.toShortString\"},\"toString(bytes32)\":{\"details\":\"converts the provided short string into a string. code from OZ ShortStrings.toString\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/CropProduct.sol\":\"CropProduct\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":forge-std/=lib/forge-std/src/\"]},\"sources\":{\"src/CropProduct.sol\":{\"keccak256\":\"0x15ea24c22145d91926e880a7fd72e2bb44a8b3a62faa38100c37a5588476cb32\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://e49e23cb02068c729eb8708614f9063ed2e5e3b8e12105b7cec35af0eb949be5\",\"dweb:/ipfs/QmWYqST19CU5uGZLp9Vb3ufx28f5UYjVzv7nC2aJd9PJDM\"]},\"src/Types.sol\":{\"keccak256\":\"0x4c3c95d21faeee8c69bd41f83636eb8a851b5247163faf06953f54b2e9dda40e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://7c78471ec7d545f2c033447738699d64d1e67b7f23ace9ab8240ac596acb959f\",\"dweb:/ipfs/QmUQFZ4c9FvpJy1JsPfqG7dbUxCNr3gpSFUWzvA36XpU3N\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.27+commit.40a35a09"},"language":"Solidity","output":{"abi":[{"inputs":[],"type":"error","name":"InvalidShortString"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"type":"error","name":"StringTooLong"},{"inputs":[{"internalType":"NftId","name":"policyNftId","type":"uint96","indexed":false}],"type":"event","name":"LogCropPolicyCreated","anonymous":false},{"inputs":[],"stateMutability":"view","type":"function","name":"MAX_POLICIES_TO_PROCESS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MAX_PREMIUM","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MAX_SUM_INSURED","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MIN_PREMIUM","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MIN_SUM_INSURED","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[{"internalType":"Str","name":"crop","type":"bytes32"}],"stateMutability":"nonpayable","type":"function","name":"createCrop"},{"inputs":[{"internalType":"Str","name":"locationId","type":"bytes32"},{"internalType":"int32","name":"latitude","type":"int32"},{"internalType":"int32","name":"longitude","type":"int32"}],"stateMutability":"nonpayable","type":"function","name":"createLocation","outputs":[{"internalType":"Location","name":"location","type":"uint64"}]},{"inputs":[{"internalType":"address","name":"policyHolder","type":"address"},{"internalType":"RiskId","name":"riskId","type":"bytes8"},{"internalType":"Timestamp","name":"activateAt","type":"uint40"},{"internalType":"Amount","name":"sumInsuredAmount","type":"uint96"},{"internalType":"Amount","name":"premiumAmount","type":"uint96"}],"stateMutability":"nonpayable","type":"function","name":"createPolicy","outputs":[{"internalType":"NftId","name":"policyNftId","type":"uint96"}]},{"inputs":[{"internalType":"Str","name":"id","type":"bytes32"},{"internalType":"Str","name":"seasonId","type":"bytes32"},{"internalType":"Str","name":"locationId","type":"bytes32"},{"internalType":"Str","name":"crop","type":"bytes32"},{"internalType":"Timestamp","name":"seasonEndAt","type":"uint40"}],"stateMutability":"nonpayable","type":"function","name":"createRisk","outputs":[{"internalType":"RiskId","name":"riskId","type":"bytes8"}]},{"inputs":[{"internalType":"Str","name":"seasonId","type":"bytes32"},{"internalType":"uint16","name":"year","type":"uint16"},{"internalType":"Str","name":"name","type":"bytes32"},{"internalType":"Str","name":"seasonStart","type":"bytes32"},{"internalType":"Str","name":"seasonEnd","type":"bytes32"},{"internalType":"uint16","name":"seasonDays","type":"uint16"}],"stateMutability":"nonpayable","type":"function","name":"createSeason"},{"inputs":[],"stateMutability":"view","type":"function","name":"crops","outputs":[{"internalType":"Str[]","name":"","type":"bytes32[]"}]},{"inputs":[{"internalType":"Str","name":"locationId","type":"bytes32"}],"stateMutability":"view","type":"function","name":"getLocation","outputs":[{"internalType":"Location","name":"location","type":"uint64"}]},{"inputs":[{"internalType":"RiskId","name":"riskId","type":"bytes8"}],"stateMutability":"view","type":"function","name":"getRisk","outputs":[{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"struct CropProduct.CropRisk","name":"cropRisk","type":"tuple","components":[{"internalType":"Str","name":"seasonId","type":"bytes32"},{"internalType":"Str","name":"locationId","type":"bytes32"},{"internalType":"Str","name":"crop","type":"bytes32"},{"internalType":"Timestamp","name":"seasonEndAt","type":"uint40"},{"internalType":"UFixed","name":"payoutFactor","type":"uint160"},{"internalType":"bool","name":"payoutDefined","type":"bool"}]}]},{"inputs":[{"internalType":"Str","name":"id","type":"bytes32"}],"stateMutability":"view","type":"function","name":"getRiskId","outputs":[{"internalType":"RiskId","name":"riskId","type":"bytes8"}]},{"inputs":[{"internalType":"Str","name":"seasonId","type":"bytes32"}],"stateMutability":"view","type":"function","name":"getSeason","outputs":[{"internalType":"struct CropProduct.Season","name":"season","type":"tuple","components":[{"internalType":"uint16","name":"year","type":"uint16"},{"internalType":"Str","name":"name","type":"bytes32"},{"internalType":"Str","name":"seasonStart","type":"bytes32"},{"internalType":"Str","name":"seasonEnd","type":"bytes32"},{"internalType":"uint16","name":"seasonDays","type":"uint16"}]}]},{"inputs":[{"internalType":"Str","name":"sstr","type":"bytes32"}],"stateMutability":"pure","type":"function","name":"length","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"policyNftCounter","outputs":[{"internalType":"uint96","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"riskCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"seasons","outputs":[{"internalType":"Str[]","name":"","type":"bytes32[]"}]},{"inputs":[{"internalType":"Amount","name":"minPremium","type":"uint96"},{"internalType":"Amount","name":"maxPremium","type":"uint96"},{"internalType":"Amount","name":"minSumInsured","type":"uint96"},{"internalType":"Amount","name":"maxSumInsured","type":"uint96"},{"internalType":"uint8","name":"maxPoliciesToProcess","type":"uint8"}],"stateMutability":"nonpayable","type":"function","name":"setConstants"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"stateMutability":"pure","type":"function","name":"toStr","outputs":[{"internalType":"Str","name":"","type":"bytes32"}]},{"inputs":[{"internalType":"Str","name":"sstr","type":"bytes32"}],"stateMutability":"pure","type":"function","name":"toString","outputs":[{"internalType":"string","name":"","type":"string"}]}],"devdoc":{"kind":"dev","methods":{"length(bytes32)":{"details":"returns the length of the provided short string. code from OZ ShortStrings.byteLength"},"toStr(string)":{"details":"converts the provided string into a short string. code from OZ ShortStrings.toShortString"},"toString(bytes32)":{"details":"converts the provided short string into a string. code from OZ ShortStrings.toString"}},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["forge-std/=lib/forge-std/src/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"src/CropProduct.sol":"CropProduct"},"evmVersion":"cancun","libraries":{}},"sources":{"src/CropProduct.sol":{"keccak256":"0x15ea24c22145d91926e880a7fd72e2bb44a8b3a62faa38100c37a5588476cb32","urls":["bzz-raw://e49e23cb02068c729eb8708614f9063ed2e5e3b8e12105b7cec35af0eb949be5","dweb:/ipfs/QmWYqST19CU5uGZLp9Vb3ufx28f5UYjVzv7nC2aJd9PJDM"],"license":"Apache-2.0"},"src/Types.sol":{"keccak256":"0x4c3c95d21faeee8c69bd41f83636eb8a851b5247163faf06953f54b2e9dda40e","urls":["bzz-raw://7c78471ec7d545f2c033447738699d64d1e67b7f23ace9ab8240ac596acb959f","dweb:/ipfs/QmUQFZ4c9FvpJy1JsPfqG7dbUxCNr3gpSFUWzvA36XpU3N"],"license":"Apache-2.0"}},"version":1},"id":24} \ No newline at end of file +{"abi":[{"type":"function","name":"MAX_POLICIES_TO_PROCESS","inputs":[],"outputs":[{"name":"","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"type":"function","name":"MAX_PREMIUM","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"MAX_SUM_INSURED","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"MIN_PREMIUM","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"MIN_SUM_INSURED","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"Amount"}],"stateMutability":"view"},{"type":"function","name":"createCrop","inputs":[{"name":"crop","type":"bytes32","internalType":"Str"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"createLocation","inputs":[{"name":"locationId","type":"bytes32","internalType":"Str"},{"name":"latitude","type":"int32","internalType":"int32"},{"name":"longitude","type":"int32","internalType":"int32"}],"outputs":[{"name":"location","type":"uint64","internalType":"Location"}],"stateMutability":"nonpayable"},{"type":"function","name":"createPolicy","inputs":[{"name":"policyHolder","type":"address","internalType":"address"},{"name":"riskId","type":"bytes8","internalType":"RiskId"},{"name":"activateAt","type":"uint40","internalType":"Timestamp"},{"name":"sumInsuredAmount","type":"uint96","internalType":"Amount"},{"name":"premiumAmount","type":"uint96","internalType":"Amount"}],"outputs":[{"name":"policyNftId","type":"uint96","internalType":"NftId"}],"stateMutability":"nonpayable"},{"type":"function","name":"createRisk","inputs":[{"name":"id","type":"bytes32","internalType":"Str"},{"name":"seasonId","type":"bytes32","internalType":"Str"},{"name":"locationId","type":"bytes32","internalType":"Str"},{"name":"crop","type":"bytes32","internalType":"Str"},{"name":"seasonEndAt","type":"uint40","internalType":"Timestamp"}],"outputs":[{"name":"riskId","type":"bytes8","internalType":"RiskId"}],"stateMutability":"nonpayable"},{"type":"function","name":"createSeason","inputs":[{"name":"seasonId","type":"bytes32","internalType":"Str"},{"name":"year","type":"uint16","internalType":"uint16"},{"name":"name","type":"bytes32","internalType":"Str"},{"name":"seasonStart","type":"bytes32","internalType":"Str"},{"name":"seasonEnd","type":"bytes32","internalType":"Str"},{"name":"seasonDays","type":"uint16","internalType":"uint16"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"crops","inputs":[],"outputs":[{"name":"","type":"bytes32[]","internalType":"Str[]"}],"stateMutability":"view"},{"type":"function","name":"getLocation","inputs":[{"name":"locationId","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"location","type":"uint64","internalType":"Location"}],"stateMutability":"view"},{"type":"function","name":"getRisk","inputs":[{"name":"riskId","type":"bytes8","internalType":"RiskId"}],"outputs":[{"name":"exists","type":"bool","internalType":"bool"},{"name":"cropRisk","type":"tuple","internalType":"struct CropProduct.CropRisk","components":[{"name":"seasonId","type":"bytes32","internalType":"Str"},{"name":"locationId","type":"bytes32","internalType":"Str"},{"name":"crop","type":"bytes32","internalType":"Str"},{"name":"seasonEndAt","type":"uint40","internalType":"Timestamp"},{"name":"payoutFactor","type":"uint160","internalType":"UFixed"},{"name":"payoutDefined","type":"bool","internalType":"bool"}]}],"stateMutability":"view"},{"type":"function","name":"getRiskId","inputs":[{"name":"id","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"riskId","type":"bytes8","internalType":"RiskId"}],"stateMutability":"view"},{"type":"function","name":"getSeason","inputs":[{"name":"seasonId","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"season","type":"tuple","internalType":"struct CropProduct.Season","components":[{"name":"year","type":"uint16","internalType":"uint16"},{"name":"name","type":"bytes32","internalType":"Str"},{"name":"seasonStart","type":"bytes32","internalType":"Str"},{"name":"seasonEnd","type":"bytes32","internalType":"Str"},{"name":"seasonDays","type":"uint16","internalType":"uint16"}]}],"stateMutability":"view"},{"type":"function","name":"getTokenHandler","inputs":[],"outputs":[{"name":"tokenHandler","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"length","inputs":[{"name":"sstr","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"type":"function","name":"policyNftCounter","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"uint96"}],"stateMutability":"view"},{"type":"function","name":"riskCounter","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"seasons","inputs":[],"outputs":[{"name":"","type":"bytes32[]","internalType":"Str[]"}],"stateMutability":"view"},{"type":"function","name":"setConstants","inputs":[{"name":"minPremium","type":"uint96","internalType":"Amount"},{"name":"maxPremium","type":"uint96","internalType":"Amount"},{"name":"minSumInsured","type":"uint96","internalType":"Amount"},{"name":"maxSumInsured","type":"uint96","internalType":"Amount"},{"name":"maxPoliciesToProcess","type":"uint8","internalType":"uint8"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"toStr","inputs":[{"name":"str","type":"string","internalType":"string"}],"outputs":[{"name":"","type":"bytes32","internalType":"Str"}],"stateMutability":"pure"},{"type":"function","name":"toString","inputs":[{"name":"sstr","type":"bytes32","internalType":"Str"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"pure"},{"type":"event","name":"LogCropPolicyCreated","inputs":[{"name":"policyNftId","type":"uint96","indexed":false,"internalType":"NftId"}],"anonymous":false},{"type":"error","name":"InvalidShortString","inputs":[]},{"type":"error","name":"StringTooLong","inputs":[{"name":"str","type":"string","internalType":"string"}]}],"bytecode":{"object":"0x60806040526001805460ff60c01b1916600160c01b179055600380546001600160601b03191660641790553480156034575f5ffd5b50610abb806100425f395ff3fe608060405234801561000f575f5ffd5b5060043610610148575f3560e01c8063729ff16c116100bf578063bb31332111610079578063bb31332114610400578063be5c8f4414610413578063cdc23e6914610425578063def6aeca14610438578063f1338cda1461044b578063f44f30cd1461017d575f5ffd5b8063729ff16c146103235780637d1c52901461037f5780637f73fa9c14610394578063a4846cbf146103a5578063a9dbaf25146103bf578063b11a19e8146103e0575f5ffd5b806343d752d31161011057806343d752d3146102895780634b396c4f146102975780634cdabb16146102bd5780635be6405e146102d6578063694ac999146102e95780636f336d7c1461030b575f5ffd5b80630228ec7b1461014c57806323c9bc521461017d5780632a6f8ef21461018c5780633405f20c146101bb578063422e9f411461025e575b5f5ffd5b61015f61015a36600461065f565b610454565b6040516001600160c01b031990911681526020015b60405180910390f35b606060405161017491906106a4565b6101a261019a3660046106f7565b5f9392505050565b60405167ffffffffffffffff9091168152602001610174565b6101fe6101c9366004610747565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a08101829052915091565b60408051921515835281516020808501919091528201518382015281015160608084019190915281015164ffffffffff166080808401919091528101516001600160a01b031660a0808401919091520151151560c082015260e001610174565b61027161026c36600461077d565b6104c1565b6040516001600160601b039091168152602001610174565b6040515f8152602001610174565b6001546102ab90600160c01b900460ff1681565b60405160ff9091168152602001610174565b5f5461027190600160601b90046001600160601b031681565b6101a26102e43660046107df565b505f90565b61015f6102f73660046107df565b5f9081526004602052604090205460c01b90565b610321610319366004610807565b505050505050565b005b6103366103313660046107df565b610561565b60405161017491905f60a08201905061ffff835116825260208301516020830152604083015160408301526060830151606083015261ffff608084015116608083015292915050565b61032161038d36600461085b565b5050505050565b6103216103a23660046107df565b50565b60015461027190600160601b90046001600160601b031681565b6103d26103cd3660046107df565b61059b565b604051908152602001610174565b6103f36103ee3660046107df565b6105c8565b60405161017491906108c5565b600354610271906001600160601b031681565b5f54610271906001600160601b031681565b6103d261043336600461090e565b610605565b600154610271906001600160601b031681565b6103d260025481565b600280545f9182610464836109d5565b919050555060025460405160200161047e91815260200190565b60408051808303601f1901815291815281516020928301205f9889526004909252909620805467ffffffffffffffff191660c088901c1790555093949350505050565b600380545f916001600160601b0390911690826104dd836109ed565b82546101009290920a6001600160601b0381810219909316918316021790915560035461050e9250166103e8610a17565b610519906065610a40565b6040516001600160601b03821681529091507fc31147b2435123798832cf3c9d8ce5cd012cb3d548b18d196793c5a8e65f57d19060200160405180910390a195945050505050565b6105966040518060a001604052805f61ffff1681526020015f81526020015f81526020015f81526020015f61ffff1681525090565b919050565b5f60ff8216601f8111156105c257604051632cd44ac360e21b815260040160405180910390fd5b92915050565b60605f6105d48361059b565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f5f829050601f81511115610638578260405163305a27a960e01b815260040161062f91906108c5565b60405180910390fd5b805161064382610a5f565b179392505050565b803564ffffffffff81168114610596575f5ffd5b5f5f5f5f5f60a08688031215610673575f5ffd5b853594506020860135935060408601359250606086013591506106986080870161064b565b90509295509295909350565b602080825282518282018190525f918401906040840190835b818110156106db5783518352602093840193909201916001016106bd565b509095945050505050565b8035600381900b8114610596575f5ffd5b5f5f5f60608486031215610709575f5ffd5b83359250610719602085016106e6565b9150610727604085016106e6565b90509250925092565b80356001600160c01b031981168114610596575f5ffd5b5f60208284031215610757575f5ffd5b61076082610730565b9392505050565b80356001600160601b0381168114610596575f5ffd5b5f5f5f5f5f60a08688031215610791575f5ffd5b85356001600160a01b03811681146107a7575f5ffd5b94506107b560208701610730565b93506107c36040870161064b565b92506107d160608701610767565b915061069860808701610767565b5f602082840312156107ef575f5ffd5b5035919050565b803561ffff81168114610596575f5ffd5b5f5f5f5f5f5f60c0878903121561081c575f5ffd5b8635955061082c602088016107f6565b945060408701359350606087013592506080870135915061084f60a088016107f6565b90509295509295509295565b5f5f5f5f5f60a0868803121561086f575f5ffd5b61087886610767565b945061088660208701610767565b935061089460408701610767565b92506108a260608701610767565b9150608086013560ff811681146108b7575f5ffd5b809150509295509295909350565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561091e575f5ffd5b813567ffffffffffffffff811115610934575f5ffd5b8201601f81018413610944575f5ffd5b803567ffffffffffffffff81111561095e5761095e6108fa565b604051601f8201601f19908116603f0116810167ffffffffffffffff8111828210171561098d5761098d6108fa565b6040528181528282016020018610156109a4575f5ffd5b816020840160208301375f91810160200191909152949350505050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016109e6576109e66109c1565b5060010190565b5f6001600160601b0382166001600160601b038103610a0e57610a0e6109c1565b60010192915050565b6001600160601b038181168382160290811690818114610a3957610a396109c1565b5092915050565b6001600160601b0381811683821601908111156105c2576105c26109c1565b80516020808301519190811015610a7f575f198160200360031b1b821691505b5091905056fea26469706673582212203658213bf9e0912bf136fd4ad3edaa13f6a571b5b1c78364af57352b0650c14564736f6c634300081b0033","sourceMap":"151:3995:26:-:0;;;869:1;830:40;;-1:-1:-1;;;;830:40:26;-1:-1:-1;;;830:40:26;;;950:36;;;-1:-1:-1;;;;;;950:36:26;983:3;950:36;;;151:3995;;;;;;;;;;;;;;;;","linkReferences":{}},"deployedBytecode":{"object":"0x608060405234801561000f575f5ffd5b5060043610610148575f3560e01c8063729ff16c116100bf578063bb31332111610079578063bb31332114610400578063be5c8f4414610413578063cdc23e6914610425578063def6aeca14610438578063f1338cda1461044b578063f44f30cd1461017d575f5ffd5b8063729ff16c146103235780637d1c52901461037f5780637f73fa9c14610394578063a4846cbf146103a5578063a9dbaf25146103bf578063b11a19e8146103e0575f5ffd5b806343d752d31161011057806343d752d3146102895780634b396c4f146102975780634cdabb16146102bd5780635be6405e146102d6578063694ac999146102e95780636f336d7c1461030b575f5ffd5b80630228ec7b1461014c57806323c9bc521461017d5780632a6f8ef21461018c5780633405f20c146101bb578063422e9f411461025e575b5f5ffd5b61015f61015a36600461065f565b610454565b6040516001600160c01b031990911681526020015b60405180910390f35b606060405161017491906106a4565b6101a261019a3660046106f7565b5f9392505050565b60405167ffffffffffffffff9091168152602001610174565b6101fe6101c9366004610747565b6040805160c0810182525f80825260208201819052918101829052606081018290526080810182905260a08101829052915091565b60408051921515835281516020808501919091528201518382015281015160608084019190915281015164ffffffffff166080808401919091528101516001600160a01b031660a0808401919091520151151560c082015260e001610174565b61027161026c36600461077d565b6104c1565b6040516001600160601b039091168152602001610174565b6040515f8152602001610174565b6001546102ab90600160c01b900460ff1681565b60405160ff9091168152602001610174565b5f5461027190600160601b90046001600160601b031681565b6101a26102e43660046107df565b505f90565b61015f6102f73660046107df565b5f9081526004602052604090205460c01b90565b610321610319366004610807565b505050505050565b005b6103366103313660046107df565b610561565b60405161017491905f60a08201905061ffff835116825260208301516020830152604083015160408301526060830151606083015261ffff608084015116608083015292915050565b61032161038d36600461085b565b5050505050565b6103216103a23660046107df565b50565b60015461027190600160601b90046001600160601b031681565b6103d26103cd3660046107df565b61059b565b604051908152602001610174565b6103f36103ee3660046107df565b6105c8565b60405161017491906108c5565b600354610271906001600160601b031681565b5f54610271906001600160601b031681565b6103d261043336600461090e565b610605565b600154610271906001600160601b031681565b6103d260025481565b600280545f9182610464836109d5565b919050555060025460405160200161047e91815260200190565b60408051808303601f1901815291815281516020928301205f9889526004909252909620805467ffffffffffffffff191660c088901c1790555093949350505050565b600380545f916001600160601b0390911690826104dd836109ed565b82546101009290920a6001600160601b0381810219909316918316021790915560035461050e9250166103e8610a17565b610519906065610a40565b6040516001600160601b03821681529091507fc31147b2435123798832cf3c9d8ce5cd012cb3d548b18d196793c5a8e65f57d19060200160405180910390a195945050505050565b6105966040518060a001604052805f61ffff1681526020015f81526020015f81526020015f81526020015f61ffff1681525090565b919050565b5f60ff8216601f8111156105c257604051632cd44ac360e21b815260040160405180910390fd5b92915050565b60605f6105d48361059b565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f5f829050601f81511115610638578260405163305a27a960e01b815260040161062f91906108c5565b60405180910390fd5b805161064382610a5f565b179392505050565b803564ffffffffff81168114610596575f5ffd5b5f5f5f5f5f60a08688031215610673575f5ffd5b853594506020860135935060408601359250606086013591506106986080870161064b565b90509295509295909350565b602080825282518282018190525f918401906040840190835b818110156106db5783518352602093840193909201916001016106bd565b509095945050505050565b8035600381900b8114610596575f5ffd5b5f5f5f60608486031215610709575f5ffd5b83359250610719602085016106e6565b9150610727604085016106e6565b90509250925092565b80356001600160c01b031981168114610596575f5ffd5b5f60208284031215610757575f5ffd5b61076082610730565b9392505050565b80356001600160601b0381168114610596575f5ffd5b5f5f5f5f5f60a08688031215610791575f5ffd5b85356001600160a01b03811681146107a7575f5ffd5b94506107b560208701610730565b93506107c36040870161064b565b92506107d160608701610767565b915061069860808701610767565b5f602082840312156107ef575f5ffd5b5035919050565b803561ffff81168114610596575f5ffd5b5f5f5f5f5f5f60c0878903121561081c575f5ffd5b8635955061082c602088016107f6565b945060408701359350606087013592506080870135915061084f60a088016107f6565b90509295509295509295565b5f5f5f5f5f60a0868803121561086f575f5ffd5b61087886610767565b945061088660208701610767565b935061089460408701610767565b92506108a260608701610767565b9150608086013560ff811681146108b7575f5ffd5b809150509295509295909350565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b634e487b7160e01b5f52604160045260245ffd5b5f6020828403121561091e575f5ffd5b813567ffffffffffffffff811115610934575f5ffd5b8201601f81018413610944575f5ffd5b803567ffffffffffffffff81111561095e5761095e6108fa565b604051601f8201601f19908116603f0116810167ffffffffffffffff8111828210171561098d5761098d6108fa565b6040528181528282016020018610156109a4575f5ffd5b816020840160208301375f91810160200191909152949350505050565b634e487b7160e01b5f52601160045260245ffd5b5f600182016109e6576109e66109c1565b5060010190565b5f6001600160601b0382166001600160601b038103610a0e57610a0e6109c1565b60010192915050565b6001600160601b038181168382160290811690818114610a3957610a396109c1565b5092915050565b6001600160601b0381811683821601908111156105c2576105c26109c1565b80516020808301519190811015610a7f575f198160200360031b1b821691505b5091905056fea26469706673582212203658213bf9e0912bf136fd4ad3edaa13f6a571b5b1c78364af57352b0650c14564736f6c634300081b0033","sourceMap":"151:3995:26:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1429:278;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;;1220:41:30;;;1202:60;;1190:2;1175:18;1429:278:26;;;;;;;;2489:54;2527:12;2489:54;;;;;;:::i;1264:112::-;;;;;;:::i;:::-;1355:17;1264:112;;;;;;;;;2680:18:30;2668:31;;;2650:50;;2638:2;2623:18;1264:112:26;2475:231:30;2776:94:26;;;;;;:::i;:::-;-1:-1:-1;;;;;;;;2829:11:26;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2776:94:26;;;;;;;;3405:14:30;;3398:22;3380:41;;3457:13;;3452:2;3437:18;;;3430:41;;;;3513:15;;3507:22;3487:18;;;3480:50;3572:15;;3566:22;3561:2;3546:18;;;3539:50;;;;3636:15;;3630:22;3654:12;3626:41;3620:3;3605:19;;;3598:70;;;;3715:16;;3709:23;-1:-1:-1;;;;;3705:49:30;3742:3;3684:19;;;3677:78;;;;3812:16;3806:23;3799:31;3792:39;3786:3;3771:19;;3764:68;3367:3;3352:19;2776:94:26;3157:681:30;1713:388:26;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;5025:39:30;;;5007:58;;4995:2;4980:18;1713:388:26;4835:236:30;2875:80:26;;;2931:20;5222:51:30;;5210:2;5195:18;2875:80:26;5076:203:30;830:40:26;;;;;-1:-1:-1;;;830:40:26;;;;;;;;;5456:4:30;5444:17;;;5426:36;;5414:2;5399:18;830:40:26;5284:184:30;729:25:26;;;;;-1:-1:-1;;;729:25:26;;-1:-1:-1;;;;;729:25:26;;;2692:79;;;;;;:::i;:::-;-1:-1:-1;2750:17:26;;2692:79;2107:100;;;;;;:::i;:::-;2157:13;2189:11;;;:7;:11;;;;;;;;;2107:100;1049:209;;;;;;:::i;:::-;;;;;;;;;;2609:78;;;;;;:::i;:::-;;:::i;:::-;;;;;;7115:4:30;7157:3;7146:9;7142:19;7134:27;;7207:6;7198;7192:13;7188:26;7177:9;7170:45;7271:4;7263:6;7259:17;7253:24;7246:4;7235:9;7231:20;7224:54;7334:4;7326:6;7322:17;7316:24;7309:4;7298:9;7294:20;7287:54;7397:4;7389:6;7385:17;7379:24;7372:4;7361:9;7357:20;7350:54;7472:6;7464:4;7456:6;7452:17;7446:24;7442:37;7435:4;7424:9;7420:20;7413:67;6973:513;;;;;2213:189:26;;;;;;:::i;:::-;;;;;;;1382:41;;;;;;:::i;:::-;;;795:29;;;;;-1:-1:-1;;;795:29:26;;-1:-1:-1;;;;;795:29:26;;;3921:223;;;;;;:::i;:::-;;:::i;:::-;;;8401:25:30;;;8389:2;8374:18;3921:223:26;8255:177:30;3444:364:26;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;950:36::-;;;;;-1:-1:-1;;;;;950:36:26;;;698:25;;;;;-1:-1:-1;;;;;698:25:26;;;3072:260;;;;;;:::i;:::-;;:::i;760:29::-;;;;;-1:-1:-1;;;;;760:29:26;;;918:26;;;;;;1429:278;1583:11;:13;;1554;;;1583;;;:::i;:::-;;;;;;1655:11;;1644:23;;;;;;8401:25:30;;8389:2;8374:18;;8255:177;1644:23:26;;;;;;;-1:-1:-1;;1644:23:26;;;;;;1634:34;;1644:23;1634:34;;;;1680:11;;;;:7;:11;;;;;;:20;;-1:-1:-1;;1680:20:26;;;;;;;;-1:-1:-1;1634:34:26;;;-1:-1:-1;;;;1429:278:26:o;1713:388::-;1934:16;:18;;1905:17;;-1:-1:-1;;;;;1934:18:26;;;;1905:17;1934:18;;;:::i;:::-;;;;;;;;-1:-1:-1;;;;;1934:18:26;;;;;;;;;;;;;;;1994:16;;1987:23;;-1:-1:-1;1994:16:26;1987:4;:23;:::i;:::-;:29;;2013:3;1987:29;:::i;:::-;2032:33;;-1:-1:-1;;;;;5025:39:30;;5007:58;;1962:55:26;;-1:-1:-1;2032:33:26;;4995:2:30;4980:18;2032:33:26;;;;;;;1713:388;;;;;;;:::o;2609:78::-;2663:20;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2663:20:26;2609:78;;;:::o;3921:223::-;3968:7;4032:4;4004:32;;4059:2;4050:11;;4046:69;;;4084:20;;-1:-1:-1;;;4084:20:26;;;;;;;;;;;4046:69;4131:6;3921:223;-1:-1:-1;;3921:223:26:o;3444:364::-;3493:13;3518:11;3532:12;3539:4;3532:6;:12::i;:::-;3652:14;;;3663:2;3652:14;;;;;;;;;3518:26;;-1:-1:-1;3632:17:26;;3652:14;;;;;;;;;-1:-1:-1;;;3715:16:26;;;-1:-1:-1;3760:4:26;3751:14;;3744:28;;;;-1:-1:-1;3715:16:26;3444:364::o;3072:260::-;3127:3;3142:17;3168:3;3142:30;;3200:2;3186:4;:11;:16;3182:72;;;3239:3;3225:18;;-1:-1:-1;;;3225:18:26;;;;;;;;:::i;:::-;;;;;;;;3182:72;3312:11;;3295:13;3312:4;3295:13;:::i;:::-;3287:36;;3072:260;-1:-1:-1;;;3072:260:26:o;14:189:30:-;105:20;;165:12;154:24;;144:35;;134:63;;193:1;190;183:12;208:816;434:6;442;450;458;466;519:3;507:9;498:7;494:23;490:33;487:53;;;536:1;533;526:12;487:53;581:23;;;-1:-1:-1;701:2:30;686:18;;673:32;;-1:-1:-1;804:2:30;789:18;;776:32;;-1:-1:-1;907:2:30;892:18;;879:32;;-1:-1:-1;956:62:30;1013:3;998:19;;956:62;:::i;:::-;946:72;;208:816;;;;;;;;:::o;1273:636::-;1488:2;1500:21;;;1570:13;;1473:18;;;1592:22;;;1440:4;;1671:15;;;1645:2;1630:18;;;1440:4;1714:169;1728:6;1725:1;1722:13;1714:169;;;1789:13;;1777:26;;1832:2;1858:15;;;;1823:12;;;;1750:1;1743:9;1714:169;;;-1:-1:-1;1900:3:30;;1273:636;-1:-1:-1;;;;;1273:636:30:o;1914:160::-;1980:20;;2040:1;2029:20;;;2019:31;;2009:59;;2064:1;2061;2054:12;2079:391;2177:6;2185;2193;2246:2;2234:9;2225:7;2221:23;2217:32;2214:52;;;2262:1;2259;2252:12;2214:52;2307:23;;;-1:-1:-1;2373:36:30;2405:2;2390:18;;2373:36;:::i;:::-;2363:46;;2428:36;2460:2;2449:9;2445:18;2428:36;:::i;:::-;2418:46;;2079:391;;;;;:::o;2711:202::-;2799:20;;-1:-1:-1;;;;;;2848:40:30;;2838:51;;2828:79;;2903:1;2900;2893:12;2918:234;3005:6;3058:2;3046:9;3037:7;3033:23;3029:32;3026:52;;;3074:1;3071;3064:12;3026:52;3097:49;3136:9;3097:49;:::i;:::-;3087:59;2918:234;-1:-1:-1;;;2918:234:30:o;3843:200::-;3931:20;;-1:-1:-1;;;;;3980:38:30;;3970:49;;3960:77;;4033:1;4030;4023:12;4048:782;4258:6;4266;4274;4282;4290;4343:3;4331:9;4322:7;4318:23;4314:33;4311:53;;;4360:1;4357;4350:12;4311:53;4386:23;;-1:-1:-1;;;;;4438:31:30;;4428:42;;4418:70;;4484:1;4481;4474:12;4418:70;4507:5;-1:-1:-1;4531:58:30;4585:2;4570:18;;4531:58;:::i;:::-;4521:68;;4608:61;4665:2;4654:9;4650:18;4608:61;:::i;:::-;4598:71;;4688:58;4742:2;4731:9;4727:18;4688:58;:::i;:::-;4678:68;;4765:59;4819:3;4808:9;4804:19;4765:59;:::i;5715:251::-;5799:6;5852:2;5840:9;5831:7;5827:23;5823:32;5820:52;;;5868:1;5865;5858:12;5820:52;-1:-1:-1;5913:23:30;;5715:251;-1:-1:-1;5715:251:30:o;5971:159::-;6038:20;;6098:6;6087:18;;6077:29;;6067:57;;6120:1;6117;6110:12;6135:833;6337:6;6345;6353;6361;6369;6377;6430:3;6418:9;6409:7;6405:23;6401:33;6398:53;;;6447:1;6444;6437:12;6398:53;6492:23;;;-1:-1:-1;6558:37:30;6591:2;6576:18;;6558:37;:::i;:::-;6548:47;-1:-1:-1;6668:2:30;6653:18;;6640:32;;-1:-1:-1;6771:2:30;6756:18;;6743:32;;-1:-1:-1;6874:3:30;6859:19;;6846:33;;-1:-1:-1;6924:38:30;6957:3;6942:19;;6924:38;:::i;:::-;6914:48;;6135:833;;;;;;;;:::o;7491:759::-;7696:6;7704;7712;7720;7728;7781:3;7769:9;7760:7;7756:23;7752:33;7749:53;;;7798:1;7795;7788:12;7749:53;7821:49;7860:9;7821:49;:::i;:::-;7811:59;;7889:58;7943:2;7932:9;7928:18;7889:58;:::i;:::-;7879:68;;7966:58;8020:2;8009:9;8005:18;7966:58;:::i;:::-;7956:68;;8043:58;8097:2;8086:9;8082:18;8043:58;:::i;:::-;8033:68;;8151:3;8140:9;8136:19;8123:33;8196:4;8189:5;8185:16;8178:5;8175:27;8165:55;;8216:1;8213;8206:12;8165:55;8239:5;8229:15;;;7491:759;;;;;;;;:::o;8437:418::-;8586:2;8575:9;8568:21;8549:4;8618:6;8612:13;8661:6;8656:2;8645:9;8641:18;8634:34;8720:6;8715:2;8707:6;8703:15;8698:2;8687:9;8683:18;8677:50;8776:1;8771:2;8762:6;8751:9;8747:22;8743:31;8736:42;8846:2;8839;8835:7;8830:2;8822:6;8818:15;8814:29;8803:9;8799:45;8795:54;8787:62;;;8437:418;;;;:::o;9073:127::-;9134:10;9129:3;9125:20;9122:1;9115:31;9165:4;9162:1;9155:15;9189:4;9186:1;9179:15;9205:945;9274:6;9327:2;9315:9;9306:7;9302:23;9298:32;9295:52;;;9343:1;9340;9333:12;9295:52;9383:9;9370:23;9416:18;9408:6;9405:30;9402:50;;;9448:1;9445;9438:12;9402:50;9471:22;;9524:4;9516:13;;9512:27;-1:-1:-1;9502:55:30;;9553:1;9550;9543:12;9502:55;9593:2;9580:16;9619:18;9611:6;9608:30;9605:56;;;9641:18;;:::i;:::-;9690:2;9684:9;9782:2;9744:17;;-1:-1:-1;;9740:31:30;;;9773:2;9736:40;9732:54;9720:67;;9817:18;9802:34;;9838:22;;;9799:62;9796:88;;;9864:18;;:::i;:::-;9900:2;9893:22;9924;;;9965:15;;;9982:2;9961:24;9958:37;-1:-1:-1;9955:57:30;;;10008:1;10005;9998:12;9955:57;10064:6;10059:2;10055;10051:11;10046:2;10038:6;10034:15;10021:50;10117:1;10091:19;;;10112:2;10087:28;10080:39;;;;10095:6;9205:945;-1:-1:-1;;;;9205:945:30:o;10362:127::-;10423:10;10418:3;10414:20;10411:1;10404:31;10454:4;10451:1;10444:15;10478:4;10475:1;10468:15;10494:135;10533:3;10554:17;;;10551:43;;10574:18;;:::i;:::-;-1:-1:-1;10621:1:30;10610:13;;10494:135::o;10634:220::-;10672:3;-1:-1:-1;;;;;10709:5:30;10705:38;-1:-1:-1;;;;;10758:7:30;10755:39;10752:65;;10797:18;;:::i;:::-;10846:1;10833:15;;10634:220;-1:-1:-1;;10634:220:30:o;10859:292::-;-1:-1:-1;;;;;10943:34:30;;;10979;;;10939:75;11034:44;;;;11097:24;;;11087:58;;11125:18;;:::i;:::-;11087:58;10859:292;;;;:::o;11156:215::-;-1:-1:-1;;;;;11224:34:30;;;11260;;;11220:75;;11307:35;;11304:61;;;11345:18;;:::i;11376:297::-;11494:12;;11541:4;11530:16;;;11524:23;;11494:12;11559:16;;11556:111;;;11653:1;11649:6;11639;11633:4;11629:17;11626:1;11622:25;11618:38;11611:5;11607:50;11598:59;;11556:111;;11376:297;;;:::o","linkReferences":{}},"methodIdentifiers":{"MAX_POLICIES_TO_PROCESS()":"4b396c4f","MAX_PREMIUM()":"4cdabb16","MAX_SUM_INSURED()":"a4846cbf","MIN_PREMIUM()":"be5c8f44","MIN_SUM_INSURED()":"def6aeca","createCrop(bytes32)":"7f73fa9c","createLocation(bytes32,int32,int32)":"2a6f8ef2","createPolicy(address,bytes8,uint40,uint96,uint96)":"422e9f41","createRisk(bytes32,bytes32,bytes32,bytes32,uint40)":"0228ec7b","createSeason(bytes32,uint16,bytes32,bytes32,bytes32,uint16)":"6f336d7c","crops()":"23c9bc52","getLocation(bytes32)":"5be6405e","getRisk(bytes8)":"3405f20c","getRiskId(bytes32)":"694ac999","getSeason(bytes32)":"729ff16c","getTokenHandler()":"43d752d3","length(bytes32)":"a9dbaf25","policyNftCounter()":"bb313321","riskCounter()":"f1338cda","seasons()":"f44f30cd","setConstants(uint96,uint96,uint96,uint96,uint8)":"7d1c5290","toStr(string)":"cdc23e69","toString(bytes32)":"b11a19e8"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.27+commit.40a35a09\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidShortString\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"}],\"name\":\"StringTooLong\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"NftId\",\"name\":\"policyNftId\",\"type\":\"uint96\"}],\"name\":\"LogCropPolicyCreated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_POLICIES_TO_PROCESS\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_PREMIUM\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_SUM_INSURED\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_PREMIUM\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MIN_SUM_INSURED\",\"outputs\":[{\"internalType\":\"Amount\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"crop\",\"type\":\"bytes32\"}],\"name\":\"createCrop\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"},{\"internalType\":\"int32\",\"name\":\"latitude\",\"type\":\"int32\"},{\"internalType\":\"int32\",\"name\":\"longitude\",\"type\":\"int32\"}],\"name\":\"createLocation\",\"outputs\":[{\"internalType\":\"Location\",\"name\":\"location\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"policyHolder\",\"type\":\"address\"},{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"},{\"internalType\":\"Timestamp\",\"name\":\"activateAt\",\"type\":\"uint40\"},{\"internalType\":\"Amount\",\"name\":\"sumInsuredAmount\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"premiumAmount\",\"type\":\"uint96\"}],\"name\":\"createPolicy\",\"outputs\":[{\"internalType\":\"NftId\",\"name\":\"policyNftId\",\"type\":\"uint96\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"id\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"crop\",\"type\":\"bytes32\"},{\"internalType\":\"Timestamp\",\"name\":\"seasonEndAt\",\"type\":\"uint40\"}],\"name\":\"createRisk\",\"outputs\":[{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"},{\"internalType\":\"uint16\",\"name\":\"year\",\"type\":\"uint16\"},{\"internalType\":\"Str\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonStart\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonEnd\",\"type\":\"bytes32\"},{\"internalType\":\"uint16\",\"name\":\"seasonDays\",\"type\":\"uint16\"}],\"name\":\"createSeason\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"crops\",\"outputs\":[{\"internalType\":\"Str[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"}],\"name\":\"getLocation\",\"outputs\":[{\"internalType\":\"Location\",\"name\":\"location\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"}],\"name\":\"getRisk\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"exists\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"locationId\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"crop\",\"type\":\"bytes32\"},{\"internalType\":\"Timestamp\",\"name\":\"seasonEndAt\",\"type\":\"uint40\"},{\"internalType\":\"UFixed\",\"name\":\"payoutFactor\",\"type\":\"uint160\"},{\"internalType\":\"bool\",\"name\":\"payoutDefined\",\"type\":\"bool\"}],\"internalType\":\"struct CropProduct.CropRisk\",\"name\":\"cropRisk\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"getRiskId\",\"outputs\":[{\"internalType\":\"RiskId\",\"name\":\"riskId\",\"type\":\"bytes8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"seasonId\",\"type\":\"bytes32\"}],\"name\":\"getSeason\",\"outputs\":[{\"components\":[{\"internalType\":\"uint16\",\"name\":\"year\",\"type\":\"uint16\"},{\"internalType\":\"Str\",\"name\":\"name\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonStart\",\"type\":\"bytes32\"},{\"internalType\":\"Str\",\"name\":\"seasonEnd\",\"type\":\"bytes32\"},{\"internalType\":\"uint16\",\"name\":\"seasonDays\",\"type\":\"uint16\"}],\"internalType\":\"struct CropProduct.Season\",\"name\":\"season\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTokenHandler\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"tokenHandler\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"sstr\",\"type\":\"bytes32\"}],\"name\":\"length\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"policyNftCounter\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"\",\"type\":\"uint96\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"riskCounter\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"seasons\",\"outputs\":[{\"internalType\":\"Str[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Amount\",\"name\":\"minPremium\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"maxPremium\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"minSumInsured\",\"type\":\"uint96\"},{\"internalType\":\"Amount\",\"name\":\"maxSumInsured\",\"type\":\"uint96\"},{\"internalType\":\"uint8\",\"name\":\"maxPoliciesToProcess\",\"type\":\"uint8\"}],\"name\":\"setConstants\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"str\",\"type\":\"string\"}],\"name\":\"toStr\",\"outputs\":[{\"internalType\":\"Str\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"Str\",\"name\":\"sstr\",\"type\":\"bytes32\"}],\"name\":\"toString\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"length(bytes32)\":{\"details\":\"returns the length of the provided short string. code from OZ ShortStrings.byteLength\"},\"toStr(string)\":{\"details\":\"converts the provided string into a short string. code from OZ ShortStrings.toShortString\"},\"toString(bytes32)\":{\"details\":\"converts the provided short string into a string. code from OZ ShortStrings.toString\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/CropProduct.sol\":\"CropProduct\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":forge-std/=lib/forge-std/src/\"]},\"sources\":{\"src/CropProduct.sol\":{\"keccak256\":\"0x0768519925626e162585fad06ed54b192bfa2493c7526b2bf661534c810e51c1\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://b38861d8c28b712623a794dc0bfe0636fe872a580a488ceb42b90ac24d950b4f\",\"dweb:/ipfs/QmZNM7RuWRUvUHqsG9Pem7sg5siy3SjpWLxjxa4pEn4pqL\"]},\"src/Types.sol\":{\"keccak256\":\"0x4c3c95d21faeee8c69bd41f83636eb8a851b5247163faf06953f54b2e9dda40e\",\"license\":\"Apache-2.0\",\"urls\":[\"bzz-raw://7c78471ec7d545f2c033447738699d64d1e67b7f23ace9ab8240ac596acb959f\",\"dweb:/ipfs/QmUQFZ4c9FvpJy1JsPfqG7dbUxCNr3gpSFUWzvA36XpU3N\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.27+commit.40a35a09"},"language":"Solidity","output":{"abi":[{"inputs":[],"type":"error","name":"InvalidShortString"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"type":"error","name":"StringTooLong"},{"inputs":[{"internalType":"NftId","name":"policyNftId","type":"uint96","indexed":false}],"type":"event","name":"LogCropPolicyCreated","anonymous":false},{"inputs":[],"stateMutability":"view","type":"function","name":"MAX_POLICIES_TO_PROCESS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MAX_PREMIUM","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MAX_SUM_INSURED","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MIN_PREMIUM","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"MIN_SUM_INSURED","outputs":[{"internalType":"Amount","name":"","type":"uint96"}]},{"inputs":[{"internalType":"Str","name":"crop","type":"bytes32"}],"stateMutability":"nonpayable","type":"function","name":"createCrop"},{"inputs":[{"internalType":"Str","name":"locationId","type":"bytes32"},{"internalType":"int32","name":"latitude","type":"int32"},{"internalType":"int32","name":"longitude","type":"int32"}],"stateMutability":"nonpayable","type":"function","name":"createLocation","outputs":[{"internalType":"Location","name":"location","type":"uint64"}]},{"inputs":[{"internalType":"address","name":"policyHolder","type":"address"},{"internalType":"RiskId","name":"riskId","type":"bytes8"},{"internalType":"Timestamp","name":"activateAt","type":"uint40"},{"internalType":"Amount","name":"sumInsuredAmount","type":"uint96"},{"internalType":"Amount","name":"premiumAmount","type":"uint96"}],"stateMutability":"nonpayable","type":"function","name":"createPolicy","outputs":[{"internalType":"NftId","name":"policyNftId","type":"uint96"}]},{"inputs":[{"internalType":"Str","name":"id","type":"bytes32"},{"internalType":"Str","name":"seasonId","type":"bytes32"},{"internalType":"Str","name":"locationId","type":"bytes32"},{"internalType":"Str","name":"crop","type":"bytes32"},{"internalType":"Timestamp","name":"seasonEndAt","type":"uint40"}],"stateMutability":"nonpayable","type":"function","name":"createRisk","outputs":[{"internalType":"RiskId","name":"riskId","type":"bytes8"}]},{"inputs":[{"internalType":"Str","name":"seasonId","type":"bytes32"},{"internalType":"uint16","name":"year","type":"uint16"},{"internalType":"Str","name":"name","type":"bytes32"},{"internalType":"Str","name":"seasonStart","type":"bytes32"},{"internalType":"Str","name":"seasonEnd","type":"bytes32"},{"internalType":"uint16","name":"seasonDays","type":"uint16"}],"stateMutability":"nonpayable","type":"function","name":"createSeason"},{"inputs":[],"stateMutability":"view","type":"function","name":"crops","outputs":[{"internalType":"Str[]","name":"","type":"bytes32[]"}]},{"inputs":[{"internalType":"Str","name":"locationId","type":"bytes32"}],"stateMutability":"view","type":"function","name":"getLocation","outputs":[{"internalType":"Location","name":"location","type":"uint64"}]},{"inputs":[{"internalType":"RiskId","name":"riskId","type":"bytes8"}],"stateMutability":"view","type":"function","name":"getRisk","outputs":[{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"struct CropProduct.CropRisk","name":"cropRisk","type":"tuple","components":[{"internalType":"Str","name":"seasonId","type":"bytes32"},{"internalType":"Str","name":"locationId","type":"bytes32"},{"internalType":"Str","name":"crop","type":"bytes32"},{"internalType":"Timestamp","name":"seasonEndAt","type":"uint40"},{"internalType":"UFixed","name":"payoutFactor","type":"uint160"},{"internalType":"bool","name":"payoutDefined","type":"bool"}]}]},{"inputs":[{"internalType":"Str","name":"id","type":"bytes32"}],"stateMutability":"view","type":"function","name":"getRiskId","outputs":[{"internalType":"RiskId","name":"riskId","type":"bytes8"}]},{"inputs":[{"internalType":"Str","name":"seasonId","type":"bytes32"}],"stateMutability":"view","type":"function","name":"getSeason","outputs":[{"internalType":"struct CropProduct.Season","name":"season","type":"tuple","components":[{"internalType":"uint16","name":"year","type":"uint16"},{"internalType":"Str","name":"name","type":"bytes32"},{"internalType":"Str","name":"seasonStart","type":"bytes32"},{"internalType":"Str","name":"seasonEnd","type":"bytes32"},{"internalType":"uint16","name":"seasonDays","type":"uint16"}]}]},{"inputs":[],"stateMutability":"view","type":"function","name":"getTokenHandler","outputs":[{"internalType":"address","name":"tokenHandler","type":"address"}]},{"inputs":[{"internalType":"Str","name":"sstr","type":"bytes32"}],"stateMutability":"pure","type":"function","name":"length","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"policyNftCounter","outputs":[{"internalType":"uint96","name":"","type":"uint96"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"riskCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"seasons","outputs":[{"internalType":"Str[]","name":"","type":"bytes32[]"}]},{"inputs":[{"internalType":"Amount","name":"minPremium","type":"uint96"},{"internalType":"Amount","name":"maxPremium","type":"uint96"},{"internalType":"Amount","name":"minSumInsured","type":"uint96"},{"internalType":"Amount","name":"maxSumInsured","type":"uint96"},{"internalType":"uint8","name":"maxPoliciesToProcess","type":"uint8"}],"stateMutability":"nonpayable","type":"function","name":"setConstants"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"stateMutability":"pure","type":"function","name":"toStr","outputs":[{"internalType":"Str","name":"","type":"bytes32"}]},{"inputs":[{"internalType":"Str","name":"sstr","type":"bytes32"}],"stateMutability":"pure","type":"function","name":"toString","outputs":[{"internalType":"string","name":"","type":"string"}]}],"devdoc":{"kind":"dev","methods":{"length(bytes32)":{"details":"returns the length of the provided short string. code from OZ ShortStrings.byteLength"},"toStr(string)":{"details":"converts the provided string into a short string. code from OZ ShortStrings.toShortString"},"toString(bytes32)":{"details":"converts the provided short string into a string. code from OZ ShortStrings.toString"}},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["forge-std/=lib/forge-std/src/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"src/CropProduct.sol":"CropProduct"},"evmVersion":"cancun","libraries":{}},"sources":{"src/CropProduct.sol":{"keccak256":"0x0768519925626e162585fad06ed54b192bfa2493c7526b2bf661534c810e51c1","urls":["bzz-raw://b38861d8c28b712623a794dc0bfe0636fe872a580a488ceb42b90ac24d950b4f","dweb:/ipfs/QmZNM7RuWRUvUHqsG9Pem7sg5siy3SjpWLxjxa4pEn4pqL"],"license":"Apache-2.0"},"src/Types.sol":{"keccak256":"0x4c3c95d21faeee8c69bd41f83636eb8a851b5247163faf06953f54b2e9dda40e","urls":["bzz-raw://7c78471ec7d545f2c033447738699d64d1e67b7f23ace9ab8240ac596acb959f","dweb:/ipfs/QmUQFZ4c9FvpJy1JsPfqG7dbUxCNr3gpSFUWzvA36XpU3N"],"license":"Apache-2.0"}},"version":1},"id":26} \ No newline at end of file diff --git a/app/server/config.py b/app/server/config.py index 28317aa..a03e91d 100644 --- a/app/server/config.py +++ b/app/server/config.py @@ -26,6 +26,7 @@ class Settings(BaseSettings): # farmer minimum funding amount FARMER_FUNDING_AMOUNT: int = 100000001 + FARMER_ETH_FUNDING_AMOUNT: int = 0.005 * 10 ** 18 # smart contracs settings PRODUCT_CONTRACT_ADDRESS: str | None @@ -37,6 +38,9 @@ class Settings(BaseSettings): # rpc node settings (default is local anvil node) RPC_NODE_URL: str | None = "http://127.0.0.1:8545" + # gas price settings + GAS_PRICE: int = 25.5 * 10 ** 9 + # mongodb settings MONGO_ID_ATTRIBUTE: str = "_id" MONGO_CREATE_COLLECTIONS: bool = True diff --git a/app/server/sync/onchain.py b/app/server/sync/onchain.py index f98d835..15eb5ec 100644 --- a/app/server/sync/onchain.py +++ b/app/server/sync/onchain.py @@ -13,4 +13,4 @@ token = Contract(w3, "AccountingToken", settings.TOKEN_CONTRACT_ADDRESS, out_path="./app/abi") operator = Wallet.from_mnemonic(settings.OPERATOR_WALLET_MNEMONIC, index=settings.OPERATOR_ACCOUNT_INDEX) - +logger.info(f"operator wallet {operator.address}") diff --git a/app/server/sync/person.py b/app/server/sync/person.py index e2496eb..dd276de 100644 --- a/app/server/sync/person.py +++ b/app/server/sync/person.py @@ -1,9 +1,12 @@ from util.logging import get_logger +from web3utils.blocks import wait_for_blocks +from web3utils.send_eth import send_eth +from web3utils.wallet import Wallet from server.config import settings from server.model.person import PersonOut from server.mongo import update_in_collection -from server.sync.onchain import token, operator +from server.sync.onchain import token, operator, product, w3 # setup for module logger = get_logger() @@ -18,10 +21,10 @@ def sync_person_onchain(person: PersonOut, force: bool = False): # check balance of wallet balance = token.balanceOf(person.wallet) logger.info(f"balance {balance} (min amount {settings.FARMER_FUNDING_AMOUNT}) for wallet {person.wallet}") + funding = settings.FARMER_FUNDING_AMOUNT - balance # send tokens to wallet if balance is below threshold - if balance < settings.FARMER_FUNDING_AMOUNT: - funding = settings.FARMER_FUNDING_AMOUNT - balance + if balance < settings.FARMER_FUNDING_AMOUNT or force: # execute transaction tx = token.transfer(person.wallet, funding, {'from': operator}) @@ -31,3 +34,16 @@ def sync_person_onchain(person: PersonOut, force: bool = False): person.tx = tx update_in_collection(person, PersonOut) + # fund wallet with eth for approval + send_eth(operator, person.wallet, settings.FARMER_ETH_FUNDING_AMOUNT, settings.GAS_PRICE) + + # initialze farmer wallet + farmer_wallet = Wallet.from_mnemonic(settings.FARMER_WALLET_MNEMONIC, index=person.walletIndex) + product_token_handler = product.getTokenHandler() + farmer_wallet_balance = w3.eth.get_balance(farmer_wallet.address) + logger.info(f"farmer wallet {farmer_wallet.address} token handler {product_token_handler} approval of {settings.FARMER_FUNDING_AMOUNT} balance {farmer_wallet_balance}") + + # and approve token handler for policy payment + tx2 = token.approve(product_token_handler, settings.FARMER_FUNDING_AMOUNT, {'from': farmer_wallet, 'gasPrice': settings.GAS_PRICE, 'gasLimit': 50000}) + logger.info(f"tx {tx2} approval of {funding} token to {product_token_handler}") + diff --git a/app/server/sync/policy.py b/app/server/sync/policy.py index d805b2c..fdcfdf7 100644 --- a/app/server/sync/policy.py +++ b/app/server/sync/policy.py @@ -1,6 +1,7 @@ from datetime import datetime from util.logging import get_logger +from server.config import settings from server.mongo import find_in_collection, update_in_collection from server.model.person import PersonOut from server.model.policy import PolicyOut @@ -34,10 +35,11 @@ def sync_policy_onchain(policy: PolicyOut, force: bool = False): risk_id = product.getRiskId(risk_id_str) subscription_date = datetime.fromisoformat(policy.subscriptionDate) activate_at = int(subscription_date.timestamp()) - sum_insured = int(policy.sumInsuredAmount) - premium = int(policy.premiumAmount) + sum_insured = int(policy.sumInsuredAmount) * 10 ** settings.LOCATION_DECIMALS + premium = int(policy.premiumAmount) * 10 ** settings.LOCATION_DECIMALS - tx = product.createPolicy(policy_holder, risk_id, activate_at, sum_insured, premium, {'from': operator}) + logger.info(f"creating policy policy_holder {policy_holder} risk_id {risk_id} activate_at {activate_at} sum_insured {sum_insured} premium {premium}") + tx = product.createPolicy(policy_holder, risk_id, activate_at, sum_insured, premium, {'from': operator, 'gasLimit': 10000000, 'gasPrice': settings.GAS_PRICE}) logger.info(f"{tx} onchain policy {policy.id} created") diff --git a/app/web3utils/blocks.py b/app/web3utils/blocks.py new file mode 100644 index 0000000..d5dc2bd --- /dev/null +++ b/app/web3utils/blocks.py @@ -0,0 +1,15 @@ +from util.logging import get_logger +from server.sync.onchain import w3 +import time + +logger = get_logger() + +def wait_for_blocks(blocks=10): + initial_block_number = w3.eth.block_number + + while True: + current_block_number = w3.eth.block_number + if current_block_number >= initial_block_number + blocks: + break + logger.info(f"Waiting for blocks... Current: {current_block_number - initial_block_number}, Required: {blocks}") + time.sleep(5) # Wait for 5 seconds before checking again diff --git a/app/web3utils/contract.py b/app/web3utils/contract.py index f00a884..a978832 100644 --- a/app/web3utils/contract.py +++ b/app/web3utils/contract.py @@ -6,8 +6,11 @@ from web3.contract import Contract as Web3Contract from web3.exceptions import TimeExhausted from web3.types import FilterParams +from util.logging import get_logger from web3utils.wallet import Wallet +logger = get_logger() + class Contract: FOUNDRY_OUT = "../out" @@ -92,23 +95,30 @@ def write_method(*args) -> str: try: wallet = tx_params['from'] + logger.info(f"Sending transaction for function '{func_name}' with wallet: {wallet.address}") # create tx properties chain_id = self.w3.eth.chain_id gas = tx_params.get('gas', self.GAS) gas_price = tx_params.get('gasPrice', self.w3.eth.gas_price) + gas_limit = tx_params.get('gasLimit', None) nonce = self.w3.eth.get_transaction_count(wallet.address) # transform wallet args to addresses (str) modified_args = [arg.address if isinstance(arg, Wallet) else arg for arg in function_args] - # create tx - txn = getattr(self.contract.functions, func_name)(*modified_args).build_transaction({ + options = { 'chainId': chain_id, 'gas': gas, 'gasPrice': gas_price, 'nonce': nonce, - }) + } + + if gas_limit: + options['gas'] = gas_limit + + # create tx + txn = getattr(self.contract.functions, func_name)(*modified_args).build_transaction(options) # sign tx private_key = bytes(wallet.account.key) @@ -138,7 +148,10 @@ def write_method(*args) -> str: except Exception as e: logger.warning(f"Error sending transaction for function '{func_name}': {e}") - return tx_hash.hex() + if 'tx_hash' in locals(): + logger.warning(f"Transaction hash: {tx_hash.hex()}") + return tx_hash.hex() + return None write_method.__name__ = func_name write_method.__doc__ = f"Sends a transaction to the '{func_name}' function of the contract." diff --git a/app/web3utils/send_eth.py b/app/web3utils/send_eth.py new file mode 100644 index 0000000..1d8e632 --- /dev/null +++ b/app/web3utils/send_eth.py @@ -0,0 +1,25 @@ +from server.sync.onchain import w3 +from util.logging import get_logger +from web3utils.wallet import Wallet + +logger = get_logger() + +def send_eth(sender: Wallet, rcpt: str, amount: int, gas_price: int) -> str: + """Send a specified amount of wei to a specified address.""" + nonce = w3.eth.get_transaction_count(sender.account.address) + tx = { + 'nonce': nonce, #prevents from sending a transaction twice on ethereum + 'to': rcpt, + 'value': w3.to_wei(amount, 'wei'), + 'gas': 21000, + 'gasPrice': gas_price, + 'chainId': w3.eth.chain_id + } + signed_tx = w3.eth.account.sign_transaction(tx, sender.account.key) + logger.info(f"Sending {amount} wei to {rcpt}") + #send the transaction + tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction) + logger.info(f"Transaction sent: {tx_hash.hex()}") + tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) + logger.info(f"Transaction mined: {tx_hash}") + \ No newline at end of file diff --git a/src/CropProduct.sol b/src/CropProduct.sol index a14b879..01206a7 100644 --- a/src/CropProduct.sol +++ b/src/CropProduct.sol @@ -94,6 +94,7 @@ contract CropProduct { 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) {} + function getTokenHandler() public virtual view returns (address tokenHandler) {} /// @dev converts the provided string into a short string. /// code from OZ ShortStrings.toShortString