Skip to content

Commit c2e57fc

Browse files
committed
updated for multi-deployments
1 parent bebc805 commit c2e57fc

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4-
[submodule "lib/foundry-devops"]
5-
path = lib/foundry-devops
6-
url = https://github.com/ChainAccelOrg/foundry-devops

lib/foundry-devops

-1
This file was deleted.

src/get_recent_deployment.sh

+12-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ files=$(find $path -name "run-latest.json" -type f)
2929
for file in $files; do
3030
if [[ $file == *"/$chainId/"* ]]; then
3131
timestamp=$(jq '.timestamp' "$file")
32-
currentTransactionType=$(jq -r '.transactions[0].transactionType' "$file")
33-
currentContractName=$(jq -r '.transactions[0].contractName' "$file")
34-
35-
if [ "$currentTransactionType" == "CREATE" ] && [ "$currentContractName" == "$contractName" ] && [ $timestamp -gt $latestTimestamp ]; then
36-
latestTimestamp=$timestamp
37-
latestContractAddress=$(jq -r '.transactions[0].contractAddress' "$file")
38-
fi
32+
33+
transactions_length=$(jq '.transactions | length' "$file")
34+
35+
for ((i=0; i<$transactions_length; i++)); do
36+
currentTransactionType=$(jq -r ".transactions[$i].transactionType" "$file")
37+
currentContractName=$(jq -r ".transactions[$i].contractName" "$file")
38+
39+
if [ "$currentTransactionType" == "CREATE" ] && [ "$currentContractName" == "$contractName" ] && [ $timestamp -gt $latestTimestamp ]; then
40+
latestTimestamp=$timestamp
41+
latestContractAddress=$(jq -r ".transactions[$i].contractAddress" "$file")
42+
fi
43+
done
3944
fi
4045
done
4146

test/DevOpsToolsTest.t.sol

+13
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ contract DevOpsToolsTest is Test {
2121
);
2222
assertEq(mostRecentDeployment, EXPECTED_ADDRESS);
2323
}
24+
25+
function testGetMostRecentlyDeployedEvenWhenMultipleAreDeployed() public {
26+
string memory contractName = "FundMe";
27+
uint256 chainId = 1234;
28+
address expectedAddress = 0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9;
29+
address mostRecentDeployment = DevOpsTools.get_most_recent_deployment(
30+
contractName,
31+
chainId,
32+
SEARCH_PATH,
33+
SCRIPT_PATH
34+
);
35+
assertEq(mostRecentDeployment, expectedAddress);
36+
}
2437
}

0 commit comments

Comments
 (0)