public-awesome / cw-nfts

Examples and helpers to build NFT contracts on CosmWasm
Apache License 2.0
186 stars 179 forks source link

feature: optional withdrawal address #149

Closed taitruong closed 6 months ago

taitruong commented 6 months ago

This feature adds an optional withdrawal address. Please note: existing 3rd party doesnt need to update. Like it is still possible using old instantiate msg without defining a withdraw address!

This PR allows current NFT contracts to:

  1. set and remove withdraw addresses by owner
  2. withdraw funds by any to given address

This way launchpads, fee sharing, marketplaces etc. can benefit from this, like:

Added these new messages to cw721-base:

ExecuteMsg:

    /// Sets address to send withdrawn fees to. Only owner can call this.
    SetWithdrawAddress { address: String },
    /// Removes the withdraw address, so fees are sent to the contract. Only owner can call this.
    RemoveWithdrawAddress {},
    /// Withdraw from the contract to the given address. Anyone can call this,
    /// which is okay since withdraw address has been set by owner.
    WithdrawFunds { amount: Coin },

QueryMsg:

    #[returns(String)]
    GetWithdrawAddress {},
taitruong commented 6 months ago

@shanev could u have a look at this? PR allows now NFT contracts having funds. Owner can set/remove withdraw address - which is used for WithdrawFunds msg.

withdraw_address is optional and backward compatible.