From d86342d8064973e88bd245f1f1c547d11d99b61e Mon Sep 17 00:00:00 2001 From: scolear Date: Tue, 19 Nov 2024 14:02:36 +0100 Subject: [PATCH] update deps --- foundry.toml | 9 + lib/core | 2 +- lib/forge-std | 2 +- lib/openzeppelin-contracts | 2 +- lib/openzeppelin-contracts-upgradeable | 2 +- lib/rewards | 2 +- src/DLCManager.sol | 105 ++++++++---- src/SimpleKeyRegistry32.sol | 8 +- src/SimpleMiddleware.sol | 78 ++++++--- src/{ => libraries}/MapWithTimeData.sol | 0 test/DLCBTC.t.sol | 211 ------------------------ test/MapWithTimeData.t.sol | 2 +- test/mocks/MapWithTimeDataContract.sol | 22 ++- 13 files changed, 169 insertions(+), 276 deletions(-) rename src/{ => libraries}/MapWithTimeData.sol (100%) delete mode 100644 test/DLCBTC.t.sol diff --git a/foundry.toml b/foundry.toml index 931f251..36686ca 100644 --- a/foundry.toml +++ b/foundry.toml @@ -9,4 +9,13 @@ ast = true build_info = true extra_output = ["storageLayout"] +[fmt] +bracket_spacing = false +int_types = "long" +line_length = 120 +multiline_func_header = "params_first" +number_underscore = "thousands" +quote_style = "double" +tab_width = 4 + # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options diff --git a/lib/core b/lib/core index 327bf64..2a5f6f0 160000 --- a/lib/core +++ b/lib/core @@ -1 +1 @@ -Subproject commit 327bf6443abe9c62de17e8e90d508bb4e4174c9a +Subproject commit 2a5f6f0fcee9a8d0ace03c38c77a352c5e5f95ae diff --git a/lib/forge-std b/lib/forge-std index 5a802d7..0e70977 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 5a802d7c10abb4bbfb3e7214c75052ef9e6a06f8 +Subproject commit 0e7097750918380d84dd3cfdef595bee74dabb70 diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts index 2f0bc58..dac63c4 160000 --- a/lib/openzeppelin-contracts +++ b/lib/openzeppelin-contracts @@ -1 +1 @@ -Subproject commit 2f0bc58946db746c0d17a2b9d9a8e13f5a8edd7f +Subproject commit dac63c4612df765c9d0f24d9148e912b8cd5032f diff --git a/lib/openzeppelin-contracts-upgradeable b/lib/openzeppelin-contracts-upgradeable index c3a1c27..2f0d9bd 160000 --- a/lib/openzeppelin-contracts-upgradeable +++ b/lib/openzeppelin-contracts-upgradeable @@ -1 +1 @@ -Subproject commit c3a1c275f209637b5781e04233455305ea860f5b +Subproject commit 2f0d9bd3da66a4072081d396760fecb517f50b56 diff --git a/lib/rewards b/lib/rewards index 4a6abb7..07bf5b7 160000 --- a/lib/rewards +++ b/lib/rewards @@ -1 +1 @@ -Subproject commit 4a6abb7b2dba0440d1e2df40b4ec96f0d622e5a5 +Subproject commit 07bf5b7bf04cc195b084511801d4b695e6e76e7f diff --git a/src/DLCManager.sol b/src/DLCManager.sol index a04a4b6..da42b69 100644 --- a/src/DLCManager.sol +++ b/src/DLCManager.sol @@ -113,7 +113,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, _; } - modifier onlyVaultCreator(bytes32 _uuid) { + modifier onlyVaultCreator( + bytes32 _uuid + ) { if (dlcs[dlcIDsByUUID[_uuid]].creator != tx.origin) revert NotOwner(); _; } @@ -211,7 +213,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, * @param signatures Array of signatures. * @return bool True if there are duplicates, false otherwise. */ - function _hasDuplicates(bytes[] memory signatures) internal pure returns (bool) { + function _hasDuplicates( + bytes[] memory signatures + ) internal pure returns (bool) { for (uint256 i = 0; i < signatures.length - 1; i++) { for (uint256 j = i + 1; j < signatures.length; j++) { if (keccak256(signatures[i]) == keccak256(signatures[j])) { @@ -277,11 +281,12 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, * @param signatures Signatures of the Attestors. * @param newValueLocked New value locked in the DLC. */ - function setStatusFunded(bytes32 uuid, string calldata btcTxId, bytes[] calldata signatures, uint256 newValueLocked) - external - whenNotPaused - onlyApprovedSigners - { + function setStatusFunded( + bytes32 uuid, + string calldata btcTxId, + bytes[] calldata signatures, + uint256 newValueLocked + ) external whenNotPaused onlyApprovedSigners { _attestorMultisigIsValid(abi.encode(uuid, btcTxId, "set-status-funded", newValueLocked), signatures); DLCLink.DLC storage dlc = dlcs[dlcIDsByUUID[uuid]]; @@ -378,14 +383,18 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, // VIEW FUNCTIONS // //////////////////////////////////////////////////////////////// - function getDLC(bytes32 uuid) public view returns (DLCLink.DLC memory) { + function getDLC( + bytes32 uuid + ) public view returns (DLCLink.DLC memory) { DLCLink.DLC memory _dlc = dlcs[dlcIDsByUUID[uuid]]; if (_dlc.uuid == bytes32(0)) revert DLCNotFound(); if (_dlc.uuid != uuid) revert DLCNotFound(); return _dlc; } - function getDLCByIndex(uint256 index) external view returns (DLCLink.DLC memory) { + function getDLCByIndex( + uint256 index + ) external view returns (DLCLink.DLC memory) { return dlcs[index]; } @@ -408,15 +417,21 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, return dlcSubset; } - function getVault(bytes32 uuid) public view returns (DLCLink.DLC memory) { + function getVault( + bytes32 uuid + ) public view returns (DLCLink.DLC memory) { return getDLC(uuid); } - function getAllVaultUUIDsForAddress(address owner) public view returns (bytes32[] memory) { + function getAllVaultUUIDsForAddress( + address owner + ) public view returns (bytes32[] memory) { return userVaults[owner]; } - function getAllVaultsForAddress(address owner) public view returns (DLCLink.DLC[] memory) { + function getAllVaultsForAddress( + address owner + ) public view returns (DLCLink.DLC[] memory) { bytes32[] memory uuids = getAllVaultUUIDsForAddress(owner); DLCLink.DLC[] memory vaults = new DLCLink.DLC[](uuids.length); for (uint256 i = 0; i < uuids.length; i++) { @@ -425,7 +440,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, return vaults; } - function isWhitelisted(address account) external view returns (bool) { + function isWhitelisted( + address account + ) external view returns (bool) { return _whitelistedAddresses[account]; } @@ -445,7 +462,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, // ADMIN FUNCTIONS // //////////////////////////////////////////////////////////////// - function _hasAnyRole(address account) internal view returns (bool) { + function _hasAnyRole( + address account + ) internal view returns (bool) { return hasRole(DLC_ADMIN_ROLE, account) || hasRole(WHITELISTED_CONTRACT, account) || hasRole(APPROVED_SIGNER, account); } @@ -477,7 +496,9 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, _unpause(); } - function setThreshold(uint16 newThreshold) external onlyAdmin { + function setThreshold( + uint16 newThreshold + ) external onlyAdmin { if (newThreshold < _minimumThreshold) { revert ThresholdTooLow(_minimumThreshold); } @@ -485,48 +506,66 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, emit SetThreshold(newThreshold); } - function setTSSCommitment(bytes32 commitment) external onlyAdmin { + function setTSSCommitment( + bytes32 commitment + ) external onlyAdmin { tssCommitment = commitment; } - function setAttestorGroupPubKey(string calldata pubKey) external onlyAdmin { + function setAttestorGroupPubKey( + string calldata pubKey + ) external onlyAdmin { attestorGroupPubKey = pubKey; } - function whitelistAddress(address addressToWhitelist) external onlyAdmin { + function whitelistAddress( + address addressToWhitelist + ) external onlyAdmin { _whitelistedAddresses[addressToWhitelist] = true; emit WhitelistAddress(addressToWhitelist); } - function unwhitelistAddress(address addressToUnWhitelist) external onlyAdmin { + function unwhitelistAddress( + address addressToUnWhitelist + ) external onlyAdmin { _whitelistedAddresses[addressToUnWhitelist] = false; emit UnwhitelistAddress(addressToUnWhitelist); } - function setMinimumDeposit(uint256 newMinimumDeposit) external onlyAdmin { + function setMinimumDeposit( + uint256 newMinimumDeposit + ) external onlyAdmin { minimumDeposit = newMinimumDeposit; emit SetMinimumDeposit(newMinimumDeposit); } - function setMaximumDeposit(uint256 newMaximumDeposit) external onlyAdmin { + function setMaximumDeposit( + uint256 newMaximumDeposit + ) external onlyAdmin { maximumDeposit = newMaximumDeposit; emit SetMaximumDeposit(newMaximumDeposit); } - function setBtcMintFeeRate(uint256 newBtcMintFeeRate) external onlyAdmin { - if (newBtcMintFeeRate > 10000) { + function setBtcMintFeeRate( + uint256 newBtcMintFeeRate + ) external onlyAdmin { + if (newBtcMintFeeRate > 10_000) { revert FeeRateOutOfBounds(newBtcMintFeeRate); } btcMintFeeRate = newBtcMintFeeRate; emit SetBtcMintFeeRate(newBtcMintFeeRate); } - function setBtcRedeemFeeRate(uint256 newBtcRedeemFeeRate) external onlyAdmin { + function setBtcRedeemFeeRate( + uint256 newBtcRedeemFeeRate + ) external onlyAdmin { btcRedeemFeeRate = newBtcRedeemFeeRate; emit SetBtcRedeemFeeRate(newBtcRedeemFeeRate); } - function setBtcFeeRecipient(string calldata btcFeeRecipientToSet) external onlyAdmin { + function setBtcFeeRecipient( + string calldata btcFeeRecipientToSet + ) external onlyAdmin { btcFeeRecipient = btcFeeRecipientToSet; emit SetBtcFeeRecipient(btcFeeRecipient); } @@ -536,21 +575,29 @@ contract DLCManager is Initializable, AccessControlDefaultAdminRulesUpgradeable, dlc.btcFeeRecipient = btcFeeRecipientToSet; } - function setWhitelistingEnabled(bool isWhitelistingEnabled) external onlyAdmin { + function setWhitelistingEnabled( + bool isWhitelistingEnabled + ) external onlyAdmin { whitelistingEnabled = isWhitelistingEnabled; emit SetWhitelistingEnabled(isWhitelistingEnabled); } - function transferTokenContractOwnership(address newOwner) external onlyAdmin { + function transferTokenContractOwnership( + address newOwner + ) external onlyAdmin { dlcBTC.transferOwnership(newOwner); emit TransferTokenContractOwnership(newOwner); } - function setMinterOnTokenContract(address minter) external onlyAdmin { + function setMinterOnTokenContract( + address minter + ) external onlyAdmin { dlcBTC.setMinter(minter); } - function setBurnerOnTokenContract(address burner) external onlyAdmin { + function setBurnerOnTokenContract( + address burner + ) external onlyAdmin { dlcBTC.setBurner(burner); } } diff --git a/src/SimpleKeyRegistry32.sol b/src/SimpleKeyRegistry32.sol index 90f5de6..5255d8f 100644 --- a/src/SimpleKeyRegistry32.sol +++ b/src/SimpleKeyRegistry32.sol @@ -18,11 +18,15 @@ abstract contract SimpleKeyRegistry32 { uint208 internal constant EMPTY_KEY_IDX = 0; - function getOperatorByKey(bytes32 key) public view returns (address) { + function getOperatorByKey( + bytes32 key + ) public view returns (address) { return keyToOperator[key]; } - function getCurrentOperatorKey(address operator) public view returns (bytes32) { + function getCurrentOperatorKey( + address operator + ) public view returns (bytes32) { uint208 keyIdx = operatorToIdx[operator].latest(); if (keyIdx == EMPTY_KEY_IDX) { diff --git a/src/SimpleMiddleware.sol b/src/SimpleMiddleware.sol index fa3b1bd..425cb20 100644 --- a/src/SimpleMiddleware.sol +++ b/src/SimpleMiddleware.sol @@ -17,7 +17,7 @@ import {IVetoSlasher} from "@symbiotic/interfaces/slasher/IVetoSlasher.sol"; import {Subnetwork} from "@symbiotic/contracts/libraries/Subnetwork.sol"; import {SimpleKeyRegistry32} from "./SimpleKeyRegistry32.sol"; -import {MapWithTimeData} from "./MapWithTimeData.sol"; +import {MapWithTimeData} from "./libraries/MapWithTimeData.sol"; contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { using EnumerableMap for EnumerableMap.AddressToUintMap; @@ -69,7 +69,9 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { EnumerableMap.AddressToUintMap private operators; EnumerableMap.AddressToUintMap private vaults; - modifier updateStakeCache(uint48 epoch) { + modifier updateStakeCache( + uint48 epoch + ) { if (!totalStakeCached[epoch]) { calcAndCacheStakes(epoch); } @@ -101,11 +103,15 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { subnetworksCnt = 1; } - function getEpochStartTs(uint48 epoch) public view returns (uint48 timestamp) { + function getEpochStartTs( + uint48 epoch + ) public view returns (uint48 timestamp) { return START_TIME + epoch * EPOCH_DURATION; } - function getEpochAtTs(uint48 timestamp) public view returns (uint48 epoch) { + function getEpochAtTs( + uint48 timestamp + ) public view returns (uint48 epoch) { return (timestamp - START_TIME) / EPOCH_DURATION; } @@ -140,15 +146,21 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { updateKey(operator, key); } - function pauseOperator(address operator) external onlyOwner { + function pauseOperator( + address operator + ) external onlyOwner { operators.disable(operator); } - function unpauseOperator(address operator) external onlyOwner { + function unpauseOperator( + address operator + ) external onlyOwner { operators.enable(operator); } - function unregisterOperator(address operator) external onlyOwner { + function unregisterOperator( + address operator + ) external onlyOwner { (, uint48 disabledTime) = operators.getTimes(operator); if (disabledTime == 0 || disabledTime + SLASHING_WINDOW > Time.timestamp()) { @@ -158,7 +170,9 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { operators.remove(operator); } - function registerVault(address vault) external onlyOwner { + function registerVault( + address vault + ) external onlyOwner { if (vaults.contains(vault)) { revert VaultAlreadyRegistred(); } @@ -182,15 +196,21 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { vaults.enable(vault); } - function pauseVault(address vault) external onlyOwner { + function pauseVault( + address vault + ) external onlyOwner { vaults.disable(vault); } - function unpauseVault(address vault) external onlyOwner { + function unpauseVault( + address vault + ) external onlyOwner { vaults.enable(vault); } - function unregisterVault(address vault) external onlyOwner { + function unregisterVault( + address vault + ) external onlyOwner { (, uint48 disabledTime) = vaults.getTimes(vault); if (disabledTime == 0 || disabledTime + SLASHING_WINDOW > Time.timestamp()) { @@ -200,7 +220,9 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { vaults.remove(vault); } - function setSubnetworksCnt(uint256 _subnetworksCnt) external onlyOwner { + function setSubnetworksCnt( + uint256 _subnetworksCnt + ) external onlyOwner { if (subnetworksCnt >= _subnetworksCnt) { revert InvalidSubnetworksCnt(); } @@ -233,14 +255,18 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { return stake; } - function getTotalStake(uint48 epoch) public view returns (uint256) { + function getTotalStake( + uint48 epoch + ) public view returns (uint256) { if (totalStakeCached[epoch]) { return totalStakeCache[epoch]; } return _calcTotalStake(epoch); } - function getValidatorSet(uint48 epoch) public view returns (ValidatorData[] memory validatorsData) { + function getValidatorSet( + uint48 epoch + ) public view returns (ValidatorData[] memory validatorsData) { uint48 epochStartTs = getEpochStartTs(epoch); validatorsData = new ValidatorData[](operators.length()); @@ -259,7 +285,7 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { continue; } - uint256 stake = getOperatorStake(operator, epochStartTs); + uint256 stake = getOperatorStake(operator, epoch); validatorsData[valIdx++] = ValidatorData(stake, key); } @@ -310,7 +336,9 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { } } - function calcAndCacheStakes(uint48 epoch) public returns (uint256 totalStake) { + function calcAndCacheStakes( + uint48 epoch + ) public returns (uint256 totalStake) { uint48 epochStartTs = getEpochStartTs(epoch); // for epoch older than SLASHING_WINDOW total stake can be invalidated (use cache) @@ -330,7 +358,7 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { continue; } - uint256 operatorStake = getOperatorStake(operator, epochStartTs); + uint256 operatorStake = getOperatorStake(operator, epoch); operatorStakeCache[epoch][operator] = operatorStake; totalStake += operatorStake; @@ -340,7 +368,9 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { totalStakeCache[epoch] = totalStake; } - function _calcTotalStake(uint48 epoch) private view returns (uint256 totalStake) { + function _calcTotalStake( + uint48 epoch + ) private view returns (uint256 totalStake) { uint48 epochStartTs = getEpochStartTs(epoch); // for epoch older than SLASHING_WINDOW total stake can be invalidated (use cache) @@ -360,7 +390,7 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { continue; } - uint256 operatorStake = getOperatorStake(operator, epochStartTs); + uint256 operatorStake = getOperatorStake(operator, epoch); totalStake += operatorStake; } } @@ -369,9 +399,13 @@ contract SimpleMiddleware is SimpleKeyRegistry32, Ownable { return enabledTime != 0 && enabledTime <= timestamp && (disabledTime == 0 || disabledTime >= timestamp); } - function _slashVault(uint48 timestamp, address vault, bytes32 subnetwork, address operator, uint256 amount) - private - { + function _slashVault( + uint48 timestamp, + address vault, + bytes32 subnetwork, + address operator, + uint256 amount + ) private { address slasher = IVault(vault).slasher(); uint256 slasherType = IEntity(slasher).TYPE(); if (slasherType == INSTANT_SLASHER_TYPE) { diff --git a/src/MapWithTimeData.sol b/src/libraries/MapWithTimeData.sol similarity index 100% rename from src/MapWithTimeData.sol rename to src/libraries/MapWithTimeData.sol diff --git a/test/DLCBTC.t.sol b/test/DLCBTC.t.sol deleted file mode 100644 index 6da17d9..0000000 --- a/test/DLCBTC.t.sol +++ /dev/null @@ -1,211 +0,0 @@ -// // SPDX-License-Identifier: MIT -// pragma solidity ^0.8.0; - -// import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; -// import "forge-std/Test.sol"; -// import "forge-std/console.sol"; - -// import "../src/DLCBTC.sol"; -// import "../src/DLCManager.sol"; - -// contract DLCBTCTest is Test { -// DLCBTC public dlcBtc; -// DLCManager public dlcManager; -// SignatureHelper public signatureHelper; - -// address public deployer; -// address public user; -// address public someRandomAccount; -// address public attestor1; -// address public attestor2; -// address public attestor3; - -// address[] public attestors; -// uint256 public deposit = 100000000; // 1 BTC -// string public btcFeeRecipient = -// "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"; - -// bytes32 public mockUUID = -// 0x96eecb386fb10e82f510aaf3e2b99f52f8dcba03f9e0521f7551b367d8ad4967; -// string public mockBTCTxId = -// "0x1234567890123456789012345678901234567890123456789012345678901234"; -// string public mockTaprootPubkey = -// "0x1234567890123456789012345678901234567890123456789012345678901234"; - -// function setUp() public { -// signatureHelper = new SignatureHelper(); -// // Set signers -// deployer = vm.addr(1); -// user = vm.addr(2); -// someRandomAccount = vm.addr(3); -// attestor1 = vm.addr(6); -// attestor2 = vm.addr(7); -// attestor3 = vm.addr(8); - -// attestors = [attestor1, attestor2, attestor3]; - -// // Deploy contracts -// vm.startPrank(deployer); - -// address tokenProxy = Upgrades.deployTransparentProxy( -// "DLCBTC.sol", -// deployer, -// abi.encodeCall(DLCBTC.initialize, ()) -// ); - -// dlcBtc = DLCBTC(tokenProxy); - -// address proxy = Upgrades.deployTransparentProxy( -// "DLCManager.sol", -// deployer, -// abi.encodeCall( -// DLCManager.initialize, -// (deployer, deployer, 3, dlcBtc, btcFeeRecipient) -// ) -// ); -// dlcManager = DLCManager(proxy); -// vm.stopPrank(); - -// // Transfer ownership to DLCManager -// vm.startPrank(deployer); -// dlcBtc.transferOwnership(proxy); -// vm.stopPrank(); -// } - -// function testShouldDeploy() public view { -// assertTrue(address(dlcBtc) != address(0)); -// } - -// function testShouldHave8Decimals() public view { -// assertEq(dlcBtc.decimals(), 8); -// } - -// function testShouldHaveZeroTotalSupply() public view { -// assertEq(dlcBtc.totalSupply(), 0); -// } - -// function testShouldRevertOnUnauthorizedMint() public { -// vm.expectRevert(); -// vm.prank(user); -// dlcBtc.mint(user, deposit); -// } - -// function testShouldRevertOnUnauthorizedBurn() public { -// vm.expectRevert(); -// vm.prank(user); -// dlcBtc.burn(user, deposit); -// } - -// function testOwnerCanMintTokens() public { -// vm.prank(address(dlcManager)); -// dlcBtc.mint(user, deposit); -// assertEq(dlcBtc.balanceOf(user), deposit); -// } - -// function testOwnerCanBurnTokens() public { -// vm.startPrank(address(dlcManager)); -// dlcBtc.mint(user, deposit); -// dlcBtc.burn(user, deposit); -// assertEq(dlcBtc.balanceOf(user), 0); -// vm.stopPrank(); -// } - -// // function testDLCManagerCanMintTokens() public { -// // vm.startPrank(deployer); -// // dlcManager.whitelistAddress(user); -// // vm.stopPrank(); - -// // vm.startPrank(user); -// // bytes32 _uuid = dlcManager.setupVault(); -// // vm.stopPrank(); - -// // uint256 existingBalance = dlcBtc.balanceOf(user); - -// // // Set signatures and status -// // setSignersAndStatuses( -// // _uuid, -// // mockBTCTxId, -// // mockTaprootPubkey, -// // 0, -// // deposit -// // ); - -// // assertEq(dlcBtc.balanceOf(user), existingBalance + deposit); -// // } - -// // function testDLCManagerCanBurnTokens() public { -// // vm.startPrank(deployer); -// // dlcManager.whitelistAddress(user); -// // vm.stopPrank(); - -// // vm.startPrank(user); -// // bytes32 _uuid = dlcManager.setupVault(); -// // vm.stopPrank(); - -// // uint256 existingBalance = dlcBtc.balanceOf(user); - -// // console.log("Existing balance: ", existingBalance); - -// // // Set signatures and status -// // setSignersAndStatuses( -// // _uuid, -// // mockBTCTxId, -// // mockTaprootPubkey, -// // 0, -// // deposit -// // ); - -// // assertEq(dlcBtc.balanceOf(user), existingBalance + deposit); - -// // vm.startPrank(user); -// // dlcManager.withdraw(mockUUID, deposit); -// // vm.stopPrank(); - -// // assertEq(dlcBtc.balanceOf(user), existingBalance); -// // } - -// // function setSignersAndStatuses( -// // bytes32 uuid, -// // string memory btcTxId, -// // string memory taprootPubkey, -// // uint256 newLockedAmountPending, -// // uint256 newLockedAmountFunded -// // ) internal { -// // // Mock function to set signatures and call status updates. -// // bytes[] memory signatureBytesForPending = signatureHelper.getSignatures( -// // uuid, -// // btcTxId, -// // "set-status-pending", -// // newLockedAmountPending, -// // attestors, -// // 3 -// // ); -// // bytes[] memory signatureBytesForFunding = signatureHelper.getSignatures( -// // uuid, -// // btcTxId, -// // "set-status-funded", -// // deposit, -// // attestors, -// // 3 -// // ); - -// // console.log("signatureBytesForPending: ", signatureBytesForPending); -// // console.log("signatureBytesForFunding: ", signatureBytesForFunding); - -// // vm.startPrank(attestor1); -// // dlcManager.setStatusPending( -// // uuid, -// // btcTxId, -// // signatureBytesForPending, -// // taprootPubkey, -// // 0 -// // ); -// // dlcManager.setStatusFunded( -// // uuid, -// // btcTxId, -// // signatureBytesForFunding, -// // newLockedAmountFunded -// // ); -// // vm.stopPrank(); -// // } -// } diff --git a/test/MapWithTimeData.t.sol b/test/MapWithTimeData.t.sol index 351e481..dc9f07c 100644 --- a/test/MapWithTimeData.t.sol +++ b/test/MapWithTimeData.t.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.25; import {Test, console2} from "forge-std/Test.sol"; -import {MapWithTimeData} from "../src/MapWithTimeData.sol"; +import {MapWithTimeData} from "../src/libraries/MapWithTimeData.sol"; import {MapWithTimeDataContract} from "./mocks/MapWithTimeDataContract.sol"; contract DefaultOperatorRewardsTest is Test { diff --git a/test/mocks/MapWithTimeDataContract.sol b/test/mocks/MapWithTimeDataContract.sol index c449951..615d5ba 100644 --- a/test/mocks/MapWithTimeDataContract.sol +++ b/test/mocks/MapWithTimeDataContract.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.25; import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; -import {MapWithTimeData} from "../../src/MapWithTimeData.sol"; +import {MapWithTimeData} from "../../src/libraries/MapWithTimeData.sol"; contract MapWithTimeDataContract { using EnumerableMap for EnumerableMap.AddressToUintMap; @@ -11,23 +11,33 @@ contract MapWithTimeDataContract { EnumerableMap.AddressToUintMap internal elements; - function add(address addr) public { + function add( + address addr + ) public { elements.add(addr); } - function disable(address addr) public { + function disable( + address addr + ) public { elements.disable(addr); } - function enable(address addr) public { + function enable( + address addr + ) public { elements.enable(addr); } - function atWithTimes(uint256 idx) public view returns (address key, uint48 enabledTime, uint48 disabledTime) { + function atWithTimes( + uint256 idx + ) public view returns (address key, uint48 enabledTime, uint48 disabledTime) { return elements.atWithTimes(idx); } - function getTimes(address addr) public view returns (uint48 enabledTime, uint48 disabledTime) { + function getTimes( + address addr + ) public view returns (uint48 enabledTime, uint48 disabledTime) { return elements.getTimes(addr); }