Skip to content

Commit

Permalink
fix(Burn/Recover): change the message hash checked
Browse files Browse the repository at this point in the history
  • Loading branch information
KristenPire committed Jun 3, 2024
1 parent 14d697e commit 07d95f2
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 9 deletions.
2 changes: 1 addition & 1 deletion script/configureToken.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export MAX_MINT_ALLOWANCE=$allowance

# Call the Forge script
echo "configure tokens"
forge script script/configureToken.s.sol --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY
forge script script/configureToken.s.sol --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --legacy


103 changes: 99 additions & 4 deletions script/deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pragma solidity ^0.8.20;
import "forge-std/Script.sol";
import "../src/Token.sol";
import "../src/ControllerToken.sol";
import "../src/GnosisControllerToken.sol";
import "../src/PolygonControllerToken.sol";
import "../src/EthereumControllerToken.sol";

import "../src/BlacklistValidatorUpgradeable.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

Expand Down Expand Up @@ -50,7 +54,7 @@ contract All is Script {
}
}

contract AllController is Script {
contract AllControllerGnosis is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

Expand All @@ -63,7 +67,7 @@ contract AllController is Script {
);

// Deploy only one implementation of the Token contract for all currencies.
ControllerToken implementation = new ControllerToken();
GnosisControllerToken implementation = new GnosisControllerToken();

deployTokenProxy(implementation, "Monerium EURe", "EURe", bytes3("EUR"), address(validatorProxy));
deployTokenProxy(implementation, "Monerium GBPe", "GBPe", bytes3("GBP"), address(validatorProxy));
Expand All @@ -74,7 +78,7 @@ contract AllController is Script {
}

function deployTokenProxy(
ControllerToken implementation,
GnosisControllerToken implementation,
string memory name,
string memory symbol,
bytes3 _ticker,
Expand All @@ -83,7 +87,98 @@ contract AllController is Script {
ERC1967Proxy proxy = new ERC1967Proxy(
address(implementation),
abi.encodeWithSelector(
ControllerToken.initialize.selector,
GnosisControllerToken.initialize.selector,
name,
symbol,
_ticker,
validatorProxy
)
);

console.log("Deployed", symbol, "at", address(proxy));
}
}


contract AllControllerPolygon is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(deployerPrivateKey);

BlacklistValidatorUpgradeable blacklistValidator = new BlacklistValidatorUpgradeable();
ERC1967Proxy validatorProxy = new ERC1967Proxy(
address(blacklistValidator),
abi.encodeWithSelector(BlacklistValidatorUpgradeable.initialize.selector)
);

// Deploy only one implementation of the Token contract for all currencies.
PolygonControllerToken implementation = new PolygonControllerToken();

deployTokenProxy(implementation, "Monerium EURe", "EURe", bytes3("EUR"), address(validatorProxy));
deployTokenProxy(implementation, "Monerium GBPe", "GBPe", bytes3("GBP"), address(validatorProxy));
deployTokenProxy(implementation, "Monerium ISKe", "ISKe", bytes3("ISK") ,address(validatorProxy));
deployTokenProxy(implementation, "Monerium USDe", "USDe", bytes3("USD") ,address(validatorProxy));

vm.stopBroadcast();
}

function deployTokenProxy(
PolygonControllerToken implementation,
string memory name,
string memory symbol,
bytes3 _ticker,
address validatorProxy
) internal {
ERC1967Proxy proxy = new ERC1967Proxy(
address(implementation),
abi.encodeWithSelector(
PolygonControllerToken.initialize.selector,
name,
symbol,
_ticker,
validatorProxy
)
);

console.log("Deployed", symbol, "at", address(proxy));
}
}

contract AllControllerEthereum is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(deployerPrivateKey);

BlacklistValidatorUpgradeable blacklistValidator = new BlacklistValidatorUpgradeable();
ERC1967Proxy validatorProxy = new ERC1967Proxy(
address(blacklistValidator),
abi.encodeWithSelector(BlacklistValidatorUpgradeable.initialize.selector)
);

// Deploy only one implementation of the Token contract for all currencies.
EthereumControllerToken implementation = new EthereumControllerToken();

