Skip to content

Commit

Permalink
chore: pump dep version + remove hardhat to replace with forge verifi…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
TuDo1403 committed Jul 29, 2024
1 parent e3b4c1b commit 40befeb
Show file tree
Hide file tree
Showing 38 changed files with 147 additions and 3,031 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ docs/
*.env
.vscode

node_modules/
yarn-error.log
.yarn
.yarnrc.yml
deployments/**/exported_address
dependencies
deployments
Expand Down
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ ronin-testnet = "https://saigon-archive.roninchain.com/rpc"
localhost = "http://localhost:8545"

[dependencies]
forge-std = { version = "1.8.2" }
solady = { version = "0.0.206" }
"@openzeppelin-contracts" = { version = "4.9.3" }
"@openzeppelin" = { version = "4.9.3", url = "https://github.com/OpenZeppelin/openzeppelin-contracts/archive/refs/tags/v4.9.3.zip" }
"@forge-std" = { version = "1.9.1", url = "https://github.com/foundry-rs/forge-std/archive/refs/tags/v1.9.1.zip" }
"@solady" = { version = "0.0.228", url = "https://github.com/Vectorized/solady/archive/refs/tags/v0.0.228.zip" }
28 changes: 0 additions & 28 deletions hardhat.config.ts

This file was deleted.

28 changes: 20 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Install foundryup
curl -L https://foundry.paradigm.xyz | bash
# Install foundry
$HOME/.foundry/bin/foundryup -v nightly-de33b6af53005037b463318d2628b5cfcaf39916 # Stable version
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Check if foundry is installed
if ! command -v $HOME/.foundry/bin/forge &>/dev/null; then
# Install foundryup
curl -L https://foundry.paradigm.xyz | bash
# Install foundry
$HOME/.foundry/bin/foundryup -v nightly-de33b6af53005037b463318d2628b5cfcaf39916 # Stable version
fi

# Check if rustup is installed
if ! command -v rustup &>/dev/null; then
# Install rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi

# Update rustup
$HOME/.cargo/bin/rustup update stable
# Install soldeer
Expand All @@ -12,5 +20,9 @@ $HOME/.cargo/bin/cargo install soldeer
$HOME/.cargo/bin/soldeer update
# Run forge build
$HOME/.foundry/bin/forge build
# Install jq
brew install jq

# Check if rustup is installed
if ! command -v jq &>/dev/null; then
# Install jq
brew install jq
fi
28 changes: 0 additions & 28 deletions package.json

This file was deleted.

6 changes: 4 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@fdk/=script/
@forge-std-1.8.2=dependencies/forge-std-1.8.2/src/
@solady-0.0.206=dependencies/solady-0.0.206
@openzeppelin-contracts-4.9.3=dependencies/@openzeppelin-contracts-4.9.3
@contract-libs-0.1.1=dependencies/contract-libs-0.1.1
@contract-libs-0.1.1=dependencies/contract-libs-0.1.1
@forge-std-1.9.1=dependencies/@forge-std-1.9.1/src/
@openzeppelin-4.9.3=dependencies/@openzeppelin-4.9.3
@solady-0.0.228=dependencies/@solady-0.0.228
33 changes: 8 additions & 25 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ done
export_address

echo "\033[33mTrying to compile contracts ...\033[0m"
forge build # Ensure the contracts are compiled before running the script
forge build --offline # Ensure the contracts are compiled before running the script

should_verify=$([[ $should_verify == true && $is_broadcast == true ]] && echo true || echo false)

Expand All @@ -153,8 +153,12 @@ if [[ $should_verify == true ]] && [[ $force_generate_artifact == false ]]; then
extra_argument+=generate-artifact@
fi

if [[ $should_verify == true ]] && [[ ! $network_name == "ronin-mainnet" ]] && [[ ! $network_name == "ronin-testnet" ]]; then
verify_arg="--verify --retries 5"
if [[ $should_verify == true ]]; then
if [[ $network_name == "ronin-mainnet" ]] || [[ $network_name == "ronin-testnet" ]]; then
verify_arg="--verify --retries 5 --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/"
else
verify_arg="--verify --retries 5"
fi
fi

