Skip to content
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

transfer hook: add new onchain helper #6111

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

buffalojoec
Copy link
Contributor

@buffalojoec buffalojoec commented Jan 10, 2024

As another step for solving #6064, the onchain helpers now need to be
replaced. This PR makes that change in the SPL Transfer Hook interface.

Specifically, this commit adds a new add_extra_accounts_for_execute_cpi(..)
helper and deprecates the old one.

Like its offchain counterpart, this new helper requires the arguments for
instruction::execute(..) in order to validate that a proper
ExecuteInstruction is being resolved, thus ensuring proper account resolution.

This function, like its now-deprecated sibling, is designed specifically to add
extra accounts to an ExecuteInstruction CPI instruction. It's expected that
the instruction being provided is a CPI instruction for another program, and
that program will CPI to the transfer hook program in question. Details about
this have been added to the helper's documentation.

@buffalojoec buffalojoec changed the base branch from 01-10-token_js_create_new_offchain_helper to 01-10-token_2022_test_refactor_transfer_hook_test_to_use_new_offchain_helper January 10, 2024 22:04
@buffalojoec buffalojoec force-pushed the 01-10-transfer_hook_add_new_onchain_helper branch from e80383e to 26ed6f5 Compare January 10, 2024 22:04
@buffalojoec buffalojoec force-pushed the 01-10-transfer_hook_add_new_onchain_helper branch 2 times, most recently from 1b717ce to dfb7feb Compare January 10, 2024 23:25
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 good! Just a question on the interface for the function

token/transfer-hook/interface/src/onchain.rs Outdated Show resolved Hide resolved
token/transfer-hook/interface/src/onchain.rs Outdated Show resolved Hide resolved
token/js/test/e2e-2022/tokenMetadata.test.ts Outdated Show resolved Hide resolved
joncinque
joncinque previously approved these changes Jan 11, 2024
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.

Rolling right along, looks great!

@buffalojoec buffalojoec force-pushed the 01-10-token_2022_test_refactor_transfer_hook_test_to_use_new_offchain_helper branch from 0b076b1 to 269ff6f Compare January 11, 2024 16:36
@buffalojoec buffalojoec force-pushed the 01-10-transfer_hook_add_new_onchain_helper branch from e6238ed to b1c626e Compare January 11, 2024 16:37
Copy link
Contributor Author

buffalojoec commented Jan 11, 2024

Merge activity

  • Jan 11, 4:15 PM: @buffalojoec started a stack merge that includes this pull request via Graphite.
  • Jan 11, 4:21 PM: Graphite rebased this pull request as part of a merge.
  • Jan 11, 4:22 PM: @buffalojoec merged this pull request with Graphite.

@buffalojoec buffalojoec force-pushed the 01-10-token_2022_test_refactor_transfer_hook_test_to_use_new_offchain_helper branch from 269ff6f to 63e8f91 Compare January 11, 2024 21:18
Base automatically changed from 01-10-token_2022_test_refactor_transfer_hook_test_to_use_new_offchain_helper to master January 11, 2024 21:20
@buffalojoec buffalojoec force-pushed the 01-10-transfer_hook_add_new_onchain_helper branch from b1c626e to 667b867 Compare January 11, 2024 21:20
@mergify mergify bot dismissed joncinque’s stale review January 11, 2024 21:22

Pull request has been modified.

@buffalojoec buffalojoec merged commit 095bc48 into master Jan 11, 2024
33 checks passed
@buffalojoec buffalojoec deleted the 01-10-transfer_hook_add_new_onchain_helper branch January 11, 2024 21:22
buffalojoec pushed a commit that referenced this pull request Jan 11, 2024
Continuing on from the new helper introduced in #6111.

Here the onchain helper in Token2022 is updated to use the non-deprecated new
onchain helper from SPL Transfer Hook interface.

PDAs as extra meta configs are also added to the transfer hook test in
`program-2022-test` for additional assurance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants