Closed thr0wn closed 4 years ago
Let's save this feature for it's own production release as it requires more testing compared to other PRs.
Changes
- [x] Remove ability to cancel dividends.
We want to avoid a user cancelling a dividend payment requiring, say, 3 transactions each to 2500 recipients -- after 1 or 2 transactions -- and then wishing to complete the payment. We may bring this back once the API has the ability to take SLP balance snapshots at specific blockheights. We also don't want users to think that 'canceling' can somehow undo and refund their already-sent BCH. It should be clear that all BCH transactions are final.
- [x] Clarify which components depend on
localStorage
-- is this full dividend history or only active dividends? Please add a short summary of how this PR useslocalStorage
The PR now describes better how localStorage is used and 8a931d0 removes the cancel button. Thanks for the feedback, @josephroyking.
All new dividends created are persisted in localStorage and batches are sent for each Mint's update. More specifically, clicking at 'Pay Dividends' in 'Pay Dividends' page and at 'Portfolio' just saves the new dividend on the localStorage.
The first step to create and then persist the dividend occurs here: https://github.com/Bitcoin-com/mint/blob/feat/dividends-batches/src/utils/sendDividends.js#L107
After that, each update of Mint will call the following line: https://github.com/Bitcoin-com/mint/blob/feat/dividends-batches/src/utils/useWallet.js#L98
The above call executes the functions below: https://github.com/Bitcoin-com/mint/blob/feat/dividends-batches/src/utils/dividends/dividends-manager.js
It takes the first 'In progress'/incompleted dividend to send a new batch of payments using all available utxos. As a dividend carries the remaining addresses to receive dividends,
_update
only slicesdividend.remainingAddresses
anddividend.remainingValues
and pass it tosendBch
. So, to track the progress of a dividend we just need to do the following:Only dividends created after that PR will be persisted and tracked at 'Dividends History'. Active (in progress) and Inactive (Completed or Crashed) dividends are showed at too.