Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tool] Document with all RPC endpoints #1256

Merged
merged 2 commits into from
Oct 7, 2024
Merged

Conversation

tclemos
Copy link

@tclemos tclemos commented Oct 1, 2024

adds a tool to generate a markdown document with all implemented rpc endpoints

@tclemos tclemos self-assigned this Oct 1, 2024
@cla-bot cla-bot bot added the cla-signed label Oct 1, 2024
@tclemos tclemos marked this pull request as ready for review October 7, 2024 13:52
Copy link

sonarcloud bot commented Oct 7, 2024

@V-Staykov V-Staykov merged commit d98050d into zkevm Oct 7, 2024
17 checks passed
@V-Staykov V-Staykov deleted the tool-endpoints-list branch October 7, 2024 15:01
EndpointGroups []keyValue
}

type keyValue struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

keyValue seems too general name to me. Maybe use endpointGroup?

}

endpointGroups := []keyValue{}
for _, apiInterface := range apiInterfaces {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this for loop be extracted as function for better readability? Maybe endpointGroups() and have eg := endpointGroups(apiInterfaces)

}

fileName := "endpoints.md"
fmt.Println(os.Args)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this println needed?

endpointGroups = append(endpointGroups, endpointGroup)
}

fileName := "endpoints.md"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can one more function be created for getting the filename - fileName() that also contains the check
if len(os.Args) > 1 { fileName = os.Args[1] }

}

f, err := createOrOpen(fileName)
checkErr(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if checkErr function is needed. There aren't complex checks for error behavior. It's pretty common to use if err != nil {

}

type keyValue struct {
Key any
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's better to avoid using any as type. Could the key be string and the value []string?

}
}

func createOrOpen(name string) (*os.File, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would personally rename this to createOrTruncateFile to better describe the behavior

f, err := createOrOpen(fileName)
checkErr(err)

t := template.Must(template.New("template.md").ParseFiles("template.md"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move "template.md" and the default fileName to constants

return os.Create(name)
}

func firstToLower(s string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be simplified to

func firstLetterToLower(s string) string {
	if s == "" {
		return s
	}
	return strings.ToLower(s[:1]) + s[1:]
}

@tclemos
Copy link
Author

tclemos commented Oct 7, 2024

Hey @MorettiGeorgiev, thanks for the feedback.
I'll check the suggestions and review the PR.

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

Successfully merging this pull request may close these issues.

3 participants