-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from axieinfinity/feature/migration-script
feat: refactor migration scripts
- Loading branch information
Showing
58 changed files
with
1,980 additions
and
499 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,10 @@ | ||
# Fork block number to debug | ||
BLOCK=0x0 | ||
# Caller | ||
FROM=0x0000000000000000000000000000000000000000 | ||
# Callee | ||
TO=0x0000000000000000000000000000000000000000 | ||
# Sent Value | ||
VALUE=0x27cdb0997a65b2de99 | ||
# Call Data | ||
CALLDATA=0x0 |
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,39 @@ | ||
# Source (or "dot") the .env file to load environment variables | ||
if [ -f .env ]; then | ||
source .debug.env | ||
else | ||
echo "Error: .debug.env file not found." | ||
fi | ||
|
||
verify_arg="" | ||
extra_argument="" | ||
op_command="" | ||
|
||
for arg in "$@"; do | ||
case $arg in | ||
--trezor) | ||
op_command="" | ||
extra_argument+=trezor@ | ||
;; | ||
--broadcast) | ||
op_command="op run --env-file="./.env" --" | ||
;; | ||
--log) | ||
set -- "${@/#--log/}" | ||
extra_argument+=log@ | ||
;; | ||
*) ;; | ||
esac | ||
done | ||
|
||
# Remove the @ character from the end of extra_argument | ||
extra_argument="${extra_argument%%@}" | ||
|
||
echo Debug Tx... | ||
echo From: ${FROM} | ||
echo To: ${TO} | ||
echo Value: ${VALUE} | ||
echo Calldata: | ||
cast pretty-calldata ${CALLDATA} | ||
calldata=$(cast calldata 'trace(uint256,address,address,uint256,bytes)' ${BLOCK} ${FROM} ${TO} ${VALUE} ${CALLDATA}) | ||
${op_command} forge script ${verify_arg} --legacy ${@} script/OnchainDebugger.s.sol --sig 'run(bytes,string)' ${calldata} "${extra_argument}" |
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 @@ | ||
2020 |
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 @@ | ||
2021 |
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
Submodule contract-libs
added at
238860
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 |
---|---|---|
@@ -1,3 +1 @@ | ||
ds-test/=lib/forge-std/lib/ds-test/src/ | ||
forge-std/=lib/forge-std/src/ | ||
@openzeppelin/=lib/openzeppelin-contracts/ | ||
foundry-deployment-kit/=script/ |
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,27 @@ | ||
verify_arg="" | ||
extra_argument="" | ||
op_command="op run --env-file="./.env" --" | ||
|
||
for arg in "$@"; do | ||
case $arg in | ||
--trezor) | ||
op_command="" | ||
extra_argument+=trezor@ | ||
;; | ||
--broadcast) | ||
op_command="op run --env-file="./.env" --" | ||
# verify_arg="--verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/" | ||
;; | ||
--log) | ||
set -- "${@/#--log/}" | ||
extra_argument+=log@ | ||
;; | ||
*) ;; | ||
esac | ||
done | ||
|
||
# Remove the @ character from the end of extra_argument | ||
extra_argument="${extra_argument%%@}" | ||
|
||
calldata=$(cast calldata 'run()') | ||
${op_command} forge script ${verify_arg} --legacy ${@} --sig 'run(bytes,string)' ${calldata} "${extra_argument}" |
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,88 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { Vm } from "../lib/forge-std/src/Vm.sol"; | ||
import { stdJson } from "../lib/forge-std/src/StdJson.sol"; | ||
import { StdStyle } from "../lib/forge-std/src/StdStyle.sol"; | ||
import { console2 as console } from "../lib/forge-std/src/console2.sol"; | ||
import { LibString } from "../lib/solady/src/utils/LibString.sol"; | ||
import { JSONParserLib } from "../lib/solady/src/utils/JSONParserLib.sol"; | ||
import { IArtifactFactory } from "./interfaces/IArtifactFactory.sol"; | ||
import { IGeneralConfig } from "./interfaces/IGeneralConfig.sol"; | ||
import { LibSharedAddress } from "./libraries/LibSharedAddress.sol"; | ||
|
||
contract ArtifactFactory is IArtifactFactory { | ||
using stdJson for *; | ||
using StdStyle for *; | ||
using LibString for *; | ||
using JSONParserLib for *; | ||
|
||
Vm internal constant vm = Vm(LibSharedAddress.VM); | ||
IGeneralConfig public constant CONFIG = IGeneralConfig(LibSharedAddress.CONFIG); | ||
|
||
function generateArtifact( | ||
address deployer, | ||
address contractAddr, | ||
string memory contractAbsolutePath, | ||
string calldata fileName, | ||
bytes calldata args, | ||
uint256 nonce | ||
) external { | ||
console.log( | ||
string.concat( | ||
fileName, | ||
" will be deployed at: ", | ||
CONFIG.getExplorer(CONFIG.getCurrentNetwork()), | ||
"address/", | ||
contractAddr.toHexString() | ||
).green(), | ||
string.concat("(nonce: ", nonce.toString(), ")") | ||
); | ||
if (!CONFIG.getRuntimeConfig().log) { | ||
console.log("Skipping artifact generation for:", vm.getLabel(contractAddr), "\n"); | ||
return; | ||
} | ||
string memory dirPath = CONFIG.getDeploymentDirectory(CONFIG.getCurrentNetwork()); | ||
string memory filePath = string.concat(dirPath, fileName, ".json"); | ||
|
||
string memory json; | ||
uint256 numDeployments = 1; | ||
|
||
if (vm.exists(filePath)) { | ||
string memory existedJson = vm.readFile(filePath); | ||
if (vm.keyExists(existedJson, ".numDeployments")) { | ||
numDeployments = vm.parseJsonUint(vm.readFile(filePath), ".numDeployments"); | ||
numDeployments += 1; | ||
} | ||
} | ||
|
||
json.serialize("args", args); | ||
json.serialize("nonce", nonce); | ||
json.serialize("isFoundry", true); | ||
json.serialize("deployer", deployer); | ||
json.serialize("chainId", block.chainid); | ||
json.serialize("address", contractAddr); | ||
json.serialize("blockNumber", block.number); | ||
json.serialize("timestamp", block.timestamp); | ||
json.serialize("contractAbsolutePath", contractAbsolutePath); | ||
json.serialize("numDeployments", numDeployments); | ||
|
||
string[] memory s = contractAbsolutePath.split(":"); | ||
string memory artifactPath = s.length == 2 | ||
? string.concat("./out/", s[0], "/", s[1], ".json") | ||
: string.concat("./out/", contractAbsolutePath, "/", contractAbsolutePath.replace(".sol", ".json")); | ||
string memory artifact = vm.readFile(artifactPath); | ||
JSONParserLib.Item memory item = artifact.parse(); | ||
|
||
json.serialize("abi", item.at('"abi"').value()); | ||
json.serialize("ast", item.at('"ast"').value()); | ||
json.serialize("devdoc", item.at('"devdoc"').value()); | ||
json.serialize("userdoc", item.at('"userdoc"').value()); | ||
json.serialize("metadata", item.at('"rawMetadata"').value()); | ||
json.serialize("storageLayout", item.at('"storageLayout"').value()); | ||
json.serialize("bytecode", item.at('"bytecode"').at('"object"').value()); | ||
json = json.serialize("deployedBytecode", item.at('"deployedBytecode"').at('"object"').value()); | ||
|
||
json.write(filePath); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.