Skip to content

Commit

Permalink
Merge pull request #134 from axieinfinity/testnet
Browse files Browse the repository at this point in the history
Merge all feature from 'testnet'
  • Loading branch information
TuDo1403 authored Mar 25, 2024
2 parents 0802f46 + 8c84798 commit 2f48f7d
Show file tree
Hide file tree
Showing 23 changed files with 276 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-PR-implement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
toBranch: ${{ env.FEATURE_BRANCH }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6.0.1
with:
branch: ${{ env.HEAD_BRANCH }}
base: ${{env.FEATURE_BRANCH}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-PR-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
toBranch: ${{matrix.branch_name}}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6.0.1
with:
labels: automated PR
delete-branch: true
Expand Down
6 changes: 5 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
shallow = true
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
shallow = true
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/Vectorized/solady
url = https://github.com/vectorized/solady
shallow = true
[submodule "lib/contract-libs"]
path = lib/contract-libs
url = https://github.com/axieinfinity/contract-libs
shallow = true
12 changes: 10 additions & 2 deletions broadcast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ else
echo "Error: .broadcast.env file not found."
fi

verify_arg=""
extra_argument=""

for arg in "$@"; do
Expand All @@ -20,6 +19,15 @@ done
# Remove the @ character from the end of extra_argument
extra_argument="${extra_argument%%@}"

op_command=""
## Check if the private key is stored in the .env file
if [[ ! $extra_argument == *"sender"* ]] && [[ ! $extra_argument == *"trezor"* ]]; then
source .env
if [[ $MAINNET_PK == op* ]] || [[ $TESTNET_PK == op* ]] || [[ $LOCAL_PK == op* ]]; then
op_command="op run --env-file="./.env" --"
fi
fi

echo Broadcast Tx...
echo From: ${FROM}
echo To: ${TO}
Expand All @@ -28,4 +36,4 @@ echo GasAmount: ${GAS}
echo Calldata:
cast pretty-calldata ${CALLDATA}
calldata=$(cast calldata 'broadcast(address,address,uint256,uint256,bytes)' ${FROM} ${TO} ${GAS} ${VALUE} ${CALLDATA})
forge script ${verify_arg} ${@} -g 200 OnchainExecutor --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
${op_command} forge script ${verify_arg} ${@} -g 200 OnchainExecutor --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
1 change: 0 additions & 1 deletion debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ else
echo "Error: .debug.env file not found."
fi

verify_arg=""
extra_argument=""

for arg in "$@"; do
Expand Down
25 changes: 21 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ for arg in "$@"; do
--trezor)
extra_argument+=trezor@
;;
--log)
set -- "${@/#--log/}"
extra_argument+=log@
--no-postcheck)
set -- "${@/#--no-postcheck/}"
extra_argument+=no-postcheck@
;;
--generate-artifacts)
set -- "${@/#--generate-artifacts/}"
extra_argument+=generate-artifact@
;;
-atf)
set -- "${@/#-atf/}"
extra_argument+=generate-artifact@
;;
*) ;;
esac
Expand All @@ -17,5 +25,14 @@ done
# Remove the @ character from the end of extra_argument
extra_argument="${extra_argument%%@}"

op_command=""
## Check if the private key is stored in the .env file
if [[ ! $extra_argument == *"sender"* ]] && [[ ! $extra_argument == *"trezor"* ]]; then
source .env
if [[ $MAINNET_PK == op* ]] || [[ $TESTNET_PK == op* ]] || [[ $LOCAL_PK == op* ]]; then
op_command="op run --env-file="./.env" --"
fi
fi

calldata=$(cast calldata 'run()')
forge script ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
${op_command} forge script ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
21 changes: 15 additions & 6 deletions script/ArtifactFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract ArtifactFactory is IArtifactFactory {
address deployer,
address contractAddr,
string memory contractAbsolutePath,
string calldata fileName,
string memory fileName,
bytes calldata args,
uint256 nonce
) external {
Expand All @@ -38,11 +38,16 @@ contract ArtifactFactory is IArtifactFactory {
).green(),
string.concat("(nonce: ", nonce.toString(), ")")
);
if (!CONFIG.getRuntimeConfig().log) {
if (!CONFIG.getRuntimeConfig().generateArtifact || CONFIG.isPostChecking()) {
console.log("Skipping artifact generation for:", vm.getLabel(contractAddr), "\n");
return;
}
string memory dirPath = CONFIG.getDeploymentDirectory(CONFIG.getCurrentNetwork());
if (!vm.exists(dirPath)) {
console.log("\n", string.concat(dirPath, " not existed, making one...").yellow());
vm.createDir(dirPath, true);
vm.writeFile(string.concat(dirPath, ".chainId"), vm.toString(block.chainid));
}
string memory filePath = string.concat(dirPath, fileName, ".json");

string memory json;
Expand All @@ -67,10 +72,14 @@ contract ArtifactFactory is IArtifactFactory {
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 artifactPath = contractAbsolutePath;
if (!artifactPath.endsWith(".json")) {
string[] memory s = contractAbsolutePath.split(":");
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();

Expand Down
8 changes: 8 additions & 0 deletions script/BaseGeneralConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ contract BaseGeneralConfig is RuntimeConfig, WalletConfig, ContractConfig, Netwo

function _setUpDefaultContracts() private {
_contractNameMap[DefaultContract.ProxyAdmin.key()] = DefaultContract.ProxyAdmin.name();
_contractNameMap[DefaultContract.Multicall3.key()] = DefaultContract.Multicall3.name();
setAddress(
DefaultNetwork.RoninTestnet.key(), DefaultContract.ProxyAdmin.key(), 0x505d91E8fd2091794b45b27f86C045529fa92CD7
);
setAddress(
DefaultNetwork.RoninMainnet.key(), DefaultContract.ProxyAdmin.key(), 0xA3e7d085E65CB0B916f6717da876b7bE5cC92f03
);
setAddress(
DefaultNetwork.RoninMainnet.key(), DefaultContract.Multicall3.key(), 0xcA11bde05977b3631167028862bE2a173976CA11
);
setAddress(
DefaultNetwork.RoninTestnet.key(), DefaultContract.Multicall3.key(), 0xcA11bde05977b3631167028862bE2a173976CA11
);

_setUpContracts();
}
Expand All @@ -92,6 +99,7 @@ contract BaseGeneralConfig is RuntimeConfig, WalletConfig, ContractConfig, Netwo

function getSender() public view virtual override returns (address payable sender) {
sender = _option.trezor ? payable(_trezorSender) : payable(_envSender);
if (sender == address(0x0) && getCurrentNetwork() == DefaultNetwork.Local.key()) sender = payable(DEFAULT_SENDER);
require(sender != address(0x0), "GeneralConfig: Sender is address(0x0)");
}

Expand Down
Loading

0 comments on commit 2f48f7d

Please sign in to comment.