Skip to content

cmd/network/show: Print entity name#695

Draft
matevz wants to merge 1 commit intomasterfrom
matevz/feat/entity-name
Draft

cmd/network/show: Print entity name#695
matevz wants to merge 1 commit intomasterfrom
matevz/feat/entity-name

Conversation

@matevz
Copy link
Copy Markdown
Member

@matevz matevz commented Apr 17, 2026

Fixes #633

Vibe coded with qwen3.6.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 17, 2026

Deploy Preview for oasisprotocol-cli canceled.

Name Link
🔨 Latest commit d5ef5b6
🔍 Latest deploy log https://app.netlify.com/projects/oasisprotocol-cli/deploys/69e1d71a1d105b0008050087

Comment thread cmd/network/show.go
if err != nil {
common.Warnf("Warning: failed to query metadata registry: %v\n", err)
}
fromOasisscan, err := metadata.EntitiesFromOasisscan(ctx)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need data also from Oasis scan?

Comment thread cmd/network/show.go
{&fromRegistry, ""},
{&fromOasisscan, " (from oasisscan)"},
} {
if src.m == nil || *src.m == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ... 🤔

				// Build a lookup map from entity ID to entity name.
				fromRegistry, err := metadata.EntitiesFromRegistry(ctx)
				if err != nil {
					common.Warnf("Warning: failed to query metadata registry: %v\n", err)
				}
				fromOasisscan, err := metadata.EntitiesFromOasisscan(ctx)
				if err != nil {
					common.Warnf("Warning: failed to query oasisscan: %v\n", err)
				}
				entityNameByID := make(map[string]string)
				for _, src := range []struct {
					m      map[types.Address]*metadata.Entity
					suffix string
				}{
					{fromRegistry, ""},
					{fromOasisscan, " (oasisscan)"},
				} {
					for _, ent := range src.m {
						id := ent.ID.String()
						if _, ok := entityNameByID[id]; ok {
							continue
						}
						entityNameByID[id] = ent.Name + src.suffix
					}
				}

Comment thread cmd/network/show.go
}
table := table.New()
table.Header("Entity ID", "Node ID", "Role")
table.Header("Entity Name", "Entity ID", "Node ID", "Role")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the entity name is not to be trusted and can be empty, I would not put it in the first column.

Comment thread cmd/network/show.go

name := entityNameByID[node.EntityID.String()]
if name == "" {
name = "unknown"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use "", as one could have an entity with name unknown.

Comment thread cmd/network/show.go
if _, exists := entityNameByID[ent.ID.String()]; exists {
continue
}
entityNameByID[ent.ID.String()] = ent.Name + src.suffix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the name is empty, would this produce name " (from oasiscan)"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add validator names to oasis network show committees

2 participants