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

The Address type in crypto.gno and crypto.go have different types #1632

Open
jefft0 opened this issue Feb 6, 2024 · 3 comments
Open

The Address type in crypto.gno and crypto.go have different types #1632

jefft0 opened this issue Feb 6, 2024 · 3 comments

Comments

@jefft0
Copy link
Contributor

jefft0 commented Feb 6, 2024

crypto.gno defines Address as a string.

crypto.go defines Address as a byte array.

It's not a show-stopper but it has caused me confusion as I switch between Go and Gno. If it's worthwhile to address this (pun intended), here's a suggestion. crypto.go also defines Bech32Address as a string. Maybe rename Address in crypto.gno to Bech32Address? (This is a nice, descriptive name.)

@thehowl
Copy link
Member

thehowl commented Feb 6, 2024

crypto.Bech32Address == std.Address even internally within the GnoVM.

I understand your proposal of switching std.Address to Bech32Address but it seems to me to be quite long for what is a fundamental type used within realm programming, so I would actually be slightly more inclined to do the opposite. Looking for other opinions and arguments, though.

@jefft0
Copy link
Contributor Author

jefft0 commented Feb 6, 2024

I'm not sure what you mean by "crypto.Bech32Address within the GnoVM". The GnoVM runs *.gno code, right? There is no crypto package in the *.gno code. So, maybe you mean something like "std.Address within the GnoVM == crypto.Bech32Address outside the GnoVM"? (This is part of the confusion.)

@thehowl
Copy link
Member

thehowl commented Feb 6, 2024

Apologies, I phrased it a bit confusingly without context.

To understand what I'm talking about see these two snippets:

store.AddGo2GnoMapping(reflect.TypeOf(crypto.Bech32Address("")), "std", "Address")

OrigCaller crypto.Bech32Address
OrigPkgAddr crypto.Bech32Address

What I'm trying to say is that the two types in the two languages are effectively equivalent. ie. GetOrigCaller retrieves the value in the ExecContext (second snippet) which is a crypto.Bech32Address, not an Address. So a bit confusing, but what I'm saying is that even in the ways the GnoVM generates std.Address values they are always Bech32Addresses in Go.

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

No branches or pull requests

2 participants