Commit beb36a70 authored by Will Cory's avatar Will Cory

comments

parent 8ab7c2c1
...@@ -140,10 +140,6 @@ type ServerConfig struct { ...@@ -140,10 +140,6 @@ type ServerConfig struct {
Port int `toml:"port"` Port int `toml:"port"`
} }
var (
DEVNET_CHAIN_ID = 901
)
// LoadConfig loads the `indexer.toml` config file from a given path // LoadConfig loads the `indexer.toml` config file from a given path
func LoadConfig(log log.Logger, path string) (Config, error) { func LoadConfig(log log.Logger, path string) (Config, error) {
log.Debug("loading config", "path", path) log.Debug("loading config", "path", path)
...@@ -161,7 +157,7 @@ func LoadConfig(log log.Logger, path string) (Config, error) { ...@@ -161,7 +157,7 @@ func LoadConfig(log log.Logger, path string) (Config, error) {
return conf, err return conf, err
} }
if conf.Chain.Preset == DEVNET_CHAIN_ID { if conf.Chain.Preset == DEVNET_L2_CHAIN_ID {
preset, err := GetDevnetPreset() preset, err := GetDevnetPreset()
if err != nil { if err != nil {
return conf, err return conf, err
......
...@@ -2,59 +2,31 @@ package config ...@@ -2,59 +2,31 @@ package config
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "errors"
"io/fs"
"os" "os"
"github.com/ethereum/go-ethereum/common"
) )
type ethereumContracts struct { var (
AddressManager string `json:"AddressManager"` filePath = "../.devnet/addresses.json"
BlockOracle string `json:"BlockOracle"` DEVNET_L2_CHAIN_ID = 901
DisputeGameFactory string `json:"DisputeGameFactory"` )
DisputeGameFactoryProxy string `json:"DisputeGameFactoryProxy"`
L1CrossDomainMessenger string `json:"L1CrossDomainMessenger"`
L1CrossDomainMessengerProxy string `json:"L1CrossDomainMessengerProxy"`
L1ERC721Bridge string `json:"L1ERC721Bridge"`
L1ERC721BridgeProxy string `json:"L1ERC721BridgeProxy"`
L1StandardBridge string `json:"L1StandardBridge"`
L1StandardBridgeProxy string `json:"L1StandardBridgeProxy"`
L2OutputOracle string `json:"L2OutputOracle"`
L2OutputOracleProxy string `json:"L2OutputOracleProxy"`
Mips string `json:"Mips"`
OptimismMintableERC20Factory string `json:"OptimismMintableERC20Factory"`
OptimismMintableERC20FactoryProxy string `json:"OptimismMintableERC20FactoryProxy"`
OptimismPortal string `json:"OptimismPortal"`
OptimismPortalProxy string `json:"OptimismPortalProxy"`
PreimageOracle string `json:"PreimageOracle"`
ProxyAdmin string `json:"ProxyAdmin"`
SystemConfig string `json:"SystemConfig"`
SystemConfigProxy string `json:"SystemConfigProxy"`
}
func readEthereumContracts(filename string) (*ethereumContracts, error) { func GetDevnetPreset() (*Preset, error) {
// Check if the file exists if _, err := os.Stat(filePath); errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(filename); os.IsNotExist(err) {
return nil, err return nil, err
} }
// Read the file content, err := os.ReadFile(filePath)
content, err := ioutil.ReadFile(filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Unmarshal the JSON var l1Contracts L1Contracts
var contracts ethereumContracts if err := json.Unmarshal(content, &l1Contracts); err != nil {
if err := json.Unmarshal(content, &contracts); err != nil {
return nil, err return nil, err
} }
return &contracts, nil
}
func GetDevnetPreset() (*Preset, error) {
ethereumContracts, err := readEthereumContracts("../.devnet/addresses.json")
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -64,17 +36,7 @@ func GetDevnetPreset() (*Preset, error) { ...@@ -64,17 +36,7 @@ func GetDevnetPreset() (*Preset, error) {
L1StartingHeight: 0, L1StartingHeight: 0,
L1BedrockStartingHeight: 0, L1BedrockStartingHeight: 0,
L2BedrockStartingHeight: 0, L2BedrockStartingHeight: 0,
L1Contracts: L1Contracts{ L1Contracts: l1Contracts,
AddressManager: common.HexToAddress(ethereumContracts.AddressManager),
SystemConfigProxy: common.HexToAddress(ethereumContracts.SystemConfigProxy),
OptimismPortalProxy: common.HexToAddress(ethereumContracts.OptimismPortalProxy),
L2OutputOracleProxy: common.HexToAddress(ethereumContracts.L2OutputOracleProxy),
L1CrossDomainMessengerProxy: common.HexToAddress(ethereumContracts.L1CrossDomainMessengerProxy),
L1StandardBridgeProxy: common.HexToAddress(ethereumContracts.L1StandardBridgeProxy),
L1ERC721BridgeProxy: common.HexToAddress(ethereumContracts.L1ERC721BridgeProxy),
LegacyCanonicalTransactionChain: common.HexToAddress("0x0"),
LegacyStateCommitmentChain: common.HexToAddress("0x0"),
},
}, },
}, nil }, nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment