Skip to content

Commit

Permalink
chore: get contract addresses from manifest in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielattilasimon committed Sep 9, 2024
1 parent 65db4b3 commit 2dcddc0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ evm_version = 'shanghai'
ignored_error_codes = [5574] # contract-size
fs_permissions = [
{ access = "read", path = "./utils/assets/" },
{ access = "write", path = "./deployment-manifest.json" }
{ access = "read-write", path = "./deployment-manifest.json" }
]

[invariant]
Expand Down
21 changes: 19 additions & 2 deletions contracts/src/scripts/OpenTroves.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,27 @@ contract OpenTroves is Script {
function run() external {
vm.startBroadcast();

ICollateralRegistry collateralRegistry = ICollateralRegistry(vm.envAddress("COLLATERAL_REGISTRY"));
string memory manifestJson;
try vm.readFile("deployment-manifest.json") returns (string memory content) {
manifestJson = content;
} catch {}

ICollateralRegistry collateralRegistry;
try vm.envAddress("COLLATERAL_REGISTRY") returns (address value) {
collateralRegistry = ICollateralRegistry(value);
} catch {
collateralRegistry = ICollateralRegistry(vm.parseJsonAddress(manifestJson, ".collateralRegistry"));
}
vm.label(address(collateralRegistry), "CollateralRegistry");
IHintHelpers hintHelpers = IHintHelpers(vm.envAddress("HINT_HELPERS"));

IHintHelpers hintHelpers;
try vm.envAddress("HINT_HELPERS") returns (address value) {
hintHelpers = IHintHelpers(value);
} catch {
hintHelpers = IHintHelpers(vm.parseJsonAddress(manifestJson, ".hintHelpers"));
}
vm.label(address(hintHelpers), "HintHelpers");

address proxyImplementation = address(new Proxy());
vm.label(proxyImplementation, "ProxyImplementation");

Expand Down
13 changes: 12 additions & 1 deletion contracts/src/scripts/RedeemCollateral.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ contract RedeemCollateral is Script {
function run() external {
vm.startBroadcast();

ICollateralRegistry collateralRegistry = ICollateralRegistry(vm.envAddress("COLLATERAL_REGISTRY"));
string memory manifestJson;
try vm.readFile("deployment-manifest.json") returns (string memory content) {
manifestJson = content;
} catch {}

ICollateralRegistry collateralRegistry;
try vm.envAddress("COLLATERAL_REGISTRY") returns (address value) {
collateralRegistry = ICollateralRegistry(value);
} catch {
collateralRegistry = ICollateralRegistry(vm.parseJsonAddress(manifestJson, ".collateralRegistry"));
}
vm.label(address(collateralRegistry), "CollateralRegistry");

IBoldToken boldToken = IBoldToken(collateralRegistry.boldToken());
vm.label(address(boldToken), "BoldToken");

Expand Down

0 comments on commit 2dcddc0

Please sign in to comment.