Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

token-2022: Add MemoTransfer extension #2822

Merged
merged 8 commits into from
Feb 5, 2022

Conversation

CriesofCarrots
Copy link
Contributor

@CriesofCarrots CriesofCarrots commented Jan 28, 2022

Some users would like to require all transfers into particular accounts be accompanied by a memo.
This PR implements a MemoTransfer extension, which stores a byte indicating whether memo-transfers are or are not required. The extension can be initialized on any existing token Account, assuming the account has space for the extension. Callers should call Reallocate to make space, if the account is too small.

Currently, there is only a placeholder where the memo-requirement would be in _process_transfer(), pending the syscall that will expose previous sibling instructions to be checked for the memo. Bumping the solana crates and using the syscall will be done in a subsequent PR.

Needs:

Closes #2729

@CriesofCarrots CriesofCarrots force-pushed the memo-extension branch 3 times, most recently from a77df16 to 63d507a Compare February 1, 2022 19:28
@CriesofCarrots
Copy link
Contributor Author

CriesofCarrots commented Feb 1, 2022

Just fyi that this PR needs a lot of work around reallocation; coming soon

@CriesofCarrots CriesofCarrots changed the title WIP: Memo extension token-2022: Add MemoTransfer extension Feb 2, 2022
@CriesofCarrots CriesofCarrots force-pushed the memo-extension branch 2 times, most recently from c552197 to 7f6e2c0 Compare February 2, 2022 03:54
@CriesofCarrots CriesofCarrots force-pushed the memo-extension branch 2 times, most recently from 22025a4 to 7ec723a Compare February 2, 2022 23:11
@CriesofCarrots CriesofCarrots marked this pull request as ready for review February 2, 2022 23:17
@CriesofCarrots
Copy link
Contributor Author

Not fully functional, due to syscall, but everything else ready for a look!

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great for the most part! The realloc part is a bit tough, so we might need to refactor StateWithExtensionsMut

@CriesofCarrots CriesofCarrots marked this pull request as draft February 3, 2022 22:32
@CriesofCarrots CriesofCarrots force-pushed the memo-extension branch 3 times, most recently from a6e0486 to bc0dbae Compare February 4, 2022 19:49
@CriesofCarrots CriesofCarrots force-pushed the memo-extension branch 2 times, most recently from 91340df to 60a97dc Compare February 4, 2022 22:31
@CriesofCarrots CriesofCarrots marked this pull request as ready for review February 4, 2022 22:34
joncinque
joncinque previously approved these changes Feb 4, 2022
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just two nittiest of comment nits

token/rust/src/token.rs Outdated Show resolved Hide resolved
@mergify mergify bot dismissed joncinque’s stale review February 4, 2022 23:44

Pull request has been modified.

@CriesofCarrots
Copy link
Contributor Author

Woot! Excited to get this one in

@CriesofCarrots CriesofCarrots merged commit 482a928 into solana-labs:master Feb 5, 2022
@CriesofCarrots CriesofCarrots deleted the memo-extension branch February 26, 2022 20:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

token: add extension to support TransferWithMemo
3 participants