एक्सटेंशन्स
Token Extensions क्या हैं?
Token Extensions Program (Token 2022) अतिरिक्त निर्देशों के माध्यम से अधिक सुविधाएँ प्रदान करता है जिन्हें एक्सटेंशन्स कहा जाता है। एक्सटेंशन्स वैकल्पिक सुविधाएँ हैं जिन्हें आप टोकन मिंट या टोकन अकाउंट में जोड़ सकते हैं। आप इन एक्सटेंशन निर्देशों का कार्यान्वयन 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?