echo "Should Verify Contract: $should_verify"
Expand Down Expand Up @@ -191,29 +195,8 @@ fi

start_time=$(date +%s)

${op_command} forge script ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' $(cast calldata 'run()') "${extra_argument}"

# Check if the command was successful
if [ $? -eq 0 ]; then
if [[ $should_verify == true ]]; then
if [[ $network_name == "ronin-mainnet" ]] || [[ $network_name == "ronin-testnet" ]]; then
echo "Verifying contract..."
# Remove .env content
env_data=$(cat .env)
>.env

while IFS=',' read -r deployed; do
yarn hardhat sourcify --endpoint https://sourcify.roninchain.com/server --network ${network_name} --contract-name $deployed
done <./logs/deployed-contracts

# Restore the .env content
echo $env_data >.env
fi
fi
fi
${op_command} forge script --offline ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' $(cast calldata 'run()') "${extra_argument}"

end_time=$(date +%s)

# Remove the deployed-contracts file
rm -rf ./logs/deployed-contracts
echo "Execution time: $((end_time - start_time))s"
6 changes: 3 additions & 3 deletions script/BaseGeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { Vm, VmSafe } from "../dependencies/forge-std-1.8.2/src/Vm.sol";
import { StdStyle } from "../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { console } from "../dependencies/forge-std-1.8.2/src/console.sol";
import { Vm, VmSafe } from "../dependencies/@forge-std-1.9.1/src/Vm.sol";
import { StdStyle } from "../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { console } from "../dependencies/@forge-std-1.9.1/src/console.sol";
import { WalletConfig } from "./configs/WalletConfig.sol";
import { RuntimeConfig } from "./configs/RuntimeConfig.sol";
import { MigrationConfig } from "./configs/MigrationConfig.sol";
Expand Down
19 changes: 16 additions & 3 deletions script/BaseMigration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { LibString } from "../dependencies/solady-0.0.206/src/utils/LibString.sol";
import { console } from "../dependencies/forge-std-1.8.2/src/console.sol";
import { StdStyle } from "../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { TransparentProxyV2 } from "../src/TransparentProxyV2.sol";
import { TransparentProxyOZv4_9_5 } from "../src/TransparentProxyOZv4_9_5.sol";
import { LibString } from "../dependencies/@solady-0.0.228/src/utils/LibString.sol";
import { console } from "../dependencies/@forge-std-1.9.1/src/console.sol";
import { StdStyle } from "../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { ScriptExtended, IScriptExtended } from "./extensions/ScriptExtended.s.sol";
import { OnchainExecutor } from "./OnchainExecutor.s.sol"; // cheat to load artifact to parent `out` directory
import { IMigrationScript } from "./interfaces/IMigrationScript.sol";
Expand Down Expand Up @@ -284,4 +286,15 @@ abstract contract BaseMigration is ScriptExtended {
vm.makePersistent(deployScript);
vm.allowCheatcodes(deployScript);
}

