Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Jan 3, 2025
1 parent 72c11a5 commit 177409e
Show file tree
Hide file tree
Showing 55 changed files with 320 additions and 509 deletions.
12 changes: 3 additions & 9 deletions contracts/governance/ValidatorSetSig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,14 @@ contract ValidatorSetSig is ReentrancyGuard {
*/
event Delivered(address indexed targetContractAddress, uint256 indexed nonce);

constructor(
bytes32 validatorBlockchainID_
) {
constructor(bytes32 validatorBlockchainID_) {
validatorBlockchainID = validatorBlockchainID_;
blockchainID = WARP_MESSENGER.getBlockchainID();
}

receive() external payable {}

function executeCall(
uint32 messageIndex
) external payable nonReentrant {
function executeCall(uint32 messageIndex) external payable nonReentrant {
// Get the WarpMessage from the WarpMessenger precompile and verify that it is valid
(WarpMessage memory message, bool valid) =
WARP_MESSENGER.getVerifiedWarpMessage(messageIndex);
Expand Down Expand Up @@ -131,9 +127,7 @@ contract ValidatorSetSig is ReentrancyGuard {
emit Delivered(validatorSetSigMessage.targetContractAddress, validatorSetSigMessage.nonce);
}

function validateMessage(
ValidatorSetSigMessage memory message
) public view {
function validateMessage(ValidatorSetSigMessage memory message) public view {
require(
message.targetBlockchainID == blockchainID,
"ValidatorSetSig: invalid targetBlockchainID"
Expand Down
12 changes: 3 additions & 9 deletions contracts/ictt/TokenHome/ERC20TokenHomeUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ contract ERC20TokenHomeUpgradeable is IERC20TokenHome, TokenHome {
}
}

constructor(
ICMInitializable init
) {
constructor(ICMInitializable init) {
if (init == ICMInitializable.Disallowed) {
_disableInitializers();
}
Expand Down Expand Up @@ -109,9 +107,7 @@ contract ERC20TokenHomeUpgradeable is IERC20TokenHome, TokenHome {
}

// solhint-disable-next-line func-name-mixedcase
function __ERC20TokenHome_init_unchained(
address tokenAddress
) internal onlyInitializing {
function __ERC20TokenHome_init_unchained(address tokenAddress) internal onlyInitializing {
_getERC20TokenHomeStorage()._token = IERC20(tokenAddress);
}
// solhint-enable ordering
Expand Down Expand Up @@ -150,9 +146,7 @@ contract ERC20TokenHomeUpgradeable is IERC20TokenHome, TokenHome {
/**
* @dev See {TokenHome-_deposit}
*/
function _deposit(
uint256 amount
) internal virtual override returns (uint256) {
function _deposit(uint256 amount) internal virtual override returns (uint256) {
ERC20TokenHomeStorage storage $ = _getERC20TokenHomeStorage();
return SafeERC20TransferFrom.safeTransferFrom($._token, _msgSender(), amount);
}
Expand Down
23 changes: 8 additions & 15 deletions contracts/ictt/TokenHome/NativeTokenHomeUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ contract NativeTokenHomeUpgradeable is INativeTokenHome, TokenHome {
}
}

constructor(
ICMInitializable init
) {
constructor(ICMInitializable init) {
if (init == ICMInitializable.Disallowed) {
_disableInitializers();
}
Expand Down Expand Up @@ -106,9 +104,10 @@ contract NativeTokenHomeUpgradeable is INativeTokenHome, TokenHome {
}

// solhint-disable-next-line func-name-mixedcase
function __NativeTokenHome_init_unchained(
address wrappedTokenAddress
) internal onlyInitializing {
function __NativeTokenHome_init_unchained(address wrappedTokenAddress)
internal
onlyInitializing
{
_getNativeTokenHomeStorage()._wrappedToken = IWrappedNativeToken(wrappedTokenAddress);
}
// solhint-enable ordering
Expand All @@ -127,18 +126,14 @@ contract NativeTokenHomeUpgradeable is INativeTokenHome, TokenHome {
/**
* @dev See {INativeTokenTransferrer-send}
*/
function send(
SendTokensInput calldata input
) external payable {
function send(SendTokensInput calldata input) external payable {
_send(input, msg.value);
}

/**
* @dev See {INativeTokenTransferrer-sendAndCall}
*/
function sendAndCall(
SendAndCallInput calldata input
) external payable {
function sendAndCall(SendAndCallInput calldata input) external payable {
_sendAndCall({
sourceBlockchainID: getBlockchainID(),
originTokenTransferrerAddress: address(this),
Expand All @@ -162,9 +157,7 @@ contract NativeTokenHomeUpgradeable is INativeTokenHome, TokenHome {
* @dev See {TokenHome-_deposit}
* Deposits the native tokens sent to this contract
*/
function _deposit(
uint256 amount
) internal virtual override returns (uint256) {
function _deposit(uint256 amount) internal virtual override returns (uint256) {
NativeTokenHomeStorage storage $ = _getNativeTokenHomeStorage();
return SafeWrappedNativeTokenDeposit.safeDeposit($._wrappedToken, amount);
}
Expand Down
12 changes: 3 additions & 9 deletions contracts/ictt/TokenHome/TokenHome.sol
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,7 @@ abstract contract TokenHome is
* @param amount The initial amount sent to this contract.
* @return The actual amount deposited to this contract.
*/
function _deposit(
uint256 amount
) internal virtual returns (uint256);
function _deposit(uint256 amount) internal virtual returns (uint256);

/**
* @notice Withdraws tokens to the recipient address.
Expand Down Expand Up @@ -800,9 +798,7 @@ abstract contract TokenHome is
senderBalance - amount;
}

function _validateSendAndCallInput(
SendAndCallInput memory input
) private pure {
function _validateSendAndCallInput(SendAndCallInput memory input) private pure {
require(input.recipientContract != address(0), "TokenHome: zero recipient contract address");
require(input.requiredGasLimit > 0, "TokenHome: zero required gas limit");
require(input.recipientGasLimit > 0, "TokenHome: zero recipient gas limit");
Expand All @@ -814,9 +810,7 @@ abstract contract TokenHome is
require(input.secondaryFee == 0, "TokenHome: non-zero secondary fee");
}

function _validateSendTokensInput(
SendTokensInput memory input
) private pure {
function _validateSendTokensInput(SendTokensInput memory input) private pure {
require(input.recipient != address(0), "TokenHome: zero recipient address");
require(input.requiredGasLimit > 0, "TokenHome: zero required gas limit");
require(input.secondaryFee == 0, "TokenHome: non-zero secondary fee");
Expand Down
12 changes: 3 additions & 9 deletions contracts/ictt/TokenRemote/ERC20TokenRemoteUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ contract ERC20TokenRemoteUpgradeable is IERC20TokenTransferrer, ERC20Upgradeable
}
}

constructor(
ICMInitializable init
) {
constructor(ICMInitializable init) {
if (init == ICMInitializable.Disallowed) {
_disableInitializers();
}
Expand Down Expand Up @@ -97,9 +95,7 @@ contract ERC20TokenRemoteUpgradeable is IERC20TokenTransferrer, ERC20Upgradeable
}

// solhint-disable-next-line func-name-mixedcase
function __ERC20TokenRemote_init_unchained(
uint8 tokenDecimals
) internal {
function __ERC20TokenRemote_init_unchained(uint8 tokenDecimals) internal {
_getERC20TokenRemoteStorage()._decimals = tokenDecimals;
}
// solhint-enable ordering
Expand Down Expand Up @@ -149,9 +145,7 @@ contract ERC20TokenRemoteUpgradeable is IERC20TokenTransferrer, ERC20Upgradeable
* Child contracts with different {_burn} implementations may need to override this
* implemenation to ensure the amount returned is correct.
*/
function _burn(
uint256 amount
) internal virtual override returns (uint256) {
function _burn(uint256 amount) internal virtual override returns (uint256) {
_spendAllowance(_msgSender(), address(this), amount);
_burn(_msgSender(), amount);
return amount;
Expand Down
31 changes: 10 additions & 21 deletions contracts/ictt/TokenRemote/NativeTokenRemoteUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ contract NativeTokenRemoteUpgradeable is
_;
}

constructor(
ICMInitializable init
) {
constructor(ICMInitializable init) {
if (init == ICMInitializable.Disallowed) {
_disableInitializers();
}
Expand Down Expand Up @@ -175,9 +173,10 @@ contract NativeTokenRemoteUpgradeable is
}

// solhint-disable-next-line func-name-mixedcase
function __NativeTokenRemote_init_unchained(
uint256 burnedFeesReportingRewardPercentage
) internal onlyInitializing {
function __NativeTokenRemote_init_unchained(uint256 burnedFeesReportingRewardPercentage)
internal
onlyInitializing
{
require(burnedFeesReportingRewardPercentage < 100, "NativeTokenRemote: invalid percentage");
_getNativeTokenRemoteStorage()._burnedFeesReportingRewardPercentage =
burnedFeesReportingRewardPercentage;
Expand All @@ -203,27 +202,21 @@ contract NativeTokenRemoteUpgradeable is
/**
* @dev See {INativeTokenTransferrer-send}.
*/
function send(
SendTokensInput calldata input
) external payable onlyWhenCollateralized {
function send(SendTokensInput calldata input) external payable onlyWhenCollateralized {
_send(input, msg.value);
}

/**
* @dev See {INativeTokenTransferrer-sendAndCall}
*/
function sendAndCall(
SendAndCallInput calldata input
) external payable onlyWhenCollateralized {
function sendAndCall(SendAndCallInput calldata input) external payable onlyWhenCollateralized {
_sendAndCall(input, msg.value);
}

/**
* @dev See {INativeTokenRemote-reportBurnedTxFees}.
*/
function reportBurnedTxFees(
uint256 requiredGasLimit
) external sendNonReentrant {
function reportBurnedTxFees(uint256 requiredGasLimit) external sendNonReentrant {
NativeTokenRemoteStorage storage $ = _getNativeTokenRemoteStorage();
uint256 burnAddressBalance = BURNED_TX_FEES_ADDRESS.balance;
require(
Expand Down Expand Up @@ -282,9 +275,7 @@ contract NativeTokenRemoteUpgradeable is
* for the native token itself. {TokenRemote-_withdraw} is the internal method used when
* processing token transfers.
*/
function withdraw(
uint256 amount
) external {
function withdraw(uint256 amount) external {
emit Withdrawal(_msgSender(), amount);
_burn(_msgSender(), amount);
payable(_msgSender()).sendValue(amount);
Expand Down Expand Up @@ -335,9 +326,7 @@ contract NativeTokenRemoteUpgradeable is
* The tokens to be burnt are already held by this contract. To burn the tokens, send the
* native token amount to the BURNED_FOR_TRANSFER_ADDRESS.
*/
function _burn(
uint256 amount
) internal virtual override returns (uint256) {
function _burn(uint256 amount) internal virtual override returns (uint256) {
payable(BURNED_FOR_TRANSFER_ADDRESS).sendValue(amount);
return amount;
}
Expand Down
20 changes: 5 additions & 15 deletions contracts/ictt/TokenRemote/TokenRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ abstract contract TokenRemote is
* instance. TokenRemote instances must be registered with their home contract prior to being able to receive
* tokens from them.
*/
function registerWithHome(
TeleporterFeeInfo calldata feeInfo
) external virtual {
function registerWithHome(TeleporterFeeInfo calldata feeInfo) external virtual {
TokenRemoteStorage storage $ = _getTokenRemoteStorage();
require(!$._isRegistered, "TokenRemote: already registered");

Expand Down Expand Up @@ -238,9 +236,7 @@ abstract contract TokenRemote is
* @dev Calculates the number of 32-byte words required to fit a payload of a given length.
* The payloads are padded to have a length that is a multiple of 32.
*/
function calculateNumWords(
uint256 payloadSize
) public pure returns (uint256) {
function calculateNumWords(uint256 payloadSize) public pure returns (uint256) {
// Add 31 to effectively round up to the nearest multiple of 32.
// Right-shift by 5 bits to divide by 32.
return (payloadSize + 31) >> 5;
Expand Down Expand Up @@ -380,9 +376,7 @@ abstract contract TokenRemote is
* @return The amount of tokens burned, which is the amount to credit
* for the token transfer.
*/
function _burn(
uint256 amount
) internal virtual returns (uint256);
function _burn(uint256 amount) internal virtual returns (uint256);

/**
* @notice Processes a send and call message by calling the recipient contract.
Expand Down Expand Up @@ -680,9 +674,7 @@ abstract contract TokenRemote is
require(multiHopFallback != address(0), "TokenRemote: zero multi-hop fallback");
}

function _validateSendTokensInput(
SendTokensInput calldata input
) private pure {
function _validateSendTokensInput(SendTokensInput calldata input) private pure {
require(input.recipient != address(0), "TokenRemote: zero recipient address");
require(input.requiredGasLimit > 0, "TokenRemote: zero required gas limit");
require(
Expand All @@ -695,9 +687,7 @@ abstract contract TokenRemote is
);
}

function _validateSendAndCallInput(
SendAndCallInput calldata input
) private pure {
function _validateSendAndCallInput(SendAndCallInput calldata input) private pure {
require(
input.destinationBlockchainID != bytes32(0),
"TokenRemote: zero destination blockchain ID"
Expand Down
4 changes: 1 addition & 3 deletions contracts/ictt/TokenRemote/interfaces/INativeTokenRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ interface INativeTokenRemote is ITokenRemote, INativeTokenTransferrer {
* @notice Reports the increase in total burned transaction fees on this chain to its corresponding TokenHome instance.
* @param requiredGasLimit The gas limit required to report the burned transaction fees to the home contract.
*/
function reportBurnedTxFees(
uint256 requiredGasLimit
) external;
function reportBurnedTxFees(uint256 requiredGasLimit) external;

/**
* @notice Returns a best-estimate (upper bound) of the supply of the native asset
Expand Down
4 changes: 1 addition & 3 deletions contracts/ictt/TokenRemote/interfaces/ITokenRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ interface ITokenRemote is ITokenTransferrer {
* @notice Sends a Teleporter message to register the TokenRemote instance with its configured home.
* @param feeInfo The optional fee asset and amount for the Teleporter message, for relayer incentivization.
*/
function registerWithHome(
TeleporterFeeInfo calldata feeInfo
) external;
function registerWithHome(TeleporterFeeInfo calldata feeInfo) external;
}
10 changes: 4 additions & 6 deletions contracts/ictt/WrappedNativeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {Address} from "@openzeppelin/[email protected]/utils/Address.sol";
contract WrappedNativeToken is IWrappedNativeToken, ERC20 {
using Address for address payable;

constructor(
string memory symbol
) ERC20(string.concat("Wrapped ", symbol), string.concat("W", symbol)) {}
constructor(string memory symbol)
ERC20(string.concat("Wrapped ", symbol), string.concat("W", symbol))
{}

receive() external payable {
deposit();
Expand All @@ -24,9 +24,7 @@ contract WrappedNativeToken is IWrappedNativeToken, ERC20 {
deposit();
}

function withdraw(
uint256 amount
) external {
function withdraw(uint256 amount) external {
_burn(_msgSender(), amount);
emit Withdrawal(_msgSender(), amount);
payable(_msgSender()).sendValue(amount);
Expand Down
8 changes: 2 additions & 6 deletions contracts/ictt/interfaces/INativeTokenTransferrer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ interface INativeTokenTransferrer is ITokenTransferrer {
* @notice Sends native tokens to the specified destination.
* @param input Specifies information for delivery of the tokens
*/
function send(
SendTokensInput calldata input
) external payable;
function send(SendTokensInput calldata input) external payable;

/**
* @notice Sends native tokens to the specified destination to be used in a smart contract interaction.
* @param input Specifies information for delivery of the tokens to the remote contract and contract to be called
* on the remote chain.
*/
function sendAndCall(
SendAndCallInput calldata input
) external payable;
function sendAndCall(SendAndCallInput calldata input) external payable;
}
4 changes: 1 addition & 3 deletions contracts/ictt/interfaces/IWrappedNativeToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,5 @@ interface IWrappedNativeToken is IERC20 {
* @notice Withdraws native tokens for wrapped tokens.
* @param amount Amount of native tokens to withdraw
*/
function withdraw(
uint256 amount
) external;
function withdraw(uint256 amount) external;
}
Loading

0 comments on commit 177409e

Please sign in to comment.