Skip to content

Add Token Authority Management Functions#4

Merged
gitteri merged 2 commits intomainfrom
update-authority-sdk
Jul 29, 2025
Merged

Add Token Authority Management Functions#4
gitteri merged 2 commits intomainfrom
update-authority-sdk

Conversation

@gitteri
Copy link
Copy Markdown
Collaborator

@gitteri gitteri commented Jul 29, 2025

Add Token Authority Management Functions

Summary

This PR introduces a new administration module to the SDK with functions for updating token authorities on Solana Token-2022 program. The module provides a unified interface for updating both standard token authorities (mint, freeze, etc.) and metadata authorities.

🆕 What's Added

New Module: packages/sdk/src/administration/

Core Functions:

  • getUpdateAuthorityInstructions - Creates instructions to update token authorities
  • getUpdateAuthorityTransaction - Creates complete transactions for authority updates

Key Features:

  • ✅ Supports all 17 Token-2022 authority types (MintTokens, FreezeAccount, PermanentDelegate, etc.)
  • ✅ Special handling for metadata authority updates via getUpdateTokenMetadataUpdateAuthorityInstruction
  • ✅ Unified interface for both standard and metadata authority management
  • ✅ Automatic program address handling (TOKEN_2022_PROGRAM_ADDRESS)
  • ✅ Transaction building with latest blockhash fetching

Authority Types Supported

// Standard token authorities
AuthorityType.MintTokens | AuthorityType.FreezeAccount | AuthorityType.AccountOwner
AuthorityType.CloseAccount | AuthorityType.TransferFeeConfig | AuthorityType.WithheldWithdraw
AuthorityType.CloseMint | AuthorityType.InterestRate | AuthorityType.PermanentDelegate
AuthorityType.ConfidentialTransferMint | AuthorityType.TransferHookProgramId
AuthorityType.ConfidentialTransferFeeConfig | AuthorityType.MetadataPointer
AuthorityType.GroupPointer | AuthorityType.GroupMemberPointer | AuthorityType.ScaledUiAmount
AuthorityType.Pause

// Special metadata authority
'Metadata'

Testing

Comprehensive test suite with 28 test cases:

  • ✅ Tests all authority types individually
  • ✅ Tests metadata authority handling
  • ✅ Edge cases and validation
  • ✅ Function signature and type checking
  • ✅ Consistent behavior verification
  • No mocking - uses real gill/programs/token implementations

📝 Usage Examples

import { getUpdateAuthorityInstructions, getUpdateAuthorityTransaction } from '@mosaic/sdk/administration';

// Update mint authority instruction
const instructions = getUpdateAuthorityInstructions({
  mint: mintAddress,
  role: AuthorityType.MintTokens,
  currentAuthority: currentMintAuthority,
  newAuthority: newMintAuthority,
});

// Update metadata authority instruction
const metadataInstructions = getUpdateAuthorityInstructions({
  mint: mintAddress,
  role: 'Metadata',
  currentAuthority: currentMetadataAuthority,
  newAuthority: newMetadataAuthority,
});

// Create complete transaction
const transaction = await getUpdateAuthorityTransaction({
  rpc,
  payer: feePayer,
  mint: mintAddress,
  role: AuthorityType.FreezeAccount,
  currentAuthority: currentFreezeAuthority,
  newAuthority: newFreezeAuthority,
});

Important

Add new module for managing token authorities in Solana Token-2022 program with comprehensive testing and utility functions.

  • New Module: packages/sdk/src/administration/
    • getUpdateAuthorityInstructions: Creates instructions for updating token authorities.
    • getUpdateAuthorityTransaction: Creates transactions for authority updates.
    • Supports 17 Token-2022 authority types and metadata authority.
    • Handles automatic program address and transaction building.
  • Testing:
    • 28 test cases in updateAuthority.test.ts for authority types, metadata, edge cases, and validation.
    • Uses real gill/programs/token implementations.
  • Utilities:
    • transactionUtil.ts: Functions to convert transactions to base58 and base64 encoded strings.
  • Misc:
    • Added precommit and check scripts in package.json.

This description was created by Ellipsis for 36b97e0. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Changes requested ❌

Reviewed everything up to d28637c in 2 minutes and 10 seconds. Click for details.
  • Reviewed 447 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. package.json:17
  • Draft comment:
    New 'precommit' and 'check' scripts look useful; ensure their command ordering matches your intended workflow.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. packages/sdk/src/administration/__tests__/updateAuthority.test.ts:21
  • Draft comment:
    Tests comprehensively cover both 'Metadata' and standard authority roles. Verify that using AuthorityType[authorityType] (line 77) reliably gives the expected string.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to verify that a specific line of code behaves as expected. This falls under the category of asking the author to double-check or ensure behavior, which is against the rules. Therefore, this comment should be removed.

Workflow ID: wflow_fkyI9bzUXmmaqz6j

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed 36b97e0 in 43 seconds. Click for details.
  • Reviewed 46 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/sdk/src/administration/updateAuthority.ts:89
  • Draft comment:
    Explicitly passing an object literal to getUpdateAuthorityInstructions clarifies which parameters are used.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. packages/sdk/src/transactionUtil.ts:25
  • Draft comment:
    Inlining the getBase58Decoder call makes the code more concise without affecting readability.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. packages/sdk/src/transactionUtil.ts:44
  • Draft comment:
    Inlining the getBase64Decoder call improves conciseness while maintaining clarity.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_UgrdoDJnwM25Famh

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@gitteri gitteri merged commit 79d9fe6 into main Jul 29, 2025
2 checks passed
@gitteri gitteri deleted the update-authority-sdk branch July 29, 2025 14:13
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.

1 participant