/**
* @dev Cheat to force build artifact for customized TransparentProxy contract
*
* Can be disabled in child contract by overriding this function
*/
function _precompileProxyContracts() internal pure virtual {
bytes memory dummy;
dummy = type(TransparentProxyV2).creationCode;
dummy = type(TransparentProxyOZv4_9_5).creationCode;
}
}
4 changes: 2 additions & 2 deletions script/OnchainExecutor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { StdStyle } from "../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { console } from "../dependencies/forge-std-1.8.2/src/console.sol";
import { StdStyle } from "../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { console } from "../dependencies/@forge-std-1.9.1/src/console.sol";
import { ScriptExtended } from "./extensions/ScriptExtended.s.sol";
import { BaseGeneralConfig } from "./BaseGeneralConfig.sol";
import { sendRawTransaction } from "./utils/Helpers.sol";
Expand Down
19 changes: 8 additions & 11 deletions script/configs/ContractConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { EnumerableSet } from "../../dependencies/@openzeppelin-contracts-4.9.3/utils/structs/EnumerableSet.sol";
import { Vm, VmSafe } from "../../dependencies/forge-std-1.8.2/src/Vm.sol";
import { console } from "../../dependencies/forge-std-1.8.2/src/console.sol";
import { StdStyle } from "../../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { LibString } from "../../dependencies/solady-0.0.206/src/utils/LibString.sol";
import { EnumerableSet } from "../../dependencies/@openzeppelin-4.9.3/contracts/utils/structs/EnumerableSet.sol";
import { Vm, VmSafe } from "../../dependencies/@forge-std-1.9.1/src/Vm.sol";
import { console } from "../../dependencies/@forge-std-1.9.1/src/console.sol";
import { StdStyle } from "../../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { LibString } from "../../dependencies/@solady-0.0.228/src/utils/LibString.sol";
import { IContractConfig } from "../interfaces/configs/IContractConfig.sol";
import { LibSharedAddress } from "../libraries/LibSharedAddress.sol";
import { vme } from "../utils/Constants.sol";
Expand Down Expand Up @@ -183,12 +183,9 @@ abstract contract ContractConfig is IContractConfig {

label(network, contractAddr, contractName);

// filter out logic deployments
if (!contractName.endsWith("Logic")) {
_contractAddrSet[network].add(contractAddr);
_contractAddrMap[network][contractName] = contractAddr;
_contractTypeMap[network][contractAddr] = TContract.wrap(contractName.packOne());
}
_contractAddrSet[network].add(contractAddr);
_contractAddrMap[network][contractName] = contractAddr;
_contractTypeMap[network][contractAddr] = TContract.wrap(contractName.packOne());
}
}

