mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
forge fmt
This commit is contained in:
@@ -35,7 +35,9 @@ contract Router {
|
||||
}
|
||||
|
||||
event SeraiKeyUpdated(uint256 indexed nonce, bytes32 indexed key);
|
||||
event InInstruction(address indexed from, address indexed coin, uint256 amount, bytes instruction);
|
||||
event InInstruction(
|
||||
address indexed from, address indexed coin, uint256 amount, bytes instruction
|
||||
);
|
||||
event Executed(uint256 indexed nonce, bytes32 indexed batch);
|
||||
|
||||
error InvalidSignature();
|
||||
@@ -62,10 +64,10 @@ contract Router {
|
||||
|
||||
// updateSeraiKey validates the given Schnorr signature against the current public key, and if
|
||||
// successful, updates the contract's public key to the one specified.
|
||||
function updateSeraiKey(
|
||||
bytes32 newSeraiKey,
|
||||
Signature calldata signature
|
||||
) external _updateSeraiKeyAtEndOfFn(_nonce, newSeraiKey) {
|
||||
function updateSeraiKey(bytes32 newSeraiKey, Signature calldata signature)
|
||||
external
|
||||
_updateSeraiKeyAtEndOfFn(_nonce, newSeraiKey)
|
||||
{
|
||||
bytes memory message = abi.encodePacked("updateSeraiKey", block.chainid, _nonce, newSeraiKey);
|
||||
_nonce++;
|
||||
|
||||
@@ -74,25 +76,15 @@ contract Router {
|
||||
}
|
||||
}
|
||||
|
||||
function inInstruction(
|
||||
address coin,
|
||||
uint256 amount,
|
||||
bytes memory instruction
|
||||
) external payable {
|
||||
function inInstruction(address coin, uint256 amount, bytes memory instruction) external payable {
|
||||
if (coin == address(0)) {
|
||||
if (amount != msg.value) {
|
||||
revert InvalidAmount();
|
||||
}
|
||||
} else {
|
||||
(bool success, bytes memory res) =
|
||||
address(coin).call(
|
||||
abi.encodeWithSelector(
|
||||
IERC20.transferFrom.selector,
|
||||
msg.sender,
|
||||
address(this),
|
||||
amount
|
||||
)
|
||||
);
|
||||
(bool success, bytes memory res) = address(coin).call(
|
||||
abi.encodeWithSelector(IERC20.transferFrom.selector, msg.sender, address(this), amount)
|
||||
);
|
||||
|
||||
// Require there was nothing returned, which is done by some non-standard tokens, or that the
|
||||
// ERC20 contract did in fact return true
|
||||
@@ -193,9 +185,9 @@ contract Router {
|
||||
|
||||
// Perform the calls with a set gas budget
|
||||
(uint32 gas, bytes memory code) = abi.decode(transactions[i].destination, (uint32, bytes));
|
||||
address(this).call{
|
||||
gas: gas
|
||||
}(abi.encodeWithSelector(Router.arbitaryCallOut.selector, code));
|
||||
address(this).call{ gas: gas }(
|
||||
abi.encodeWithSelector(Router.arbitaryCallOut.selector, code)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ contract TestERC20 {
|
||||
function name() public pure returns (string memory) {
|
||||
return "Test ERC20";
|
||||
}
|
||||
|
||||
function symbol() public pure returns (string memory) {
|
||||
return "TEST";
|
||||
}
|
||||
|
||||
function decimals() public pure returns (uint8) {
|
||||
return 18;
|
||||
}
|
||||
@@ -29,11 +31,13 @@ contract TestERC20 {
|
||||
function balanceOf(address owner) public view returns (uint256) {
|
||||
return balances[owner];
|
||||
}
|
||||
|
||||
function transfer(address to, uint256 value) public returns (bool) {
|
||||
balances[msg.sender] -= value;
|
||||
balances[to] += value;
|
||||
return true;
|
||||
}
|
||||
|
||||
function transferFrom(address from, address to, uint256 value) public returns (bool) {
|
||||
allowances[from][msg.sender] -= value;
|
||||
balances[from] -= value;
|
||||
@@ -45,6 +49,7 @@ contract TestERC20 {
|
||||
allowances[msg.sender][spender] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
function allowance(address owner, address spender) public view returns (uint256) {
|
||||
return allowances[owner][spender];
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ contract Deployer {
|
||||
uint64 block_number;
|
||||
address created_contract;
|
||||
}
|
||||
|
||||
mapping(bytes32 => Deployment) public deployments;
|
||||
|
||||
error Reentrancy();
|
||||
@@ -51,11 +52,15 @@ contract Deployer {
|
||||
bool called;
|
||||
// This contract doesn't have any other use of transient storage, nor is to be inherited, making
|
||||
// this usage of the zero address safe
|
||||
assembly { called := tload(0) }
|
||||
assembly {
|
||||
called := tload(0)
|
||||
}
|
||||
if (called) {
|
||||
revert Reentrancy();
|
||||
}
|
||||
assembly { tstore(0, 1) }
|
||||
assembly {
|
||||
tstore(0, 1)
|
||||
}
|
||||
|
||||
// Check this wasn't prior deployed
|
||||
bytes32 init_code_hash = keccak256(init_code);
|
||||
|
||||
Reference in New Issue
Block a user