-
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 support for transfer hook instructions #5096
Conversation
@joncinque is it currently possible to update the transfer hook authority (optionally set it to null)? If so where would I find the spec for that? |
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! Nothing big, just a few nits to sort out. After looking through this, I'm thinking the TransferHookAccount
extension can get added separately, since this is very neatly contained.
Regarding your question:
is it currently possible to update the transfer hook authority (optionally set it to null)? If so where would I find the spec for that?
It certainly is, you can find the program source code doing it at
solana-program-library/token/program-2022/src/processor.rs
Lines 810 to 822 in 47f09c9
AuthorityType::TransferHookProgramId => { | |
let extension = mint.get_extension_mut::<TransferHook>()?; | |
let maybe_authority: Option<Pubkey> = extension.authority.into(); | |
let authority = maybe_authority.ok_or(TokenError::AuthorityTypeNotSupported)?; | |
Self::validate_owner( | |
program_id, | |
&authority, | |
authority_info, | |
authority_info_data_len, | |
account_info_iter.as_slice(), | |
)?; | |
extension.authority = new_authority.try_into()?; | |
} |
The concept is that you can reuse set-authority and pass in the correct authority. Given the disparity between the Rust side:
solana-program-library/token/program-2022/src/instruction.rs
Lines 1042 to 1070 in 47f09c9
pub enum AuthorityType { | |
/// Authority to mint new tokens | |
MintTokens, | |
/// Authority to freeze any account associated with the Mint | |
FreezeAccount, | |
/// Owner of a given token account | |
AccountOwner, | |
/// Authority to close a token account | |
CloseAccount, | |
/// Authority to set the transfer fee | |
TransferFeeConfig, | |
/// Authority to withdraw withheld tokens from a mint | |
WithheldWithdraw, | |
/// Authority to close a mint account | |
CloseMint, | |
/// Authority to set the interest rate | |
InterestRate, | |
/// Authority to transfer or burn any tokens for a mint | |
PermanentDelegate, | |
/// Authority to update confidential transfer mint and aprove accounts for confidential | |
/// transfers | |
ConfidentialTransferMint, | |
/// Authority to set the transfer hook program id | |
TransferHookProgramId, | |
/// Authority to set the withdraw withheld authority encryption key | |
ConfidentialTransferFeeConfig, | |
/// Authority to set the metadata address | |
MetadataPointer, | |
} |
and the JS side
solana-program-library/token/js/src/instructions/setAuthority.ts
Lines 16 to 21 in 47f09c9
export enum AuthorityType { | |
MintTokens = 0, | |
FreezeAccount = 1, | |
AccountOwner = 2, | |
CloseAccount = 3, | |
} |
We have a bit of work to do there 😅 I put in #5100 to address that
Will do the changes!
That is what I figured. Just didn't see it for other extension authorities like the transfer fee extension. |
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.
Great job, thanks for the contribution!
resolves: #4337