Expand Down
12 changes: 7 additions & 5 deletions script/configs/NetworkConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { Vm } from "../../dependencies/forge-std-1.8.2/src/Vm.sol";
import { StdStyle } from "../../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { console } from "../../dependencies/forge-std-1.8.2/src/console.sol";
import { Vm } from "../../dependencies/@forge-std-1.9.1/src/Vm.sol";
import { StdStyle } from "../../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { console } from "../../dependencies/@forge-std-1.9.1/src/console.sol";
import { INetworkConfig } from "../interfaces/configs/INetworkConfig.sol";
import { IGeneralConfig } from "../interfaces/IGeneralConfig.sol";
import { LibSharedAddress } from "../libraries/LibSharedAddress.sol";
Expand Down Expand Up @@ -216,10 +216,12 @@ abstract contract NetworkConfig is INetworkConfig {
vm.toString(vm.getBlockNumber()),
" - Timestamp ".blue(),
vm.toString(vm.getBlockTimestamp()),
" - Chain ID ".blue(),
vm.toString(block.chainid)
" - Period ".blue(),
vm.toString(vm.getBlockTimestamp() / 1 days)
);
string memory logB = string.concat(
" - Chain ID ".blue(),
vm.toString(block.chainid),
" - Gas Price ".blue(),
vm.toString(tx.gasprice / 1 gwei),
" GWEI",
Expand Down
8 changes: 4 additions & 4 deletions script/configs/RuntimeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { Vm } from "../../dependencies/forge-std-1.8.2/src/Vm.sol";
import { StdStyle } from "../../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { console } from "../../dependencies/forge-std-1.8.2/src/console.sol";
import { LibString } from "../../dependencies/solady-0.0.206/src/utils/LibString.sol";
import { Vm } from "../../dependencies/@forge-std-1.9.1/src/Vm.sol";
import { StdStyle } from "../../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { console } from "../../dependencies/@forge-std-1.9.1/src/console.sol";
import { LibString } from "../../dependencies/@solady-0.0.228/src/utils/LibString.sol";
import { LibSharedAddress } from "../libraries/LibSharedAddress.sol";
import { IRuntimeConfig } from "../interfaces/configs/IRuntimeConfig.sol";
import { TNetwork } from "../types/Types.sol";
Expand Down
4 changes: 2 additions & 2 deletions script/configs/WalletConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { CommonBase } from "../../dependencies/forge-std-1.8.2/src/Base.sol";
import { LibString } from "../../dependencies/solady-0.0.206/src/utils/LibString.sol";
import { CommonBase } from "../../dependencies/@forge-std-1.9.1/src/Base.sol";
import { LibString } from "../../dependencies/@solady-0.0.228/src/utils/LibString.sol";
import { IWalletConfig } from "../interfaces/configs/IWalletConfig.sol";

abstract contract WalletConfig is CommonBase, IWalletConfig {
Expand Down
8 changes: 4 additions & 4 deletions script/extensions/ScriptExtended.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { VmSafe } from "../../dependencies/forge-std-1.8.2/src/Vm.sol";
import { StdStyle } from "../../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { console, Script } from "../../dependencies/forge-std-1.8.2/src/Script.sol";
import { StdAssertions } from "../../dependencies/forge-std-1.8.2/src/StdAssertions.sol";
import { VmSafe } from "../../dependencies/@forge-std-1.9.1/src/Vm.sol";
import { StdStyle } from "../../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { console, Script } from "../../dependencies/@forge-std-1.9.1/src/Script.sol";
import { StdAssertions } from "../../dependencies/@forge-std-1.9.1/src/StdAssertions.sol";
import { IVme } from "../interfaces/IVme.sol";
import { IRuntimeConfig } from "../interfaces/configs/IRuntimeConfig.sol";
import { IScriptExtended } from "../interfaces/IScriptExtended.sol";
Expand Down
8 changes: 8 additions & 0 deletions script/interfaces/IEIP173.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

interface IEIP173 {
function owner() external view returns (address);
function transferOwnership(address newOwner) external;
}
14 changes: 6 additions & 8 deletions script/libraries/LibArtifact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import { Vm } from "../../dependencies/forge-std-1.8.2/src/Vm.sol";
import { stdJson } from "../../dependencies/forge-std-1.8.2/src/StdJson.sol";
import { console } from "../../dependencies/forge-std-1.8.2/src/console.sol";
import { StdStyle } from "../../dependencies/forge-std-1.8.2/src/StdStyle.sol";
import { Vm } from "../../dependencies/@forge-std-1.9.1/src/Vm.sol";
import { stdJson } from "../../dependencies/@forge-std-1.9.1/src/StdJson.sol";
import { console } from "../../dependencies/@forge-std-1.9.1/src/console.sol";
import { StdStyle } from "../../dependencies/@forge-std-1.9.1/src/StdStyle.sol";
import { IGeneralConfig } from "../interfaces/IGeneralConfig.sol";
import { LibSharedAddress } from "./LibSharedAddress.sol";
import { LibString } from "../../dependencies/solady-0.0.206/src/utils/LibString.sol";
import { JSONParserLib } from "../../dependencies/solady-0.0.206/src/utils/JSONParserLib.sol";
import { LibString } from "../../dependencies/@solady-0.0.228/src/utils/LibString.sol";
import { JSONParserLib } from "../../dependencies/@solady-0.0.228/src/utils/JSONParserLib.sol";

struct ArtifactInfo {
address deployer;
Expand Down Expand Up @@ -44,8 +44,6 @@ library LibArtifact {
}

console.log(string.concat("By: ", vm.getLabel(info.deployer), ", nonce: ", vm.toString(info.nonce), "\n"));
if (!vm.exists("logs")) vm.createDir("logs", true);
vm.writeLine("logs/deployed-contracts", info.artifactName);

string memory dirPath = vme.getDeploymentDirectory(vme.getCurrentNetwork());

Expand Down
Loading

0 comments on commit 40befeb

Please sign in to comment.