Skip to content

Commit bb293ff

Browse files
update: config re-name addr to rpc_url (#20)
* update: config name addr to url * update to RPC_URL
1 parent 28c212f commit bb293ff

File tree

8 files changed

+32
-32
lines changed

8 files changed

+32
-32
lines changed

op-translator/internal/config/config.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ var (
2828
)
2929

3030
type Config struct {
31-
SettlementChainAddr string `koanf:"settlement_chain_addr"`
32-
SequencingChainAddr string `koanf:"sequencing_chain_addr"`
33-
MetaBasedChainAddr string `koanf:"meta_based_chain_addr"`
31+
SettlementChainRPCURL string `koanf:"settlement_chain_rpc_url"`
32+
SequencingChainRPCURL string `koanf:"sequencing_chain_rpc_url"`
33+
MetaBasedChainRPCURL string `koanf:"meta_based_chain_rpc_url"`
3434
SequencingContractAddress string `koanf:"sequencing_contract_address"`
3535
BatcherAddress string `koanf:"batcher_address"`
3636
BatchInboxAddress string `koanf:"batch_inbox_address"`
@@ -48,9 +48,9 @@ type Config struct {
4848
// setCLIFlags sets all valid CLI flags for the app
4949
func setCLIFlags(f *pflag.FlagSet) {
5050
f.Int("port", defaultPort, "Server port number for the app")
51-
f.String("settlement_chain_addr", "https://sepolia.base.org", "Settlement chain address")
52-
f.String("sequencing_chain_addr", "https://sepolia.base.org", "Sequencing chain address")
53-
f.String("meta_based_chain_addr", "https://sepolia.base.org", "Meta based chain address")
51+
f.String("settlement_chain_rpc_url", "https://sepolia.base.org", "Settlement chain address")
52+
f.String("sequencing_chain_rpc_url", "https://sepolia.base.org", "Sequencing chain address")
53+
f.String("meta_based_chain_rpc_url", "https://sepolia.base.org", "Meta based chain address")
5454
f.String("log_level", constants.Info.String(), "Log level for the app")
5555
f.Int("frame_size", defaultFrameSize, "Size of each frame in bytes. Max is 1,000,000")
5656
f.Bool("pretty", false, "Pretty print JSON log responses")
@@ -67,9 +67,9 @@ func setCLIFlags(f *pflag.FlagSet) {
6767
// hydrateFromConfMap sets the Config values from the koanf conf map
6868
func hydrateFromConfMap(config *Config) {
6969
config.Port = k.Int("port")
70-
config.SettlementChainAddr = k.String("settlement_chain_addr")
71-
config.SequencingChainAddr = k.String("sequencing_chain_addr")
72-
config.MetaBasedChainAddr = k.String("meta_based_chain_addr")
70+
config.SettlementChainRPCURL = k.String("settlement_chain_rpc_url")
71+
config.SequencingChainRPCURL = k.String("sequencing_chain_rpc_url")
72+
config.MetaBasedChainRPCURL = k.String("meta_based_chain_rpc_url")
7373
config.FrameSize = k.Int("frame_size")
7474
config.LogLevel = k.String("log_level")
7575
config.Pretty = k.Bool("pretty")
@@ -136,17 +136,17 @@ func ValidateConfigValues(config *Config) (result error) {
136136
result = multierror.Append(result, errors.New("frameSize must be less than maximum"))
137137
}
138138

139-
_, err := url.ParseRequestURI(config.SequencingChainAddr)
139+
_, err := url.ParseRequestURI(config.SequencingChainRPCURL)
140140
if err != nil {
141141
result = multierror.Append(result, fmt.Errorf("invalid URL for sequencing chain address: %w", err))
142142
}
143143

144-
_, err = url.ParseRequestURI(config.SettlementChainAddr)
144+
_, err = url.ParseRequestURI(config.SettlementChainRPCURL)
145145
if err != nil {
146146
result = multierror.Append(result, fmt.Errorf("invalid URL for settlement chain address: %w", err))
147147
}
148148

149-
_, err = url.ParseRequestURI(config.MetaBasedChainAddr)
149+
_, err = url.ParseRequestURI(config.MetaBasedChainRPCURL)
150150
if err != nil {
151151
result = multierror.Append(result, fmt.Errorf("invalid URL for meta based chain address: %w", err))
152152
}

op-translator/internal/config/config_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func validConfig() config.Config {
1515
return config.Config{
1616
Port: 1234,
1717
FrameSize: 100,
18-
SequencingChainAddr: "http://example.com",
19-
SettlementChainAddr: "https://example.org",
20-
MetaBasedChainAddr: "https://example.io",
18+
SequencingChainRPCURL: "http://example.com",
19+
SettlementChainRPCURL: "https://example.org",
20+
MetaBasedChainRPCURL: "https://example.io",
2121
LogLevel: constants.Info.String(),
2222
Pretty: false,
2323
SequencingContractAddress: "0x0000000000000000000000000000000000000000",
@@ -59,21 +59,21 @@ func TestValidateConfigValues(t *testing.T) {
5959
{
6060
name: "Invalid sequencingChainAddr",
6161
configChangeUnderTest: func(c *config.Config) {
62-
c.SequencingChainAddr = "invalid sequencing chain address"
62+
c.SequencingChainRPCURL = "invalid sequencing chain address"
6363
},
6464
expectedErrors: []string{"invalid URL for sequencing chain address"},
6565
},
6666
{
6767
name: "Invalid settlementChainAddr",
6868
configChangeUnderTest: func(c *config.Config) {
69-
c.SettlementChainAddr = "invalid settlement chain address"
69+
c.SettlementChainRPCURL = "invalid settlement chain address"
7070
},
7171
expectedErrors: []string{"invalid URL for settlement chain address"},
7272
},
7373
{
7474
name: "Invalid metaBasedChainAddr",
7575
configChangeUnderTest: func(c *config.Config) {
76-
c.MetaBasedChainAddr = "invalid meta based chain address"
76+
c.MetaBasedChainRPCURL = "invalid meta based chain address"
7777
},
7878
expectedErrors: []string{"invalid URL for meta based chain address"},
7979
},
@@ -131,9 +131,9 @@ func TestValidateConfigValues(t *testing.T) {
131131
configChangeUnderTest: func(c *config.Config) {
132132
c.Port = -1
133133
c.FrameSize = 0
134-
c.SequencingChainAddr = "invalid"
135-
c.SettlementChainAddr = "also invalid"
136-
c.MetaBasedChainAddr = "https://example.io"
134+
c.SequencingChainRPCURL = "invalid"
135+
c.SettlementChainRPCURL = "also invalid"
136+
c.MetaBasedChainRPCURL = "https://example.io"
137137
c.SequencePerSettlementBlock = 0
138138
},
139139
expectedErrors: []string{

op-translator/internal/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
func TranslatorHandler(cfg *config.Config, translator any) (*http.ServeMux, error) {
2020
// Setup proxy
21-
parsedURL, err := url.Parse(cfg.SettlementChainAddr)
21+
parsedURL, err := url.Parse(cfg.SettlementChainRPCURL)
2222
if err != nil {
2323
return nil, err
2424
}

op-translator/internal/server/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestProxyEndpoint(t *testing.T) {
6666
defer mockBackend.Close()
6767

6868
config := mocks.DefaultTestingConfig
69-
config.SettlementChainAddr = mockBackend.URL
69+
config.SettlementChainRPCURL = mockBackend.URL
7070
router, err := server.TranslatorHandler(config, mockTranslator)
7171
assert.NoError(t, err)
7272

op-translator/mocks/config_mock.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ var DefaultTestingConfig = &config.Config{
3030
SettlementStartBlock: TestingSettlementStartBlock,
3131
SequencePerSettlementBlock: TestingSequencePerSettlementBlock,
3232
BatcherPrivateKey: TestingBatcherPrivateKey,
33-
SettlementChainAddr: "http://localhost:8545",
34-
SequencingChainAddr: "http://localhost:8545",
35-
MetaBasedChainAddr: "http://localhost:8545",
33+
SettlementChainRPCURL: "http://localhost:8545",
34+
SequencingChainRPCURL: "http://localhost:8545",
35+
MetaBasedChainRPCURL: "http://localhost:8545",
3636
BatchInboxAddress: TestingBatchInboxAddress,
3737
BatcherAddress: TestingBatcherAddress,
3838
SettlementChainID: TestingSettlementChainID,

op-translator/pkg/translator/batch_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ type MetaBasedBatchProvider struct {
4141
}
4242

4343
func InitMetaBasedBatchProvider(cfg *config.Config) *MetaBasedBatchProvider {
44-
sequencingChain, err := rpc.Connect(cfg.SequencingChainAddr)
44+
sequencingChain, err := rpc.Connect(cfg.SequencingChainRPCURL)
4545
if err != nil {
4646
log.Panic().Err(err).Msg("Failed to initialize sequencing chain")
4747
}
4848

49-
metaBasedChain, err := rpc.Connect(cfg.MetaBasedChainAddr)
49+
metaBasedChain, err := rpc.Connect(cfg.MetaBasedChainRPCURL)
5050
if err != nil {
5151
log.Panic().Err(err).Msg("Failed to initialize metabased chain")
5252
}

op-translator/pkg/translator/translator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type OPTranslator struct {
3636
}
3737

3838
func Init(cfg *config.Config) *OPTranslator {
39-
settlementChain, err := rpc.Connect(cfg.SettlementChainAddr)
39+
settlementChain, err := rpc.Connect(cfg.SettlementChainRPCURL)
4040
if err != nil {
4141
log.Panic().Err(err).Msg("Failed to initialize settlement chain")
4242
}

op-translator/template.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## NOTE: keys are case-sensitive
22

33
PORT=9999
4-
SETTLEMENT_CHAIN_ADDR=http://localhost:8548
5-
SEQUENCING_CHAIN_ADDR=http://localhost:8548
6-
META_BASED_CHAIN_ADDR=http://localhost:8548
4+
SETTLEMENT_CHAIN_RPC_URL=http://localhost:8548
5+
SEQUENCING_CHAIN_RPC_URL=http://localhost:8548
6+
META_BASED_CHAIN_RPC_URL=http://localhost:8548
77
FRAME_SIZE=<>
88
LOG_LEVEL=debug
99
SEQUENCING_CONTRACT_ADDRESS=<>

0 commit comments

Comments
 (0)