-
Notifications
You must be signed in to change notification settings - Fork 26
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
Mdjakovic/mint burn #803
base: main
Are you sure you want to change the base?
Mdjakovic/mint burn #803
Conversation
…-core into mdjakovic/mint-burn
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…-core into mdjakovic/mint-burn
use cw_storage_plus::{Item, Map}; | ||
|
||
pub const NEXT_ORDER_ID: Item<Uint128> = Item::new("next_order_id"); | ||
pub const ORDERS: Map<u128, OrderInfo> = Map::new("orders"); |
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.
Why not Uint128
?
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 method may_load
exists for struct Map<'static, Uint128, OrderInfo>
, but its trait bounds were not satisfied
the following trait bounds were not satisfied:
Uint128: PrimaryKey<'_>
let hook_msg = Cw20HookMsg::FillOrder { | ||
order_id: Uint128::one(), | ||
}; | ||
let cw20_receive_msg = Cw20ReceiveMsg { | ||
sender: "origin_cw20_sender".to_string(), | ||
amount: Uint128::new(5000), | ||
msg: encode_binary(&hook_msg).unwrap(), | ||
}; | ||
|
||
receive_cw20(deps.as_mut(), cw20_receive_msg, MOCK_CW20_CONTRACT).unwrap(); | ||
|
||
let cw20_receive_msg = Cw20ReceiveMsg { | ||
sender: "origin_cw20_sender_2".to_string(), | ||
amount: Uint128::new(6000), | ||
msg: encode_binary(&hook_msg).unwrap(), | ||
}; | ||
|
||
receive_cw20(deps.as_mut(), cw20_receive_msg, MOCK_CW20_CONTRACT).unwrap(); | ||
|
||
let created_order: GetOrderInfoResponse = | ||
query_order_info(deps.as_ref(), Uint128::one()).unwrap(); | ||
|
||
let order_status = created_order.order_status; | ||
assert_eq!(order_status, OrderStatus::NotCompleted); | ||
|
||
let cw20_receive_msg = Cw20ReceiveMsg { | ||
sender: "origin_cw20_sender".to_string(), | ||
amount: Uint128::new(7000), | ||
msg: encode_binary(&hook_msg).unwrap(), | ||
}; | ||
|
||
receive_cw20(deps.as_mut(), cw20_receive_msg, MOCK_CW20_CONTRACT).unwrap(); | ||
|
||
let cw20_receive_msg = Cw20ReceiveMsg { | ||
sender: "origin_cw20_sender_2".to_string(), | ||
amount: Uint128::new(4000), | ||
msg: encode_binary(&hook_msg).unwrap(), | ||
}; | ||
|
||
receive_cw20(deps.as_mut(), cw20_receive_msg, MOCK_CW20_CONTRACT).unwrap(); | ||
|
||
let created_order: GetOrderInfoResponse = | ||
query_order_info(deps.as_ref(), Uint128::one()).unwrap(); | ||
|
||
let order_status = created_order.order_status; | ||
assert_eq!(order_status, OrderStatus::NotCompleted); | ||
|
||
let cw20_receive_msg = Cw20ReceiveMsg { | ||
sender: "origin_cw20_sender".to_string(), | ||
amount: Uint128::new(24000), | ||
msg: encode_binary(&hook_msg).unwrap(), | ||
}; | ||
|
||
receive_cw20(deps.as_mut(), cw20_receive_msg, MOCK_CW20_CONTRACT_2).unwrap(); | ||
|
||
let created_order: GetOrderInfoResponse = | ||
query_order_info(deps.as_ref(), Uint128::one()).unwrap(); | ||
|
||
let order_status = created_order.order_status; | ||
assert_eq!(order_status, OrderStatus::Completed); |
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.
Is there any reason this can't be done in a loop? Seems to make the test unnecessarily long
ORDERS.save(ctx.deps.storage, order_id.clone().u128(), &order)?; | ||
|
||
// Refund excess tokens (only applicable for CW20) | ||
if excess_amount.gt(&Uint128::zero()) { |
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 happens here if the user sends the incorrect CW20 tokens? Should this not error? Seems like wasted gas to have an empty tx (just refunding the entire amount sent). We're also missing test cases for this scenario.
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.
Similarly for a CW721 token.
Motivation
This PR introduces a new Burn-Mint ADO contract built using CosmWasm and Andromeda ADO standards.
Key Features & Purpose
This contract maybe ideal for in-game economies, DeFi applications, and token exchanges that require dynamic asset transformations.
Implementation
Order Creation
Users create burn-mint orders, specifying:
Automated Token Handling
Minting New Tokens/NFTs
Once all required deposits are met, the contract:
Query System
The contract includes robust querying functions, allowing users to:
Testing
The unit test cases are added.
Version Changes
Version is set as
0.1.0-b.1
Checklist