-
Notifications
You must be signed in to change notification settings - Fork 336
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
Extend Addr implementation #868
Comments
Why |
Regarding the other helpers in the file:
We can add |
We can also create |
I am not so much pushing to change I think CosmWasm/cw-plus#260 shows some of the pain |
I guess not needed, I just needed to implement somewhere, but maybe I can revisit why it was even there. |
Okay, my goal would rather be to make |
I think the same. You either use |
I think you both miss the purpose of You could never return I implemented this with I just wanted better integration of a nice, light, im-memory reference with the original Addr to make usage less verbose. |
If you want to use an |
I've also noticed that using |
Or do you want lifetimes compatibility? Isn't there a way around it? Maybe I haven't hit the issue yet, but working with |
My concern here is the same than in the |
I implemented I used
fn (some: &'a str) -> &'a Addr {
&Addr(some.to_string());
} is impossible as we return a reference to a local variable. Thus |
Please try playing with |
The alternative here is simple: convert unvalidated input to I understand this is less robust, but it's also less verbose. I will play with this, to see if I can come up with another alternative. |
This may be sub-optimal, but is what's always being done when working with values. This is a struct with a slice of less than a hundred bytes. I see no problem with cloning it once or twice in contract code. Not to talk about test code. |
Currently our keys are typically |
In any case, we can introduce these changes / improvemnts when and if we detect an issue or bottleneck with using values in keys. Or, as I said above, use |
See the new map types pub const PERMISSIONS: Map<AddrRef, Permissions> = Map::new("permissions");
pub const ALLOWANCES: Map<AddrRef, Allowance> = Map::new("allowances"); Once we start using addresses there, let's be safe about it. I want to check if this use case is valid and understood by everyone. And #872 would make this as easy to do with |
And then we would have to wrap everything into an It's your call, but I think that it tries to solve cases that are intrinsic to programing in general. Your |
That said, maybe with helpers and conversions, I'll give it a try during the weekend and comment back. |
Finally, if this is going to be used, why not replacing In any case, let's try to have one And, let's stick to what the language already offers for dealing with references, inner references, lifetimes, etc. Again, that's just my opinion, and I may very well be missing something here. |
The biggest issue I have with this discussion is that it is not about the
Those requirements are very hard to archive. Given 1. and 2. there is not much you can do other than re-interpreting For this reason #872 is not an alternative to #869. Instead it upstreams a In CosmWasm/cw-plus#264 and CosmWasm/cw-plus#265 I propose two different approaches that relax the requirements of |
I don't know if you ever tried, but for the same reason as 👆implementing CosmWasm/cw-plus#256 or |
Thank you for the thoughts. And I also agree that this logic needs to live with I did Also, I find #869 very heavy. I would extract a line or two from #872 to get just that Let me look at cosmwasm-plus PRs first |
I'm happy to drop #869 if you think the cost (copies of 100bytes on the stack) is not worth the gain (simpler literals and no heap usage at all). But I would also like to avoid adding extra types just for test code. Regarding to_owned: The ToOwned trait is a generalization of Clone to borrowed data.. This also means |
Good, to sum up:
|
Using it in contracts and a few more nice to haves.
I will be extending this
is_empty()
helperAddrRef::from(&addr)
.The text was updated successfully, but these errors were encountered: