From 5e24ee2735db2f797709961a3c8a1816b65b6a55 Mon Sep 17 00:00:00 2001 From: Ryan Collingham Date: Tue, 26 Sep 2023 16:12:33 +0100 Subject: [PATCH] remove address binder address from config --- config.toml | 1 - indexer/config/config.go | 3 +-- indexer/cronjob/mirror_stubs.go | 13 ++++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config.toml b/config.toml index 0151550..0c407e0 100644 --- a/config.toml +++ b/config.toml @@ -64,6 +64,5 @@ enabled = false timeout = "10s" [contract_addresses] -address_binder = "0x0000000" mirroring = "0x0000000" voting = "0x0000000" diff --git a/indexer/config/config.go b/indexer/config/config.go index f4d25c2..5cdf41b 100644 --- a/indexer/config/config.go +++ b/indexer/config/config.go @@ -57,8 +57,7 @@ type UptimeConfig struct { type ContractAddresses struct { config.ContractAddresses - AddressBinder common.Address `toml:"address_binder" envconfig:"ADDRESS_BINDER_CONTRACT_ADDRESS"` - Mirroring common.Address `toml:"mirroring" envconfig:"MIRRORING_CONTRACT_ADDRESS"` + Mirroring common.Address `toml:"mirroring" envconfig:"MIRRORING_CONTRACT_ADDRESS"` } func newConfig() *Config { diff --git a/indexer/cronjob/mirror_stubs.go b/indexer/cronjob/mirror_stubs.go index 4418e37..34507c9 100644 --- a/indexer/cronjob/mirror_stubs.go +++ b/indexer/cronjob/mirror_stubs.go @@ -95,7 +95,7 @@ func initMirrorJobContracts(cfg *config.Config) (mirrorContracts, error) { return nil, err } - addressBinderContract, err := addresses.NewBinder(cfg.ContractAddresses.AddressBinder, eth) + addressBinderContract, err := newAddressBinderContract(eth, mirroringContract) if err != nil { return nil, err } @@ -118,6 +118,17 @@ func initMirrorJobContracts(cfg *config.Config) (mirrorContracts, error) { }, nil } +func newAddressBinderContract( + eth *ethclient.Client, mirroringContract *mirroring.Mirroring, +) (*addresses.Binder, error) { + addressBinderAddress, err := mirroringContract.AddressBinder(new(bind.CallOpts)) + if err != nil { + return nil, err + } + + return addresses.NewBinder(addressBinderAddress, eth) +} + func (m mirrorContractsCChain) GetMerkleRoot(epoch int64) ([32]byte, error) { return m.voting.GetMerkleRoot(new(bind.CallOpts), big.NewInt(epoch)) }