hirosystems / stacks-subnets

Stacks Subnets: a layer-2 scaling solution for Stacks, intended for high-throughput, low-latency workloads
http://docs.hiro.so
GNU General Public License v3.0
52 stars 13 forks source link

Fix: Refund failed FT deposits #253

Closed jbencin closed 1 year ago

jbencin commented 1 year ago

Description

If a fungible token deposit onto a subnet fails, create a withdrawal transaction to allow the user to withdraw it from the contract

Applicable issues

Additional info (benefits, drawbacks, caveats)

There is no attempt here to handle the case of a partial success (for example, a user deposits 50 tokens and only 20 appear on the subnet). This shouldn't happen, and if it does I would think it indicates a problem with the Clarity contract.

Should I move make_withdrawal_event() out of blocks.rs and into clarity_vm/withrdawal.rs?

Also including a couple minor fixes, see commit messages for details.

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #253 (8369a9e) into master (a762f8f) will not change coverage. The diff coverage is n/a.

:exclamation: Current head 8369a9e differs from pull request most recent head b32b7eb. Consider uploading reports for the commit b32b7eb to get more accurate results

@@           Coverage Diff           @@
##           master     #253   +/-   ##
=======================================
  Coverage   93.47%   93.47%           
=======================================
  Files           6        6           
  Lines         337      337           
=======================================
  Hits          315      315           
  Misses         22       22           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

jbencin commented 1 year ago

Just made all the changes requested, except removing the TODO, which I'll do as part of #256