deployTokenProxy(implementation, "Monerium EURe", "EURe", bytes3("EUR"), address(validatorProxy));
deployTokenProxy(implementation, "Monerium GBPe", "GBPe", bytes3("GBP"), address(validatorProxy));
deployTokenProxy(implementation, "Monerium ISKe", "ISKe", bytes3("ISK") ,address(validatorProxy));
deployTokenProxy(implementation, "Monerium USDe", "USDe", bytes3("USD") ,address(validatorProxy));

vm.stopBroadcast();
}

function deployTokenProxy(
EthereumControllerToken implementation,
string memory name,
string memory symbol,
bytes3 _ticker,
address validatorProxy
) internal {
ERC1967Proxy proxy = new ERC1967Proxy(
address(implementation),
abi.encodeWithSelector(
EthereumControllerToken.initialize.selector,
name,
symbol,
_ticker,
Expand Down
17 changes: 16 additions & 1 deletion script/deployAll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,26 @@ elif [ "$1" == "--avalanche-fuji" ]; then
RPC_URL=$AVALANCHE_FUJI_RPC
ETHERSCAN_API_KEY=$SNOWTRACE_API_KEY
VERIFIER_URL="--verifier-url $SNOWTRACE_URL --chain-id $AVALANCHE_FUJI_CHAIN_ID"
elif [ "$1" == "--gnosis-chiado" ]; then
echo "Deploying to Gnosis Chiado..."
RPC_URL=$GNOSIS_CHIADO_RPC
VERIFIER_URL="--verifier blockscout --verifier-url $GNOSIS_CHIADO_BLOCKSCOUT_URL --chain-id $GNOSIS_CHIADO_CHAIN_ID"
echo $VERIFIER_URL
forge script script/deploy.s.sol:AllControllerGnosis --rpc-url $RPC_URL --broadcast --verify $VERIFIER_URL -vvvv --legacy
exit 0
elif [ "$1" == "--polygon-amoy" ]; then
echo "Deploying to Polygon Amoy..."
RPC_URL=$POLYGON_AMOY_RPC
ETHERSCAN_API_KEY=$POLYGONSCAN_API
VERIFIER_URL="--verifier-url $POLYGONSCAN_URL --chain-id $POLYGON_AMOY_CHAIN_ID"
echo $VERIFIER_URL
forge script script/deploy.s.sol:AllControllerPolygon --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify $VERIFIER_URL -vvvv --legacy
exit 0
fi

# Deploying all tokens
echo "Deploying all tokens..."
forge script script/deploy.s.sol:AllController --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify $VERIFIER_URL -vvvv --legacy
forge script script/deploy.s.sol:AllControllerEthereum --rpc-url $RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify $VERIFIER_URL -vvvv --legacy


echo "Deployment process completed."
2 changes: 1 addition & 1 deletion script/generateBatchMint.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const erc20ABI = [
},
];

if (process.argv.length < 7) {
if (process.argv.length < 6) {
console.error(
"Usage: node script.js <rpcURL> <V2Address> <startBlock> <V1Address> "
);
Expand Down
4 changes: 2 additions & 2 deletions src/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract Token is
bytes memory signature
) public onlySystemAccounts {
require(
from.isValidSignatureNow(0x7eb17b1cb295cfefd09fe4c8604c0699503f9e35dd36bb15a4fed852a828f503, signature),
from.isValidSignatureNow(0xb77c35c892a1b24b10a2ce49b424e578472333ee8d2456234fff90626332c50f, signature),
"signature/hash does not match"
);
_burn(from, amount);
Expand All @@ -97,7 +97,7 @@ contract Token is
signature = abi.encodePacked(r, s, v);
}
require(
from.isValidSignatureNow(0x7eb17b1cb295cfefd09fe4c8604c0699503f9e35dd36bb15a4fed852a828f503, signature),
from.isValidSignatureNow(0xb77c35c892a1b24b10a2ce49b424e578472333ee8d2456234fff90626332c50f, signature),
"signature/hash does not match"
);
uint256 amount = balanceOf(from);
Expand Down

0 comments on commit 07d95f2

Please sign in to comment.