Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge latest feature into 'mainnet' #15

Merged
merged 53 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9926c61
feat: refactor migration scripts
TuDo1403 Oct 10, 2023
529915f
feat: add migration config && remove unused code
TuDo1403 Oct 14, 2023
f34dcf6
fix: resolve some issue with migration script
TuDo1403 Oct 15, 2023
c684c2b
feat: minor refactor & change run interface & remove redundant file
TuDo1403 Oct 17, 2023
35ffdea
fix: interface IScript
TuDo1403 Oct 17, 2023
89f8bf1
feat: override testnet proxy admin contract
TuDo1403 Oct 17, 2023
83cff06
fix: fix upgrade logic
TuDo1403 Oct 20, 2023
6f1e5ad
feat: refactort script
TuDo1403 Nov 4, 2023
a1a4fab
feat: add minor refactor
TuDo1403 Nov 4, 2023
75fa83f
fix: minor bug fix
TuDo1403 Nov 5, 2023
a61a3e1
forge install: openzeppelin-contracts
TuDo1403 Nov 17, 2023
5ef3edc
feat: update package
TuDo1403 Nov 17, 2023
255431b
feat: update package + minor refactor
TuDo1403 Nov 17, 2023
dbacb2d
fix: remove remappings
TuDo1403 Nov 20, 2023
e2329e3
fix: use relative mapping
TuDo1403 Nov 20, 2023
da94287
fix: use relative mapping
TuDo1403 Nov 20, 2023
c005e36
fix: use relative mapping
TuDo1403 Nov 20, 2023
cb33f0e
feat: refactor and add example script
TuDo1403 Nov 28, 2023
02d524d
chore: add virtual keyword
TuDo1403 Nov 28, 2023
b91ee76
feat: allow override artifact name with contract type, add explorer l…
TuDo1403 Nov 28, 2023
a2aa308
fix: fix overriding artifact name for _deployImmutable
TuDo1403 Nov 28, 2023
23ea6de
fix: minor bug fix
TuDo1403 Nov 28, 2023
5afc0e8
feat: add get all addresses by chain id
TuDo1403 Nov 28, 2023
dbb2a70
feat: add getter for addr => contract type
TuDo1403 Nov 29, 2023
2d3ed2a
fix: getAddress function
TuDo1403 Nov 29, 2023
bf883b1
fix: minor bug fix
TuDo1403 Nov 29, 2023
0d4962c
forge install: openzeppelin-contracts
TuDo1403 Dec 4, 2023
d674bc1
feat: add networl utilities and fn logging
TuDo1403 Dec 4, 2023
3f32848
chore: remove artifact
TuDo1403 Dec 4, 2023
84db4df
chore: fix openzeppelin version import
TuDo1403 Dec 4, 2023
67b3559
chore: add mockUpgrade function
TuDo1403 Dec 5, 2023
e9a54cc
chore: update forge-std
TuDo1403 Dec 5, 2023
8d66968
chore: add multichain example
TuDo1403 Dec 5, 2023
a20d23b
feat: add OnchainDebugger and handle different cases for proxy upgrade
TuDo1403 Dec 11, 2023
3ebdcf3
forge install: contract-libs
TuDo1403 Dec 11, 2023
13f00bb
chore: import contract-libs
TuDo1403 Dec 11, 2023
407c5fb
fix: estimate gas by default
TuDo1403 Dec 11, 2023
7c7da0e
Merge pull request #2 from axieinfinity/implement-feature/migration-s…
TuDo1403 Dec 11, 2023
cc92d20
Merge pull request #4 from axieinfinity/feature/migration-script
TuDo1403 Dec 11, 2023
37f5284
Merge pull request #5 from axieinfinity/merge/release/v0.1.0-feature/…
TuDo1403 Dec 11, 2023
a3715e5
chore: minor refactor
TuDo1403 Dec 12, 2023
63507d8
Merge pull request #6 from axieinfinity/implement-feature/migration-s…
TuDo1403 Dec 12, 2023
6c87d57
Merge pull request #7 from axieinfinity/feature/migration-script
TuDo1403 Dec 12, 2023
5850c2a
Merge pull request #9 from axieinfinity/release/v0.1.0
TuDo1403 Dec 12, 2023
d96cb55
Merge pull request #8 from axieinfinity/merge/release/v0.1.0-feature/…
TuDo1403 Dec 12, 2023
6b75a10
chore: remove duplicate log
TuDo1403 Dec 14, 2023
ed44275
fix: Fix old ProxyAdmin cannot upgrade openzeppelin-v5's TransparentU…
TuDo1403 Dec 14, 2023
6df1977
Merge pull request #10 from axieinfinity/implement-feature/migration-…
TuDo1403 Dec 14, 2023
b82b320
feat: add _postCheck internal function
TuDo1403 Dec 14, 2023
15e7e67
fix: fix issue with import into parent directory
TuDo1403 Dec 15, 2023
427b29f
Merge pull request #11 from axieinfinity/implement-feature/migration-…
TuDo1403 Dec 15, 2023
4f8d011
Merge pull request #12 from axieinfinity/feature/migration-script
TuDo1403 Dec 15, 2023
288efb2
Merge pull request #14 from axieinfinity/release/v0.1.0
TuDo1403 Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .debug.env.example
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
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/Vectorized/solady
[submodule "lib/contract-libs"]
path = lib/contract-libs
url = https://github.com/axieinfinity/contract-libs
39 changes: 39 additions & 0 deletions debug.sh
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="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" --"
;;
--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 ${@} OnchainDebugger --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
1 change: 1 addition & 0 deletions deployments/ronin-mainnet/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020
1 change: 1 addition & 0 deletions deployments/ronin-testnet/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2021
12 changes: 10 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
src = "src"
out = "out"
libs = ["lib"]

ffi = true
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

solc = '0.8.21'
solc = '0.8.23'
extra_output = ["devdoc", "userdoc", "storagelayout"]
evm_version = 'istanbul'
use_literal_content = true
Expand All @@ -14,3 +14,11 @@ fs_permissions = [{ access = "read-write", path = "./" }]
[fmt]
line_length = 120
tab_width = 2
bracket_spacing = true

[rpc_endpoints]
ethereum = "https://eth.llamarpc.com"
goerli = "https://ethereum-goerli.publicnode.com"
ronin-mainnet = "https://api-partner.roninchain.com/rpc"
ronin-testnet = "https://saigon-archive.roninchain.com/rpc"
localhost = "http://localhost:8545"
1 change: 1 addition & 0 deletions lib/contract-libs
Submodule contract-libs added at 238860
4 changes: 1 addition & 3 deletions remappings.txt
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/
27 changes: 27 additions & 0 deletions run.sh
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}"
88 changes: 88 additions & 0 deletions script/ArtifactFactory.sol
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);
}
}
144 changes: 0 additions & 144 deletions script/BaseDeploy.s.sol

This file was deleted.

Loading