-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelperConfig.s.sol
More file actions
54 lines (40 loc) · 1.56 KB
/
HelperConfig.s.sol
File metadata and controls
54 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
//Deploy mock when we are testing on anvil local chain
//other wise, use testnet/mainnet network
import {Script} from "forge-std/Script.sol";
import {MockV3Aggregator} from "../test/Mocks/MockV3Aggregator.sol";
contract HelperConfig is Script {
NetworkConfig public ActiveNetworkConfig;
uint8 public constant DECIMAL_NUMBER = 8;
int256 public constant INTIAL_PRICE = 2000e8;
//address public TEST_ADDRESS = 0x694AA1769357215DE4FAC081bf1f309aDC325306;
struct NetworkConfig {
address priceFeed; //ETH/USD price feed address
}
constructor() {
if (block.chainid == 11155111) {
ActiveNetworkConfig = getSepoliaConfig();
} else {
ActiveNetworkConfig = getAnvilConfig();
}
}
function getSepoliaConfig() public pure returns (NetworkConfig memory) {
//testnet
//priceFeed
NetworkConfig memory sepoliaConfig = NetworkConfig({priceFeed: 0x694AA1769357215DE4FAC081bf1f309aDC325306});
return sepoliaConfig;
}
function getAnvilConfig() public returns (NetworkConfig memory) {
if (ActiveNetworkConfig.priceFeed != address(0)) {
return ActiveNetworkConfig;
}
//Mock ---Anvil
//priceFeed
vm.startBroadcast();
MockV3Aggregator mockPriceFeed = new MockV3Aggregator(DECIMAL_NUMBER, INTIAL_PRICE);
vm.stopBroadcast();
NetworkConfig memory anvilConfig = NetworkConfig({priceFeed: address(mockPriceFeed)});
return anvilConfig;
}
}