Skip to content

Commit

Permalink
feat: updated libraries and removed hardcoded x (#7)
Browse files Browse the repository at this point in the history
* feat: updated libraries and removed hardcoded x

* chore: add comment for updating salt

* feat: deployments

* fix: deployment address in txt

---------

Co-authored-by: Sven Meyer <[email protected]>
Co-authored-by: just-a-node <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2023
1 parent 8d9172e commit 36a9d3b
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 232 deletions.
13 changes: 8 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
MAINNET_RPC=
OPTIMISM_RPC=
POLYGON_RPC=
ARBITRUM_RPC=
ETHEREUM_MAINNET_RPC=
POLYGON_MAINNET_RPC=
OPTIMISM_MAINNET_RPC=
ARBITRUM_MAINNET_RPC=
GNOSIS_RPC=
BSC_RPC=
GOERLI_RPC=
ETHEREUM_GOERLI_RPC=
POLYGON_MUMBAI_RPC=
ARBITRUM_GOERLI_RPC=
OPTIMISM_GOERLI_RPC=

ETHERSCAN_API_KEY=

Expand Down
3 changes: 1 addition & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib\\openzeppelin-contracts"]
branch = v4.8.3
branch = v4.9.3
[submodule "lib/permit2"]
path = lib/permit2
url = https://github.com/Uniswap/permit2
36 changes: 18 additions & 18 deletions broadcast/MultichainDeploy.sol/1/run-latest.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions broadcast/MultichainDeploy.sol/10/run-latest.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions broadcast/MultichainDeploy.sol/100/run-latest.json

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions broadcast/MultichainDeploy.sol/137/run-latest.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions broadcast/MultichainDeploy.sol/420/run-latest.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions broadcast/MultichainDeploy.sol/42161/run-latest.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions broadcast/MultichainDeploy.sol/421613/run-latest.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions broadcast/MultichainDeploy.sol/5/run-latest.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions broadcast/MultichainDeploy.sol/56/run-latest.json

Large diffs are not rendered by default.

54 changes: 10 additions & 44 deletions broadcast/MultichainDeploy.sol/80001/run-latest.json

Large diffs are not rendered by default.

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.23'
src = 'solidity'
test = 'solidity/test'
out = 'out'
Expand Down
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
8 changes: 2 additions & 6 deletions solidity/contracts/XERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity >=0.8.4 <0.9.0;

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 {ERC20Permit} from '@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol';
import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';

contract XERC20 is ERC20, Ownable, IXERC20, ERC20Permit {
Expand Down Expand Up @@ -35,11 +35,7 @@ contract XERC20 is ERC20, Ownable, IXERC20, ERC20Permit {
* @param _factory The factory which deployed this contract
*/

constructor(
string memory _name,
string memory _symbol,
address _factory
) ERC20(string.concat('x', _name), string.concat('x', _symbol)) ERC20Permit(string.concat('x', _name)) {
constructor(string memory _name, string memory _symbol, address _factory) ERC20(_name, _symbol) ERC20Permit(_name) {
_transferOwnership(_factory);
FACTORY = _factory;
}
Expand Down
19 changes: 15 additions & 4 deletions solidity/scripts/MultichainDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ import {ScriptingLibrary} from './ScriptingLibrary/ScriptingLibrary.sol';
contract MultichainDeploy is Script, ScriptingLibrary {
uint256 public deployer = vm.envUint('DEPLOYER_PRIVATE_KEY');
address constant CREATE2 = 0x4e59b44847b379578588920cA78FbF26c0B4956C;
string[] public chains = ['MAINNET_RPC', 'POLYGON_RPC', 'OPTIMISM_RPC', 'ARBITRUM_RPC', 'GNOSIS_RPC', 'BSC_RPC'];
string[] public chains = [
'ETHEREUM_MAINNET_RPC',
'POLYGON_MAINNET_RPC',
'OPTIMISM_MAINNET_RPC',
'ARBITRUM_MAINNET_RPC',
'GNOSIS_RPC',
'BSC_RPC',
'ETHEREUM_GOERLI_RPC',
'POLYGON_MUMBAI_RPC',
'ARBITRUM_GOERLI_RPC',
'OPTIMISM_GOERLI_RPC'
];

function run() public {
//TODO: Change salt from this test to prod before release
bytes32 _salt = keccak256(abi.encodePacked('de4y6D2tuMLufI7YOZMZ9AKw6YCMZeII7mX4U', msg.sender));
// When new factories need to be deployed, make sure to update the salt version
bytes32 _salt = keccak256(abi.encodePacked('xERC20-v1.2', msg.sender));
address[] memory _factories = new address[](chains.length);

for (uint256 _i; _i < chains.length; _i++) {
Expand All @@ -27,7 +38,7 @@ contract MultichainDeploy is Script, ScriptingLibrary {
address _deployedFactory = getAddress(_bytecodeFactory, _salt, CREATE2);
XERC20Factory _fact = new XERC20Factory{salt: _salt}();
require(address(_fact) == _deployedFactory, 'Factory address does not match');

vm.stopBroadcast();
// solhint-disable-next-line no-console
console.log(chains[_i], 'factory deployed to:', address(_deployedFactory));
Expand Down
2 changes: 1 addition & 1 deletion solidity/scripts/ScriptingLibrary/FactoryAddress.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0xc10fa06d401c05bce65b55efb1ef2158e55ff1d7
0x44b9153a9c24a7283e86C5eF6453A658Bfb982A0
4 changes: 2 additions & 2 deletions solidity/test/e2e/XERC20Factory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {XERC20Lockbox} from '../../contracts/XERC20Lockbox.sol';
contract E2EDeployment is CommonE2EBase {
function testDeploy() public {
assertEq(address(_xerc20.owner()), _owner);
assertEq(_xerc20.name(), 'xDai Stablecoin');
assertEq(_xerc20.symbol(), 'xDAI');
assertEq(_xerc20.name(), 'Dai Stablecoin');
assertEq(_xerc20.symbol(), 'DAI');
assertEq(_xerc20.FACTORY(), address(_xerc20Factory));
assertEq(address(_lockbox.XERC20()), address(_xerc20));
assertEq(address(_lockbox.ERC20()), address(_dai));
Expand Down
4 changes: 2 additions & 2 deletions solidity/test/unit/XERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ abstract contract Base is Test {

contract UnitNames is Base {
function testName() public {
assertEq('xTest', _xerc20.name());
assertEq('Test', _xerc20.name());
}

function testSymbol() public {
assertEq('xTST', _xerc20.symbol());
assertEq('TST', _xerc20.symbol());
}
}

Expand Down
2 changes: 1 addition & 1 deletion solidity/test/unit/XERC20Factory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract UnitDeploy is Base {
address[] memory _minters = new address[](0);

address _xerc20 = _xerc20Factory.deployXERC20('Test', 'TST', _limits, _limits, _minters);
assertEq(XERC20(_xerc20).name(), 'xTest');
assertEq(XERC20(_xerc20).name(), 'Test');
}

function testRevertsWhenAddressIsTaken() public {
Expand Down

0 comments on commit 36a9d3b

Please sign in to comment.