-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reverse Splitter service #49
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.
Waiting for the enum change
Cargo.toml
Outdated
valence-splitter-service = { path = "contracts/services/splitter", features = ["library"] } | ||
valence-test-dynamic-ratio = { path = "contracts/testing/test-dynamic-ratio", features = ["library"] } | ||
valence-test-service = { path = "contracts/testing/test-service", features = ["library"] } |
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.
indentation
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.
fixed
name = "valence-reverse-splitter-service" | ||
authors = { workspace = true } | ||
edition = { workspace = true } |
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.
Indentation
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.
fixed
} | ||
} | ||
|
||
// // Prepare transfer messages for each denom |
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.
//
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.
fixed
let res: DynamicRatioResponse = querier.query_wasm_smart( | ||
contract_addr, | ||
&DynamicRatioQueryMsg::DynamicRatio { | ||
denoms: vec![denom_name.clone()], | ||
params: params.to_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.
Regarding querying a dynamic ration, we would probably need a wrapper of our own that will support this query because 99% other contracts wont.
Just something to note somewhere so we won't forgot.
pub fn with_factor(mut self, factor: u64) -> Self { | ||
self.factor = Some(factor); | ||
self | ||
} |
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 rest of the helper "with_" function are creating a new struct, I would suggest calling this as "set_factor" instead of with to make it clear.
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.
ok
if splits | ||
.iter() | ||
.any(|s| !matches!(s.amount, UncheckedSplitAmount::FixedAmount(..))) | ||
&& splits.iter().any(|s| { | ||
matches!(s.amount, UncheckedSplitAmount::FixedAmount(..)) && s.denom != *base_denom | ||
}) |
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 already doing a loop above, we can have a flag set to true at the above loop if any !UncheckedSplitAmount::FixedAmount(..)
, instead of doing another loop here.
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.
fixed
cw20 = { workspace = true } | ||
cw20-base = { workspace = true } | ||
sha2 = { workspace = true } | ||
valence-account-utils = { workspace = true } | ||
valence-service-utils = { workspace = true, features = ["testing"] } | ||
valence-test-dynamic-ratio = { workspace = true } |
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.
Indentation
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.
fixed
// Instantiate Splitter contract | ||
suite.splitter_init(&cfg); | ||
} | ||
|
||
#[test] | ||
#[should_panic( | ||
expected = "Configuration error: Duplicate split 'Native(\"untrn\")|AccountAddr(\"cosmwasm1ea6n0jqm0hj663khx7a5xklsmjgrazjp9vjeewejn84sanr0wgxq2p70xl\")' in split config." |
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 changed this line because I renamed an enum variant from AccountAddr
to Addr
,
Would be great if we can avoid those should_panic
when we need to include some parsing of enums or alike.
#[getset(get)] | ||
inner: ServiceTestSuiteBase, | ||
#[getset(get)] |
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.
What is the purpose of getset(get)
again? you are building the get functions below anyways
); | ||
} | ||
|
||
// // Native & CW20 token amount splits |
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.
double //
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.
fixed
Implemented:
Todo: