Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions contracts/moonstream/ERC20Initializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import "../diamond/libraries/LibDiamond.sol";
import "./LibERC20.sol";

contract ERC20Initializer {
function init() external {
function init(string memory name, string memory symbol) external {
LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
ds.supportedInterfaces[type(IERC20).interfaceId] = true;

LibERC20.ERC20Storage storage es = LibERC20.erc20Storage();
es.controller = msg.sender;
es.name = "Moonstream DAO";
es.symbol = "MNSTR";
es.name = name;
es.symbol = symbol;
}
}
18 changes: 0 additions & 18 deletions contracts/moonstream/ERC20WithCommonStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,6 @@ import "@openzeppelin-contracts/contracts/utils/Context.sol";
import "./LibERC20.sol";

contract ERC20WithCommonStorage is Context, IERC20, IERC20Metadata {
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function setERC20Metadata(string memory name_, string memory symbol_)
external
{
LibERC20.enforceIsController();
LibERC20.ERC20Storage storage es = LibERC20.erc20Storage();
es.name = name_;
es.symbol = symbol_;
}

/**
* @dev Returns the name of the token.
*/
Expand Down
5 changes: 4 additions & 1 deletion dao/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def facet_cut(
ignore_selectors: Optional[List[str]] = None,
methods: Optional[List[str]] = None,
selectors: Optional[List[str]] = None,
initializer_params: Optional[List[Any]] = None,
) -> Any:
"""
Cuts the given facet onto the given Diamond contract.
Expand Down Expand Up @@ -127,7 +128,9 @@ def facet_cut(
if facet_name == "ERC20Facet":
if initializer_address != ZERO_ADDRESS and action != "remove":
erc20_initializer = ERC20Initializer.ERC20Initializer(initializer_address)
calldata = erc20_initializer.contract.init.encode_input()
calldata = erc20_initializer.contract.init.encode_input(
initializer_params[0], initializer_params[1]
)
elif facet_name == "TerminusFacet":
if initializer_address != ZERO_ADDRESS and action != "remove":
terminus_initializer = TerminusInitializer.TerminusInitializer(
Expand Down
1 change: 1 addition & 0 deletions dao/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def setUpClass(cls) -> None:
"add",
{"from": accounts[0]},
initializer.address,
initializer_params=["Moonstream DAO", "MNSTR"],
)

cls.erc20_initializer = initializer.address
Expand Down
20 changes: 5 additions & 15 deletions dao/test_moonstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_add_and_replace(self):
"add",
{"from": accounts[0]},
initializer.address,
initializer_params=["Moonstream DAO", "MNSTR"],
)

diamond_erc20 = ERC20Facet.ERC20Facet(diamond_address)
Expand All @@ -39,19 +40,6 @@ def test_add_and_replace(self):
expected_decimals = 18
self.assertEqual(decimals, expected_decimals)

with self.assertRaises(Exception):
diamond_erc20.set_erc20_metadata("LOL", "ROFL", {"from": accounts[1]})

diamond_erc20.set_erc20_metadata("LOL", "ROFL", {"from": accounts[0]})

name = diamond_erc20.name()
expected_name = "LOL"
self.assertEqual(name, expected_name)

symbol = diamond_erc20.symbol()
expected_symbol = "ROFL"
self.assertEqual(symbol, expected_symbol)

new_erc20_facet = ERC20Facet.ERC20Facet(None)
new_erc20_facet.deploy({"from": accounts[0]})
facet_cut(
Expand All @@ -61,14 +49,15 @@ def test_add_and_replace(self):
"replace",
{"from": accounts[0]},
initializer.address,
initializer_params=["ROFL", "LOL"],
)

name = diamond_erc20.name()
expected_name = "Moonstream DAO"
expected_name = "ROFL"
self.assertEqual(name, expected_name)

symbol = diamond_erc20.symbol()
expected_symbol = "MNSTR"
expected_symbol = "LOL"
self.assertEqual(symbol, expected_symbol)


Expand All @@ -88,6 +77,7 @@ def test_remove_facet(self):
"add",
{"from": accounts[0]},
initializer.address,
initializer_params=["Moonstream DAO", "MNSTR"],
)

diamond_erc20 = ERC20Facet.ERC20Facet(diamond_address)
Expand Down