Closed buffalojoec closed 8 months ago
Is there a timeline for publishing v0.3.12? Currently facing 0x7dc8348c (IncorrectAccount)
error on using addExtraAccountsToInstruction
for the transfer hook. cc @buffalojoec
Is there a timeline for publishing v0.3.12? Currently facing
0x7dc8348c (IncorrectAccount)
error on usingaddExtraAccountsToInstruction
for the transfer hook. cc @buffalojoec
https://github.com/solana-labs/solana-program-library/releases/tag/token-js-v0.4.0
Love it sir 😎🫡 my tx is still failing with 0x7dc8348c but at least the new package is out :)
Time to go debug more...
Any luck solving : 0x7dc8348c?
Problem
Token2022's off-chain and on-chain helpers for adding the necessary extra account metas for a transfer instruction that requires a transfer hook are missing a crucial step.
Note: This crucial step is missing only from the helpers, thus the on-chain program itself needs no change.
At the bottom of this issue is a test. In it, we're going to build instructions with extra account metas in three ways:
TransferChecked
instruction using the Token2022 off-chain helperExecute
instruction using the TLV Account Resolution library'sadd_to_instruction
Execute
CPI instruction using the TLV Account Resolution library'sadd_to_cpi_instruction
As you can probably infer, the issue is that we are adding the extra metas to a transfer instruction, rather than an
Execute
instruction.Consider the instruction keys for
TransferChecked
(simplified):Now consider the instruction keys as defined in the SPL Transfer Hook Interface's
Execute
instruction:As you can see,
Execute
requires the validation (extra metas) account, whileTransferChecked
does not.When extra account metas are hard-coded addresses, ie.
ExtraAccountMeta::new_with_pubkey(..)
, this is not an issue. However, once any extra account meta uses seed configurations that point to other account keys in the list, this difference in account keys bungles the whole resolution.The problem here is that, at the time of account resolution, the list of account keys for a transfer instruction and the list of account keys for an
Execute
instruction will yield entirely different resolutions.For example, if I have a PDA that's based off of the account at index 4, that will be two different accounts depending on the instruction. No bueno.
Consider the test.
Proposed Solution
We should be able to insert a few lines of code into the helpers that simply converts a transfer instruction into an
Execute
instruction before resolving the extra account metas.Since anyone storing extra account meta configs should be considering the list of accounts as it will arrive in their Transfer Hook program's
Execute
instruction, it makes sense to resolve forExecute
.After all, the main problem we have here is that we're asking TLV Account Resolution to resolve the extra account metas for an
Execute
instruction, but we're not actually feeding it a validExecute
instruction.