Skip to content

Commit

Permalink
Merge pull request #7 from b00ste/parse-errors-in-libraries
Browse files Browse the repository at this point in the history
feat: Parse errors in libraries
  • Loading branch information
b00ste authored Aug 3, 2023
2 parents 20421b4 + a0f48c2 commit 0a199d6
Show file tree
Hide file tree
Showing 22 changed files with 991 additions and 1,018 deletions.
8 changes: 2 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ module.exports = {
mocha: true,
node: true,
},
extends: [
'airbnb-base',
],
extends: ['airbnb-base'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
],
plugins: ['@typescript-eslint'],
rules: {
'import/extensions': ['error', 'never'],
},
Expand Down
24 changes: 22 additions & 2 deletions examples/contracts/SomeOtherLibrary/SomeOtherLibrary.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity ^0.8.6;

contract SomeOtherLibrary {
/// @notice Invalid hash.
/// @dev Reverts when hash has already been discovered.
/// @param invalidHash Invalid hash.
error SomeError(bytes32 invalidHash);

/// @notice Some Other Error fired!!!!
error SomeOtherError();

/// @dev This is the third error.
/// The error does the following things:
/// - Shows you the `functionSelector`.
/// - Shows you the `functionMask`.
/// - Shows you an error.
/// @custom:danger Be careful, this Error is dangerous!
/// @param functionSelector This is a function selector
/// @param functionMask This is a function mask
error ThirdError(bytes4 functionSelector, uint256 functionMask);

error ErrorWithoutNatspec(bytes16 somethingElse);

library SomeOtherLibrary {
/// @dev This function uses `keccak256(..)` to hash text.
/// @notice Hash returned.
/// @param someText Any text that you want to hash.
Expand All @@ -16,4 +36,4 @@ contract SomeOtherLibrary {
function someOtherFunction(string memory someText) internal pure returns(bytes32 hash) {
return sha256(bytes(someText));
}
}
}
308 changes: 154 additions & 154 deletions examples/docs/contracts/Bar.json
Original file line number Diff line number Diff line change
@@ -1,164 +1,164 @@
{
"methods": {
"constructor": {
"stateMutability": "nonpayable",
"code": "constructor(uint256 someNumber)",
"inputs": {
"someNumber": {
"type": "uint256",
"description": "The description of the parameter"
}
},
"outputs": {},
"notice": "This is the notice of the constructor",
"details": "This is a constructor",
"custom:tip": "A custom blah tag"
},
"fallback()": {
"stateMutability": "nonpayable",
"code": "fallback(bytes calldata fallbackParam) external nonpayable returns (bytes memory testtest)",
"inputs": {
"fallbackParam": {
"type": "bytes",
"description": "some details about the param"
}
},
"outputs": {
"testtest": {
"type": "bytes",
"description": "result some details about the result"
}
},
"details": "This is a fallback",
"notice": "This is the notice of the fallback",
"custom:warning": "the fallback function can return some data via assembly, but it will not be abi-encoded\n ",
"custom:hey": "hey hey hey\n ",
"custom:ho": "ho ho ho"
},
"baap(uint256,address)": {
"stateMutability": "nonpayable",
"code": "function baap(uint256 bar, address aar) external nonpayable",
"inputs": {
"bar": {
"type": "uint256",
"description": "Number of bar"
},
"aar": {
"type": "address",
"description": "Address of aar"
}
},
"outputs": {},
"notice": "Baaps the yaps"
},
"boop(uint256)": {
"stateMutability": "nonpayable",
"code": "function boop(uint256 bar) external nonpayable",
"inputs": {
"bar": {
"type": "uint256"
}
},
"outputs": {},
"notice": "Cool function bro",
"custom:requirement": "Check first requirementCheck second requirement"
},
"boop(uint256,uint256)": {
"stateMutability": "nonpayable",
"code": "function boop(uint256 bar, uint256 bar2) external nonpayable",
"inputs": {
"bar": {
"type": "uint256"
},
"bar2": {
"type": "uint256"
}
},
"outputs": {},
"notice": "Alt cool function bro"
},
"hello(bytes)": {
"stateMutability": "nonpayable",
"code": "function hello(bytes someCallData) external nonpayable",
"inputs": {
"someCallData": {
"type": "bytes",
"description": "hello tic tac toe"
}
},
"outputs": {}
},
"set(tuple)": {
"stateMutability": "nonpayable",
"code": "function set(IBar.T t) external nonpayable",
"inputs": {
"t": {
"type": "IBar.T"
}
},
"outputs": {}
"methods": {
"constructor": {
"stateMutability": "nonpayable",
"code": "constructor(uint256 someNumber)",
"inputs": {
"someNumber": {
"type": "uint256",
"description": "The description of the parameter"
}
},
"outputs": {},
"notice": "This is the notice of the constructor",
"details": "This is a constructor",
"custom:tip": "A custom blah tag"
},
"fallback()": {
"stateMutability": "nonpayable",
"code": "fallback(bytes calldata fallbackParam) external nonpayable returns (bytes memory testtest)",
"inputs": {
"fallbackParam": {
"type": "bytes",
"description": "some details about the param"
}
},
"outputs": {
"testtest": {
"type": "bytes",
"description": "result some details about the result"
}
},
"details": "This is a fallback",
"notice": "This is the notice of the fallback",
"custom:warning": "the fallback function can return some data via assembly, but it will not be abi-encoded\n ",
"custom:hey": "hey hey hey\n ",
"custom:ho": "ho ho ho"
},
"baap(uint256,address)": {
"stateMutability": "nonpayable",
"code": "function baap(uint256 bar, address aar) external nonpayable",
"inputs": {
"bar": {
"type": "uint256",
"description": "Number of bar"
},
"receive()": {
"stateMutability": "payable",
"code": "receive() external payable",
"inputs": {},
"outputs": {},
"details": "This is a `receive()` function",
"notice": "This is the notice of the `receive()` function",
"custom:info": "if sending native tokens with some graffiti, check the {`fallback()`} function documentation."
"aar": {
"type": "address",
"description": "Address of aar"
}
},
"outputs": {},
"notice": "Baaps the yaps"
},
"events": {
"Transfer": {
"code": "event Transfer(uint256 foo)",
"inputs": {
"foo": {
"type": "uint256",
"indexed": false,
"description": "Amount of stuff"
}
},
"notice": "Emitted when transfer",
"details": "Transfer some stuff",
"custom:danger": "This event exposes private info"
"boop(uint256)": {
"stateMutability": "nonpayable",
"code": "function boop(uint256 bar) external nonpayable",
"inputs": {
"bar": {
"type": "uint256"
}
},
"outputs": {},
"notice": "Cool function bro",
"custom:requirement": "Check first requirementCheck second requirement"
},
"boop(uint256,uint256)": {
"stateMutability": "nonpayable",
"code": "function boop(uint256 bar, uint256 bar2) external nonpayable",
"inputs": {
"bar": {
"type": "uint256"
},
"bar2": {
"type": "uint256"
}
},
"outputs": {},
"notice": "Alt cool function bro"
},
"errors": {
"Doh": {
"code": "error Doh(bool yay)",
"inputs": {
"yay": {
"type": "bool",
"description": "A bool"
}
},
"notice": "Thrown when doh",
"details": "Bad doh error",
"custom:info": "Additional info"
"hello(bytes)": {
"stateMutability": "nonpayable",
"code": "function hello(bytes someCallData) external nonpayable",
"inputs": {
"someCallData": {
"type": "bytes",
"description": "hello tic tac toe"
}
},
"outputs": {}
},
"internalMethods": {
"_baap(uint256,address)": {
"code": "function _baap(uint256 bar, address aar) internal nonpayable",
"inputs": {
"bar": {
"type": "uint256",
"description": "Number of bar"
},
"aar": {
"type": "address",
"description": "Address of aar"
}
},
"outputs": {},
"notice": "Baaps the yaps internally"
"set(tuple)": {
"stateMutability": "nonpayable",
"code": "function set(IBar.T t) external nonpayable",
"inputs": {
"t": {
"type": "IBar.T"
}
},
"outputs": {}
},
"path": "",
"title": "Bar contract",
"notice": "Manages the bar",
"details": "Blablou",
"author": "Primitive",
"custom:version": "v2.0.1",
"name": "Bar"
}
"receive()": {
"stateMutability": "payable",
"code": "receive() external payable",
"inputs": {},
"outputs": {},
"details": "This is a `receive()` function",
"notice": "This is the notice of the `receive()` function",
"custom:info": "if sending native tokens with some graffiti, check the {`fallback()`} function documentation."
}
},
"events": {
"Transfer": {
"code": "event Transfer(uint256 foo)",
"inputs": {
"foo": {
"type": "uint256",
"indexed": false,
"description": "Amount of stuff"
}
},
"notice": "Emitted when transfer",
"details": "Transfer some stuff",
"custom:danger": "This event exposes private info"
}
},
"errors": {
"Doh": {
"code": "error Doh(bool yay)",
"inputs": {
"yay": {
"type": "bool",
"description": "A bool"
}
},
"notice": "Thrown when doh",
"details": "Bad doh error",
"custom:info": "Additional info"
}
},
"internalMethods": {
"_baap(uint256,address)": {
"code": "function _baap(uint256 bar, address aar) internal nonpayable",
"inputs": {
"bar": {
"type": "uint256",
"description": "Number of bar"
},
"aar": {
"type": "address",
"description": "Address of aar"
}
},
"outputs": {},
"notice": "Baaps the yaps internally"
}
},
"path": "",
"title": "Bar contract",
"notice": "Manages the bar",
"details": "Blablou",
"author": "Primitive",
"custom:version": "v2.0.1",
"name": "Bar"
}
Loading

0 comments on commit 0a199d6

Please sign in to comment.