Skip to content

Commit

Permalink
contracts were modified
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonmezturk committed Sep 4, 2023
1 parent 1be0672 commit d97dedc
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Install forge dependencies
run: forge install

- name: Precompile using 0.8.14 and via-ir=false
- name: Precompile using 0.8.18 and via-ir=false
run: yarn build

- name: "Create env file"
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- name: Install forge dependencies
run: forge install

- name: Precompile using 0.8.14 and via-ir=true
- name: Precompile using 0.8.18 and via-ir=true
run: yarn build:optimized

- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ multiline_func_header = 'params_first'
fs_permissions = [{ access = "read-write", path = "./"}]

[profile.default]
solc = '0.8.14'
solc = '0.8.18'
src = 'solidity'
test = 'solidity/test'
out = 'out'
Expand Down
8 changes: 4 additions & 4 deletions solidity/contracts/XERC20.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
pragma solidity 0.8.18;

import {IXERC20} from 'interfaces/IXERC20.sol';
import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import {ERC20Permit} from '@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol';
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {Ownable2Step} from '@openzeppelin/contracts/access/Ownable2Step.sol';
import {ReentrancyGuard} from '@openzeppelin/contracts/security/ReentrancyGuard.sol';

contract XERC20 is ERC20, Ownable, IXERC20, ERC20Permit, ReentrancyGuard {
contract XERC20 is ERC20, Ownable2Step, IXERC20, ERC20Permit, ReentrancyGuard {
/**
* @notice The duration it takes for the limits to fully replenish
*/
Expand All @@ -26,7 +26,7 @@ contract XERC20 is ERC20, Ownable, IXERC20, ERC20Permit, ReentrancyGuard {
/**
* @notice Maps bridge address to bridge configurations
*/
mapping(address => Bridge) public bridges;
mapping(address bridgeAddress => Bridge) public bridges;

/**
* @notice Constructs the initial config of the XERC20
Expand Down
17 changes: 10 additions & 7 deletions solidity/contracts/XERC20Factory.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
pragma solidity 0.8.18;

import {XERC20} from 'contracts/XERC20.sol';
import {IXERC20Factory} from 'interfaces/IXERC20Factory.sol';
import {XERC20Lockbox} from 'contracts/XERC20Lockbox.sol';
import {CREATE3} from 'isolmate/utils/CREATE3.sol';
import {Ownable2Step} from '@openzeppelin/contracts/access/Ownable2Step.sol';
import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

contract XERC20Factory is IXERC20Factory {
contract XERC20Factory is Ownable2Step, IXERC20Factory {
using EnumerableSet for EnumerableSet.AddressSet;

/**
* @notice Address of the xerc20 maps to the address of its lockbox if it has one
*/
mapping(address => address) public lockboxRegistry;
mapping(address xerc20Address => address lockboxAddress) public lockboxRegistry;

/**
* @notice The set of registered lockboxes
Expand Down Expand Up @@ -41,7 +42,7 @@ contract XERC20Factory is IXERC20Factory {
uint256[] memory _minterLimits,
uint256[] memory _burnerLimits,
address[] memory _bridges
) external returns (address _xerc20) {
) external onlyOwner returns (address _xerc20) {
_xerc20 = _deployXERC20(_name, _symbol, _minterLimits, _burnerLimits, _bridges);

emit XERC20Deployed(_xerc20);
Expand All @@ -59,7 +60,7 @@ contract XERC20Factory is IXERC20Factory {
address _xerc20,
address _baseToken,
bool _isNative
) external returns (address payable _lockbox) {
) external onlyOwner returns (address payable _lockbox) {
if (_baseToken == address(0) && !_isNative) revert IXERC20Factory_BadTokenAddress();

if (XERC20(_xerc20).owner() != msg.sender) revert IXERC20Factory_NotOwner();
Expand Down Expand Up @@ -158,7 +159,8 @@ contract XERC20Factory is IXERC20Factory {

_xerc20 = CREATE3.deploy(_salt, _bytecode, 0);

EnumerableSet.add(_xerc20RegistryArray, _xerc20);
bool savedXErc20 = EnumerableSet.add(_xerc20RegistryArray, _xerc20);
require(savedXErc20, 'Not saved into EnumerableSet');

for (uint256 _i; _i < _bridgesLength; ++_i) {
XERC20(_xerc20).setLimits(_bridges[_i], _minterLimits[_i], _burnerLimits[_i]);
Expand All @@ -179,7 +181,8 @@ contract XERC20Factory is IXERC20Factory {
_lockbox = payable(CREATE3.deploy(_salt, _bytecode, 0));

XERC20(_xerc20).setLockbox(address(_lockbox));
EnumerableSet.add(_lockboxRegistryArray, _lockbox);
bool savedLockbox = EnumerableSet.add(_lockboxRegistryArray, _lockbox);
require(savedLockbox, 'Not saved into EnumerableSet');
lockboxRegistry[_xerc20] = _lockbox;
}
}
2 changes: 1 addition & 1 deletion solidity/contracts/XERC20Lockbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
pragma solidity 0.8.18;

import {IXERC20} from 'interfaces/IXERC20.sol';
import {IERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol';
Expand Down
2 changes: 1 addition & 1 deletion solidity/interfaces/IXERC20.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
pragma solidity 0.8.18;

interface IXERC20 {
/**
Expand Down
2 changes: 1 addition & 1 deletion solidity/interfaces/IXERC20Factory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
pragma solidity 0.8.18;

interface IXERC20Factory {
/**
Expand Down
5 changes: 3 additions & 2 deletions solidity/interfaces/IXERC20Lockbox.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
pragma solidity 0.8.18;


interface IXERC20Lockbox {
/**
Expand Down Expand Up @@ -47,4 +48,4 @@ interface IXERC20Lockbox {
*/

function withdraw(uint256 _amount) external;
}
}
1 change: 1 addition & 0 deletions solidity/scripts/MultichainDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ScriptingLibrary} from './ScriptingLibrary/ScriptingLibrary.sol';

contract MultichainDeploy is Script, ScriptingLibrary {
uint256 public deployer = vm.envUint('DEPLOYER_PRIVATE_KEY');
// NOTE: CHANGEABLE ?
address constant CREATE2 = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
string[] public chains = ['MUMBAI_RPC'];

Expand Down

0 comments on commit d97dedc

Please sign in to comment.