Skip to content

Commit c85dd3e

Browse files
committed
Merge branch 'andrius/validate-contract-config' into 'main'
Check required contract addresses are set in config. See merge request flarenetwork/FSP/flare-system-client!63
2 parents 503c9f2 + 763ecfc commit c85dd3e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

client/config/client.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,35 @@ func validate(cfg *Client) error {
209209
if err != nil {
210210
return fmt.Errorf("validating RelayGas: %v", err)
211211
}
212+
err = validateContracts(cfg)
213+
if err != nil {
214+
return fmt.Errorf("validating contracts: %v", err)
215+
}
216+
return nil
217+
}
218+
219+
func validateContracts(cfg *Client) error {
220+
if cfg.ContractAddresses.Submission == (common.Address{}) {
221+
return errors.New("submission contract address not set")
222+
}
223+
if cfg.ContractAddresses.SystemsManager == (common.Address{}) {
224+
return errors.New("systems_manager contract address not set")
225+
}
226+
if cfg.Clients.EnabledPreregistration {
227+
if cfg.ContractAddresses.VoterPreRegistry == (common.Address{}) {
228+
return errors.New("pre-registration enabled but voter_preregistry contract address not set")
229+
}
230+
}
231+
if cfg.Clients.EnabledRegistration {
232+
if cfg.ContractAddresses.VoterRegistry == (common.Address{}) {
233+
return errors.New("registration enabled but voter_registry contract address not set")
234+
}
235+
}
236+
if cfg.Clients.EnabledFinalizer {
237+
if cfg.ContractAddresses.Relay == (common.Address{}) {
238+
return errors.New("finalizer enabled but relay contract address not set")
239+
}
240+
}
212241
return nil
213242
}
214243

0 commit comments

Comments
 (0)