From 8c857ce712e1f81bafebb855440d808b02a28ac7 Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Tue, 1 Oct 2024 15:54:19 +0100 Subject: [PATCH] (migration): require migration amount to be greater than zero --- src/errors/Errors.sol | 4 ++++ src/migration/Migration.sol | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/errors/Errors.sol b/src/errors/Errors.sol index 155d4d0..6d6e768 100644 --- a/src/errors/Errors.sol +++ b/src/errors/Errors.sol @@ -96,3 +96,7 @@ interface INameRegistryErrors { error CirclesNamesOrganizationHasNoSymbol(address organization, uint8 code); } + +interface IMigrationErrors { + error CirclesMigrationAmountMustBeGreaterThanZero(); +} diff --git a/src/migration/Migration.sol b/src/migration/Migration.sol index 2830d9a..b7d6e13 100644 --- a/src/migration/Migration.sol +++ b/src/migration/Migration.sol @@ -6,7 +6,7 @@ import "../hub/IHub.sol"; import "./IHub.sol"; import "./IToken.sol"; -contract Migration is ICirclesErrors { +contract Migration is ICirclesErrors, IMigrationErrors { // Constant uint256 private constant ACCURACY = uint256(10 ** 8); @@ -75,6 +75,10 @@ contract Migration is ICirclesErrors { // Invalid avatar, not registered in hub V1. revert CirclesAddressCannotBeZero(2); } + if (_amounts[i] == 0) { + // Amount must be greater than zero. + revert CirclesMigrationAmountMustBeGreaterThanZero(); + } convertedAmounts[i] = convertFromV1ToDemurrage(_amounts[i]); // transfer the v1 Circles to this contract to be locked circlesV1.transferFrom(msg.sender, address(this), _amounts[i]);