-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add/contract-sizer
- Loading branch information
Showing
33 changed files
with
4,885 additions
and
5,702 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol'; | ||
import { ITokenManager } from '../interfaces/ITokenManager.sol'; | ||
|
||
import { InterchainToken } from '../interchain-token/InterchainToken.sol'; | ||
import { ERC20Permit } from '../token-implementations/ERC20Permit.sol'; | ||
import { AddressBytesUtils } from '../libraries/AddressBytesUtils.sol'; | ||
import { Implementation } from '../utils/Implementation.sol'; | ||
import { Distributable } from '../utils/Distributable.sol'; | ||
|
||
contract InvalidStandardizedToken is IERC20MintableBurnable, InterchainToken, ERC20Permit, Implementation, Distributable { | ||
using AddressBytesUtils for bytes; | ||
|
||
string public name; | ||
string public symbol; | ||
uint8 public decimals; | ||
address internal tokenManager_; | ||
|
||
bytes32 private constant CONTRACT_ID = keccak256('invalid-standardized-token'); | ||
|
||
modifier onlyDistributorOrTokenManager() { | ||
if (msg.sender != tokenManager_) { | ||
if (msg.sender != distributor()) revert NotDistributor(); | ||
} | ||
|
||
_; | ||
} | ||
|
||
/** | ||
* @notice Getter for the contract id. | ||
*/ | ||
function contractId() external pure returns (bytes32) { | ||
return CONTRACT_ID; | ||
} | ||
|
||
/** | ||
* @notice Returns the token manager for this token | ||
* @return ITokenManager The token manager contract | ||
*/ | ||
function tokenManager() public view override returns (ITokenManager) { | ||
return ITokenManager(tokenManager_); | ||
} | ||
|
||
/** | ||
* @notice Setup function to initialize contract parameters | ||
* @param params The setup parameters in bytes | ||
* The setup params include tokenManager, distributor, tokenName, symbol, decimals, mintAmount and mintTo | ||
*/ | ||
function setup(bytes calldata params) external override onlyProxy { | ||
{ | ||
address distributor_; | ||
address tokenManagerAddress; | ||
string memory tokenName; | ||
(tokenManagerAddress, distributor_, tokenName, symbol, decimals) = abi.decode( | ||
params, | ||
(address, address, string, string, uint8) | ||
); | ||
|
||
tokenManager_ = tokenManagerAddress; | ||
name = tokenName; | ||
|
||
_setDistributor(distributor_); | ||
_setNameHash(tokenName); | ||
} | ||
{ | ||
uint256 mintAmount; | ||
address mintTo; | ||
(, , , , , mintAmount, mintTo) = abi.decode(params, (address, address, string, string, uint8, uint256, address)); | ||
|
||
if (mintAmount > 0 && mintTo != address(0)) { | ||
_mint(mintTo, mintAmount); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @notice Function to mint new tokens | ||
* Can only be called by the distributor address. | ||
* @param account The address that will receive the minted tokens | ||
* @param amount The amount of tokens to mint | ||
*/ | ||
function mint(address account, uint256 amount) external onlyDistributorOrTokenManager { | ||
_mint(account, amount); | ||
} | ||
|
||
/** | ||
* @notice Function to burn tokens | ||
* Can only be called by the distributor address. | ||
* @param account The address that will have its tokens burnt | ||
* @param amount The amount of tokens to burn | ||
*/ | ||
function burn(address account, uint256 amount) external onlyDistributorOrTokenManager { | ||
_burn(account, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { AddressBytesUtils } from '../../libraries/AddressBytesUtils.sol'; | ||
|
||
contract AddressBytesUtilsTest { | ||
using AddressBytesUtils for address; | ||
using AddressBytesUtils for bytes; | ||
|
||
function toAddress(bytes memory bytesAddress) external pure returns (address addr) { | ||
return bytesAddress.toAddress(); | ||
} | ||
|
||
function toBytes(address addr) external pure returns (bytes memory bytesAddress) { | ||
return addr.toBytes(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import { NoReEntrancy } from '../../utils/NoReEntrancy.sol'; | ||
|
||
contract NoReEntrancyTest is NoReEntrancy { | ||
uint256 public value; | ||
|
||
function testFunction() external noReEntrancy { | ||
value = 1; | ||
this.callback(); | ||
value = 2; | ||
} | ||
|
||
function callback() external noReEntrancy {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.