@@ -167,18 +167,22 @@ type LivepeerEthClientConfig struct {
167
167
Signer types.Signer
168
168
ControllerAddr ethcommon.Address
169
169
CheckTxTimeout time.Duration
170
+
171
+ // For the time-being Livepeer AI Subnet uses its own ServiceRegistry, so we define it here
172
+ ServiceRegistryAddr ethcommon.Address
170
173
}
171
174
172
175
func NewClient (cfg LivepeerEthClientConfig ) (LivepeerEthClient , error ) {
173
176
174
177
backend := NewBackend (cfg .EthClient , cfg .Signer , cfg .GasPriceMonitor , cfg .TransactionManager )
175
178
176
179
return & client {
177
- accountManager : cfg .AccountManager ,
178
- backend : backend ,
179
- tm : cfg .TransactionManager ,
180
- controllerAddr : cfg .ControllerAddr ,
181
- checkTxTimeout : cfg .CheckTxTimeout ,
180
+ accountManager : cfg .AccountManager ,
181
+ backend : backend ,
182
+ tm : cfg .TransactionManager ,
183
+ controllerAddr : cfg .ControllerAddr ,
184
+ checkTxTimeout : cfg .CheckTxTimeout ,
185
+ serviceRegistryAddr : cfg .ServiceRegistryAddr ,
182
186
}, nil
183
187
}
184
188
@@ -211,28 +215,15 @@ func (c *client) setContracts(opts *bind.TransactOpts) error {
211
215
212
216
glog .V (common .SHORT ).Infof ("LivepeerToken: %v" , c .tokenAddr .Hex ())
213
217
214
- chainID , err := c .backend .ChainID (context .Background ())
215
- if err != nil {
216
- glog .Errorf ("Failed to get chain ID from remote ethereum node: %v" , err )
217
- return err
218
- }
219
-
220
- // TODO: This is a temporary setup for a separate AIServiceRegistry. Revise this when AI subnet merges with the mainnet.
221
- var serviceRegistryAddr ethcommon.Address
222
- arbitrumOneChainID := big .NewInt (42161 )
223
- if chainID .Cmp (arbitrumOneChainID ) == 0 {
224
- serviceRegistryAddr = ethcommon .HexToAddress ("0x04C0b249740175999E5BF5c9ac1dA92431EF34C5" )
225
- } else {
226
- serviceRegistryAddr , err = c .GetContract (crypto .Keccak256Hash ([]byte ("ServiceRegistry" )))
218
+ if c .serviceRegistryAddr == (ethcommon.Address {}) {
219
+ c .serviceRegistryAddr , err = c .GetContract (crypto .Keccak256Hash ([]byte ("ServiceRegistry" )))
227
220
if err != nil {
228
221
glog .Errorf ("Error getting ServiceRegistry address: %v" , err )
229
222
return err
230
223
}
231
224
}
232
225
233
- c .serviceRegistryAddr = serviceRegistryAddr
234
-
235
- serviceRegistry , err := contracts .NewServiceRegistry (serviceRegistryAddr , c .backend )
226
+ serviceRegistry , err := contracts .NewServiceRegistry (c .serviceRegistryAddr , c .backend )
236
227
if err != nil {
237
228
glog .Errorf ("Error creating ServiceRegistry binding: %v" , err )
238
229
return err
0 commit comments