|
7 | 7 | "encoding/hex" |
8 | 8 | "encoding/json" |
9 | 9 | "fmt" |
| 10 | + "regexp" |
10 | 11 | "strconv" |
11 | 12 | "strings" |
12 | 13 | "time" |
@@ -117,7 +118,7 @@ func NewWriteTarget(ctx context.Context, relayer *Relayer, chain legacyevm.Chain |
117 | 118 | ContractReader: cr, |
118 | 119 | ChainWriter: cw, |
119 | 120 | ConfigValidateFn: evaluate, |
120 | | - NodeAddress: "nil", |
| 121 | + NodeAddress: config.FromAddress().String(), |
121 | 122 | ForwarderAddress: config.ForwarderAddress().String(), |
122 | 123 | TargetStrategy: NewEVMTargetStrategy(cr, cw, config.ForwarderAddress().String(), gasLimitDefault, lggr), |
123 | 124 | } |
@@ -262,15 +263,29 @@ func getChainInfo(chainID uint64) (monitor.ChainInfo, error) { |
262 | 263 | return monitor.ChainInfo{}, fmt.Errorf("failed to get chain details for chain %d and family %s: %w", chainID, chainFamily, err) |
263 | 264 | } |
264 | 265 |
|
| 266 | + neworkName, err := ExtractNetwork(chainDetails.ChainName) |
| 267 | + if err != nil { |
| 268 | + return monitor.ChainInfo{}, fmt.Errorf("failed to get network name for chain %d: %w", chainID, err) |
| 269 | + } |
| 270 | + |
265 | 271 | return monitor.ChainInfo{ |
266 | 272 | ChainFamilyName: chainFamily, |
267 | 273 | ChainID: strconv.Itoa(int(chainID)), |
268 | | - NetworkName: chainDetails.ChainName, |
269 | | - // TODO: not sure what the difference between NetworkName and NetworkNameFull is |
270 | | - NetworkNameFull: "", |
| 274 | + NetworkName: neworkName, |
| 275 | + NetworkNameFull: chainDetails.ChainName, |
271 | 276 | }, nil |
272 | 277 | } |
273 | 278 |
|
| 279 | +func ExtractNetwork(selector string) (string, error) { |
| 280 | + // Create a regexp pattern that matches any of the three. |
| 281 | + re := regexp.MustCompile(`(mainnet|testnet|devnet)`) |
| 282 | + name := re.FindString(selector) |
| 283 | + if name == "" { |
| 284 | + return "", fmt.Errorf("failed to extract network name from selector: %s", selector) |
| 285 | + } |
| 286 | + return name, nil |
| 287 | +} |
| 288 | + |
274 | 289 | func GenerateWriteTargetName(chainID uint64) string { |
275 | 290 | id := fmt.Sprintf("write_%v@1.0.0", chainID) |
276 | 291 | chainName, err := chainselectors.NameFromChainId(chainID) |
|
0 commit comments