diff --git a/packages/ethereum-contracts/CHANGELOG.md b/packages/ethereum-contracts/CHANGELOG.md index 1fa5988d93..416512776a 100644 --- a/packages/ethereum-contracts/CHANGELOG.md +++ b/packages/ethereum-contracts/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## Unreleased +### Breaking +- `TokenInfo` and `ERC20WithTokenInfo` interface/abstract contract are removed from the codebase, including the bundled ABI contracts + - Migration: Use `IERC20Metadata` instead, as this replaces the previous contracts + ### Added - Added 'test-slither' yarn sub-task. diff --git a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol index cf113976ba..83bdc6c9b7 100644 --- a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol +++ b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol @@ -2,9 +2,8 @@ pragma solidity >= 0.8.11; import { ISuperfluidToken } from "./ISuperfluidToken.sol"; -import { TokenInfo } from "../tokens/TokenInfo.sol"; +import { IERC20, IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC777 } from "@openzeppelin/contracts/token/ERC777/IERC777.sol"; -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IConstantOutflowNFT } from "./IConstantOutflowNFT.sol"; import { IConstantInflowNFT } from "./IConstantInflowNFT.sol"; @@ -12,7 +11,7 @@ import { IConstantInflowNFT } from "./IConstantInflowNFT.sol"; * @title Super token (Superfluid Token + ERC20 + ERC777) interface * @author Superfluid */ -interface ISuperToken is ISuperfluidToken, TokenInfo, IERC20, IERC777 { +interface ISuperToken is ISuperfluidToken, IERC20Metadata, IERC777 { /************************************************************************** * Errors @@ -52,19 +51,19 @@ interface ISuperToken is ISuperfluidToken, TokenInfo, IERC20, IERC777 { function CONSTANT_INFLOW_NFT() external view returns (IConstantInflowNFT); /************************************************************************** - * TokenInfo & ERC777 + * IERC20Metadata & ERC777 *************************************************************************/ /** * @dev Returns the name of the token. */ - function name() external view override(IERC777, TokenInfo) returns (string memory); + function name() external view override(IERC777, IERC20Metadata) returns (string memory); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ - function symbol() external view override(IERC777, TokenInfo) returns (string memory); + function symbol() external view override(IERC777, IERC20Metadata) returns (string memory); /** * @dev Returns the number of decimals used to get its user representation. @@ -81,7 +80,7 @@ interface ISuperToken is ISuperfluidToken, TokenInfo, IERC20, IERC777 { * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ - function decimals() external view override(TokenInfo) returns (uint8); + function decimals() external view override(IERC20Metadata) returns (uint8); /************************************************************************** * ERC20 & ERC777 diff --git a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol index b780727a11..7d8b1491e1 100644 --- a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol +++ b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.sol @@ -1,9 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity >= 0.8.11; +import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { ISuperToken } from "./ISuperToken.sol"; -import { IERC20, ERC20WithTokenInfo } from "../tokens/ERC20WithTokenInfo.sol"; - /** * @title Super token factory interface * @author Superfluid @@ -59,7 +58,7 @@ interface ISuperTokenFactory { * @return superToken The deployed and initialized wrapper super token */ function createERC20Wrapper( - IERC20 underlyingToken, + IERC20Metadata underlyingToken, uint8 underlyingDecimals, Upgradability upgradability, string calldata name, @@ -79,7 +78,7 @@ interface ISuperTokenFactory { * - It assumes token provide the .decimals() function */ function createERC20Wrapper( - ERC20WithTokenInfo underlyingToken, + IERC20Metadata underlyingToken, Upgradability upgradability, string calldata name, string calldata symbol @@ -93,7 +92,7 @@ interface ISuperTokenFactory { * @param _underlyingToken Underlying ERC20 token * @return ISuperToken the created supertoken */ - function createCanonicalERC20Wrapper(ERC20WithTokenInfo _underlyingToken) + function createCanonicalERC20Wrapper(IERC20Metadata _underlyingToken) external returns (ISuperToken); diff --git a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol index d66c80fa87..06bddb2c22 100644 --- a/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol +++ b/packages/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol @@ -16,9 +16,8 @@ import { } from "./Definitions.sol"; /// Super token related interfaces: /// Note: CustomSuperTokenBase is not included for people building CustomSuperToken. -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { IERC20, IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC777 } from "@openzeppelin/contracts/token/ERC777/IERC777.sol"; -import { TokenInfo, ERC20WithTokenInfo } from "../tokens/ERC20WithTokenInfo.sol"; import { ISuperfluidToken } from "./ISuperfluidToken.sol"; import { ISuperToken } from "./ISuperToken.sol"; import { ISuperTokenFactory } from "./ISuperTokenFactory.sol"; diff --git a/packages/ethereum-contracts/contracts/interfaces/tokens/ERC20WithTokenInfo.sol b/packages/ethereum-contracts/contracts/interfaces/tokens/ERC20WithTokenInfo.sol deleted file mode 100644 index cc93429257..0000000000 --- a/packages/ethereum-contracts/contracts/interfaces/tokens/ERC20WithTokenInfo.sol +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >= 0.8.11; - -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { TokenInfo } from "./TokenInfo.sol"; - -/** - * @title ERC20 token with token info interface - * @author Superfluid - * @dev Using abstract contract instead of interfaces because old solidity - * does not support interface inheriting other interfaces - * solhint-disable-next-line no-empty-blocks - * - */ -// solhint-disable-next-line no-empty-blocks -abstract contract ERC20WithTokenInfo is IERC20, TokenInfo {} diff --git a/packages/ethereum-contracts/contracts/interfaces/tokens/TokenInfo.sol b/packages/ethereum-contracts/contracts/interfaces/tokens/TokenInfo.sol deleted file mode 100644 index a50f4ddbe9..0000000000 --- a/packages/ethereum-contracts/contracts/interfaces/tokens/TokenInfo.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >= 0.8.11; - -/** - * @title ERC20 token info interface - * @author Superfluid - * @dev ERC20 standard interface does not specify these functions, but - * often the token implementations have them. - */ -interface TokenInfo { - /** - * @dev Returns the name of the token. - */ - function name() external view returns (string memory); - - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() external view returns (string memory); - - /** - * @dev Returns the number of decimals used to get its user representation. - * For example, if `decimals` equals `2`, a balance of `505` tokens should - * be displayed to a user as `5,05` (`505 / 10 ** 2`). - * - * Tokens usually opt for a value of 18, imitating the relationship between - * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is - * called. - * - * NOTE: This information is only used for _display_ purposes: it in - * no way affects any of the arithmetic of the contract, including - * {IERC20-balanceOf} and {IERC20-transfer}. - */ - function decimals() external view returns (uint8); -} diff --git a/packages/ethereum-contracts/contracts/mocks/CFAv1NFTMock.sol b/packages/ethereum-contracts/contracts/mocks/CFAv1NFTMock.sol index ad3c7a1cba..26b6c2c869 100644 --- a/packages/ethereum-contracts/contracts/mocks/CFAv1NFTMock.sol +++ b/packages/ethereum-contracts/contracts/mocks/CFAv1NFTMock.sol @@ -90,10 +90,10 @@ contract NoNFTSuperTokenMock is UUPSProxiable, SuperfluidToken { /// @dev Decimals of the underlying token uint8 internal _underlyingDecimals; - /// @dev TokenInfo Name property + /// @dev IERC20Metadata Name property string internal _name; - /// @dev TokenInfo Symbol property + /// @dev IERC20Metadata Symbol property string internal _symbol; /// @dev ERC20 Allowances Storage diff --git a/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol b/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol index 7ea44666b9..71194600c2 100644 --- a/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol +++ b/packages/ethereum-contracts/contracts/superfluid/SuperToken.sol @@ -57,10 +57,10 @@ contract SuperToken is /// @dev Decimals of the underlying token uint8 internal _underlyingDecimals; - /// @dev TokenInfo Name property + /// @dev IERC20Metadata Name property string internal _name; - /// @dev TokenInfo Symbol property + /// @dev IERC20Metadata Symbol property string internal _symbol; /// @dev ERC20 Allowances Storage diff --git a/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol b/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol index dd3b5fa74a..7ea1283f4b 100644 --- a/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol +++ b/packages/ethereum-contracts/contracts/superfluid/SuperTokenFactory.sol @@ -1,12 +1,11 @@ // SPDX-License-Identifier: AGPLv3 pragma solidity 0.8.19; +import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { ISuperTokenFactory, - ISuperToken, - IERC20, - ERC20WithTokenInfo + ISuperToken } from "../interfaces/superfluid/ISuperTokenFactory.sol"; import { ISuperfluid, IConstantOutflowNFT, IConstantInflowNFT } from "../interfaces/superfluid/ISuperfluid.sol"; import { UUPSProxy } from "../upgradability/UUPSProxy.sol"; @@ -155,7 +154,7 @@ abstract contract SuperTokenFactoryBase is } /// @inheritdoc ISuperTokenFactory - function createCanonicalERC20Wrapper(ERC20WithTokenInfo _underlyingToken) + function createCanonicalERC20Wrapper(IERC20Metadata _underlyingToken) external returns (ISuperToken) { @@ -209,7 +208,7 @@ abstract contract SuperTokenFactoryBase is /// @inheritdoc ISuperTokenFactory function createERC20Wrapper( - IERC20 underlyingToken, + IERC20Metadata underlyingToken, uint8 underlyingDecimals, Upgradability upgradability, string calldata name, @@ -248,7 +247,7 @@ abstract contract SuperTokenFactoryBase is /// @inheritdoc ISuperTokenFactory function createERC20Wrapper( - ERC20WithTokenInfo underlyingToken, + IERC20Metadata underlyingToken, Upgradability upgradability, string calldata name, string calldata symbol diff --git a/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol b/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol index c8d52bd23f..6d0f07bd9b 100644 --- a/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol +++ b/packages/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.11; +import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { SuperfluidFrameworkDeploymentSteps, TokenDeployerLibrary } from "./SuperfluidFrameworkDeploymentSteps.sol"; -import { ISuperTokenFactory, ERC20WithTokenInfo } from "../superfluid/SuperTokenFactory.sol"; +import { ISuperTokenFactory } from "../superfluid/SuperTokenFactory.sol"; import { SuperToken } from "../superfluid/SuperToken.sol"; import { TestToken } from "./TestToken.sol"; import { ISETH } from "../interfaces/tokens/ISETH.sol"; @@ -178,7 +179,7 @@ contract SuperfluidFrameworkDeployer is SuperfluidFrameworkDeploymentSteps { superToken = SuperToken( address( superTokenFactory.createERC20Wrapper( - ERC20WithTokenInfo(address(underlyingToken)), + IERC20Metadata(address(underlyingToken)), ISuperTokenFactory.Upgradability.SEMI_UPGRADABLE, string.concat("Super ", _underlyingSymbol), superTokenSymbol diff --git a/packages/ethereum-contracts/ops-scripts/deploy-super-token.js b/packages/ethereum-contracts/ops-scripts/deploy-super-token.js index 74474dd8ff..5c9561aaae 100644 --- a/packages/ethereum-contracts/ops-scripts/deploy-super-token.js +++ b/packages/ethereum-contracts/ops-scripts/deploy-super-token.js @@ -56,6 +56,7 @@ module.exports = eval(`(${S.toString()})()`)(async function ( "Resolver", "UUPSProxiable", "SETHProxy", + "IERC20Metadata", ], contractLoader: builtTruffleContractLoader, }); @@ -64,7 +65,7 @@ module.exports = eval(`(${S.toString()})()`)(async function ( const { Resolver, UUPSProxiable, - ERC20WithTokenInfo, + IERC20Metadata, ISuperToken, ISETH, SETHProxy, @@ -112,7 +113,7 @@ module.exports = eval(`(${S.toString()})()`)(async function ( if (web3.utils.isAddress(tokenSymbolOrAddress)) { tokenAddress = tokenSymbolOrAddress; tokenSymbol = await ( - await ERC20WithTokenInfo.at(tokenAddress) + await IERC20Metadata.at(tokenAddress) ).symbol.call(); } else { tokenSymbol = tokenSymbolOrAddress; @@ -128,20 +129,21 @@ module.exports = eval(`(${S.toString()})()`)(async function ( if (tokenAddress === ZERO_ADDRESS) { throw new Error("Underlying ERC20 Token not found"); } - const tokenInfo = await sf.contracts.TokenInfo.at(tokenAddress); - const tokenInfoName = await tokenInfo.name.call(); - const tokenInfoSymbol = await tokenInfo.symbol.call(); - const tokenInfoDecimals = await tokenInfo.decimals.call(); + const iERC20Metadata = + await sf.contracts.IERC20Metadata.at(tokenAddress); + const name = await iERC20Metadata.name.call(); + const symbol = await iERC20Metadata.symbol.call(); + const decimals = await iERC20Metadata.decimals.call(); console.log("Underlying token address", tokenAddress); - console.log("Underlying token info name()", tokenInfoName); - console.log("Underlying token info symbol()", tokenInfoSymbol); + console.log("Underlying token info name()", name); + console.log("Underlying token info symbol()", symbol); console.log( "Underlying token info decimals()", - tokenInfoDecimals.toString() + decimals.toString() ); superTokenKey = `supertokens.${protocolReleaseVersion}.${tokenSymbol}x`; deploymentFn = async () => { - return await sf.createERC20Wrapper(tokenInfo); + return await sf.createERC20Wrapper(iERC20Metadata); }; } } diff --git a/packages/ethereum-contracts/ops-scripts/deploy-unlisted-super-token.js b/packages/ethereum-contracts/ops-scripts/deploy-unlisted-super-token.js index 2d69130e4e..bb0e57f7e3 100644 --- a/packages/ethereum-contracts/ops-scripts/deploy-unlisted-super-token.js +++ b/packages/ethereum-contracts/ops-scripts/deploy-unlisted-super-token.js @@ -40,24 +40,21 @@ module.exports = eval(`(${S.toString()})()`)(async function ( const sf = new SuperfluidSDK.Framework({ ...extractWeb3Options(options), version: protocolReleaseVersion, - additionalContracts: ["UUPSProxiable"], + additionalContracts: ["UUPSProxiable", "IERC20Metadata"], contractLoader: builtTruffleContractLoader, }); await sf.initialize(); - const tokenInfo = await sf.contracts.TokenInfo.at(tokenAddress); - const tokenInfoName = await tokenInfo.name.call(); - const tokenInfoSymbol = await tokenInfo.symbol.call(); - const tokenInfoDecimals = await tokenInfo.decimals.call(); - console.log("Underlying token name", tokenInfoName); - console.log("Underlying token info name()", tokenInfoName); - console.log("Underlying token info symbol()", tokenInfoSymbol); - console.log( - "Underlying token info decimals()", - tokenInfoDecimals.toString() - ); + const iERC20Metadata = await sf.contracts.IERC20Metadata.at(tokenAddress); + const name = await iERC20Metadata.name.call(); + const symbol = await iERC20Metadata.symbol.call(); + const decimals = await iERC20Metadata.decimals.call(); + console.log("Underlying token name", name); + console.log("Underlying token info name()", name); + console.log("Underlying token info symbol()", symbol); + console.log("Underlying token info decimals()", decimals.toString()); console.log("Creating the wrapper..."); - const superToken = await sf.createERC20Wrapper(tokenInfo, { + const superToken = await sf.createERC20Wrapper(iERC20Metadata, { superTokenName, superTokenSymbol, }); diff --git a/packages/ethereum-contracts/tasks/bundled-abi-contracts-list.json b/packages/ethereum-contracts/tasks/bundled-abi-contracts-list.json index 068c1e7064..86155c49bb 100644 --- a/packages/ethereum-contracts/tasks/bundled-abi-contracts-list.json +++ b/packages/ethereum-contracts/tasks/bundled-abi-contracts-list.json @@ -4,7 +4,7 @@ "UUPSProxiable", "IERC20", "IERC777", - "TokenInfo", "ERC20WithTokenInfo", + "IERC20Metadata", "ISuperfluid", "Superfluid", "ISuperfluidToken", "SuperfluidToken", "ISuperToken", "SuperToken", diff --git a/packages/ethereum-contracts/utils/supertoken-deployer.html b/packages/ethereum-contracts/utils/supertoken-deployer.html index f740cbd2ee..238a409095 100644 --- a/packages/ethereum-contracts/utils/supertoken-deployer.html +++ b/packages/ethereum-contracts/utils/supertoken-deployer.html @@ -47,9 +47,9 @@