Skip to content

Commit

Permalink
constructor ERC20 with the agent as owner
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Apr 4, 2024
1 parent 9b7811d commit b00538f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
17 changes: 3 additions & 14 deletions contracts/src/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract ERC20 is IERC20, IERC20Permit {
bytes32 private constant PERMIT_SIGNATURE_HASH =
bytes32(0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9);

address public OWNER;
address public immutable OWNER;
string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = "\x19\x01";
uint8 public immutable decimals;

Expand All @@ -64,8 +64,8 @@ contract ERC20 is IERC20, IERC20Permit {
/**
* @dev Sets the values for {name}, {symbol}, and {decimals}.
*/
constructor(string memory name_, string memory symbol_, uint8 decimals_) {
OWNER = msg.sender;
constructor(address _owner, string memory name_, string memory symbol_, uint8 decimals_) {
OWNER = _owner;
DOMAIN_SEPARATOR = keccak256(
abi.encode(
DOMAIN_TYPE_SIGNATURE_HASH, keccak256(bytes(name_)), keccak256(bytes("1")), block.chainid, address(this)
Expand All @@ -84,17 +84,6 @@ contract ERC20 is IERC20, IERC20Permit {
_;
}

/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
OWNER = newOwner;
}

/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply. Can only be called by the owner.
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,12 @@ contract Gateway is IGateway, IInitializable {
if ($.tokenRegistryByID[tokenID].isRegistered == true) {
revert TokenAlreadyRegistered();
}
ERC20 foreignToken = new ERC20(name, symbol, decimals);
ERC20 foreignToken = new ERC20(agent, name, symbol, decimals);
address token = address(foreignToken);
TokenInfo memory info =
TokenInfo({isRegistered: true, isForeign: true, tokenID: tokenID, agentID: agentID, token: token});
$.tokenRegistry[token] = info;
$.tokenRegistryByID[tokenID] = info;
foreignToken.transferOwnership(agent);
emit ForeignTokenRegistered(tokenID, agentID, token);
}

Expand Down

0 comments on commit b00538f

Please sign in to comment.