aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Aptos Framework][Cleanup] Minor backward-compatible cleanups in stake module

Open movekevin opened this issue 2 years ago • 0 comments

Description

Multiple minor cleanups that are still backward-compatible:

  1. Check that a resource exists before borrowing it. This would return a nicer error to the users.
  2. Use the correct error::function instead of error::invalid_argument() for everything.
  3. Remove unnecessary type argument when it can be inferred from arguments. For example coin::value<AptosCoin>(aptos_coins) => coin::value(aptos_coins)
  4. Remove unused error codes.
  5. Short-circuit rather than throwing an error in several places. Throwing errors makes the stake module less composable as the modules building on top of them have to watch out for error conditions. For example, withdraw(0) can return zero coins instead of throwing an error because amount is 0.

Test Plan


This change is Reviewable

movekevin avatar Sep 14 '22 03:09 movekevin