From b32d3df1b15e470c37e4a49b796db7f7d32e2816 Mon Sep 17 00:00:00 2001 From: sirius Date: Mon, 26 Feb 2024 16:10:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20library=20function?= =?UTF-8?q?=20visibility=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #300 --- src/v0.8/core/statistics/library/StatisticsLIB.sol | 8 ++++---- .../library/StorageProvidersStatisticsLIB.sol | 4 ++-- .../core/statistics/library/StorageStatisticsLIB.sol | 12 ++++++------ src/v0.8/shared/utils/array/ArrayLIB.sol | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/v0.8/core/statistics/library/StatisticsLIB.sol b/src/v0.8/core/statistics/library/StatisticsLIB.sol index 08dbb267..6642066a 100644 --- a/src/v0.8/core/statistics/library/StatisticsLIB.sol +++ b/src/v0.8/core/statistics/library/StatisticsLIB.sol @@ -30,7 +30,7 @@ library StatisticsLIB { function addTotal( StatisticsType.Statistics storage self, uint256 size - ) external { + ) internal { self.total += size; } @@ -38,7 +38,7 @@ library StatisticsLIB { function addSuccess( StatisticsType.Statistics storage self, uint256 size - ) external { + ) internal { uint256 ongoing = self.total - self.success - self.failed; require(size <= ongoing, "invalid size to addSuccess"); self.success += size; @@ -48,7 +48,7 @@ library StatisticsLIB { function addFailed( StatisticsType.Statistics storage self, uint256 size - ) external { + ) internal { uint256 ongoing = self.total - self.success - self.failed; require(size <= ongoing, "invalid size to addFailed"); self.failed += size; @@ -58,7 +58,7 @@ library StatisticsLIB { function getOverview( StatisticsType.Statistics storage self ) - external + internal view returns ( uint256 total, diff --git a/src/v0.8/core/statistics/library/StorageProvidersStatisticsLIB.sol b/src/v0.8/core/statistics/library/StorageProvidersStatisticsLIB.sol index deeeb2de..ba9f411f 100644 --- a/src/v0.8/core/statistics/library/StorageProvidersStatisticsLIB.sol +++ b/src/v0.8/core/statistics/library/StorageProvidersStatisticsLIB.sol @@ -34,7 +34,7 @@ library StorageProvidersStatisticsLIB { StatisticsType.StorageProvidersStatistics storage self, uint64 storageProvider, uint256 size - ) external { + ) internal { require(size != 0, "invalid size to addStoraged"); if (self.storageProviderInfos[storageProvider] == 0) { @@ -50,7 +50,7 @@ library StorageProvidersStatisticsLIB { /// @return storageProviders Array of storage providers. function getOverview( StatisticsType.StorageProvidersStatistics storage self - ) external view returns (uint64[] memory storageProviders) { + ) internal view returns (uint64[] memory storageProviders) { return (self.storageProviders); } } diff --git a/src/v0.8/core/statistics/library/StorageStatisticsLIB.sol b/src/v0.8/core/statistics/library/StorageStatisticsLIB.sol index 4930c06e..53726c4c 100644 --- a/src/v0.8/core/statistics/library/StorageStatisticsLIB.sol +++ b/src/v0.8/core/statistics/library/StorageStatisticsLIB.sol @@ -30,7 +30,7 @@ library StorageStatisticsLIB { function addAllocated( StatisticsType.StorageStatistics storage self, uint256 size - ) external { + ) internal { uint256 unAllocated = self.total - self.allocatedDatacap; //solhint-disable-next-line require(unAllocated >= size, "invalid size to addAllocated"); @@ -41,7 +41,7 @@ library StorageStatisticsLIB { function addCanceled( StatisticsType.StorageStatistics storage self, uint256 size - ) external { + ) internal { uint256 available = self.allocatedDatacap - self.completed - self.canceled; @@ -54,7 +54,7 @@ library StorageStatisticsLIB { function addStoraged( StatisticsType.StorageStatistics storage self, uint256 size - ) external { + ) internal { uint256 available = self.allocatedDatacap - self.completed - self.canceled; @@ -72,7 +72,7 @@ library StorageStatisticsLIB { /// @return A boolean indicating whether the storage statistics represent a completed state. function isStorageCompleted( StatisticsType.StorageStatistics storage self - ) external view returns (bool) { + ) internal view returns (bool) { if ((self.completed + self.canceled) == self.total) { return true; } @@ -85,7 +85,7 @@ library StorageStatisticsLIB { /// @return A boolean indicating whether the storage is considered successful. function isStorageSuccessful( StatisticsType.StorageStatistics storage self - ) external view returns (bool) { + ) internal view returns (bool) { if (self.completed == self.total) { return true; } @@ -102,7 +102,7 @@ library StorageStatisticsLIB { function getOverview( StatisticsType.StorageStatistics storage self ) - external + internal view returns ( uint256 total, diff --git a/src/v0.8/shared/utils/array/ArrayLIB.sol b/src/v0.8/shared/utils/array/ArrayLIB.sol index 54a2a4fe..1c7405bd 100644 --- a/src/v0.8/shared/utils/array/ArrayLIB.sol +++ b/src/v0.8/shared/utils/array/ArrayLIB.sol @@ -184,7 +184,7 @@ library ArrayUint16LIB { function mergeSequentialArray( uint16[] memory _starts, uint16[] memory _ends - ) public pure returns (uint16[] memory) { + ) internal pure returns (uint16[] memory) { // Check if the number of start values matches the number of end values require(_starts.length == _ends.length, "start and end not match"); @@ -386,7 +386,7 @@ library ArrayUint32LIB { function mergeSequentialArray( uint32[] memory _starts, uint32[] memory _ends - ) public pure returns (uint32[] memory) { + ) internal pure returns (uint32[] memory) { // Check if the number of start values matches the number of end values require(_starts.length == _ends.length, "start and end not match"); @@ -588,7 +588,7 @@ library ArrayUint64LIB { function mergeSequentialArray( uint64[] memory _starts, uint64[] memory _ends - ) public pure returns (uint64[] memory) { + ) internal pure returns (uint64[] memory) { // Check if the number of start values matches the number of end values require(_starts.length == _ends.length, "start and end not match");