From 31b062a52d6a53c813393368822986056a57dd03 Mon Sep 17 00:00:00 2001 From: adu Date: Mon, 1 Jul 2024 16:56:31 +0800 Subject: [PATCH] fix(typo): TOKEN_ADDRESS_BYTES_LENTH => TOKEN_ADDRESS_BYTES_LENGTH --- script/3_Setup.s.sol | 2 +- script/BaseScript.sol | 2 +- src/core/ClientGatewayLzReceiver.sol | 6 +++--- src/storage/ClientChainGatewayStorage.sol | 2 +- src/storage/ExocoreGatewayStorage.sol | 2 +- test/foundry/unit/ExocoreGateway.t.sol | 22 +++++++++++----------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/script/3_Setup.s.sol b/script/3_Setup.s.sol index 92e9e364..2284f3c0 100644 --- a/script/3_Setup.s.sol +++ b/script/3_Setup.s.sol @@ -101,7 +101,7 @@ contract SetupScript is BaseScript { names[1] = "RestakeToken"; metaData[1] = ""; - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokensBytes32.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokensBytes32.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); exocoreGateway.addWhitelistTokens{value: nativeFee}( clientChainId, whitelistTokensBytes32, decimals, tvlLimits, names, metaData diff --git a/script/BaseScript.sol b/script/BaseScript.sol index abaeefc1..8a82a90e 100644 --- a/script/BaseScript.sol +++ b/script/BaseScript.sol @@ -70,7 +70,7 @@ contract BaseScript is Script { uint256 constant DEPOSIT_AMOUNT = 1 ether; uint256 constant WITHDRAW_AMOUNT = 1 ether; address internal constant VIRTUAL_STAKED_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; - uint256 internal constant TOKEN_ADDRESS_BYTES_LENTH = 32; + uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32; bool useExocorePrecompileMock; bool useEndpointMock; diff --git a/src/core/ClientGatewayLzReceiver.sol b/src/core/ClientGatewayLzReceiver.sol index 8ffad5db..b0d9d6b8 100644 --- a/src/core/ClientGatewayLzReceiver.sol +++ b/src/core/ClientGatewayLzReceiver.sol @@ -189,14 +189,14 @@ abstract contract ClientGatewayLzReceiver is PausableUpgradeable, OAppReceiverUp whenNotPaused { uint8 count = uint8(requestPayload[0]); - uint256 expectedLength = count * TOKEN_ADDRESS_BYTES_LENTH + 1; + uint256 expectedLength = count * TOKEN_ADDRESS_BYTES_LENGTH + 1; if (requestPayload.length != expectedLength) { revert InvalidAddWhitelistTokensRequest(expectedLength, requestPayload.length); } for (uint256 i; i < count; i++) { - uint256 start = i * TOKEN_ADDRESS_BYTES_LENTH + 1; - uint256 end = start + TOKEN_ADDRESS_BYTES_LENTH; + uint256 start = i * TOKEN_ADDRESS_BYTES_LENGTH + 1; + uint256 end = start + TOKEN_ADDRESS_BYTES_LENGTH; address token = address(bytes20(requestPayload[start:end])); if (!isWhitelistedToken[token]) { diff --git a/src/storage/ClientChainGatewayStorage.sol b/src/storage/ClientChainGatewayStorage.sol index 86eee8ab..d32bbaca 100644 --- a/src/storage/ClientChainGatewayStorage.sol +++ b/src/storage/ClientChainGatewayStorage.sol @@ -28,7 +28,7 @@ contract ClientChainGatewayStorage is BootstrapStorage { uint256 internal constant GWEI_TO_WEI = 1e9; address internal constant VIRTUAL_STAKED_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; IETHPOSDeposit internal constant ETH_POS = IETHPOSDeposit(0x00000000219ab540356cBB839Cbe05303d7705Fa); - uint256 internal constant TOKEN_ADDRESS_BYTES_LENTH = 32; + uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32; uint256[40] private __gap; diff --git a/src/storage/ExocoreGatewayStorage.sol b/src/storage/ExocoreGatewayStorage.sol index af0b3506..06f2c777 100644 --- a/src/storage/ExocoreGatewayStorage.sol +++ b/src/storage/ExocoreGatewayStorage.sol @@ -16,7 +16,7 @@ contract ExocoreGatewayStorage is GatewayStorage { uint256 internal constant CLAIM_REWARD_REQUEST_LENGTH = 96; // bytes32 token + bytes32 delegator + bytes(42) operator + uint256 amount uint256 internal constant DEPOSIT_THEN_DELEGATE_REQUEST_LENGTH = DELEGATE_REQUEST_LENGTH; - uint256 internal constant TOKEN_ADDRESS_BYTES_LENTH = 32; + uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32; uint256 internal constant UINT8_BYTES_LENGTH = 1; uint256 internal constant UINT256_BYTES_LENGTH = 32; diff --git a/test/foundry/unit/ExocoreGateway.t.sol b/test/foundry/unit/ExocoreGateway.t.sol index 69c63688..203b80e0 100644 --- a/test/foundry/unit/ExocoreGateway.t.sol +++ b/test/foundry/unit/ExocoreGateway.t.sol @@ -191,7 +191,7 @@ contract AddWhitelistTokens is SetUp { using stdStorage for StdStorage; using AddressCast for address; - uint256 internal constant TOKEN_ADDRESS_BYTES_LENTH = 32; + uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32; event WhitelistTokenAdded(uint32 clientChainId, bytes32 token); @@ -204,7 +204,7 @@ contract AddWhitelistTokens is SetUp { function test_RevertWhen_CallerNotOwner() public { _prepareInputs(2); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(deployer.addr); @@ -220,7 +220,7 @@ contract AddWhitelistTokens is SetUp { _prepareInputs(2); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.expectRevert(PausableUpgradeable.EnforcedPause.selector); exocoreGateway.addWhitelistTokens{value: nativeFee}( @@ -232,7 +232,7 @@ contract AddWhitelistTokens is SetUp { uint32 anotherClientChain = 3; _prepareInputs(2); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(exocoreValidatorSet.addr); @@ -247,7 +247,7 @@ contract AddWhitelistTokens is SetUp { function test_RevertWhen_TokensListTooLong() public { _prepareInputs(256); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(exocoreValidatorSet.addr); @@ -261,7 +261,7 @@ contract AddWhitelistTokens is SetUp { _prepareInputs(2); decimals.push(18); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(exocoreValidatorSet.addr); @@ -277,7 +277,7 @@ contract AddWhitelistTokens is SetUp { tvlLimits[0] = 1e8 ether; tvlLimits[1] = 1e8 ether; - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(exocoreValidatorSet.addr); @@ -291,7 +291,7 @@ contract AddWhitelistTokens is SetUp { _prepareInputs(1); whitelistTokens[0] = bytes32(bytes20(address(restakeToken))); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(exocoreValidatorSet.addr); @@ -309,7 +309,7 @@ contract AddWhitelistTokens is SetUp { names[0] = "RestakeToken"; metaData[0] = ""; - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); vm.startPrank(exocoreValidatorSet.addr); @@ -347,7 +347,7 @@ contract UpdateWhitelistTokens is SetUp { using AddressCast for address; - uint256 internal constant TOKEN_ADDRESS_BYTES_LENTH = 32; + uint256 internal constant TOKEN_ADDRESS_BYTES_LENGTH = 32; event WhitelistTokenUpdated(uint32 clientChainId, bytes32 token); @@ -489,7 +489,7 @@ contract UpdateWhitelistTokens is SetUp { string[] memory metaData_ ) internal { vm.startPrank(exocoreValidatorSet.addr); - uint256 messageLength = TOKEN_ADDRESS_BYTES_LENTH * whitelistTokens.length + 2; + uint256 messageLength = TOKEN_ADDRESS_BYTES_LENGTH * whitelistTokens.length + 2; uint256 nativeFee = exocoreGateway.quote(clientChainId, new bytes(messageLength)); exocoreGateway.addWhitelistTokens{value: nativeFee}( clientChainId_, whitelistTokens_, decimals_, tvlLimits_, names_, metaData_