Skip to content

feat: add token name to show cmd #230

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

Merged
merged 2 commits into from
Oct 19, 2024
Merged

Conversation

shrimalmadhur
Copy link
Collaborator

Fixes # .

What Changed?

  • Adds token name to show rewards output
Screenshot 2024-10-18 at 10 15 17 PM

@nelsonijih
Copy link
Contributor

Minor suggestion: Denomination is also showing Wei also for Eigen token. Also, should we be displaying ETH in ETH(e.g 0.1 ETH) instead of wei for ease of of readability for user?

@shrimalmadhur
Copy link
Collaborator Author

Minor suggestion: Denomination is also showing Wei also for Eigen token. Also, should we be displaying ETH in ETH(e.g 0.1 ETH) instead of wei for ease of of readability for user?

yea I need to overhaul and add a common lib for this - so will do that in separate PR.

@shrimalmadhur shrimalmadhur merged commit 05c7637 into master Oct 19, 2024
8 checks passed
@shrimalmadhur shrimalmadhur deleted the madhur/add-token-name branch October 19, 2024 03:39
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
Copy link
Contributor

@bdchatham bdchatham Oct 19, 2024

Choose a reason for hiding this comment

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

nit: return err. Can also use nil, but seeing inconsistent pattern used is why I mention it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

didn't get this comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's inconsistent convention. In some places you're reusing err knowing its nil since you've made it past the if-statement check. Other times you are explicitly returning nil.

Copy link
Collaborator Author

@shrimalmadhur shrimalmadhur Oct 19, 2024

Choose a reason for hiding this comment

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

sorry I still did not get this. can you give me an example of inconsistency here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha no worries. When you return, you know err == nil. I saw a place in the code where we return the err object rather than specifying the nil return. Just pointing out we could reconcile these different uses of convention. It's of course a very small detail.

Copy link
Collaborator Author

@shrimalmadhur shrimalmadhur Oct 19, 2024

Choose a reason for hiding this comment

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

oh I see what you are saying
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil

you want me to return
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), err

I think the first one is the right pattern since I can explicitly see I am returning nil, if I pass err then you have to see the above code to see what is the err.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can you share where I have returned err when I know it's nil? probably that needs to be changed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah I see. stupid generated code. I generally don't do it - let me fix it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed on the explicit nil 👍

return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}

func GetTokenName(tokenAddress common.Address, client *ethclient.Client) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: client is a bit nondescript given you're calling something else a ...client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ethclient.Client already depicts what this client is so I think it's okay - trying not to be super verbose - unless you have other clients which I think below you see erc20Client

"Token Address",
"Amount (Wei)",
}
widths := []int{46, 30}
widths := []int{20, 46, 30}
Copy link
Contributor

@bdchatham bdchatham Oct 19, 2024

Choose a reason for hiding this comment

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

nit: nice to have these as constants to be more self-explanatory of their meaning.

Copy link
Collaborator Author

@shrimalmadhur shrimalmadhur Oct 19, 2024

Choose a reason for hiding this comment

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

they are just the width of a columns, I can add that comment but those numbers are arbitrary and doesn't have any particular meaning.

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally get that, but leaving them unnamed makes them "magic numbers".

Magic numbers stackoverflow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess the only readability improvement it makes is you can know it's tokenname width which is fair.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I usually really like it because it immediately hints at contextual reasoning. For example, if it's a token address, familiarity with max address length. It can be inferred from reading but I find this helps me read smoother

@bdchatham
Copy link
Contributor

Tests please :)

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.

3 participants