From 6b2474f1a581aa9eaced723270c645eb0bad1989 Mon Sep 17 00:00:00 2001 From: Igor Yalovoy Date: Thu, 6 Feb 2025 08:59:31 -0600 Subject: [PATCH] Refactor isSanctionsSafe functions to use days for EXIT_WINDOW_PERIOD and add test for KYC expiration after monitor period. --- src/KintoID.sol | 4 ++-- test/unit/KintoID.t.sol | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/KintoID.sol b/src/KintoID.sol index 3827735a..1f9ba144 100644 --- a/src/KintoID.sol +++ b/src/KintoID.sol @@ -467,7 +467,7 @@ contract KintoID is */ function isSanctionsSafe(address _account) public view virtual override returns (bool) { // If the sanction is not confirmed within SANCTION_EXPIRY_PERIOD, consider the account sanctions safe - return isSanctionsMonitored(EXIT_WINDOW_PERIOD) + return isSanctionsMonitored(EXIT_WINDOW_PERIOD / (1 days)) && ( _kycmetas[_account].sanctionsCount == 0 || (sanctionedAt[_account] != 0 && (block.timestamp - sanctionedAt[_account]) > SANCTION_EXPIRY_PERIOD) @@ -483,7 +483,7 @@ contract KintoID is */ function isSanctionsSafeIn(address _account, uint16 _countryId) external view virtual override returns (bool) { // If the sanction is not confirmed within SANCTION_EXPIRY_PERIOD, consider the account sanctions safe - return isSanctionsMonitored(EXIT_WINDOW_PERIOD) + return isSanctionsMonitored(EXIT_WINDOW_PERIOD / (1 days)) && ( !_kycmetas[_account].sanctions.get(_countryId) || (sanctionedAt[_account] != 0 && (block.timestamp - sanctionedAt[_account]) > SANCTION_EXPIRY_PERIOD) diff --git a/test/unit/KintoID.t.sol b/test/unit/KintoID.t.sol index a5748de1..bdba223f 100644 --- a/test/unit/KintoID.t.sol +++ b/test/unit/KintoID.t.sol @@ -256,6 +256,19 @@ contract KintoIDTest is SharedSetup { _kintoID.monitor(new address[](0), new IKintoID.MonitorUpdateData[][](0)); } + function testIsKYC_WhenMonitorExpires() public { + IKintoID.SignatureData memory sigdata = _auxCreateSignature(_kintoID, _user, _userPk, block.timestamp + 1000); + uint16[] memory traits = new uint16[](0); + vm.startPrank(_kycProvider); + _kintoID.mintIndividualKyc(sigdata, traits); + + assertEq(_kintoID.isKYC(_user), true); + + vm.warp(block.timestamp + 11 days); + + assertEq(_kintoID.isKYC(_user), false); + } + function testIsSanctionsMonitored() public { vm.prank(_kycProvider); _kintoID.monitor(new address[](0), new IKintoID.MonitorUpdateData[][](0));