Skip to content

Commit 40a1c66

Browse files
committed
made changes as asked
1 parent 6cd0ecc commit 40a1c66

File tree

10 files changed

+334
-304
lines changed

10 files changed

+334
-304
lines changed

foundry.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
src = "src"
33
out = "out"
44
libs = ["lib"]
5-
remappings = ["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts"]
5+
remappings = [
6+
'@openzeppelin/contracts=lib/openzeppelin-contracts/contracts',
7+
'@chainlink/contracts=lib/chainlink-brownie-contracts/contracts'
8+
]
69

710
[invariant]
811
runs=128

script/ HelperConfig.s.sol

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.18;
2+
pragma solidity ^0.8.19;
33

44
import {Script} from "lib/forge-std/src/Script.sol";
55
import {MockV3Aggregator} from "../test/mocks/MockV3Aggregator.sol";
@@ -9,8 +9,7 @@ contract HelperConfig is Script {
99
uint8 public constant DECIMALS = 8;
1010
int256 public constant ETH_USD_PRICE = 2000e8;
1111
int256 public constant BTC_USD_PRICE = 1000e8;
12-
uint256 public constant DEFAULT_ANVIL_PRIVATE_KEY =
13-
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
12+
uint256 public constant DEFAULT_ANVIL_PRIVATE_KEY = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
1413

1514
struct NetworkConfig {
1615
address wethUsdPriceFeed;
@@ -20,19 +19,19 @@ contract HelperConfig is Script {
2019
uint256 deployerKey;
2120
}
2221

22+
NetworkConfig public activeNetworkConfig;
23+
2324
constructor() {
24-
if (block.chainid == 11155111) {
25+
if(block.chainid == 11155111){
2526
activeNetworkConfig = getSepoliaEthConfig();
26-
} else {
27+
} else{
2728
activeNetworkConfig = getOrCreateAnvilEthConfig();
2829
}
2930
}
3031

31-
NetworkConfig public activeNetworkConfig;
32-
3332
function getSepoliaEthConfig() public view returns (NetworkConfig memory sepoliaNetworkConfig) {
3433
sepoliaNetworkConfig = NetworkConfig({
35-
wethUsdPriceFeed: 0x694AA1769357215DE4FAC081bf1f309aDC325306, // ETH / USD
34+
wethUsdPriceFeed: 0x694AA1769357215DE4FAC081bf1f309aDC325306,
3635
wbtcUsdPriceFeed: 0x1b44F3514812d835EB1BDB0acB33d3fA3351Ee43,
3736
weth: 0xdd13E55209Fd76AfE204dBda4007C227904f0a81,
3837
wbtc: 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063,
@@ -41,7 +40,6 @@ contract HelperConfig is Script {
4140
}
4241

4342
function getOrCreateAnvilEthConfig() public returns (NetworkConfig memory anvilNetworkConfig) {
44-
// Check to see if we set an active network config
4543
if (activeNetworkConfig.wethUsdPriceFeed != address(0)) {
4644
return activeNetworkConfig;
4745
}
@@ -54,12 +52,12 @@ contract HelperConfig is Script {
5452
ERC20Mock wbtcMock = new ERC20Mock();
5553
vm.stopBroadcast();
5654

57-
return anvilNetworkConfig = NetworkConfig({
58-
wethUsdPriceFeed: address(ethUsdPriceFeed), // ETH / USD
59-
weth: address(wethMock),
60-
wbtcUsdPriceFeed: address(btcUsdPriceFeed),
61-
wbtc: address(wbtcMock),
62-
deployerKey: DEFAULT_ANVIL_PRIVATE_KEY
55+
anvilNetworkConfig = NetworkConfig({
56+
wethUsdPriceFeed: address(ethUsdPriceFeed),
57+
weth: address(wethMock),
58+
wbtcUsdPriceFeed: address(btcUsdPriceFeed),
59+
wbtc: address(wbtcMock),
60+
deployerKey: DEFAULT_ANVIL_PRIVATE_KEY
6361
});
6462
}
6563
}

script/DeployDSC.s.sol

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.18;
2+
pragma solidity ^0.8.19;
33

44
import {Script} from "lib/forge-std/src/Script.sol";
5-
import {DecentralizedStableCoin} from "src/DecentralisedStableCoin.sol";
5+
import {DecentralizedStableCoin} from "src/DecentralizedStableCoin.sol";
66
import {DSCEngine} from "src/DSCEngine.sol";
77
import {HelperConfig} from "../script/ HelperConfig.s.sol";
88

@@ -13,18 +13,12 @@ contract DeployDSC is Script {
1313
function run() external returns (DecentralizedStableCoin, DSCEngine, HelperConfig) {
1414
HelperConfig config = new HelperConfig();
1515

16-
(
17-
address wethUsdPriceFeed,
18-
address wbtcUsdPriceFeed,
19-
address weth,
20-
address wbtc,
21-
// uint256 deployerKey
22-
) = config.activeNetworkConfig();
16+
(address wethUsdPriceFeed, address wbtcUsdPriceFeed, address weth, address wbtc, uint256 deployerKey) = config.activeNetworkConfig();
2317

2418
tokenAddresses = [weth, wbtc];
2519
priceFeedAddresses = [wethUsdPriceFeed, wbtcUsdPriceFeed];
2620

27-
vm.startBroadcast();
21+
vm.startBroadcast(deployerKey);
2822
DecentralizedStableCoin dsc = new DecentralizedStableCoin();
2923
DSCEngine engine = new DSCEngine(tokenAddresses, priceFeedAddresses, address(dsc));
3024
dsc.transferOwnership(address(engine));

0 commit comments

Comments
 (0)