├── .babelrc ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── README.md ├── package.json ├── src ├── abi2solidity.js └── index.js ├── test ├── SmolTest.sol ├── abi │ └── SmolTest.abi ├── index.spec.js ├── oraclizeLib-out.sol ├── oraclizeLib.abi ├── test-solidity-v0.8.x.abi ├── test-solidity-v0.8.x.sol ├── test1-out.sol ├── test1.abi └── test2.abi └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "targets": { 7 | "node": 6 8 | } 9 | } 10 | ], 11 | "stage-2" 12 | ], 13 | "plugins": [ 14 | "add-module-exports" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb", 3 | "env": { 4 | "jest": true, 5 | "node": true 6 | }, 7 | "parserOptions": { 8 | }, 9 | "rules": {} 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | dist/ 64 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # abi2solidity 2 | 3 | Convert an ABI to a Solidity interface 4 | 5 | ## Install 6 | 7 | ```shell 8 | $ npm install --save abi2solidity 9 | # OR 10 | $ yarn add abi2solidity 11 | ``` 12 | 13 | If you want to use the cli, you can install it globally: 14 | 15 | ```shell 16 | $ npm install --global abi2solidity 17 | # OR 18 | $ yarn global add abi2solidity 19 | ``` 20 | 21 | ## CLI Usage 22 | 23 | ```shell 24 | $ abi2solidity -h 25 | Usage: abi2solidity [options] 26 | 27 | Options: 28 | -V, --version output the version number 29 | -i, --input JSON ABI Input file (default: "") 30 | -o, --output Solidity output file (default: "") 31 | -e, --header Set the header (default: "") 32 | -n, --interface-name Set the interface name (default: "GeneratedInterface") 33 | -h, --help display help for command 34 | 35 | # Examples 36 | $ abi2solidity -i abi.json -o export.sol 37 | $ abi2solidity --header "" --interface-name McNulty < test/abi/SmolTest.abi 38 | $ abi2solidity --header "" --interface-name McNulty < test/abi/SmolTest.abi 39 | $ abi2solidity --header "`printf "// SPDX-License-Identifier: MIT\\npragma solidity >=0.1.0 <0.9.0;\n "`" --interface-name McNulty < test/abi/SmolTest.abi 40 | ``` 41 | 42 | ## Code Usage 43 | 44 | ```js 45 | import ABI2solidity from "abi2solidity"; 46 | 47 | const ABI = ` 48 | [ 49 | { 50 | "constant": false, 51 | "inputs": [], 52 | "name": "f", 53 | "outputs": [ 54 | { 55 | "name": "", 56 | "type": "uint256" 57 | } 58 | ], 59 | "payable": false, 60 | "stateMutability": "nonpayable", 61 | "type": "function" 62 | } 63 | ] 64 | `; 65 | 66 | const solidity = ABI2solidity(ABI); 67 | console.log(solidity); 68 | // Will print out: 69 | // interface GeneratedInterface { 70 | // function f ( ) external returns ( uint256 ); 71 | // } 72 | ``` 73 | 74 | Alternative usage with files: 75 | 76 | ```js 77 | import { ABI2solidityFiles } from "abi2solidity"; 78 | 79 | ABI2solidityFiles(inputFileABI, outputFileSolidity); 80 | ``` 81 | 82 | # Development 83 | 84 | Run tests 85 | 86 | ```shell 87 | $ yarn test 88 | ``` 89 | 90 | # License 91 | 92 | MIT 93 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "abi2solidity", 3 | "version": "0.2.0", 4 | "description": "Converts an Ethereum ABI to a Solidity interface", 5 | "author": { 6 | "name": "Maxime Biais", 7 | "email": "maxime.biais@gmail.com" 8 | }, 9 | "main": "dist/abi2solidity.js", 10 | "devDependencies": { 11 | "babel-cli": "^6.26.0", 12 | "babel-eslint": "^7.2.3", 13 | "babel-jest": "^20.0.3", 14 | "babel-plugin-add-module-exports": "^0.2.1", 15 | "babel-preset-env": "^1.6.0", 16 | "babel-preset-stage-2": "^6.24.1", 17 | "coveralls": "^2.13.1", 18 | "del-cli": "^1.1.0", 19 | "documentation": "4.0.0-rc.1", 20 | "eslint": "^4.1.0", 21 | "eslint-config-airbnb": "^17.1.0", 22 | "eslint-plugin-import": "^2.14.0", 23 | "eslint-plugin-jsx-a11y": "^6.1.2", 24 | "eslint-plugin-react": "^7.11.1", 25 | "jest": "^19.0.2", 26 | "jest-cli": "^20.0.0", 27 | "solc": "0.8.15" 28 | }, 29 | "engines": { 30 | "node": ">=6.0.0" 31 | }, 32 | "dependencies": { 33 | "commander": "^9.3.0" 34 | }, 35 | "jest": { 36 | "testEnvironment": "node" 37 | }, 38 | "scripts": { 39 | "start": "babel-node -- src/index.js", 40 | "start-built": "node dist/index.js", 41 | "build": "babel src -d dist", 42 | "test": "jest", 43 | "lint": "eslint src test", 44 | "lint-fix": "yarn lint -- --fix", 45 | "clean": "del dist", 46 | "coverage": "yarn test -- --coverage", 47 | "preversion": "yarn lint && yarn test && yarn build", 48 | "prepublish": "yarn lint && yarn test && yarn build" 49 | }, 50 | "files": [ 51 | "dist" 52 | ], 53 | "bin": { 54 | "abi2solidity": "dist/index.js" 55 | }, 56 | "license": "MIT" 57 | } 58 | -------------------------------------------------------------------------------- /src/abi2solidity.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | 3 | function injectOutMemory(input) { 4 | if (input === 'string' || input === 'address[]') { 5 | return `${input} memory`; 6 | } 7 | return input; 8 | } 9 | 10 | function getInOrOut(inputs) { 11 | let out = ''; 12 | for (let i = 0; i < inputs.length; i += 1) { 13 | out += injectOutMemory(inputs[i].type); 14 | if (inputs[i].name) { 15 | out += ` ${inputs[i].name}`; 16 | } 17 | if (i !== inputs.length - 1) { 18 | out += ', '; 19 | } 20 | } 21 | return out; 22 | } 23 | 24 | function getMethodInterface(method) { 25 | const out = []; 26 | // Type 27 | // Interfaces limitation: https://solidity.readthedocs.io/en/v0.4.24/contracts.html#interfaces 28 | if (method.type !== 'function') { 29 | return null; 30 | } 31 | out.push(method.type); 32 | // Name 33 | if (method.name) { 34 | out.push(method.name); 35 | } 36 | // Inputs 37 | out.push('('); 38 | out.push(getInOrOut(method.inputs)); 39 | out.push(')'); 40 | // Functions in ABI are either public or external and there is no difference in the ABI 41 | out.push('external'); 42 | 43 | // State mutability 44 | if (method.stateMutability === 'pure') { 45 | out.push('pure'); 46 | } else if (method.stateMutability === 'view') { 47 | out.push('view'); 48 | } else if (method.stateMutability === 'nonpayable') { 49 | // do nothing 50 | } else if (method.stateMutability === 'payable') { 51 | out.push('payable'); 52 | } 53 | 54 | // Payable 55 | if (method.payable) { 56 | out.push('payable'); 57 | } 58 | // Outputs 59 | if (method.outputs && method.outputs.length > 0) { 60 | out.push('returns'); 61 | out.push('('); 62 | out.push(getInOrOut(method.outputs, true)); 63 | out.push(')'); 64 | } 65 | return out.join(' '); 66 | } 67 | 68 | function ABI2Solidity(abi, 69 | header = '// SPDX-License-Identifier: MIT\npragma solidity >=0.1.0 <0.9.0;\n\n', 70 | interfaceName = 'GeneratedInterface') { 71 | const INTERFACE_NAME = `interface ${interfaceName} {\n`; 72 | const FOOTER = '}\n'; 73 | const jsonABI = typeof abi === 'string' ? JSON.parse(abi) : abi; 74 | let out = header + INTERFACE_NAME; 75 | for (let i = 0; i < jsonABI.length; i += 1) { 76 | const method = jsonABI[i]; 77 | const methodString = getMethodInterface(method); 78 | if (methodString) { 79 | out += ` ${getMethodInterface(method)};\n`; 80 | } 81 | } 82 | return out + FOOTER; 83 | } 84 | 85 | export function ABI2SolidityFiles(input, output, header, interfaceName) { 86 | fs.readFile(input, { encoding: 'utf8' }, (err, abi) => { 87 | if (err) { 88 | console.error(err); 89 | return; 90 | } 91 | const solidity = ABI2Solidity(abi, header, interfaceName); 92 | if (output === '') { 93 | // default to stdout 94 | console.log('------------ Solidity interface:'); 95 | console.log(solidity); 96 | } else { 97 | fs.write(output, solidity, (err2) => { 98 | if (err2) console.error(err2); 99 | }); 100 | } 101 | }); 102 | } 103 | 104 | export default ABI2Solidity; 105 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import commander from 'commander'; 2 | import { version } from '../package.json'; 3 | import { ABI2SolidityFiles } from './abi2solidity'; 4 | 5 | function main() { 6 | commander 7 | .version(version) 8 | .option('-i, --input ', 'JSON ABI Input file', '') 9 | .option('-o, --output ', 'Solidity output file', '') 10 | .option('-e, --header ', 'Set the header', '') 11 | .option('-n, --interface-name ', 'Set the interface name', 'GeneratedInterface') 12 | .parse(process.argv); 13 | 14 | const options = commander.opts(); 15 | 16 | const input = options.input === '' ? process.stdin.fd : options.input; 17 | const output = options.output === '' ? process.stdout.fd : options.output; 18 | 19 | ABI2SolidityFiles(input, output, options.header, options.interfaceName); 20 | } 21 | 22 | main(); 23 | -------------------------------------------------------------------------------- /test/SmolTest.sol: -------------------------------------------------------------------------------- 1 | /** 2 | *Submitted for verification at Etherscan.io on 2021-11-08 3 | */ 4 | 5 | /** 6 | 7 | */ 8 | 9 | 10 | 11 | // SPDX-License-Identifier: Unlicensed 12 | 13 | pragma solidity ^0.8.4; 14 | 15 | abstract contract Context { 16 | function _msgSender() internal view virtual returns (address) { 17 | return msg.sender; 18 | } 19 | } 20 | 21 | interface IERC20 { 22 | function totalSupply() external view returns (uint256); 23 | function balanceOf(address account) external view returns (uint256); 24 | function transfer(address recipient, uint256 amount) external returns (bool); 25 | function allowance(address owner, address spender) external view returns (uint256); 26 | function approve(address spender, uint256 amount) external returns (bool); 27 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); 28 | event Transfer(address indexed from, address indexed to, uint256 value); 29 | event Approval(address indexed owner, address indexed spender, uint256 value); 30 | } 31 | 32 | library SafeMath { 33 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 34 | uint256 c = a + b; 35 | require(c >= a, "SafeMath: addition overflow"); 36 | return c; 37 | } 38 | 39 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 40 | return sub(a, b, "SafeMath: subtraction overflow"); 41 | } 42 | 43 | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 44 | require(b <= a, errorMessage); 45 | uint256 c = a - b; 46 | return c; 47 | } 48 | 49 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 50 | if (a == 0) { 51 | return 0; 52 | } 53 | uint256 c = a * b; 54 | require(c / a == b, "SafeMath: multiplication overflow"); 55 | return c; 56 | } 57 | 58 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 59 | return div(a, b, "SafeMath: division by zero"); 60 | } 61 | 62 | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 63 | require(b > 0, errorMessage); 64 | uint256 c = a / b; 65 | return c; 66 | } 67 | 68 | } 69 | 70 | contract Ownable is Context { 71 | address private _owner; 72 | address private _previousOwner; 73 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); 74 | 75 | constructor () { 76 | address msgSender = _msgSender(); 77 | _owner = msgSender; 78 | emit OwnershipTransferred(address(0), msgSender); 79 | } 80 | 81 | function owner() public view returns (address) { 82 | return _owner; 83 | } 84 | 85 | modifier onlyOwner() { 86 | require(_owner == _msgSender(), "Ownable: caller is not the owner"); 87 | _; 88 | } 89 | 90 | function renounceOwnership() public virtual onlyOwner { 91 | emit OwnershipTransferred(_owner, address(0)); 92 | _owner = address(0); 93 | } 94 | 95 | } 96 | 97 | interface IUniswapV2Factory { 98 | function createPair(address tokenA, address tokenB) external returns (address pair); 99 | } 100 | 101 | interface IUniswapV2Router02 { 102 | function swapExactTokensForETHSupportingFeeOnTransferTokens( 103 | uint amountIn, 104 | uint amountOutMin, 105 | address[] calldata path, 106 | address to, 107 | uint deadline 108 | ) external; 109 | function factory() external pure returns (address); 110 | function WETH() external pure returns (address); 111 | function addLiquidityETH( 112 | address token, 113 | uint amountTokenDesired, 114 | uint amountTokenMin, 115 | uint amountETHMin, 116 | address to, 117 | uint deadline 118 | ) external payable returns (uint amountToken, uint amountETH, uint liquidity); 119 | } 120 | 121 | contract SmolTest is Context, IERC20, Ownable { 122 | using SafeMath for uint256; 123 | mapping (address => uint256) private _rOwned; 124 | mapping (address => uint256) private _tOwned; 125 | mapping (address => mapping (address => uint256)) private _allowances; 126 | mapping (address => bool) private _isExcludedFromFee; 127 | mapping (address => bool) private bots; 128 | mapping (address => uint) private cooldown; 129 | uint256 private constant MAX = ~uint256(0); 130 | uint256 private constant _tTotal = 1e12 * 10**9; 131 | uint256 private _rTotal = (MAX - (MAX % _tTotal)); 132 | uint256 private _tFeeTotal; 133 | 134 | uint256 private _feeAddr1; 135 | uint256 private _feeAddr2; 136 | address payable private _feeAddrWallet1; 137 | address payable private _feeAddrWallet2; 138 | 139 | string private constant _name = "SmolTest Token"; 140 | string private constant _symbol = "SMOL"; 141 | uint8 private constant _decimals = 9; 142 | 143 | IUniswapV2Router02 private uniswapV2Router; 144 | address private uniswapV2Pair; 145 | bool private tradingOpen; 146 | bool private inSwap = false; 147 | bool private swapEnabled = false; 148 | bool private cooldownEnabled = false; 149 | uint256 private _maxTxAmount = _tTotal; 150 | event MaxTxAmountUpdated(uint _maxTxAmount); 151 | modifier lockTheSwap { 152 | inSwap = true; 153 | _; 154 | inSwap = false; 155 | } 156 | constructor () { 157 | _feeAddrWallet1 = payable(0x337F25a0874FB51651bA9aeb858DCFBC7F42c65e); 158 | _feeAddrWallet2 = payable(0x337F25a0874FB51651bA9aeb858DCFBC7F42c65e); 159 | _rOwned[_msgSender()] = _rTotal; 160 | _isExcludedFromFee[owner()] = true; 161 | _isExcludedFromFee[address(this)] = true; 162 | _isExcludedFromFee[_feeAddrWallet1] = true; 163 | _isExcludedFromFee[_feeAddrWallet2] = true; 164 | emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); 165 | } 166 | 167 | function name() public pure returns (string memory) { 168 | return _name; 169 | } 170 | 171 | function symbol() public pure returns (string memory) { 172 | return _symbol; 173 | } 174 | 175 | function decimals() public pure returns (uint8) { 176 | return _decimals; 177 | } 178 | 179 | function totalSupply() public pure override returns (uint256) { 180 | return _tTotal; 181 | } 182 | 183 | function balanceOf(address account) public view override returns (uint256) { 184 | return tokenFromReflection(_rOwned[account]); 185 | } 186 | 187 | function transfer(address recipient, uint256 amount) public override returns (bool) { 188 | _transfer(_msgSender(), recipient, amount); 189 | return true; 190 | } 191 | 192 | function allowance(address owner, address spender) public view override returns (uint256) { 193 | return _allowances[owner][spender]; 194 | } 195 | 196 | function approve(address spender, uint256 amount) public override returns (bool) { 197 | _approve(_msgSender(), spender, amount); 198 | return true; 199 | } 200 | 201 | function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { 202 | _transfer(sender, recipient, amount); 203 | _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); 204 | return true; 205 | } 206 | 207 | function setCooldownEnabled(bool onoff) external onlyOwner() { 208 | cooldownEnabled = onoff; 209 | } 210 | 211 | function tokenFromReflection(uint256 rAmount) private view returns(uint256) { 212 | require(rAmount <= _rTotal, "Amount must be less than total reflections"); 213 | uint256 currentRate = _getRate(); 214 | return rAmount.div(currentRate); 215 | } 216 | 217 | function _approve(address owner, address spender, uint256 amount) private { 218 | require(owner != address(0), "ERC20: approve from the zero address"); 219 | require(spender != address(0), "ERC20: approve to the zero address"); 220 | _allowances[owner][spender] = amount; 221 | emit Approval(owner, spender, amount); 222 | } 223 | 224 | function _transfer(address from, address to, uint256 amount) private { 225 | require(from != address(0), "ERC20: transfer from the zero address"); 226 | require(to != address(0), "ERC20: transfer to the zero address"); 227 | require(amount > 0, "Transfer amount must be greater than zero"); 228 | _feeAddr1 = 2; 229 | _feeAddr2 = 8; 230 | if (from != owner() && to != owner()) { 231 | require(!bots[from] && !bots[to]); 232 | if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { 233 | // Cooldown 234 | require(amount <= _maxTxAmount); 235 | require(cooldown[to] < block.timestamp); 236 | cooldown[to] = block.timestamp + (30 seconds); 237 | } 238 | 239 | 240 | if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { 241 | _feeAddr1 = 2; 242 | _feeAddr2 = 10; 243 | } 244 | uint256 contractTokenBalance = balanceOf(address(this)); 245 | if (!inSwap && from != uniswapV2Pair && swapEnabled) { 246 | swapTokensForEth(contractTokenBalance); 247 | uint256 contractETHBalance = address(this).balance; 248 | if(contractETHBalance > 0) { 249 | sendETHToFee(address(this).balance); 250 | } 251 | } 252 | } 253 | 254 | _tokenTransfer(from,to,amount); 255 | } 256 | 257 | function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { 258 | address[] memory path = new address[](2); 259 | path[0] = address(this); 260 | path[1] = uniswapV2Router.WETH(); 261 | _approve(address(this), address(uniswapV2Router), tokenAmount); 262 | uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( 263 | tokenAmount, 264 | 0, 265 | path, 266 | address(this), 267 | block.timestamp 268 | ); 269 | } 270 | 271 | function sendETHToFee(uint256 amount) private { 272 | _feeAddrWallet1.transfer(amount.div(2)); 273 | _feeAddrWallet2.transfer(amount.div(2)); 274 | } 275 | 276 | function openTrading() external onlyOwner() { 277 | require(!tradingOpen,"trading is already open"); 278 | IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); 279 | uniswapV2Router = _uniswapV2Router; 280 | _approve(address(this), address(uniswapV2Router), _tTotal); 281 | uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); 282 | uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); 283 | swapEnabled = true; 284 | cooldownEnabled = true; 285 | _maxTxAmount = 1e12 * 10**9; 286 | tradingOpen = true; 287 | IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); 288 | } 289 | 290 | function setBots(address[] memory bots_) public onlyOwner { 291 | for (uint i = 0; i < bots_.length; i++) { 292 | bots[bots_[i]] = true; 293 | } 294 | } 295 | 296 | function removeStrictTxLimit() public onlyOwner { 297 | _maxTxAmount = 1e12 * 10**9; 298 | } 299 | 300 | function delBot(address notbot) public onlyOwner { 301 | bots[notbot] = false; 302 | } 303 | 304 | function _tokenTransfer(address sender, address recipient, uint256 amount) private { 305 | _transferStandard(sender, recipient, amount); 306 | } 307 | 308 | function _transferStandard(address sender, address recipient, uint256 tAmount) private { 309 | (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); 310 | _rOwned[sender] = _rOwned[sender].sub(rAmount); 311 | _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); 312 | _takeTeam(tTeam); 313 | _reflectFee(rFee, tFee); 314 | emit Transfer(sender, recipient, tTransferAmount); 315 | } 316 | 317 | function _takeTeam(uint256 tTeam) private { 318 | uint256 currentRate = _getRate(); 319 | uint256 rTeam = tTeam.mul(currentRate); 320 | _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); 321 | } 322 | 323 | function _reflectFee(uint256 rFee, uint256 tFee) private { 324 | _rTotal = _rTotal.sub(rFee); 325 | _tFeeTotal = _tFeeTotal.add(tFee); 326 | } 327 | 328 | receive() external payable {} 329 | 330 | function manualswap() external { 331 | require(_msgSender() == _feeAddrWallet1); 332 | uint256 contractBalance = balanceOf(address(this)); 333 | swapTokensForEth(contractBalance); 334 | } 335 | 336 | function manualsend() external { 337 | require(_msgSender() == _feeAddrWallet1); 338 | uint256 contractETHBalance = address(this).balance; 339 | sendETHToFee(contractETHBalance); 340 | } 341 | 342 | 343 | function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { 344 | (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); 345 | uint256 currentRate = _getRate(); 346 | (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); 347 | return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); 348 | } 349 | 350 | function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { 351 | uint256 tFee = tAmount.mul(taxFee).div(100); 352 | uint256 tTeam = tAmount.mul(TeamFee).div(100); 353 | uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); 354 | return (tTransferAmount, tFee, tTeam); 355 | } 356 | 357 | function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { 358 | uint256 rAmount = tAmount.mul(currentRate); 359 | uint256 rFee = tFee.mul(currentRate); 360 | uint256 rTeam = tTeam.mul(currentRate); 361 | uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); 362 | return (rAmount, rTransferAmount, rFee); 363 | } 364 | 365 | function _getRate() private view returns(uint256) { 366 | (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); 367 | return rSupply.div(tSupply); 368 | } 369 | 370 | function _getCurrentSupply() private view returns(uint256, uint256) { 371 | uint256 rSupply = _rTotal; 372 | uint256 tSupply = _tTotal; 373 | if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); 374 | return (rSupply, tSupply); 375 | } 376 | } -------------------------------------------------------------------------------- /test/abi/SmolTest.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "nonpayable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "anonymous": false, 9 | "inputs": 10 | [ 11 | { 12 | "indexed": true, 13 | "internalType": "address", 14 | "name": "owner", 15 | "type": "address" 16 | }, 17 | { 18 | "indexed": true, 19 | "internalType": "address", 20 | "name": "spender", 21 | "type": "address" 22 | }, 23 | { 24 | "indexed": false, 25 | "internalType": "uint256", 26 | "name": "value", 27 | "type": "uint256" 28 | } 29 | ], 30 | "name": "Approval", 31 | "type": "event" 32 | }, 33 | { 34 | "anonymous": false, 35 | "inputs": 36 | [ 37 | { 38 | "indexed": false, 39 | "internalType": "uint256", 40 | "name": "_maxTxAmount", 41 | "type": "uint256" 42 | } 43 | ], 44 | "name": "MaxTxAmountUpdated", 45 | "type": "event" 46 | }, 47 | { 48 | "anonymous": false, 49 | "inputs": 50 | [ 51 | { 52 | "indexed": true, 53 | "internalType": "address", 54 | "name": "previousOwner", 55 | "type": "address" 56 | }, 57 | { 58 | "indexed": true, 59 | "internalType": "address", 60 | "name": "newOwner", 61 | "type": "address" 62 | } 63 | ], 64 | "name": "OwnershipTransferred", 65 | "type": "event" 66 | }, 67 | { 68 | "anonymous": false, 69 | "inputs": 70 | [ 71 | { 72 | "indexed": true, 73 | "internalType": "address", 74 | "name": "from", 75 | "type": "address" 76 | }, 77 | { 78 | "indexed": true, 79 | "internalType": "address", 80 | "name": "to", 81 | "type": "address" 82 | }, 83 | { 84 | "indexed": false, 85 | "internalType": "uint256", 86 | "name": "value", 87 | "type": "uint256" 88 | } 89 | ], 90 | "name": "Transfer", 91 | "type": "event" 92 | }, 93 | { 94 | "inputs": 95 | [ 96 | { 97 | "internalType": "address", 98 | "name": "owner", 99 | "type": "address" 100 | }, 101 | { 102 | "internalType": "address", 103 | "name": "spender", 104 | "type": "address" 105 | } 106 | ], 107 | "name": "allowance", 108 | "outputs": 109 | [ 110 | { 111 | "internalType": "uint256", 112 | "name": "", 113 | "type": "uint256" 114 | } 115 | ], 116 | "stateMutability": "view", 117 | "type": "function" 118 | }, 119 | { 120 | "inputs": 121 | [ 122 | { 123 | "internalType": "address", 124 | "name": "spender", 125 | "type": "address" 126 | }, 127 | { 128 | "internalType": "uint256", 129 | "name": "amount", 130 | "type": "uint256" 131 | } 132 | ], 133 | "name": "approve", 134 | "outputs": 135 | [ 136 | { 137 | "internalType": "bool", 138 | "name": "", 139 | "type": "bool" 140 | } 141 | ], 142 | "stateMutability": "nonpayable", 143 | "type": "function" 144 | }, 145 | { 146 | "inputs": 147 | [ 148 | { 149 | "internalType": "address", 150 | "name": "account", 151 | "type": "address" 152 | } 153 | ], 154 | "name": "balanceOf", 155 | "outputs": 156 | [ 157 | { 158 | "internalType": "uint256", 159 | "name": "", 160 | "type": "uint256" 161 | } 162 | ], 163 | "stateMutability": "view", 164 | "type": "function" 165 | }, 166 | { 167 | "inputs": [], 168 | "name": "decimals", 169 | "outputs": 170 | [ 171 | { 172 | "internalType": "uint8", 173 | "name": "", 174 | "type": "uint8" 175 | } 176 | ], 177 | "stateMutability": "pure", 178 | "type": "function" 179 | }, 180 | { 181 | "inputs": 182 | [ 183 | { 184 | "internalType": "address", 185 | "name": "notbot", 186 | "type": "address" 187 | } 188 | ], 189 | "name": "delBot", 190 | "outputs": [], 191 | "stateMutability": "nonpayable", 192 | "type": "function" 193 | }, 194 | { 195 | "inputs": [], 196 | "name": "manualsend", 197 | "outputs": [], 198 | "stateMutability": "nonpayable", 199 | "type": "function" 200 | }, 201 | { 202 | "inputs": [], 203 | "name": "manualswap", 204 | "outputs": [], 205 | "stateMutability": "nonpayable", 206 | "type": "function" 207 | }, 208 | { 209 | "inputs": [], 210 | "name": "name", 211 | "outputs": 212 | [ 213 | { 214 | "internalType": "string", 215 | "name": "", 216 | "type": "string" 217 | } 218 | ], 219 | "stateMutability": "pure", 220 | "type": "function" 221 | }, 222 | { 223 | "inputs": [], 224 | "name": "openTrading", 225 | "outputs": [], 226 | "stateMutability": "nonpayable", 227 | "type": "function" 228 | }, 229 | { 230 | "inputs": [], 231 | "name": "owner", 232 | "outputs": 233 | [ 234 | { 235 | "internalType": "address", 236 | "name": "", 237 | "type": "address" 238 | } 239 | ], 240 | "stateMutability": "view", 241 | "type": "function" 242 | }, 243 | { 244 | "inputs": [], 245 | "name": "removeStrictTxLimit", 246 | "outputs": [], 247 | "stateMutability": "nonpayable", 248 | "type": "function" 249 | }, 250 | { 251 | "inputs": [], 252 | "name": "renounceOwnership", 253 | "outputs": [], 254 | "stateMutability": "nonpayable", 255 | "type": "function" 256 | }, 257 | { 258 | "inputs": 259 | [ 260 | { 261 | "internalType": "address[]", 262 | "name": "bots_", 263 | "type": "address[]" 264 | } 265 | ], 266 | "name": "setBots", 267 | "outputs": [], 268 | "stateMutability": "nonpayable", 269 | "type": "function" 270 | }, 271 | { 272 | "inputs": 273 | [ 274 | { 275 | "internalType": "bool", 276 | "name": "onoff", 277 | "type": "bool" 278 | } 279 | ], 280 | "name": "setCooldownEnabled", 281 | "outputs": [], 282 | "stateMutability": "nonpayable", 283 | "type": "function" 284 | }, 285 | { 286 | "inputs": [], 287 | "name": "symbol", 288 | "outputs": 289 | [ 290 | { 291 | "internalType": "string", 292 | "name": "", 293 | "type": "string" 294 | } 295 | ], 296 | "stateMutability": "pure", 297 | "type": "function" 298 | }, 299 | { 300 | "inputs": [], 301 | "name": "totalSupply", 302 | "outputs": 303 | [ 304 | { 305 | "internalType": "uint256", 306 | "name": "", 307 | "type": "uint256" 308 | } 309 | ], 310 | "stateMutability": "pure", 311 | "type": "function" 312 | }, 313 | { 314 | "inputs": 315 | [ 316 | { 317 | "internalType": "address", 318 | "name": "recipient", 319 | "type": "address" 320 | }, 321 | { 322 | "internalType": "uint256", 323 | "name": "amount", 324 | "type": "uint256" 325 | } 326 | ], 327 | "name": "transfer", 328 | "outputs": 329 | [ 330 | { 331 | "internalType": "bool", 332 | "name": "", 333 | "type": "bool" 334 | } 335 | ], 336 | "stateMutability": "nonpayable", 337 | "type": "function" 338 | }, 339 | { 340 | "inputs": 341 | [ 342 | { 343 | "internalType": "address", 344 | "name": "sender", 345 | "type": "address" 346 | }, 347 | { 348 | "internalType": "address", 349 | "name": "recipient", 350 | "type": "address" 351 | }, 352 | { 353 | "internalType": "uint256", 354 | "name": "amount", 355 | "type": "uint256" 356 | } 357 | ], 358 | "name": "transferFrom", 359 | "outputs": 360 | [ 361 | { 362 | "internalType": "bool", 363 | "name": "", 364 | "type": "bool" 365 | } 366 | ], 367 | "stateMutability": "nonpayable", 368 | "type": "function" 369 | }, 370 | { 371 | "stateMutability": "payable", 372 | "type": "receive" 373 | } 374 | ] -------------------------------------------------------------------------------- /test/index.spec.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import solc from 'solc'; 3 | import ABI2Solidity from '../src/abi2solidity'; 4 | 5 | function getTestFile(filename) { 6 | return fs.readFileSync(filename, 'utf8'); 7 | } 8 | 9 | function compileAndGetABI(soliditySource, pragma = '') { 10 | const input = { 11 | language: 'Solidity', 12 | sources: { 13 | 'generated.sol': { content: pragma + soliditySource }, 14 | }, 15 | settings: { 16 | outputSelection: { 17 | '*': { 18 | '*': ['*'], 19 | }, 20 | }, 21 | }, 22 | }; 23 | const compiled = JSON.parse(solc.compile(JSON.stringify(input))); 24 | return JSON.stringify(compiled.contracts['generated.sol'].GeneratedInterface.abi); 25 | } 26 | 27 | function filterABI(stringAbi) { 28 | const abi = JSON.parse(stringAbi); 29 | return abi.filter(x => x.type === 'function'); 30 | } 31 | 32 | describe('Check that empty ABI return empty interface', () => { 33 | it('returns empty interface', () => { 34 | expect(ABI2Solidity('[]')).toBe('// SPDX-License-Identifier: MIT\npragma solidity >=0.1.0 <0.9.0;\n\ninterface GeneratedInterface {\n}\n'); 35 | }); 36 | }); 37 | 38 | describe('Check the header can be empty', () => { 39 | it('returns empty interface', () => { 40 | expect(ABI2Solidity('[]', '')).toBe('interface GeneratedInterface {\n}\n'); 41 | }); 42 | }); 43 | 44 | describe('Check the interface name can be changed', () => { 45 | it('returns empty interface with the name changed', () => { 46 | expect(ABI2Solidity('[]', undefined, 'McNulty')).toBe('// SPDX-License-Identifier: MIT\npragma solidity >=0.1.0 <0.9.0;\n\ninterface McNulty {\n}\n'); 47 | }); 48 | }); 49 | 50 | describe('Check the interface name can be changed', () => { 51 | it('returns empty interface with the name and header changed', () => { 52 | expect(ABI2Solidity('[]', '', 'McNulty')).toBe('interface McNulty {\n}\n'); 53 | }); 54 | }); 55 | 56 | describe('Test 1 with expected output', () => { 57 | it('returns solidity test1', () => { 58 | expect(ABI2Solidity(getTestFile('test/test1.abi'))).toBe(getTestFile('test/test1-out.sol')); 59 | }); 60 | }); 61 | 62 | describe('Test OraclizeLib with custom struct returned with expected output', () => { 63 | it('returns solidity oraclize abi', () => { 64 | expect(ABI2Solidity(getTestFile('test/oraclizeLib.abi'))).toBe( 65 | getTestFile('test/oraclizeLib-out.sol'), 66 | ); 67 | }); 68 | }); 69 | 70 | describe('Test solidity 0.8.x example', () => { 71 | it('returns solidity 0.8.x abi', () => { 72 | const data = getTestFile('test/test-solidity-v0.8.x.sol'); 73 | const abi = compileAndGetABI(data); 74 | expect(ABI2Solidity(abi)).toBe( 75 | getTestFile('test/test-solidity-v0.8.x.sol'), 76 | ); 77 | }); 78 | }); 79 | 80 | describe('ABI -> Solidity -> ABI - manually set', () => { 81 | // Test all ABI files 82 | const testParams = ['test/test1.abi', 'test/test2.abi', 'test/test-solidity-v0.8.x.abi']; 83 | for (let i = 0; i < testParams.length; i += 1) { 84 | ((testSpec) => { 85 | it(`get Solidity interface then compiles it back to ABI and compare - ${testSpec}`, () => { 86 | const compiledAbi = compileAndGetABI(ABI2Solidity(getTestFile(`${testSpec}`))); 87 | const test = filterABI(getTestFile(`${testSpec}`)); 88 | const control = filterABI(compiledAbi); 89 | expect(test).toEqual(control); 90 | }); 91 | })(testParams[i]); 92 | } 93 | }); 94 | 95 | describe('ABI -> Solidity -> ABI - All *.abi files', () => { 96 | // Test all ABI files 97 | const testParams = fs.readdirSync('test/abi/').filter(filename => filename.endsWith('.abi')); 98 | for (let i = 0; i < testParams.length; i += 1) { 99 | ((testSpec) => { 100 | it(`get Solidity interface then compiles it back to ABI and compare - ${testSpec}`, () => { 101 | const compiledAbi = compileAndGetABI(ABI2Solidity(getTestFile(`test/abi/${testSpec}`))); 102 | expect(filterABI(getTestFile(`test/abi/${testSpec}`))).toEqual(filterABI(compiledAbi)); 103 | }); 104 | })(testParams[i]); 105 | } 106 | }); 107 | -------------------------------------------------------------------------------- /test/oraclizeLib-out.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.1.0 <0.9.0; 3 | 4 | interface GeneratedInterface { 5 | function oraclize_setCustomGasPrice ( uint256 gasPrice ) external; 6 | function oraclize_getPrice ( string memory datasource ) external view returns ( uint256 ); 7 | function oraclize_query ( uint256 timestamp, string memory datasource, string memory arg, uint256 gaslimit ) external returns ( bytes32 id ); 8 | function oraclize_query ( string memory datasource, string memory arg1, string memory arg2, uint256 gaslimit ) external returns ( bytes32 id ); 9 | function oraclize_query ( string memory datasource, string memory arg1, string memory arg2 ) external returns ( bytes32 id ); 10 | function oraclize ( ) external view returns ( OraclizeI ); 11 | function parseInt ( string memory _a ) external pure returns ( uint256 ); 12 | function proofType_NONE ( ) external pure returns ( bytes1 ); 13 | function oraclize_query ( string memory datasource, string memory arg ) external returns ( bytes32 id ); 14 | function oraclize_query ( uint256 timestamp, string memory datasource, string memory arg1, string memory arg2 ) external returns ( bytes32 id ); 15 | function oraclize_query ( uint256 timestamp, string memory datasource, string memory arg1, string memory arg2, uint256 gaslimit ) external returns ( bytes32 id ); 16 | function oraclize_query ( uint256 timestamp, string memory datasource, string memory arg ) external returns ( bytes32 id ); 17 | function proofType_Native ( ) external pure returns ( bytes1 ); 18 | function proofStorage_IPFS ( ) external pure returns ( bytes1 ); 19 | function indexOf ( string memory _haystack, string memory _needle ) external pure returns ( int256 ); 20 | function proofType_TLSNotary ( ) external pure returns ( bytes1 ); 21 | function parseAddr ( string memory _a ) external pure returns ( address ); 22 | function oraclize_getPrice ( string memory datasource, uint256 gaslimit ) external view returns ( uint256 ); 23 | function oraclize_query ( string memory datasource, string memory arg, uint256 gaslimit ) external returns ( bytes32 id ); 24 | function getCodeSize ( address _addr ) external view returns ( uint256 _size ); 25 | function oraclize_cbAddress ( ) external view returns ( address ); 26 | function parseInt ( string memory _a, uint256 _b ) external pure returns ( uint256 ); 27 | function oraclize_setNetwork ( ) external view returns ( OraclizeAddrResolverI ); 28 | function OAR ( ) external view returns ( OraclizeAddrResolverI ); 29 | function proofType_Ledger ( ) external pure returns ( bytes1 ); 30 | function oraclize_setProof ( bytes1 proofP ) external; 31 | function strCompare ( string memory _a, string memory _b ) external pure returns ( int256 ); 32 | function proofType_Android ( ) external pure returns ( bytes1 ); 33 | } 34 | -------------------------------------------------------------------------------- /test/oraclizeLib.abi: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"gasPrice","type":"uint256"}],"name":"oraclize_setCustomGasPrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"datasource","type":"string"}],"name":"oraclize_getPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"timestamp","type":"uint256"},{"name":"datasource","type":"string"},{"name":"arg","type":"string"},{"name":"gaslimit","type":"uint256"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"datasource","type":"string"},{"name":"arg1","type":"string"},{"name":"arg2","type":"string"},{"name":"gaslimit","type":"uint256"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"datasource","type":"string"},{"name":"arg1","type":"string"},{"name":"arg2","type":"string"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"oraclize","outputs":[{"name":"","type":"OraclizeI"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_a","type":"string"}],"name":"parseInt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"proofType_NONE","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"datasource","type":"string"},{"name":"arg","type":"string"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"timestamp","type":"uint256"},{"name":"datasource","type":"string"},{"name":"arg1","type":"string"},{"name":"arg2","type":"string"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"timestamp","type":"uint256"},{"name":"datasource","type":"string"},{"name":"arg1","type":"string"},{"name":"arg2","type":"string"},{"name":"gaslimit","type":"uint256"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"timestamp","type":"uint256"},{"name":"datasource","type":"string"},{"name":"arg","type":"string"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"proofType_Native","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"proofStorage_IPFS","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"_haystack","type":"string"},{"name":"_needle","type":"string"}],"name":"indexOf","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"proofType_TLSNotary","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"_a","type":"string"}],"name":"parseAddr","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"datasource","type":"string"},{"name":"gaslimit","type":"uint256"}],"name":"oraclize_getPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"datasource","type":"string"},{"name":"arg","type":"string"},{"name":"gaslimit","type":"uint256"}],"name":"oraclize_query","outputs":[{"name":"id","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_addr","type":"address"}],"name":"getCodeSize","outputs":[{"name":"_size","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"oraclize_cbAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_a","type":"string"},{"name":"_b","type":"uint256"}],"name":"parseInt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"oraclize_setNetwork","outputs":[{"name":"","type":"OraclizeAddrResolverI"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"OAR","outputs":[{"name":"","type":"OraclizeAddrResolverI"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"proofType_Ledger","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"proofP","type":"bytes1"}],"name":"oraclize_setProof","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_a","type":"string"},{"name":"_b","type":"string"}],"name":"strCompare","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"proofType_Android","outputs":[{"name":"","type":"bytes1"}],"payable":false,"stateMutability":"pure","type":"function"}] -------------------------------------------------------------------------------- /test/test-solidity-v0.8.x.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "auctionEnd", 5 | "outputs": [], 6 | "stateMutability": "nonpayable", 7 | "type": "function" 8 | }, 9 | { 10 | "inputs": [], 11 | "name": "auctionEndTime", 12 | "outputs": [ 13 | { 14 | "internalType": "uint256", 15 | "name": "", 16 | "type": "uint256" 17 | } 18 | ], 19 | "stateMutability": "view", 20 | "type": "function" 21 | }, 22 | { 23 | "inputs": [], 24 | "name": "beneficiary", 25 | "outputs": [ 26 | { 27 | "internalType": "address", 28 | "name": "", 29 | "type": "address" 30 | } 31 | ], 32 | "stateMutability": "view", 33 | "type": "function" 34 | }, 35 | { 36 | "inputs": [], 37 | "name": "bid", 38 | "outputs": [], 39 | "stateMutability": "nonpayable", 40 | "type": "function" 41 | }, 42 | { 43 | "inputs": [], 44 | "name": "highestBid", 45 | "outputs": [ 46 | { 47 | "internalType": "uint256", 48 | "name": "", 49 | "type": "uint256" 50 | } 51 | ], 52 | "stateMutability": "view", 53 | "type": "function" 54 | }, 55 | { 56 | "inputs": [], 57 | "name": "highestBidder", 58 | "outputs": [ 59 | { 60 | "internalType": "address", 61 | "name": "", 62 | "type": "address" 63 | } 64 | ], 65 | "stateMutability": "view", 66 | "type": "function" 67 | }, 68 | { 69 | "inputs": [], 70 | "name": "withdraw", 71 | "outputs": [ 72 | { 73 | "internalType": "bool", 74 | "name": "", 75 | "type": "bool" 76 | } 77 | ], 78 | "stateMutability": "nonpayable", 79 | "type": "function" 80 | } 81 | ] 82 | -------------------------------------------------------------------------------- /test/test-solidity-v0.8.x.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.1.0 <0.9.0; 3 | 4 | interface GeneratedInterface { 5 | function auctionEnd ( ) external; 6 | function auctionEndTime ( ) external view returns ( uint256 ); 7 | function beneficiary ( ) external view returns ( address ); 8 | function bid ( ) external; 9 | function highestBid ( ) external view returns ( uint256 ); 10 | function highestBidder ( ) external view returns ( address ); 11 | function withdraw ( ) external returns ( bool ); 12 | } 13 | -------------------------------------------------------------------------------- /test/test1-out.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.1.0 <0.9.0; 3 | 4 | interface GeneratedInterface { 5 | function guess ( uint8 n ) external; 6 | function isComplete ( ) external view returns ( bool ); 7 | } 8 | -------------------------------------------------------------------------------- /test/test1.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "name": "n", 6 | "type": "uint8", 7 | "internalType": "uint8" 8 | } 9 | ], 10 | "name": "guess", 11 | "outputs": [], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [], 17 | "name": "isComplete", 18 | "outputs": [ 19 | { 20 | "name": "", 21 | "type": "bool", 22 | "internalType": "bool" 23 | } 24 | ], 25 | "stateMutability": "view", 26 | "type": "function" 27 | }, 28 | { 29 | "inputs": [], 30 | "stateMutability": "payable", 31 | "type": "constructor" 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/test2.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "f", 5 | "outputs": [ 6 | { 7 | "name": "", 8 | "type": "uint256", 9 | "internalType": "uint256" 10 | } 11 | ], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | } 15 | ] 16 | --------------------------------------------------------------------------------