Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TECHDEBT][ETHEREUM-CONTRACTS] Remove token info #1679

Merged
merged 5 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
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";

/**
* @title Super token (Superfluid Token + ERC20 + ERC777) interface
* @author Superfluid
*/
interface ISuperToken is ISuperfluidToken, TokenInfo, IERC20, IERC777 {
interface ISuperToken is ISuperfluidToken, IERC20Metadata, IERC777 {

/**************************************************************************
* Errors
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -155,7 +154,7 @@ abstract contract SuperTokenFactoryBase is
}

/// @inheritdoc ISuperTokenFactory
function createCanonicalERC20Wrapper(ERC20WithTokenInfo _underlyingToken)
function createCanonicalERC20Wrapper(IERC20Metadata _underlyingToken)
external
returns (ISuperToken)
{
Expand Down Expand Up @@ -209,7 +208,7 @@ abstract contract SuperTokenFactoryBase is

/// @inheritdoc ISuperTokenFactory
function createERC20Wrapper(
IERC20 underlyingToken,
IERC20Metadata underlyingToken,
uint8 underlyingDecimals,
Upgradability upgradability,
string calldata name,
Expand Down Expand Up @@ -248,7 +247,7 @@ abstract contract SuperTokenFactoryBase is

/// @inheritdoc ISuperTokenFactory
function createERC20Wrapper(
ERC20WithTokenInfo underlyingToken,
IERC20Metadata underlyingToken,
Upgradability upgradability,
string calldata name,
string calldata symbol
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions packages/ethereum-contracts/ops-scripts/deploy-super-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = eval(`(${S.toString()})()`)(async function (
"Resolver",
"UUPSProxiable",
"SETHProxy",
"IERC20Metadata",
],
contractLoader: builtTruffleContractLoader,
});
Expand All @@ -64,7 +65,7 @@ module.exports = eval(`(${S.toString()})()`)(async function (
const {
Resolver,
UUPSProxiable,
ERC20WithTokenInfo,
IERC20Metadata,
ISuperToken,
ISETH,
SETHProxy,
Expand Down Expand Up @@ -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;
Expand All @@ -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);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"UUPSProxiable",
"IERC20",
"IERC777",
"TokenInfo", "ERC20WithTokenInfo",
"IERC20Metadata",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a breaking change that's need to be documented in CHANGELOG.

"ISuperfluid", "Superfluid",
"ISuperfluidToken", "SuperfluidToken",
"ISuperToken", "SuperToken",
Expand Down
Loading