From e1fd9a481c7623a7c3750ce3704cbee4e955b617 Mon Sep 17 00:00:00 2001 From: Vittorio Minacori Date: Thu, 10 Feb 2022 12:23:50 +0100 Subject: [PATCH] chore: update dependencies --- .editorconfig | 3 +- .prettierrc | 7 ++-- .solhint.json | 12 +++++-- contracts/token/ERC1363/ERC1363.sol | 48 ++++++++++++------------- contracts/token/ERC1363/IERC1363.sol | 20 +++++------ package.json | 24 ++++++------- test/token/ERC1363/ERC1363.behaviour.js | 4 +-- 7 files changed, 63 insertions(+), 55 deletions(-) diff --git a/.editorconfig b/.editorconfig index e885a65..d8525be 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,7 +8,8 @@ charset = utf-8 end_of_line = lf indent_style = space insert_final_newline = true -trim_trailing_whitespace = true +trim_trailing_whitespace = false +max_line_length = 120 [*.sol] indent_size = 4 diff --git a/.prettierrc b/.prettierrc index cac10ec..f91ad7e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,13 +1,12 @@ { + "singleQuote": true, + "trailingComma": "all", "overrides": [ { "files": "*.sol", "options": { - "printWidth": 120, - "tabWidth": 4, - "useTabs": false, "singleQuote": false, - "bracketSpacing": false, + "printWidth": 120, "explicitTypes": "always" } } diff --git a/.solhint.json b/.solhint.json index 11b3647..7729288 100644 --- a/.solhint.json +++ b/.solhint.json @@ -1,6 +1,14 @@ { - "plugins": ["prettier"], "rules": { - "prettier/prettier": "error" + "no-unused-vars": "error", + "const-name-snakecase": "error", + "contract-name-camelcase": "error", + "event-name-camelcase": "error", + "func-name-mixedcase": "error", + "func-param-name-mixedcase": "error", + "modifier-name-mixedcase": "error", + "private-vars-leading-underscore": "error", + "var-name-mixedcase": "error", + "imports-on-top": "error" } } diff --git a/contracts/token/ERC1363/ERC1363.sol b/contracts/token/ERC1363/ERC1363.sol index 3279aa3..327ef96 100644 --- a/contracts/token/ERC1363/ERC1363.sol +++ b/contracts/token/ERC1363/ERC1363.sol @@ -26,68 +26,68 @@ abstract contract ERC1363 is ERC20, IERC1363, ERC165 { } /** - * @dev Transfer tokens to a specified address and then execute a callback on recipient. - * @param recipient The address to transfer to. + * @dev Transfer tokens to a specified address and then execute a callback on `to`. + * @param to The address to transfer to. * @param amount The amount to be transferred. * @return A boolean that indicates if the operation was successful. */ - function transferAndCall(address recipient, uint256 amount) public virtual override returns (bool) { - return transferAndCall(recipient, amount, ""); + function transferAndCall(address to, uint256 amount) public virtual override returns (bool) { + return transferAndCall(to, amount, ""); } /** - * @dev Transfer tokens to a specified address and then execute a callback on recipient. - * @param recipient The address to transfer to + * @dev Transfer tokens to a specified address and then execute a callback on `to`. + * @param to The address to transfer to * @param amount The amount to be transferred * @param data Additional data with no specified format * @return A boolean that indicates if the operation was successful. */ function transferAndCall( - address recipient, + address to, uint256 amount, bytes memory data ) public virtual override returns (bool) { - transfer(recipient, amount); - require(_checkAndCallTransfer(_msgSender(), recipient, amount, data), "ERC1363: _checkAndCallTransfer reverts"); + transfer(to, amount); + require(_checkAndCallTransfer(_msgSender(), to, amount, data), "ERC1363: _checkAndCallTransfer reverts"); return true; } /** - * @dev Transfer tokens from one address to another and then execute a callback on recipient. - * @param sender The address which you want to send tokens from - * @param recipient The address which you want to transfer to + * @dev Transfer tokens from one address to another and then execute a callback on `to`. + * @param from The address which you want to send tokens from + * @param to The address which you want to transfer to * @param amount The amount of tokens to be transferred * @return A boolean that indicates if the operation was successful. */ function transferFromAndCall( - address sender, - address recipient, + address from, + address to, uint256 amount ) public virtual override returns (bool) { - return transferFromAndCall(sender, recipient, amount, ""); + return transferFromAndCall(from, to, amount, ""); } /** - * @dev Transfer tokens from one address to another and then execute a callback on recipient. - * @param sender The address which you want to send tokens from - * @param recipient The address which you want to transfer to + * @dev Transfer tokens from one address to another and then execute a callback on `to`. + * @param from The address which you want to send tokens from + * @param to The address which you want to transfer to * @param amount The amount of tokens to be transferred * @param data Additional data with no specified format * @return A boolean that indicates if the operation was successful. */ function transferFromAndCall( - address sender, - address recipient, + address from, + address to, uint256 amount, bytes memory data ) public virtual override returns (bool) { - transferFrom(sender, recipient, amount); - require(_checkAndCallTransfer(sender, recipient, amount, data), "ERC1363: _checkAndCallTransfer reverts"); + transferFrom(from, to, amount); + require(_checkAndCallTransfer(from, to, amount, data), "ERC1363: _checkAndCallTransfer reverts"); return true; } /** - * @dev Approve spender to transfer tokens and then execute a callback on recipient. + * @dev Approve spender to transfer tokens and then execute a callback on `to`. * @param spender The address allowed to transfer to * @param amount The amount allowed to be transferred * @return A boolean that indicates if the operation was successful. @@ -97,7 +97,7 @@ abstract contract ERC1363 is ERC20, IERC1363, ERC165 { } /** - * @dev Approve spender to transfer tokens and then execute a callback on recipient. + * @dev Approve spender to transfer tokens and then execute a callback on spender. * @param spender The address allowed to transfer to. * @param amount The amount allowed to be transferred. * @param data Additional data with no specified format. diff --git a/contracts/token/ERC1363/IERC1363.sol b/contracts/token/ERC1363/IERC1363.sol index 56e3d27..15be263 100644 --- a/contracts/token/ERC1363/IERC1363.sol +++ b/contracts/token/ERC1363/IERC1363.sol @@ -14,21 +14,21 @@ import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; interface IERC1363 is IERC20, IERC165 { /** * @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver - * @param recipient address The address which you want to transfer to + * @param to address The address which you want to transfer to * @param amount uint256 The amount of tokens to be transferred * @return true unless throwing */ - function transferAndCall(address recipient, uint256 amount) external returns (bool); + function transferAndCall(address to, uint256 amount) external returns (bool); /** * @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver - * @param recipient address The address which you want to transfer to + * @param to address The address which you want to transfer to * @param amount uint256 The amount of tokens to be transferred - * @param data bytes Additional data with no specified format, sent in call to `recipient` + * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ function transferAndCall( - address recipient, + address to, uint256 amount, bytes calldata data ) external returns (bool); @@ -36,27 +36,27 @@ interface IERC1363 is IERC20, IERC165 { /** * @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver * @param sender address The address which you want to send tokens from - * @param recipient address The address which you want to transfer to + * @param to address The address which you want to transfer to * @param amount uint256 The amount of tokens to be transferred * @return true unless throwing */ function transferFromAndCall( address sender, - address recipient, + address to, uint256 amount ) external returns (bool); /** * @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver * @param sender address The address which you want to send tokens from - * @param recipient address The address which you want to transfer to + * @param to address The address which you want to transfer to * @param amount uint256 The amount of tokens to be transferred - * @param data bytes Additional data with no specified format, sent in call to `recipient` + * @param data bytes Additional data with no specified format, sent in call to `to` * @return true unless throwing */ function transferFromAndCall( address sender, - address recipient, + address to, uint256 amount, bytes calldata data ) external returns (bool); diff --git a/package.json b/package.json index e79bed3..0a843c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "erc-payable-token", - "version": "4.4.2", + "version": "4.5.0", "description": "ERC-1363 Payable Token Implementation", "files": [ "contracts", @@ -20,9 +20,9 @@ "profile": "npm run clean && npm run coverage && open coverage/index.html", "lint": "npm run lint:js && npm run lint:sol", "lint:fix": "npm run lint:js:fix && npm run lint:sol:fix", - "lint:js": "eslint .", - "lint:js:fix": "eslint . --fix", - "lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"", + "lint:js": "eslint --ignore-path .gitignore .", + "lint:js:fix": "eslint --ignore-path .gitignore . --fix", + "lint:sol": "solhint 'contracts/**/*.sol' && prettier -c 'contracts/**/*.sol'", "lint:sol:fix": "prettier --write \"contracts/**/*.sol\"", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", @@ -47,30 +47,30 @@ }, "homepage": "https://vittominacori.github.io/erc1363-payable-token", "dependencies": { - "@openzeppelin/contracts": "4.4.2" + "@openzeppelin/contracts": "4.5.0" }, "devDependencies": { "@nomiclabs/hardhat-ganache": "^2.0.1", "@nomiclabs/hardhat-truffle5": "^2.0.3", "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/test-helpers": "^0.5.15", - "@vuepress/plugin-google-analytics": "^1.8.2", - "chai": "^4.3.4", + "@vuepress/plugin-google-analytics": "^1.9.7", + "chai": "4.3.4", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", - "eslint-plugin-import": "^2.25.3", + "eslint-plugin-import": "^2.25.4", "eslint-plugin-mocha-no-only": "^1.1.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.2.0", "eslint-plugin-standard": "^5.0.0", "ganache-cli": "^6.12.2", - "hardhat": "^2.8.0", + "hardhat": "^2.8.3", "prettier": "^2.5.1", "prettier-plugin-solidity": "^1.0.0-beta.19", "solhint": "^3.3.6", "solhint-plugin-prettier": "^0.0.5", - "solidity-coverage": "^0.7.17", - "truffle": "^5.4.24", - "vuepress": "^1.8.2" + "solidity-coverage": "^0.7.19", + "truffle": "^5.4.32", + "vuepress": "^1.9.7" } } diff --git a/test/token/ERC1363/ERC1363.behaviour.js b/test/token/ERC1363/ERC1363.behaviour.js index b9f224d..479e2d3 100644 --- a/test/token/ERC1363/ERC1363.behaviour.js +++ b/test/token/ERC1363/ERC1363.behaviour.js @@ -61,7 +61,7 @@ function shouldBehaveLikeERC1363 ([owner, spender, recipient], balance) { it('reverts', async function () { await expectRevert( transferFromAndCallWithData.call(this, sender, receiver, amount, { from: spender }), - 'ERC20: transfer amount exceeds balance', + 'ERC20: insufficient allowance', ); }); }); @@ -70,7 +70,7 @@ function shouldBehaveLikeERC1363 ([owner, spender, recipient], balance) { it('reverts', async function () { await expectRevert( transferFromAndCallWithoutData.call(this, sender, receiver, amount, { from: spender }), - 'ERC20: transfer amount exceeds balance', + 'ERC20: insufficient allowance', ); }); });