You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The previous issue only supported native tokens. Extend this to support either one native denom or one cw20 address - set in init. Try for yourself which is the best code reuse - if it is easier to make 2 different contracts, one native-only and one cw20-only and share some group logic between them, that is also fine. Any given contract instance should only take either native coins or cw20 coins, so they don't need both code paths in the contract - think about making this maintainable and bug-free.
Change handle_bond to accept native of cw20 balance. That means accepting sender: HumanAddr, amount: cw20::Balance instead of info: MessageInfo. This conversion should be done in the handle switch just like in cw20-escrow
handle_bond should enforce incoming tokens using a switch on config.denom, inspired by cw20-escrow checks. You will want to keep the current logic for the Balance::Native case (or simplify it to use cw0::must_pay if you know how to extend the custom error type.
Update handle_claim to release either native token (as now) or cw20-token (this can be unimplemented!() now, but have the branch based on the cw20::Balance variant)
Ensure all current tests pass with minor changes (just wrapping the denom in cw20::Balance::Native. You have laid the groundwork, but still have no cw20 support.
Add a HandleMsg::Receive variant to receive cw20 tokens. It should look similar to cw20-escrow::ReceiveMsg, but the ReceiveMsg should only handle the bond case, like pub enum HandleMsg { Bond {} }. The Receive interface is explained in the cw20 spec
You need to update handle to process this Receive variant. If it is properly formatted, it should call into handle_bond using a cw20::Balance::Cw20 token rather than cw20::Balance::Native. You can refer to the cw20-escrow receive switch.
You can test instantiating a contract with cw20 support and properly bonding. For this, just mock out the receive call. (You can also try cw-multi-test to test a multi-contract setup, but that is still very undocumented. Use at you own risk.
Now, go back to handle_claim and ensure it emits the proper withdraw message when the config.denom is cw20::Balance::Cw20.
Add end-to-end tests for a cw20-supporting contract: bonding, unbonding, claiming. If you can query the membership value in the bonded group, there is no need to test voting or anything else, just that the membership is properly updated.
The text was updated successfully, but these errors were encountered:
Builds on #142
The previous issue only supported native tokens. Extend this to support either one native denom or one cw20 address - set in init. Try for yourself which is the best code reuse - if it is easier to make 2 different contracts, one native-only and one cw20-only and share some group logic between them, that is also fine. Any given contract instance should only take either native coins or cw20 coins, so they don't need both code paths in the contract - think about making this maintainable and bug-free.
Here is a breakdown of the steps needed:
cw20::Balance
instead ofString
forInitMsg::denom
andConfig::denom
handle_bond
to accept native of cw20 balance. That means acceptingsender: HumanAddr, amount: cw20::Balance
instead ofinfo: MessageInfo
. This conversion should be done in thehandle
switch just like incw20-escrow
handle_bond
should enforce incoming tokens using a switch onconfig.denom
, inspired bycw20-escrow
checks. You will want to keep the current logic for the Balance::Native case (or simplify it to usecw0::must_pay
if you know how to extend the custom error type.handle_claim
to release either native token (as now) or cw20-token (this can beunimplemented!()
now, but have the branch based on thecw20::Balance
variant)cw20::Balance::Native
. You have laid the groundwork, but still have no cw20 support.HandleMsg::Receive
variant to receive cw20 tokens. It should look similar tocw20-escrow::ReceiveMsg
, but the ReceiveMsg should only handle the bond case, likepub enum HandleMsg { Bond {} }
. TheReceive
interface is explained in the cw20 spechandle
to process thisReceive
variant. If it is properly formatted, it should call intohandle_bond
using acw20::Balance::Cw20
token rather thancw20::Balance::Native
. You can refer to thecw20-escrow
receive switch.cw-multi-test
to test a multi-contract setup, but that is still very undocumented. Use at you own risk.handle_claim
and ensure it emits the proper withdraw message when theconfig.denom
iscw20::Balance::Cw20
.The text was updated successfully, but these errors were encountered: