-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[token-cli] Add support for transfer-hook account resolution for transfers with the transfer-fee extension. #7171
[token-cli] Add support for transfer-hook account resolution for transfers with the transfer-fee extension. #7171
Conversation
What tests if any needed to be 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.
Nice!! The changes look great to me.
For the tests, you'll want to test the helpers by adding a few cases to the Token-2022 tests under token/program-2022-test
in the transfer_hook
test module.
The idea is to basically make copies of success_transfer
and success_transfers_using_onchain_helper
, but add the transfer fee config to the mint. The former is going to test with the transfer hook example program, which should still work fine for this case, since it's really just going to test that the proper extra metas are loaded and passed to the example program in token/transfer-hook/example
. The latter is using a mocked-up processor in the test module (see this line here).
Then maybe add a block in the Token CLI's transfer_hook
tests to ensure we can parse a transfer instruction with a fee and all the extra transfer hook accounts as arguments.
If you have any questions, let me know, and thanks!
@buffalojoec I am working in |
And actually, does it make sense to add the combination test here in |
Yeah, you need to add
I didn't want to dump that whole workload on you. 😅 |
Looking at the rest of the tests, I actually think its okay to have these mixed extension tests in Also there are no tests here for |
I am having trouble trying to add the arguments for the expected fee to the transfer test. I have confirmed that I can successfully create the token with both the transfer-hook and transfer-fee extensions in the test, so this is not a problem. Could this be caused by I assume it's a catch-22 because we need the associated token account to be created meaning it cannot be done in offline mode. If it is online mode, the transfer-hook program would need to be deployed and initialized. Is this correct? |
Yeah that's correct. The test I linked is sending the command to create the token, then disable the transfer hook (set program to Maybe duplicate that test and set the token up with a fee config, similar to this test here, and then add the fee argument to the parsing test block? That way you can also set up the token account required. |
Okay I figured it out! In sign-only + offline mode you need to explicitly pass the |
I think this is good to go! |
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.
Nice! This is super close, just a nit and comment about the one test, then we can ship.
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.
Nice work!!
Will this auto close and not be added? 😅 |
Whoops, sorry! I thought you could merge after I approved. |
I'd need to be employed to do that right? 😉 |
Per #7059
Adds a new offchain helper
offchain::create_transfer_checked_with_fee_instruction_with_extra_metas
.Adds a new onchain helper
onchain::invoke_transfer_checked_with_fee
Adds logic to
transfer_with_fee
in token/client/src/token.rs to add the extra-account-metas using the offchain helper if the token uses the transfer-hook extension.