feat(cycles-minting): Cycles Minting canister refunds automatically. #3484
+324
−50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This happens when the
memo
(oricrc1_memo
) in an ICP transfer is not one of the special values that CMC recognizes as signaling the purpose of the transfer.This behavior gets triggered when one of the
notify_*
methods gets called.The new behavior is not actually active yet. To turn it on, we simply need to set
IS_AUTOMATIC_REFUND_ENABLED
to true.Motivation
Avoids ICP getting stuck, which can result from people making mistakes when sending ICP to the CMC.
Implementation Overview
Added
issue_automatic_refund_if_memo_not_offerred
. As indicated by the name, this is the heart of the implementation of this new functionality. This is called fromfetch_transaction
. The call is guarded behind the aforementionedIS_AUTOMATIC_REFUND_ENABLED
flag.Added
MEANINGFUL_MEMOS
constant. This is used to detect when automatic refund should be performed.Minor Changes
Added
AutomaticallyRefunded
toNotificationStatus
. This ensures that we do duplicate refunds.Changed one parameter of
fetch_transaction
fromAccountIdentifier
toSubaccount
, because you cannot go "backwards" fromAccountIdentifier
toSubaccount
.Factored out the
memo
+icrc1_memo
unifying code which used to live intransaction_has_expected_memo
. Now, that code lives in a newget_u64_memo
function.Future Work
Added a couple of other helpers. One is
set_block_status_to_processing
. This could be used to reduce code duplication innotify_*
methods, but such refactoring is left to future PRs.References
We promised to do this in this forum post.