Problem

A smart contract cannot withdraw delegation rewards on behalf of another account. With the introduction of authz, it should be possible to achieve this.

Context

After chatting in the Telegram during HackWasm 2022, it seems that the WithdrawDelegatorReward Message would need to be modified, or a new message type added. Currently, the message looks like this:

https://github.com/CosmWasm/cosmwasm/blob/7e865a2b9168679b25d041946eca3feadb192450/packages/std/src/results/cosmos_msg.rs#L99-L112

Note the part about the delegator_address automatically using the contract address. It seems that this assumption might need to be changed.

I am not well-versed in what's below the smart contract stack, but searching through GitHub I did find this:

https://github.com/CosmWasm/wasmd/blob/1a87b28539c0b0c0278bd400252f2d01b1599e85/x/wasm/keeper/handler_plugin_encoders.go#L140-L144

I wonder if that's where the contract address gets added as the delegator_address, though I'm not positive why it would be under wasmd since I thought that was a daemon/chain.

1

After chatting with @webmaster128 about this offline, it might not be tenable to change this particular message as it'd be quite backwards incompatible. Perhaps an addition of a new message type makes sense if we're going to allow for the flexibility that authz offers.

Will change the issue name accordingly.

0

According to https://github.com/CosmWasm/wasmd/issues/1031#issuecomment-1268599435 this needs to be wrapped in a MsgExec anyways. So there is nothing we can do about the existing WithdrawDelegatorReward that would help.

Maybe we should offer MsgExec natively though. Then you only have to build the inner message yourself.

1

MsgExec from a contract would make sense. 👍 I don't have a concrete use case but I can imagine that support for authz.Grant can be nice, too where the contract is the granter.

0
© 2022 pullanswer.com - All rights reserved.