From 3e99180e379e1f4cb33d52b89ea1789ff4fe2e29 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Wed, 17 Apr 2024 10:05:50 +0200 Subject: [PATCH] Fixed pending operator fee migration --- deploy/017_deploy_node_operator_fees_storage.ts | 10 ++++++++-- test/v2/unit/NodeOperatorFeesStorage.test.ts | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/deploy/017_deploy_node_operator_fees_storage.ts b/deploy/017_deploy_node_operator_fees_storage.ts index a4bc6295..9e9a36c5 100644 --- a/deploy/017_deploy_node_operator_fees_storage.ts +++ b/deploy/017_deploy_node_operator_fees_storage.ts @@ -39,11 +39,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); } - // TODO: Check the timestamp so that it's not smaller than current const pendingOperatorFee = await nofcs.operatorFeeChangeRequests(i); if (pendingOperatorFee) { - operatorFees.push(pendingOperatorFee); + if (pendingOperatorFee.timestamp < operatorFees[0].effectiveDate) { + operatorFees[0].effectiveDate = pendingOperatorFee.timestamp - 1; + } + + operatorFees.push({ + feePercentage: pendingOperatorFee.newFee, + effectiveDate: pendingOperatorFee.timestamp, + }); } if (operatorFees.length > 0) { diff --git a/test/v2/unit/NodeOperatorFeesStorage.test.ts b/test/v2/unit/NodeOperatorFeesStorage.test.ts index 3c4891c7..7d2e68d1 100644 --- a/test/v2/unit/NodeOperatorFeesStorage.test.ts +++ b/test/v2/unit/NodeOperatorFeesStorage.test.ts @@ -151,7 +151,6 @@ describe('@v2 @unit NodeOperatorFeesStorage contract', function () { } } - // TODO: Perhaps makes sense to implement the same logic as in the deployment script to automatically get legacy fees const operatorFees = [ { identityId: identityIds[0], fees: [{ feePercentage: 1, effectiveDate: BigNumber.from(latestBlockTimestamp) }] }, {