Skip to content

Commit

Permalink
chore(contract): Remove base64 library and update forge-std dependency (
Browse files Browse the repository at this point in the history
#605)

Removed the base64 library from the project as it's no longer needed,
replaced all its references with solady's Base64. Additionally, updated
the forge-std dependency to version 1.9.1. This simplifies dependencies
and ensures consistency.
  • Loading branch information
shuhuiluo authored Aug 5, 2024
1 parent 1730085 commit 446a725
Show file tree
Hide file tree
Showing 27 changed files with 42 additions and 62 deletions.
3 changes: 1 addition & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@prb/math": "^4.0.3",
"account-abstraction": "github:eth-infinitism/account-abstraction",
"base64": "github:Brechtpd/base64",
"solady": "^0.0.228"
},
"devDependencies": {
"@prb/test": "^0.6.4",
"ds-test": "github:dapphub/ds-test",
"forge-std": "github:foundry-rs/forge-std#v1",
"forge-std": "github:foundry-rs/forge-std#v1.9.1",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^5.0.2"
Expand Down
6 changes: 3 additions & 3 deletions contracts/scripts/common/DeployHelpers.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ abstract contract DeployHelpers is CommonBase {
}
}

function info(string memory message, string memory arg) internal view {
function info(string memory message, string memory arg) internal pure {
console.log(string.concat("[INFO]: ", message), arg);
}

function info(string memory message, address arg) internal view {
function info(string memory message, address arg) internal pure {
console.log(string.concat("[INFO]: ", unicode"", message), arg);
}

function warn(string memory message, address arg) internal view {
function warn(string memory message, address arg) internal pure {
console.log(string.concat("[WARN]: ", unicode"⚠️ ", message), arg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pragma solidity ^0.8.23;

// libraries
import {ERC721AStorage} from "contracts/src/diamond/facets/token/ERC721A/ERC721AStorage.sol";
import {Base64} from "base64/base64.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {Base64} from "solady/utils/Base64.sol";
import {LibString} from "solady/utils/LibString.sol";

// contracts
import {ERC721ABase} from "contracts/src/diamond/facets/token/ERC721A/ERC721ABase.sol";
Expand Down Expand Up @@ -40,11 +40,11 @@ contract MembershipMetadata is
'","image":"',
_getMembershipImage(),
'","attributes":[{"trait_type":"Renewal Price","display_type": "number", "value":"',
Strings.toString(
LibString.toString(
_getMembershipRenewalPrice(tokenId, _totalSupply())
),
'"},{"trait_type":"Membership Expiration","display_type": "number", "value":"',
Strings.toString(_expiresAt(tokenId)),
LibString.toString(_expiresAt(tokenId)),
'"},{"trait_type":"Membership Banned", "value":"',
_isBanned(tokenId) ? "true" : "false",
'"}]}'
Expand Down
1 change: 0 additions & 1 deletion contracts/src/spaces/facets/owner/SpaceOwnerUriBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity ^0.8.23;
import {ISpaceOwnerBase} from "contracts/src/spaces/facets/owner/ISpaceOwner.sol";

// libraries
import {Base64} from "base64/base64.sol";
import {LibString} from "solady/utils/LibString.sol";
import {Validator} from "contracts/src/utils/Validator.sol";

Expand Down
6 changes: 3 additions & 3 deletions contracts/test/base/registry/NodeOperator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract NodeOperatorFacetTest is
riverFacet = River(riverToken);
}

function test_initialization() public {
function test_initialization() public view {
assertTrue(
introspection.supportsInterface(type(INodeOperator).interfaceId)
);
Expand Down Expand Up @@ -113,7 +113,7 @@ contract NodeOperatorFacetTest is
// =============================================================
function test_revertWhen_isOperatorWithInvalidOperator(
address randomOperator
) external {
) external view {
vm.assume(randomOperator != address(0));
vm.assume(nodeOperator.isOperator(randomOperator) == false);
assertFalse(nodeOperator.isOperator(randomOperator));
Expand Down Expand Up @@ -338,7 +338,7 @@ contract NodeOperatorFacetTest is

function test_getOperatorStatus_operatorNotRegistered(
address randomOperator
) public {
) public view {
vm.assume(!nodeOperator.isOperator(randomOperator));
assertTrue(
nodeOperator.getOperatorStatus(randomOperator) ==
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/base/registry/RewardsDistribution.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ contract RewardsDistributionTest is
function verifyUserRewardsAgainstExpected(
Entity[] memory users,
uint256[] memory expectedUserClaims
) internal {
) internal view {
for (uint256 i = 0; i < users.length; i++) {
uint256 reward = rewardsDistributionFacet.getClaimableAmountForDelegator(
users[i].addr
Expand All @@ -994,7 +994,7 @@ contract RewardsDistributionTest is
function verifyOperatorRewardsAgainstExpected(
Entity[] memory operators,
uint256[] memory expectedOperatorClaims
) internal {
) internal view {
for (uint256 i = 0; i < operators.length; i++) {
uint256 reward = rewardsDistributionFacet.getClaimableAmountForOperator(
operator.getClaimAddressForOperator(operators[i].addr)
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/crosschain/EntitlementChecker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ contract EntitlementCheckerTest is BaseSetup, IEntitlementCheckerBase {
// =============================================================
// Random Nodes
// =============================================================
function test_getRandomNodes() external {
function test_getRandomNodes() external view {
address[] memory nodes = entitlementChecker.getRandomNodes(5);
uint256 nodeLen = nodes.length;

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/diamond/cut/DiamondCut.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract DiamondCutTest is DiamondCutSetup, IDiamondCutBase, IOwnableBase {

IDiamond.FacetCut[] internal facetCuts;

function test_supportsInterface() external {
function test_supportsInterface() external view {
assertTrue(
IERC165(diamond).supportsInterface(type(IDiamondCut).interfaceId)
);
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/diamond/loupe/DiamondLoupe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract DiamondLoupeTest is DiamondCutSetup {
DeployMockFacet mockFacetHelper = new DeployMockFacet();
IDiamond.FacetCut[] internal facetCuts;

function test_supportsInterface() external {
function test_supportsInterface() external view {
assertTrue(
IERC165(diamond).supportsInterface(type(IDiamondLoupe).interfaceId)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pragma solidity ^0.8.23;
import {OwnablePendingSetup} from "./OwnablePendingSetup.sol";

contract OwnablePendingTest is OwnablePendingSetup {
function test_currentOwner() external {
function test_currentOwner() external view {
assertEq(ownable.currentOwner(), deployer);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/diamond/proxy/ProxyManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract ProxyManagerTest is ProxyManagerSetup {
}

/// @notice This test checks that the owner of the proxy is different from the owner of the implementation
function test_proxyOwner() external {
function test_proxyOwner() external view {
assertEq(IERC173(address(implementation)).owner(), deployer);
assertEq(IERC173(address(managedProxy)).owner(), managedProxyOwner);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/fork/ForkSpaceOwner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ contract ForkSpaceOwner is
);
}

function test_getSpaceInfo() external onlyForked {
function test_getSpaceInfo() external view onlyForked {
Space memory space = SpaceOwner(spaceOwnerDiamond).getSpaceInfo(
0xC87bb04477151743070B45A3426938128896AC5D
);
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/river/registry/config/RiverConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract RiverConfigTest is
// =============================================================
// Configuration
// =============================================================
function test_configurationNonExistingKey(bytes32 key) external {
function test_configurationNonExistingKey(bytes32 key) external view {
assertFalse(riverConfig.configurationExists(key));
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/river/token/base/RiverBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract RiverBaseTest is BaseSetup, ILockBase, IOwnableBase {
stakeRequirement = riverFacet.MIN_TOKEN_THRESHOLD();
}

function test_init() external {
function test_init() external view {
assertEq(riverFacet.name(), "River");
assertEq(riverFacet.symbol(), "RVR");
assertEq(riverFacet.decimals(), 18);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract AuthorizedClaimersTest is TestUtils, IAuthorizedClaimersBase {
);
}

function test_getAuthorizedClaimer_notAuthorized() public {
function test_getAuthorizedClaimer_notAuthorized() public view {
assertEq(
authorizedClaimers.getAuthorizedClaimer(_randomAddress()),
address(0),
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/river/token/mainnet/RiverMainnet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract RiverMainnetTest is TestUtils, IRiverBase, ILockBase {
(, , inflation) = deployRiverMainnet.config();
}

function test_init() external {
function test_init() external view {
assertEq(river.name(), "River");
assertEq(river.symbol(), "RVR");
assertEq(river.decimals(), 18);
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/spaces/architect/Architect.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ contract ArchitectTest is
);
}

function test_getImplementations() external {
function test_getImplementations() external view {
(
ISpaceOwner spaceTokenAddress,
IUserEntitlement userEntitlementAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ contract EntitlementDataQueryableTest is
);
}

function test_getEntitlementDataByRole() external {
function test_getEntitlementDataByRole() external view {
EntitlementData[] memory entitlement = entitlements
.getEntitlementDataByPermission(Permissions.JoinSpace);

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/spaces/guardian/Guardian.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {GuardianSetup} from "./GuardianSetup.sol";

contract GuardianTest is GuardianSetup, IGuardianBase {
// guardian is enabled by default
function test_isGuardianEnabled() external {
function test_isGuardianEnabled() external view {
address wallet = _randomAddress();
assertTrue(guardian.isGuardianEnabled(wallet));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {MembershipBaseSetup} from "../MembershipBaseSetup.sol";
//contracts

contract MembershipDurationTest is MembershipBaseSetup {
function test_getMembershipDuration() public {
function test_getMembershipDuration() public view {
uint256 duration = membership.getMembershipDuration();
assertEq(duration, platformReqs.getMembershipDuration());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract PlatformRequirementsTest is
}

// Fee Recipient
function test_getFeeRecipient() public {
function test_getFeeRecipient() public view {
address feeRecipient = platformReqs.getFeeRecipient();
assertEq(feeRecipient, address(deployer));
}
Expand All @@ -51,7 +51,7 @@ contract PlatformRequirementsTest is

// Membership BPS

function test_getMembershipBps() public {
function test_getMembershipBps() public view {
uint16 membershipBps = platformReqs.getMembershipBps();
assertEq(membershipBps, 500);
}
Expand All @@ -78,7 +78,7 @@ contract PlatformRequirementsTest is
}

// Membership Fee
function test_getMembershipFee() public {
function test_getMembershipFee() public view {
uint256 membershipFee = platformReqs.getMembershipFee();
assertEq(membershipFee, 0.005 ether);
}
Expand All @@ -101,7 +101,7 @@ contract PlatformRequirementsTest is
}

// Membership Mint Limit
function test_getMembershipMintLimit() public {
function test_getMembershipMintLimit() public view {
uint256 membershipMintLimit = platformReqs.getMembershipMintLimit();
assertEq(membershipMintLimit, 1_000);
}
Expand Down Expand Up @@ -129,7 +129,7 @@ contract PlatformRequirementsTest is

// Membership Duration

function test_getMembershipDuration() public {
function test_getMembershipDuration() public view {
uint256 membershipDuration = platformReqs.getMembershipDuration();
assertEq(membershipDuration, 365 days);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/spaces/roles/Roles.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ contract RolesTest is BaseSetup, IRolesBase, IEntitlementBase {
assertEq(currentRoles.length, allRoles.length - 2);
}

function test_getRoles_default_roles() external {
function test_getRoles_default_roles() external view {
IRoles.Role[] memory allRoles = roles.getRoles();
assertEq(allRoles.length, 2);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/generated/dev/abis/SpaceOwner.json

Large diffs are not rendered by default.

14 changes: 3 additions & 11 deletions packages/generated/dev/abis/SpaceOwner.metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -1626,10 +1626,10 @@
"license": "MIT"
},
"contracts/src/spaces/facets/owner/SpaceOwnerUriBase.sol": {
"keccak256": "0x33836143f0920869898e15cf3c757d749a374689bab39f49931965169ea96c18",
"keccak256": "0xbc0f6bc661567cdc37620e295a3619aa5787a60fe6330fa6e2044314ab46fe49",
"urls": [
"bzz-raw://105995675fa7ed7a6032743e85166fa4d35efb2e214fdd5277b403b440507fdf",
"dweb:/ipfs/QmQnJpp7Juz35RPAYWBiMUPh7CnTEUDwoHA2x7vx5vkcPL"
"bzz-raw://6eae9fe0a43035a47e600d7a476f314c0a9aebaa59754e851751a18b1736751f",
"dweb:/ipfs/QmfN95VxwSkkvemoJ3w8gtzYjnehb1aocuu8zVLk6KPCBv"
],
"license": "MIT"
},
Expand Down Expand Up @@ -1705,14 +1705,6 @@
],
"license": "MIT"
},
"lib/base64/base64.sol": {
"keccak256": "0xa73959e6ef0b693e4423a562e612370160b934a75e618361ddd8c9c4b8ddbaaf",
"urls": [
"bzz-raw://17c12e16d8d66f3af15d8787920bd41ca6c1e7517a212a6b9cebd4b6d38f36fe",
"dweb:/ipfs/QmcXMnZUXEz6LRKsm3CSvqdPboAzmezavi8bTg2dRxM2yE"
],
"license": "MIT"
},
"lib/solady/src/utils/LibString.sol": {
"keccak256": "0xbb90caa572b7f65689b74867ec211fed8cde92714314101f4287d00a40d95ab2",
"urls": [
Expand Down
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@openzeppelin/=lib/@openzeppelin/
account-abstraction/=lib/account-abstraction/contracts/
base64/=lib/base64/
ds-test/=lib/ds-test/src/
forge-std/=lib/forge-std/src/
hardhat-deploy/=lib/hardhat-deploy/
Expand Down
1 change: 0 additions & 1 deletion scripts/copyLibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const path = require('path')
const CONTRACT_LIBS = [
'@openzeppelin',
'account-abstraction/contracts',
'base64',
'ds-test',
'forge-std/src',
'hardhat-deploy',
Expand Down
18 changes: 5 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3525,9 +3525,8 @@ __metadata:
"@prb/math": ^4.0.3
"@prb/test": ^0.6.4
account-abstraction: "github:eth-infinitism/account-abstraction"
base64: "github:Brechtpd/base64"
ds-test: "github:dapphub/ds-test"
forge-std: "github:foundry-rs/forge-std#v1"
forge-std: "github:foundry-rs/forge-std#v1.9.1"
prettier: ^2.8.8
prettier-plugin-solidity: ^1.3.1
solady: ^0.0.228
Expand Down Expand Up @@ -6658,13 +6657,6 @@ __metadata:
languageName: node
linkType: hard

"base64@github:Brechtpd/base64":
version: 1.1.0
resolution: "base64@https://github.com/Brechtpd/base64.git#commit=4d85607b18d981acff392d2e99ba654305552a97"
checksum: 833f768c1d8b2b9ebbeb05b869bc0d105624dd91f10fa9eb2975a174feb957b6d95cb343eeb6762a6874a5629f6cfdc49fc78fca1a1fbf8c75f80d559331ab35
languageName: node
linkType: hard

"bech32@npm:1.1.4":
version: 1.1.4
resolution: "bech32@npm:1.1.4"
Expand Down Expand Up @@ -10101,10 +10093,10 @@ __metadata:
languageName: node
linkType: hard

"forge-std@github:foundry-rs/forge-std#v1":
version: 1.7.6
resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=ae570fec082bfe1c1f45b0acca4a2b4f84d345ce"
checksum: fa42ca0255b610bc3f0081d3d53b191fa9986ada1870efb0f18197f1e19c83c7b0d4ad50c8e073e3980e83b77d7a5841cbe09692a1e72b57b2e48f51c46e8398
"forge-std@github:foundry-rs/forge-std#v1.9.1":
version: 1.9.1
resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=07263d193d621c4b2b0ce8b4d54af58f6957d97d"
checksum: 282ed0b5ff761edf536a8791fe182e847b610273c806fbc7b7d485831b3458ebafd69ba551b22751cb9d5c5f67db430e3ced37ef9ff0b9a292e2da2901eb0f71
languageName: node
linkType: hard

Expand Down

0 comments on commit 446a725

Please sign in to comment.