Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify coin selection to support minting and burning
- Modifies "performSelection" to account for minted and burnt tokens. On a superficial level, mints provide extra tokens to use, where burns increase the amount of tokens we need to select. - Modifies the "makeChange" algorithm to account for minted and burnt tokens. When tokens are minted they are added to the largest change bundle. When tokens are burnt they are removed from the smallest change bundles until the burn has been satisfied. See the code for more detailed commentary. - Adds property tests that ensure the "addMintChange" and "removeBurnChange" family of functions: - maintain number of change bundles, - maintain partial ascending ordering of change bundles - modify the total value of the change bundle by their respective mint/burn amounts. - Adds a few unit tests to ensure the change generation occurs as we expect it to. - Adds some debugging information to the coin selection tests to make debugging in the presence of minting and burning easier. - Adds a "minted but not spent" error to the API. This is returned when a user tries to mint a token but doesn't send it anywhere.
- Loading branch information