-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/token overhaul #5
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Honestly, I was thinking of something more minimalistic... Like, implementing send
, burn
and probably balance
(with owner_of
query under the hood) with the same params as for Fungible
trait, with only difference that amount
is always 1 (or either 0 or 1 in case of balance
), so this way it can be wrapped in some generic Token
trait.
We would just create a list of tokens with something like this:
let tokens = vec![
Token::cw721("addr", "token_id"),
Token::native("denom", 100),
Token::cw20("addr", 100)
];
...and then would be able to call those send
methods for each, not caring about what is that token exactly.
for token in tokens {
resp.add_message(token.send("recipient")?);
// ...
}
Note that cw721's TokenInfo
in this setup would require token_id
as well, e.g.:
pub enum TokenInfo {
Cw20(Cw20TokenInfo), // Cw20TokenInfo { address: Addr }
Native(NativeTokenInfo), // NativeTokenInfo { denom: String }
Cw721(Cw721TokenInfo), // Cw721TokenInfo { address: Addr, token_id: String }
}
Disadvantages:
- kinda confusing, I only started thinking about it and there are already 2 wacky conditions (one with
amount=0|1
and one withbalance
being in fact a wrapper forowner_of
) - kinda subjective, because this way we'd implement some methods from
cw721
standard but not all of them
But on the other side, the proposed wrapper methods (for tokens
, total_tokens
etc) where you just call a corresponding query under the hood, don't bring much value.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] | ||
pub struct NonFungibleToken { | ||
pub info: NonFungibleTokenInfo, | ||
pub token: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's token_id
, right? I think it would be more clear to keep that name
How about the proposed
These are mostly to avoid having to import the cw packages directly, keeping things easier to read |
Is it tho? I guess it would be quite possible to expect:
So it's always --
I totally agree with that, I mentioned that |
I feel like the purpose of |
From an interface perspective that's horrible UX, + keep in mind that balance in this perspective would mean |
Also MB, I accidentally edited your comment, I didn't know I could do that lmao |
I see value in |
If the purpose of the package is to provide different wrapper structs for those different kinds of tokens, then yeah, probably. But if the main value is abstraction that allowes to use just
Again, it depends on how you view the I see you lean towards the first approach. It's fine since it's your lib ofc, if so, I will just implement another crate / local package that meets our specific needs. |
No description provided.