Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion contracts/base/PlugBase.sol
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions contracts/protocol/payload-delivery/FeesPlug.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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_);
Expand All @@ -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_);
}
}

Expand Down
7 changes: 3 additions & 4 deletions contracts/protocol/utils/RescueFundsLib.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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_);
}
}
}
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
evm_version = 'paris'
1 change: 0 additions & 1 deletion lib/solmate
Submodule solmate deleted from c93f77
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -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/
hardhat-deploy/=node_modules/hardhat-deploy/
hardhat/=node_modules/hardhat/
solady/=lib/solady/src/
25 changes: 21 additions & 4 deletions test/apps/app-gateways/super-token-lockable/SuperTokenLockable.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();

Expand All @@ -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_;
Expand All @@ -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_;
Expand Down
23 changes: 21 additions & 2 deletions test/apps/app-gateways/super-token/SuperToken.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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_);
}

Expand All @@ -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_);
}
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading