Skip to content

Commit

Permalink
feat(contracts): add selectors to error file and update erc20 unimple…
Browse files Browse the repository at this point in the history
…mented
  • Loading branch information
koloz193 committed Jun 4, 2024
1 parent 994897b commit 18178af
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
15 changes: 15 additions & 0 deletions l2-contracts/contracts/L2ContractErrors.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

// 0xcbd9d2e0
error InvalidCaller(address);
// 0xb4fa3fb3
error InvalidInput();
// 0x2a1b2dd8
error InsufficientAllowance(uint256 providedAllowance, uint256 requiredAmount);
// 0x1bdfd505
error FailedToTransferTokens(address tokenContract, address to, uint256 amount);
// 0xff15b069
error UnsupportedPaymasterFlow();
// 0x7138356f
error EmptyAddress();
// 0x1c25715b
error EmptyBytes32();
// 0x1f73225f
error AddressMismatch(address expected, address supplied);
// 0x5e85ae73
error AmountMustBeGreaterThanZero();
// 0xb4f54111
error DeployFailed();
// 0x82b42900
error Unauthorized();
// 0x0ac76f01
error NonSequentialVersion();
// 0x6e128399
error Unimplemented();
// 0xa4dde386
error UnimplementedMessage(string);
// 0x750b219c
error WithdrawFailed();

string constant BRIDGE_MINT_NOT_IMPLEMENTED = "bridgeMint is not implemented! Use deposit/depositTo methods instead.";
8 changes: 4 additions & 4 deletions l2-contracts/contracts/bridge/L2StandardERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/Upgradeabl
import {ERC1967Upgrade} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol";

import {IL2StandardToken} from "./interfaces/IL2StandardToken.sol";
import {EmptyAddress, Unauthorized, NonSequentialVersion, Unimplemented} from "../L2ContractErrors.sol";
import {EmptyAddress, Unauthorized, NonSequentialVersion} from "../L2ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
Expand Down Expand Up @@ -167,19 +167,19 @@ contract L2StandardERC20 is ERC20PermitUpgradeable, IL2StandardToken, ERC1967Upg

function name() public view override returns (string memory) {
// If method is not available, behave like a token that does not implement this method - revert on call.
if (availableGetters.ignoreName) revert Unimplemented();
if (availableGetters.ignoreName) revert();

Check failure on line 170 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 170 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements

Check failure on line 170 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 170 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements

Check failure on line 170 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 170 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements
return super.name();
}

function symbol() public view override returns (string memory) {
// If method is not available, behave like a token that does not implement this method - revert on call.
if (availableGetters.ignoreSymbol) revert Unimplemented();
if (availableGetters.ignoreSymbol) revert();

Check failure on line 176 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 176 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements

Check failure on line 176 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 176 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements

Check failure on line 176 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 176 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements
return super.symbol();
}

function decimals() public view override returns (uint8) {
// If method is not available, behave like a token that does not implement this method - revert on call.
if (availableGetters.ignoreDecimals) revert Unimplemented();
if (availableGetters.ignoreDecimals) revert();

Check failure on line 182 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 182 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements

Check failure on line 182 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 182 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements

Check failure on line 182 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

Provide an error message for revert

Check failure on line 182 in l2-contracts/contracts/bridge/L2StandardERC20.sol

View workflow job for this annotation

GitHub Actions / lint

GC: Use Custom Errors instead of revert statements
return decimals_;
}

Expand Down
44 changes: 44 additions & 0 deletions system-contracts/contracts/SystemContractErrors.sol
Original file line number Diff line number Diff line change
@@ -1,49 +1,93 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

// 0x8e4a23d6
error Unauthorized(address);
// 0x6a84bc39
error InvalidCodeHash(CodeHashReason);
// 0x17a84415
error UnsupportedTxType(uint256);
// 0x86bb51b8
error AddressHasNoCode(address);
// 0x608aa3da
error EncodingLengthMismatch();
// 0x4e23d035
error IndexOutOfBounds();
// 0x460b9939
error ValuesNotEqual(uint256 expected, uint256 actual);
// 0x86302004
error HashMismatch(bytes32 expected, uint256 actual);
// 0x122e73e9
error IndexSizeError();
// 0x9ba6061b
error UnsupportedOperation();
// 0x60b85677
error InvalidNonceOrderingChange();
// 0x1c25715b
error EmptyBytes32();
// 0x50df6bc3
error NotAllowedToDeployInKernelSpace();
// 0x9e4a3c8a
error HashIsNonZero(bytes32);
// 0x760a1568
error NonEmptyAccount();
// 0x3e5efef9
error UnknownCodeHash(bytes32);
// 0x536ec84b
error NonEmptyMsgValue();
// 0x03eb8b54
error InsufficientFunds(uint256 required, uint256 actual);
// 0x90f049c9
error InvalidSig(SigField, uint256);
// 0x1f70c58f
error FailedToPayOperator();
// 0x1c26714c
error InsufficientGas();
// 0x43e266b0
error MalformedBytecode(BytecodeError);
// 0x7f7b0cf7
error ReconstructionMismatch(PubdataField, bytes32 expected, bytes32 actual);
// 0xae962d4e
error InvalidCall();
// 0x45ac24a6
error NonceIncreaseError(uint256 max, uint256 proposed);
// 0x6818f3f9
error ZeroNonceError();
// 0x13595475
error NonceJumpError();
// 0xe90aded4
error NonceAlreadyUsed(address account, uint256 nonce);
// 0x1f2f8478
error NonceNotUsed(address account, uint256 nonce);
// 0xe0456dfe
error TooMuchPubdata(uint256 limit, uint256 supplied);
// 0x5708aead
error UpgradeMustBeFirstTxn();
// 0xd2906dd9
error L2BlockMustBeGreaterThanZero();
// 0x9d5da395
error FirstL2BlockInitializationError();
// 0xd018e08e
error NonIncreasingTimestamp();
// 0x92bf3cf8
error EmptyVirtualBlocks();
// 0x71c3da01
error SystemCallFlagRequired();
// 0x9eedbd2b
error CallerMustBeSystemContract();
// 0xefce78c7
error CallerMustBeBootloader();
// 0xb7549616
error CallerMustBeForceDeployer();
// 0x5cb045db
error InvalidData();
// 0xe95a1fbe
error FailedToChargeGas();
// 0x35278d12
error Overflow();
// 0xb4fa3fb3
error InvalidInput();
// 0xff15b069
error UnsupportedPaymasterFlow();

enum CodeHashReason {
Expand Down

0 comments on commit 18178af

Please sign in to comment.