Extensions
Token Extensions란 무엇인가요?
Token Extensions Program(Token 2022)은 확장이라고 불리는 추가 명령을 통해 더 많은 기능을 제공합니다. Extensions는 토큰 민트나 토큰 계정에 추가할 수 있는 선택적 기능입니다. 이러한 확장 명령의 구현은 Token Extensions Program 소스 코드에서 찾을 수 있습니다.
각 확장은 일반적으로 민트나 토큰 계정 생성 중에 초기화되는 특정 상태를 추가합니다. 계정을 초기화할 때 다양한 기능을 위해 특정 확장을 동시에 활성화할 수 있습니다. 대부분의 확장은 계정이 초기화된 후에는 추가할 수 없습니다. 이는 토큰을 설계할 때 중요한 고려사항이므로, 토큰이 지원할 기능을 미리 계획해야 합니다. 각 확장에 대한 통합 가이드는 Token Extensions 개발자 문서에서 확인할 수 있습니다.
일부 확장은 서로 호환되지 않으며 동일한 토큰 민트나 토큰 계정에서 동시에
활성화할 수 없습니다. 예를 들어, NonTransferable
확장과
TransferFeeConfig
확장은 서로 충돌하는 동작을 가지고 있기 때문에 함께
사용할 수 없습니다.
Token Extensions Program은 토큰 민트나 토큰 계정에 추가할 수 있는 모든 사용
가능한 확장을 나열하는
ExtensionType
열거형을 정의합니다. 각 변형은 고유한 기능을 가진 다른 확장을 나타냅니다.
ExtensionType
열거형은 다음과 같이 정의됩니다:
/// Extensions that can be applied to mints or accounts. Mint extensions must/// only be applied to mint accounts, and account extensions must only be/// applied to token holding accounts.#[repr(u16)]#[cfg_attr(feature = "serde-traits", derive(Serialize, Deserialize))]#[cfg_attr(feature = "serde-traits", serde(rename_all = "camelCase"))]#[derive(Clone, Copy, Debug, PartialEq, TryFromPrimitive, IntoPrimitive)]pub enum ExtensionType {/// Used as padding if the account size would otherwise be 355, same as a/// multisigUninitialized,/// Includes transfer fee rate info and accompanying authorities to withdraw/// and set the feeTransferFeeConfig,/// Includes withheld transfer feesTransferFeeAmount,/// Includes an optional mint close authorityMintCloseAuthority,/// Auditor configuration for confidential transfersConfidentialTransferMint,/// State for confidential transfersConfidentialTransferAccount,/// Specifies the default Account::state for new AccountsDefaultAccountState,/// Indicates that the Account owner authority cannot be changedImmutableOwner,/// Require inbound transfers to have memoMemoTransfer,/// Indicates that the tokens from this mint can't be transferredNonTransferable,/// Tokens accrue interest over time,InterestBearingConfig,/// Locks privileged token operations from happening via CPICpiGuard,/// Includes an optional permanent delegatePermanentDelegate,/// Indicates that the tokens in this account belong to a non-transferable/// mintNonTransferableAccount,/// Mint requires a CPI to a program implementing the "transfer hook"/// interfaceTransferHook,/// Indicates that the tokens in this account belong to a mint with a/// transfer hookTransferHookAccount,/// Includes encrypted withheld fees and the encryption public that they are/// encrypted underConfidentialTransferFeeConfig,/// Includes confidential withheld transfer feesConfidentialTransferFeeAmount,/// Mint contains a pointer to another account (or the same account) that/// holds metadataMetadataPointer,/// Mint contains token-metadataTokenMetadata,/// Mint contains a pointer to another account (or the same account) that/// holds group configurationsGroupPointer,/// Mint contains token group configurationsTokenGroup,/// Mint contains a pointer to another account (or the same account) that/// holds group member configurationsGroupMemberPointer,/// Mint contains token group member configurationsTokenGroupMember,/// Mint allowing the minting and burning of confidential tokensConfidentialMintBurn,/// Tokens whose UI amount is scaled by a given amountScaledUiAmount,/// Tokens where minting / burning / transferring can be pausedPausable,/// Indicates that the account belongs to a pausable mintPausableAccount,/// Test variable-length mint extension#[cfg(test)]VariableLenMintTest = u16::MAX - 2,/// Padding extension used to make an account exactly Multisig::LEN, used/// for testing#[cfg(test)]AccountPaddingTest,/// Padding extension used to make a mint exactly Multisig::LEN, used for/// testing#[cfg(test)]MintPaddingTest,}
각 확장은 민트나 토큰 계정에 추가 상태를 포함시켜 특수 기능을 추가합니다. 모든
확장 관련 상태는 기본 계정 데이터 타입 다음에 오는
tlv_data
필드에 저장됩니다. 해당 계정에 활성화된 특정 확장 유형에 따라 tlv_data
(확장
상태 포함)를 추가로 역직렬화해야 합니다.
/// Encapsulates immutable base state data (mint or account) with possible/// extensions, where the base state is Pod for zero-copy serde.#[derive(Debug, PartialEq)]pub struct PodStateWithExtensions<'data, S: BaseState + Pod> {/// Unpacked base datapub base: &'data S,/// Slice of data containing all TLV data, deserialized on demandtlv_data: &'data [u8],}
Is this page helpful?