-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7f40a8
commit 5e67418
Showing
4 changed files
with
103 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
# Error handling: check for required arguments | ||
if [ -z "$1" ]; then | ||
echo "Error: RPC URL is required." | ||
echo "Usage: $0 <rpc-url> <verifier-url>" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$2" ]; then | ||
echo "Error: Verifier URL is required." | ||
echo "Usage: $0 <rpc-url> <verifier-url>" | ||
exit 1 | ||
fi | ||
|
||
# Assign arguments to variables | ||
RPC_URL=$1 | ||
VERIFIER_URL=$2 | ||
IS_LEGACY=${3:-false} | ||
|
||
# Display the configuration being used | ||
echo "RPC URL: $RPC_URL" | ||
echo "Verifier URL: $VERIFIER_URL" | ||
echo "Is Legacy: $IS_LEGACY" | ||
|
||
# Clear cache | ||
rm -rf cache | ||
|
||
COMMAND="forge script script/DeployMock.s.sol:DeployMock \ | ||
--broadcast \ | ||
--rpc-url \"$RPC_URL\" \ | ||
--verify \ | ||
--verifier blockscout \ | ||
--verifier-url \"$VERIFIER_URL/api/\"" | ||
|
||
# Add --legacy if IS_LEGACY is true | ||
if [ "$IS_LEGACY" = "true" ]; then | ||
COMMAND="$COMMAND --legacy" | ||
fi | ||
|
||
# Execute constructed command | ||
eval $COMMAND | ||
|
||
|
||
# Examples | ||
# ./deployMock.sh base-sepolia https://base-sepolia.blockscout.com | ||
# ./deployMock.sh world-sepolia https://worldchain-sepolia.explorer.alchemy.com | ||
# ./deployMock.sh mantle-sepolia https://explorer.sepolia.mantle.xyz | ||
# ./deployMock.sh polygonzkevm-cardona https://explorer-ui.cardona.zkevm-rpc.com true | ||
|
||
# Hedera Testnet | ||
# forge script script/DeployMock.s.sol:DeployMock \ | ||
# --broadcast \ | ||
# --rpc-url hedera-testnet |
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,19 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
import "../lib/forge-std/src/Script.sol"; | ||
import {console} from "forge-std/console.sol"; | ||
|
||
contract BaseDeploy is Script { | ||
uint256 internal immutable deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
modifier broadcast() { | ||
vm.startBroadcast(deployerPrivateKey); | ||
_; | ||
vm.stopBroadcast(); | ||
} | ||
|
||
function calculateSalt(string memory input) internal pure returns (bytes32) { | ||
return keccak256(abi.encodePacked(input)) & ~bytes32(uint256(0xfff)); | ||
} | ||
} |
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,26 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
import {Create2} from "../lib/openzeppelin-contracts/contracts/utils/Create2.sol"; | ||
import {console} from "../lib/forge-std/src/console.sol"; | ||
import {ERC20Mock} from "../src/mocks/ERC20Mock.sol"; | ||
import {BaseDeploy} from "./BaseDeploy.s.sol"; | ||
|
||
contract DeployMock is BaseDeploy { | ||
function run() public { | ||
// Calculate salt | ||
bytes32 salt = calculateSalt("Drip.Erc20Mock"); | ||
// Deploy contracts on all supported chains | ||
address deployed = _deployContract(salt); | ||
console.log("ERC20Mock deployed to", deployed); | ||
} | ||
|
||
function _deployContract(bytes32 salt) internal broadcast returns (address) { | ||
return Create2.deploy(0, salt, _getCreationBytecode()); | ||
} | ||
|
||
function _getCreationBytecode() public pure returns (bytes memory) { | ||
bytes memory bytecode = type(ERC20Mock).creationCode; | ||
return abi.encodePacked(bytecode, abi.encode("Mock Token", "MTK")); | ||
} | ||
} |