@@ -25,7 +25,11 @@ import (
2525 "github.com/flare-foundation/go-flare-common/pkg/contracts/registry"
2626)
2727
28- const breakingEpochCoston2 = 5338
28+ const (
29+ chainIDCoston2 = 114
30+
31+ breakingEpochCoston2 = 5338
32+ )
2933
3034const (
3135 newRegistryCoston2Addr = "0x6a0AF07b7972177B176d3D422555cbc98DfDe914"
@@ -148,26 +152,34 @@ func NewRegistryContractClient(
148152) (* registryContractClientImpl , error ) {
149153 registryBinding , err := registry .NewRegistry (registryAddress , ethClient )
150154 if err != nil {
151- return nil , err
155+ return nil , fmt . Errorf ( "registry binding: %w" , err )
152156 }
153157 preregistryBinding , err := preregistry .NewPreregistry (preregistryAddress , ethClient )
154158 if err != nil {
155- return nil , err
159+ return nil , fmt . Errorf ( "pre registry binding: %w" , err )
156160 }
157161
158162 var oldRegistryBinding * registry.Registry
159163 if registryAddress == newRegistryCoston2 {
160164 oldRegistryBinding , err = registry .NewRegistry (oldRegistryCoston2 , ethClient )
161165 if err != nil {
162- return nil , err
166+ return nil , fmt .Errorf ("registry binding old: %w" , err )
167+ }
168+
169+ if chainID != chainIDCoston2 {
170+ return nil , errors .New ("registry contract for coston2 on different chain" )
163171 }
164172 }
165173
166174 var oldPreRegistryBinding * preregistry.Preregistry
167175 if preregistryAddress == newPreRegistryCoston2 {
168176 oldPreRegistryBinding , err = preregistry .NewPreregistry (oldPreRegistryCoston2 , ethClient )
169177 if err != nil {
170- return nil , err
178+ return nil , fmt .Errorf ("pre registry binding old: %w" , err )
179+ }
180+
181+ if chainID != chainIDCoston2 {
182+ return nil , errors .New ("pre registry contract for coston2 on different chain" )
171183 }
172184 }
173185
@@ -212,7 +224,7 @@ func (r *registryContractClientImpl) sendRegisterVoter(nextRewardEpochID *big.In
212224 err error
213225 )
214226
215- if old {
227+ if old || r . chainID != chainIDCoston2 {
216228 rAddress = oldAddress
217229 signature , err = r .createSignatureOld (epochID , address )
218230 if err != nil {
@@ -304,11 +316,11 @@ func (r *registryContractClientImpl) sendPreRegisterVoter(nextRewardEpochID *big
304316 err error
305317 )
306318
307- if old {
319+ if old || r . chainID != chainIDCoston2 {
308320 prAddress = oldAddress
309321 signature , err = r .createSignatureOld (epochID , address )
310322 if err != nil {
311- return fmt .Errorf ("creating pre registry signature old: %w" , err )
323+ return fmt .Errorf ("creating registry signature old: %w" , err )
312324 }
313325 } else {
314326 signature , err = r .createSignatureNew (r .chainID , epochID , address )
0 commit comments