You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that if message.signer is always the string address that signed
the transaction and I use it to look up your account balance, if this encoding
ever changed, then you lose access to your account. We clearly need
a stable identifier to work with internally.
It is possible for address string representation to change, so ideally we all (smart contracts dev) should use CanonicalAddr as a key for Maps.
So, Why?
The text was updated successfully, but these errors were encountered:
Until Stargate, the Cosmos SDK stored addresses internally as raw bytes (CanonicalAddr) form.
We reflected and considered this would make sense if they changed bech32 prefix or decided to move to base58 or whatever.
However, since 0.40 the cosmos sdk uses bech32 encoding string addresses in all messages and in storage. Thus, it is near impossible to change the address encoding on a Cosmos SDK chain. Since that limits the runtime, we don't have to make all our contracts significantly more complex to handle cases the runtime doesn't support.
We also suggest using Addr in storage for 0.14 plus. This also means doing addr_validate on any address passed in via a message to ensure it is a legitimite address and not "random-text-here" which will fail later. Thus pub fn addr_validate(&self, &str) -> Addr on deps.api.
Hey guys, thanks for your work!
Have a little question :)
Why you use
Addr
(which is a String actually) as a key in Maps? Here for example?Here CosmWasm docs saying (and I agree):
It is possible for address string representation to change, so ideally we all (smart contracts dev) should use
CanonicalAddr
as a key for Maps.So, Why?
The text was updated successfully, but these errors were encountered: