-
Notifications
You must be signed in to change notification settings - Fork 697
feature: add memo field to stx-transfer clarity function #2488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think we'd also need to a |
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look great to me, thanks @pavitthrap, just had a couple of small nits.
This is great @pavitthrap! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work! One small comment but otherwise LGTM!
const STX_TRANSFER: SpecialAPI = SpecialAPI { | ||
input_type: "uint, principal, principal, buff", | ||
output_type: "(response bool uint)", | ||
signature: "(stx-transfer? amount sender recipient memo)", | ||
description: "`stx-transfer?` is used to increase the STX balance for the `recipient` principal | ||
by debiting the `sender` principal. The `sender` principal _must_ be equal to the current context's `tx-sender`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add to the description here that memo
can optionally be omitted
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Added an optional memo field to the
stx-transfer?
clarity function (by optional I mean you can choose to fully omit this argument when calling the function).Fixes #2391.
Also fixes #2485, which is a small DEBUG logging change.
Notes
buff(34)
instead ofoption(buff(34))
. The reason for this is because memo was provided as a string directly through the structTransferStxOp
insrc/chainstate/stacks/db/blocks.rs
, so I wanted to keep things consistent with that. Moreover, for backwards compatibility, the memo field is completely optional to even provide, so making the type explicitly an option felt a little unnecessary. Let me know if anyone has any opinions on this.special_stx_transfer
, I first check if there are 4 arguments. If there aren’t I then check if there are 3 arguments, which returns an error directly if there are not 3 arguments. Should I instead return an error message that thestx-transfer?
function expects 4 arguments, instead of letting thecheck_argument_count(3, args)?
return its error directly? Could be a source of confusion.stx-transfer?
in the repo (such as in test functions), I passed in the memo field, but not for all the calls. I did this because the function can now take in either 3 or 4 arguments so I thought it would be good to have instances of both in our tests. Let me know if anyone thinks I should pass in the additional memo parameter to all the tests throughout the repo.Type of Change
Does this introduce a breaking change?
Yes
Are documentation updates required?
Yes, this adds an additional field to
stx-transfer?
. Refer to change insrc/vm/docs/mod.rs
.Testing information
Run
cargo test
, there are various tests for this function in the code base.For the debug logging change(issue #2485), I ran a stacks node locally and checked for a change in the DEBUG output for
all_burns
. Example of new output:DEBG [1614734509.490227] [src/chainstate/burn/distribution.rs:289] [chains-coordinator] Burn sample, txid: 72389d8e5e512d72d4691db8ee98ada89559aeefe3bc72cb5d2f7e0144bb6997, most_recent_burn: 33332, median_burn: 1, all_burns: [33332, 1, 1, 33332, 1, 1]