solana-foundation / developer-content

Collection of Developer content for exploring, learning, and building in the Solana ecosystem.
https://solana.com/developers
94 stars 136 forks source link

TokenTransferHookInvalidSeed in Transfer Hook tutorial #124

Open csjcode opened 5 months ago

csjcode commented 5 months ago

Problem

The wSOL token extension transfer hook tutorial has a couple issues I believe, I'm getting some errors including from the "final" version listed....

Tutorial: https://solana.com/developers/guides/token-extensions/transfer-hook#run-test-file

I tested this both with (1) the "final" solpg code link and (2) code in the walkthrough (there are slight differences in each)

Linked as "final program" in the tutorial: https://beta.solpg.io/github.com/solana-developers/anchor-transfer-hook/tree/main

  1. One of the Transfer Hook tests fails, I'm not sure why yet, but it was on both the final and the walkthrough code.

Console Output:

Transaction Signature: 28b3AhseYv68pKguMo5MxQEdjqM5SbuhZ7oZ15N99yw4WuKZTZwrs6qEDYjkr7uk5ED1GnLpxRbqrmi4cG483o8Q ✔ Create Mint Account with Transfer Hook Extension (796ms) test Transaction Signature: 5dWnbeDfnF1rGrKgx7CYtv9TudXWo8W9cVPAKVNmxNcuLZeTk7HJW5vqcZ4RYVA9FGvSRiRBdn1r1cAWrMgwBSte ✔ Create Token Accounts and Mint Tokens (830ms) Transaction Signature: Hog1VA4S3oKtGBaaD2AJpZm15PYAq3AGYBTjygsphNBrutgdPUj4obeQpfMQPjDTEhNMreVZWMZEzzvaVsgShB7 ✔ Create ExtraAccountMetaList Account (860ms) 1) Transfer Hook with Extra Account Meta 3 passing (4s) 1 failing 1) transfer-hook Transfer Hook with Extra Account Meta: TokenTransferHookInvalidSeed

  1. Fyi, there are some small code differences, including errors, between the walkthrough code and the final code.

The walkthrough code for the tests has some minor errors in the ExtraAccountMetaList function (ie. bigIntAmount left out, naming different). Also, for example one uses a transferInstructionWithHelper function, while the other does not have that.

Also noticed some of the imports are different.

Not sure if the test error is related to all that... but just fyi.

Proposed Solution

I'm just hoping for any insight or if the code can be updated to make the test successful. I just encountereed it, so I am not sure of any solution yet myself.

Woody4618 commented 5 months ago

Thank you very much for the report. I can reproduce it. Ill fix it asap in the guide and playground. In the meantime please use the working version here: https://github.com/solana-developers/program-examples/tree/main/tokens/token-2022/transfer-hook/anchor/TransferHookTransferCost

csjcode commented 5 months ago

Thanks, much appreciated, I will try that!