-
Notifications
You must be signed in to change notification settings - Fork 1
DEX usage fee #230
DEX usage fee #230
Conversation
Codecov Report
@@ Coverage Diff @@
## main #230 +/- ##
==========================================
+ Coverage 53.16% 53.40% +0.23%
==========================================
Files 114 116 +2
Lines 4117 4144 +27
==========================================
+ Hits 2189 2213 +24
- Misses 1928 1931 +3
|
#[cosmwasm_schema::cw_serde] | ||
pub enum DexApiExecuteMsg { | ||
Action(DexExecuteMsg), | ||
UpdateFee { | ||
swap_fee: Option<Decimal>, | ||
recipient_os_id: Option<u32>, | ||
}, | ||
} |
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.
So I guess the json would be:
{
"app": {
"action": {
"action": {
"swap": {...}
},
"dex": "lolswap",
}
}
}
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.
{
"app": {
"execute": {
"dex": "lolswap",
"action": {
"swap": {...}
},
}
}
}
?
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.
The users shouldn't be interacting with the json too much but still the nested duplicate names can be confusing.
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.
An alternative to this is to add a configure
"endpoint" to the ApiExecuteMsg
which would be a different "handler" on the API. That way we don't add additional nesting at the api module level.
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.
Hmmmm.....
Executing:
{
"app": {
"dex": "lolswap",
"action": {
"swap": {...}
},
}
}
Configuring:
{
"configure": {
"update_fee": {...}
}
}
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.
I'd like to discuss this during standup
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.
I think adding a #[serde(flatten)] tag to the action variant should remove the nested nature of the msg
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.
I'm not even sure if those unit-enum variants actually get their own key or if the inner value name is used as key.
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.
This code:
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
struct FooFoo {
x: i32,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
enum Bar {
Foo(FooFoo),
Baz,
}
fn main() {
let bar = Bar::Foo(FooFoo { x: 42 });
println!("bar = {:?}", bar);
println!("bar = {}", serde_json::to_string_pretty(&bar).unwrap());
}
Returns:
bar = Foo(FooFoo { x: 42 })
bar = {
"Foo": {
"x": 42
}
}
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.
We could also opt for a "type" tag which would look like:
bar = {
"type": "Foo",
"x": 42
}
And change the Action name to something different.
📢 Type of change
▫️ Bugfix
▫️ New feature
▫️ Enhancement
▫️ Refactoring
▫️ Maintenance
📜 Description and Motivation
🛠️ How to test (if applicable)
📝 Checklist
▫️ Reviewed submitted code
▫️ Added tests to verify changes
▫️ Updated docs
▫️ Verified on testnet