stacks-subnets icon indicating copy to clipboard operation
stacks-subnets copied to clipboard

Add two versions of withdraw function

Open pavitthrap opened this issue 3 years ago • 2 comments

Some assets interacting with the hyperchain may not implement the mint trait (or may not allow the contract to invoke the mint function in the mint trait).

We should have two versions of the withdraw function for assets: (1) attempts to transfer asset from contract; if not present, minting is attempted (2) only attempts to transfer the asset from the contract

pavitthrap avatar Jun 01 '22 20:06 pavitthrap

This is looking like we need to duplicate withdraw-ft-asset and withdraw-nft-asset... however, it's leading to a lot of code duplication.

Things would be better if we could pass in an (option trait) in Clarity, but this doesn't easily work. Sounds like there is a "dark magic" way around this https://discord.com/channels/621759717756370964/713087894260023377/986970251323383859 but I didn't look into that.

Another option is to re-visit whether mint should be part of withdraw.

But, going to just start with the code duplication approach.

gregorycoppola avatar Jun 23 '22 19:06 gregorycoppola

This is resolved now for NFTs, using the optional trait that Aaron mentioned above, which is supported in Clarity2. The same still needs to be added for FTs it seems.

obycode avatar Jan 05 '23 03:01 obycode