-
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-js: added extra account resolution for transfer hook extension #5112
Conversation
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 mate!
The Rust lib separates serialization/deserialization of the seed configs into the seeds
module, since it has to be used to pack and unpack both on-chain and off-chain, but JavaScript doesn't need that! I appreciate your condensed version of the seed resolution, doing both deserialization and resolution in one step 🤌🏼
I left a handful of comments, but this is shaping up nicely!
Multisigs are evaluated at the Token-2022 level. The solana-program-library/token/program-2022/src/instruction.rs Lines 319 to 330 in 737a37a
You can see here we're reading the data of the authority account and then using solana-program-library/token/program-2022/src/processor.rs Lines 396 to 402 in 737a37a
Then your extra metas would come after!
We could separate it, but I mentioned in my comment above that it's actually not necessary at the moment for the JavaScript library to be able to handle (de)serialization of the seed configs and TLV state. However, the more I think about it, the more I think we will eventually want a JavaScript TLV library so we don't have to keep writing the same
Actually you're pretty damn close, I just had the comment about little-endian. It's all facilitated by the
I think these look pretty good! I don't think we'll really be able to test these handlers properly until we have the instructions from the transfer hook interface baked into the JS client, so we can tell a program to pack some extra metas and then try to transfer with them. Once there, we can probably pluck these commands out of the solana-program-library/token/js/package.json Lines 44 to 47 in 737a37a
|
Awesome! So the js implementation for this is correct and a transfer hook program would need to take these extra multisig accounts into consideration if they want to support it.
Yeah I think that would make more sense than a tlv-account-resolution library. Perhaps we can create a issue for it but guess it is not that important for now.
Yeah was thinking about that as well but figured that was beyond the scope of this PR/issue |
Extra clarification question Is it correct that i.e. if you are resolving the account at index 3 it can only use accounts 0..2 as seed inputs. |
Yep that's correct. I have an implementation where this constraint is no longer required but it was a bit complicated. If we ever need it, I'll pull that bad boy out |
Yep
Agreed I swore I made one already but I'll throw one up now #5127
Agreed not in this PR. Also made an issue for this! #5128 |
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.
Really great work! This is pretty close to ready, thanks so much for contributing. We'll just need to fixup the decoding bit and clean up a few nits, then it should be 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.
This is extremely close, just a few last little things! Thanks for your patience and quick responses
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.
This looks good to me, thanks so much for taking this on! You:
I'll give @buffalojoec a chance to add any other comments
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.
Beast! Ship it 🚢
* master: (719 commits) release: Bump token-2022 and all dependencies (solana-labs#5189) SPL errors from hashes (solana-labs#5169) stake-pool: Add comments about unnecessary ownership checks (HAL-01) (solana-labs#5084) stake-pool: Enforce that pool mint uses 9 decimal places (HAL-03) (solana-labs#5085) build(deps-dev): bump tsx from 3.12.7 to 3.12.8 in /single-pool/js (solana-labs#5188) account-compression: Fixup sdk doc deployment (solana-labs#5187) token-js: renamed `getExtraAccountMetaAccount` to `getExtraAccountMetaAddress` (solana-labs#5186) token-js: added an e2e test for transferring using a mint with a transfer hook extension (solana-labs#5138) Serde optional dependencies clean-up (solana-labs#5181) build(deps): bump chrono from 0.4.27 to 0.4.28 (solana-labs#5180) stake-pool: Use unaligned types for safe pointer cast (solana-labs#5179) spl-pod: make code docs more explicit (solana-labs#5178) token-js: added extra account resolution for transfer hook extension (solana-labs#5112) Fix incorrect code doc (solana-labs#5177) Move Pod types to separate library (solana-labs#5119) build(deps-dev): bump @typescript-eslint/eslint-plugin from 6.4.1 to 6.5.0 in /memo/js (solana-labs#5176) build(deps): bump chrono from 0.4.26 to 0.4.27 (solana-labs#5171) build(deps-dev): bump prettier from 3.0.2 to 3.0.3 in /token-swap/js (solana-labs#5174) build(deps-dev): bump prettier from 3.0.2 to 3.0.3 in /token/js (solana-labs#5172) build(deps-dev): bump prettier from 3.0.2 to 3.0.3 in /token-lending/js (solana-labs#5173) ...
resolves #5108
Couple notes:
tlv-account-resolution
in rust is now baked into@solana/spl-token
for js. Might be a nice improvement to separate that into its own package?transferCheckedWithHook
andaddExtraAccountsToInstruction
are structured is a little bit made up by me. Let me know if it matches your expectations @joncinque