Skip to content

Commit

Permalink
feat(ControllerToken): adding comment ; creating interfaces directory
Browse files Browse the repository at this point in the history
  • Loading branch information
KristenPire committed Mar 26, 2024
1 parent 479b3cf commit a1d9af0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
19 changes: 4 additions & 15 deletions src/ControllerToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@ pragma solidity 0.8.20;
//SPDX-License-Identifier: APACHE-2.0

import "./Token.sol";
import "./interfaces/IERC677Recipient.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";


interface IERC677Recipient {
/**
* @dev Receives notification from [ERC677] transferAndCall.
* @param from Sender address.
* @param amount Number of tokens.
* @param data Additional data.
*/
function onTokenTransfer(
address from,
uint256 amount,
bytes calldata data
) external returns (bool);
}

// The ControllerToken contract acts as a bridge to ensure compatibility between the Smart-Contract v2 and the v1 TokenFrontend.
// It allows the v2's proxy to function as the controller for the v1 TokenFrontend.
// The ambition is to allow the v2's proxy to be the only contract that needs to be upgraded in the future.
contract ControllerToken is Token {
struct ControllerTokenStorage {
address frontend;
Expand Down
24 changes: 9 additions & 15 deletions src/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract Token is
string memory name,
string memory symbol,
address _validator
) public initializer virtual {
) public virtual initializer {
// Those line replaces the inheritance call in the constructor, as we are using the upgradeable pattern.
// In the upgradeable pattern, the 'initialize' function replaces the constructor. It's not called automatically.
// The proxy contract calls this function using delegatecall.
Expand Down Expand Up @@ -133,7 +133,7 @@ contract Token is
return super.transferFrom(from, to, amount);
}

// setMaxMintAllowance is only callable by the owner
// setMaxMintAllowance is only callable by the owner
function setMaxMintAllowance(uint256 amount) public onlyOwner {
_setMaxMintAllowance(amount);
}
Expand Down Expand Up @@ -161,7 +161,9 @@ contract Token is
_domainSeparatorV4(),
keccak256(
abi.encode(
PERMIT_TYPEHASH,
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
Expand All @@ -181,9 +183,7 @@ contract EURe is Token {
_disableInitializers();
}

function initialize(
address _validator
) public initializer {
function initialize(address _validator) public initializer {
super.initialize("EUR", "EURe", _validator);
}
}
Expand All @@ -194,9 +194,7 @@ contract GBPe is Token {
_disableInitializers();
}

function initialize(
address _validator
) public initializer {
function initialize(address _validator) public initializer {
super.initialize("GBP", "GBPe", _validator);
}
}
Expand All @@ -207,9 +205,7 @@ contract ISKe is Token {
_disableInitializers();
}

function initialize(
address _validator
) public initializer{
function initialize(address _validator) public initializer {
super.initialize("ISK", "ISKe", _validator);
}
}
Expand All @@ -220,9 +216,7 @@ contract USDe is Token {
_disableInitializers();
}

function initialize(
address _validator
) public initializer {
function initialize(address _validator) public initializer {
super.initialize("USD", "USDe", _validator);
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/interfaces/IERC677Recipient.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: APACHE-2.0
pragma solidity 0.8.20;

interface IERC677Recipient {
/**
* @dev Receives notification from [ERC677] transferAndCall.
* @param from Sender address.
* @param amount Number of tokens.
* @param data Additional data.
*/
function onTokenTransfer(
address from,
uint256 amount,
bytes calldata data
) external returns (bool);
}

0 comments on commit a1d9af0

Please sign in to comment.