diff --git a/.env.sample b/.env.sample index 7baff038..036cb3ca 100644 --- a/.env.sample +++ b/.env.sample @@ -6,7 +6,8 @@ OPTIMISM_SEPOLIA_RPC="https://rpc.ankr.com/optimism_sepolia" BASE_SEPOLIA_RPC="https://rpc.ankr.com/base_sepolia" # EVMx key addresses -# Find the most up to date addresses in deployments/dev_addresses.json +# Find the most up to date addresses at: +# https://github.com/SocketDotTech/socket-protocol/blob/master/deployments/stage_addresses.json ADDRESS_RESOLVER="0xf3046B22F98C25305E8040286fB1b33378BA10a1" FEES_MANAGER="0x603723100172D30171B7Fd9870ba80F8baf6FaD4" ARBITRUM_FEES_PLUG="0x89324F93d852cB4fcDC4Ee202456be466ce096bb" diff --git a/.gitmodules b/.gitmodules index dbd0a97b..0f078158 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std -[submodule "lib/solmate"] - path = lib/solmate - url = https://github.com/transmissions11/solmate [submodule "lib/solady"] path = lib/solady url = https://github.com/vectorized/solady diff --git a/contracts/base/PlugBase.sol b/contracts/base/PlugBase.sol index 66a1e943..644d00c0 100644 --- a/contracts/base/PlugBase.sol +++ b/contracts/base/PlugBase.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.21; -import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; import {ISocket} from "../interfaces/ISocket.sol"; import {IPlug} from "../interfaces/IPlug.sol"; import {NotSocket} from "../protocol/utils/common/Errors.sol"; + /// @title PlugBase /// @notice Abstract contract for plugs abstract contract PlugBase is IPlug { diff --git a/contracts/protocol/payload-delivery/FeesPlug.sol b/contracts/protocol/payload-delivery/FeesPlug.sol index a6a1afdf..77778f05 100644 --- a/contracts/protocol/payload-delivery/FeesPlug.sol +++ b/contracts/protocol/payload-delivery/FeesPlug.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.21; -import "solmate/utils/SafeTransferLib.sol"; +import "solady/utils/SafeTransferLib.sol"; import "../../base/PlugBase.sol"; import "../utils/AccessControl.sol"; import {RESCUE_ROLE} from "../utils/common/AccessRoles.sol"; @@ -84,7 +84,7 @@ contract FeesPlug is PlugBase, AccessControl { balanceOf[token_] += amount_; if (token_ != ETH_ADDRESS) { - SafeTransferLib.safeTransferFrom(ERC20(token_), msg.sender, address(this), amount_); + SafeTransferLib.safeTransferFrom(token_, msg.sender, address(this), amount_); } emit FeesDeposited(appGateway_, token_, amount_); @@ -96,9 +96,9 @@ contract FeesPlug is PlugBase, AccessControl { /// @param receiver_ The receiver address function _transferTokens(address token_, uint256 amount_, address receiver_) internal { if (token_ == ETH_ADDRESS) { - SafeTransferLib.safeTransferETH(payable(receiver_), amount_); + SafeTransferLib.forceSafeTransferETH(receiver_, amount_); } else { - SafeTransferLib.safeTransfer(ERC20(token_), receiver_, amount_); + SafeTransferLib.safeTransfer(token_, receiver_, amount_); } } diff --git a/contracts/protocol/utils/RescueFundsLib.sol b/contracts/protocol/utils/RescueFundsLib.sol index a6319036..189f2a7b 100644 --- a/contracts/protocol/utils/RescueFundsLib.sol +++ b/contracts/protocol/utils/RescueFundsLib.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "solmate/utils/SafeTransferLib.sol"; -import "solmate/tokens/ERC20.sol"; +import "solady/utils/SafeTransferLib.sol"; import {ZeroAddress, InvalidTokenAddress} from "./common/Errors.sol"; import {ETH_ADDRESS} from "./common/Constants.sol"; @@ -22,10 +21,10 @@ library RescueFundsLib { if (rescueTo_ == address(0)) revert ZeroAddress(); if (token_ == ETH_ADDRESS) { - SafeTransferLib.safeTransferETH(rescueTo_, amount_); + SafeTransferLib.forceSafeTransferETH(rescueTo_, amount_); } else { if (token_.code.length == 0) revert InvalidTokenAddress(); - SafeTransferLib.safeTransfer(ERC20(token_), rescueTo_, amount_); + SafeTransferLib.safeTransfer(token_, rescueTo_, amount_); } } } diff --git a/foundry.toml b/foundry.toml index 6af74ab3..6e9cfda0 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,8 +2,8 @@ solc_version = "0.8.22" src = "contracts" out = "out" -libs = ["node_modules", "lib"] +libs = ["lib"] ffi = true optimizer = true optimizer_runs = 200 -evm_version = 'paris' \ No newline at end of file +evm_version = 'paris' diff --git a/lib/solmate b/lib/solmate deleted file mode 160000 index c93f7716..00000000 --- a/lib/solmate +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c93f7716c9909175d45f6ef80a34a650e2d24e56 diff --git a/package.json b/package.json index aee7ad7e..48430be3 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "@typechain/hardhat": "6.0.0", "dotenv": "^16.0.3", "ethers": "5.6.6", - "forge-std": "^1.1.2", "hardhat": "2.12.2", "hardhat-abi-exporter": "2.10.1", "hardhat-change-network": "^0.0.7", diff --git a/remappings.txt b/remappings.txt index 1cf3bb7d..7b75fc8f 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,4 +1,3 @@ -ds-test/=lib/forge-std/lib/ds-test/src/ -forge-std/=lib/forge-std/src/ -solmate/=lib/solmate/src/ -solady/=lib/solady/src/ \ No newline at end of file +hardhat-deploy/=node_modules/hardhat-deploy/ +hardhat/=node_modules/hardhat/ +solady/=lib/solady/src/ diff --git a/test/apps/app-gateways/super-token-lockable/SuperTokenLockable.sol b/test/apps/app-gateways/super-token-lockable/SuperTokenLockable.sol index 5aec4aec..70b5a330 100644 --- a/test/apps/app-gateways/super-token-lockable/SuperTokenLockable.sol +++ b/test/apps/app-gateways/super-token-lockable/SuperTokenLockable.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.21; -import "solmate/tokens/ERC20.sol"; +import "solady/tokens/ERC20.sol"; import {Ownable} from "solady/auth/Ownable.sol"; import {LimitHook} from "./LimitHook.sol"; import "../../../../contracts/base/PlugBase.sol"; @@ -11,10 +11,12 @@ import "../../../../contracts/base/PlugBase.sol"; * @notice An ERC20 contract which enables bridging a token to its sibling chains. */ contract SuperTokenLockable is ERC20, Ownable, PlugBase { + string private _name; + string private _symbol; + uint8 private _decimals; LimitHook public limitHook__; mapping(address => uint256) public lockedTokens; - error InsufficientBalance(); error InsufficientLockedTokens(); error InvalidSender(); @@ -24,12 +26,15 @@ contract SuperTokenLockable is ERC20, Ownable, PlugBase { uint8 decimals_, address initialSupplyHolder_, uint256 initialSupply_ - ) ERC20(name_, symbol_, decimals_) { + ) { + _name = name_; + _symbol = symbol_; + _decimals = decimals_; _mint(initialSupplyHolder_, initialSupply_); } function lockTokens(address user_, uint256 amount_) external onlySocket { - if (balanceOf[user_] < amount_) revert InsufficientBalance(); + if (balanceOf(user_) < amount_) revert InsufficientBalance(); limitHook__.beforeBurn(amount_); lockedTokens[user_] += amount_; @@ -45,6 +50,18 @@ contract SuperTokenLockable is ERC20, Ownable, PlugBase { lockedTokens[user_] -= amount_; } + function name() public view virtual override returns (string memory) { + return _name; + } + + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + function decimals() public view virtual override returns (uint8) { + return _decimals; + } + function unlockTokens(address user_, uint256 amount_) external onlySocket { if (lockedTokens[user_] < amount_) revert InsufficientLockedTokens(); lockedTokens[user_] -= amount_; diff --git a/test/apps/app-gateways/super-token/SuperToken.sol b/test/apps/app-gateways/super-token/SuperToken.sol index 4d7dfe05..8c6de970 100644 --- a/test/apps/app-gateways/super-token/SuperToken.sol +++ b/test/apps/app-gateways/super-token/SuperToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.21; -import "solmate/tokens/ERC20.sol"; +import "solady/tokens/ERC20.sol"; import {Ownable} from "solady/auth/Ownable.sol"; import "../../../../contracts/base/PlugBase.sol"; @@ -10,16 +10,23 @@ import "../../../../contracts/base/PlugBase.sol"; * @notice An ERC20 contract which enables bridging a token to its sibling chains. */ contract SuperToken is ERC20, Ownable, PlugBase { + string private _name; + string private _symbol; + uint8 private _decimals; mapping(address => uint256) public lockedTokens; error InvalidSender(); + constructor( string memory name_, string memory symbol_, uint8 decimals_, address initialSupplyHolder_, uint256 initialSupply_ - ) ERC20(name_, symbol_, decimals_) { + ) { + _name = name_; + _symbol = symbol_; + _decimals = decimals_; _mint(initialSupplyHolder_, initialSupply_); } @@ -31,6 +38,18 @@ contract SuperToken is ERC20, Ownable, PlugBase { _burn(user_, amount_); } + function name() public view virtual override returns (string memory) { + return _name; + } + + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + function decimals() public view virtual override returns (uint8) { + return _decimals; + } + function setSocket(address newSocket_) external onlyOwner { _setSocket(newSocket_); } diff --git a/yarn.lock b/yarn.lock index 3cf308a7..a90bc6c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3153,11 +3153,6 @@ follow-redirects@^1.0.0, follow-redirects@^1.12.1, follow-redirects@^1.14.0, fol resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== -forge-std@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/forge-std/-/forge-std-1.1.2.tgz#f4a0eda103538d56f9c563f3cd1fa2fd01bd9378" - integrity sha512-Wfb0iAS9PcfjMKtGpWQw9mXzJxrWD62kJCUqqLcyuI0+VRtJ3j20XembjF3kS20qELYdXft1vD/SPFVWVKMFOw== - form-data@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.2.tgz#35cabbdd30c3ce73deb2c42d3c8d3ed9ca51794c"