diff --git a/chain/core/src/builtin_func_names.rs b/chain/core/src/builtin_func_names.rs index 108ed29016..51777f201b 100644 --- a/chain/core/src/builtin_func_names.rs +++ b/chain/core/src/builtin_func_names.rs @@ -14,3 +14,9 @@ pub const SET_USERNAME_FUNC_NAME: &str = "SetUserName"; pub const MIGRATE_USERNAME_FUNC_NAME: &str = "migrateUserName"; pub const DELETE_USERNAME_FUNC_NAME: &str = "DeleteUserName"; pub const UPGRADE_CONTRACT_FUNC_NAME: &str = "upgradeContract"; +pub const ESDT_SET_TOKEN_TYPE_FUNC_NAME: &str = "ESDTSetTokenType"; +pub const ESDT_MODIFY_ROYALTIES_FUNC_NAME: &str = "ESDTModifyRoyalties"; +pub const ESDT_SET_NEW_URIS_FUNC_NAME: &str = "ESDTSetNewURIs"; +pub const ESDT_MODIFY_CREATOR_FUNC_NAME: &str = "ESDTModifyCreator"; +pub const ESDT_METADATA_RECREATE_FUNC_NAME: &str = "ESDTMetaDataRecreate"; +pub const ESDT_METADATA_UPDATE_FUNC_NAME: &str = "ESDTMetaDataUpdate"; diff --git a/chain/core/src/types/flags/esdt_local_role.rs b/chain/core/src/types/flags/esdt_local_role.rs index 048d3876ce..3634e5d891 100644 --- a/chain/core/src/types/flags/esdt_local_role.rs +++ b/chain/core/src/types/flags/esdt_local_role.rs @@ -13,6 +13,11 @@ const ESDT_ROLE_NFT_BURN: &str = "ESDTRoleNFTBurn"; const ESDT_ROLE_NFT_ADD_URI: &str = "ESDTRoleNFTAddURI"; const ESDT_ROLE_NFT_UPDATE_ATTRIBUTES: &str = "ESDTRoleNFTUpdateAttributes"; const ESDT_ROLE_TRANSFER: &str = "ESDTTransferRole"; +const ESDT_ROLE_SET_NEW_URI: &str = "ESDTRoleSetNewURI"; +const ESDT_ROLE_MODIFY_ROYALTIES: &str = "ESDTRoleModifyRoyalties"; +const ESDT_ROLE_MODIFY_CREATOR: &str = "ESDTRoleModifyCreator"; +const ESDT_ROLE_NFT_RECREATE: &str = "ESDTRoleNFTRecreate"; +const ESDT_ROLE_NFT_UPDATE: &str = "ESDTRoleNFTUpdate"; #[derive(TopDecode, TopEncode, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug, Copy)] pub enum EsdtLocalRole { @@ -25,6 +30,11 @@ pub enum EsdtLocalRole { NftAddUri, NftUpdateAttributes, Transfer, + SetNewUri, + ModifyRoyalties, + ModifyCreator, + NftRecreate, + NftUpdate, } impl EsdtLocalRole { @@ -39,6 +49,11 @@ impl EsdtLocalRole { Self::NftAddUri => 6, Self::NftUpdateAttributes => 7, Self::Transfer => 8, + Self::SetNewUri => 9, + Self::ModifyRoyalties => 10, + Self::ModifyCreator => 11, + Self::NftRecreate => 12, + Self::NftUpdate => 13, } } @@ -57,6 +72,11 @@ impl EsdtLocalRole { Self::NftAddUri => ESDT_ROLE_NFT_ADD_URI, Self::NftUpdateAttributes => ESDT_ROLE_NFT_UPDATE_ATTRIBUTES, Self::Transfer => ESDT_ROLE_TRANSFER, + Self::SetNewUri => ESDT_ROLE_SET_NEW_URI, + Self::ModifyRoyalties => ESDT_ROLE_MODIFY_ROYALTIES, + Self::ModifyCreator => ESDT_ROLE_MODIFY_CREATOR, + Self::NftRecreate => ESDT_ROLE_NFT_RECREATE, + Self::NftUpdate => ESDT_ROLE_NFT_UPDATE, } } @@ -71,13 +91,18 @@ impl EsdtLocalRole { Self::NftAddUri => EsdtLocalRoleFlags::NFT_ADD_URI, Self::NftUpdateAttributes => EsdtLocalRoleFlags::NFT_UPDATE_ATTRIBUTES, Self::Transfer => EsdtLocalRoleFlags::TRANSFER, + Self::SetNewUri => EsdtLocalRoleFlags::SET_NEW_URI, + Self::ModifyRoyalties => EsdtLocalRoleFlags::MODIFY_ROYALTIES, + Self::ModifyCreator => EsdtLocalRoleFlags::MODIFY_CREATOR, + Self::NftRecreate => EsdtLocalRoleFlags::NFT_RECREATE, + Self::NftUpdate => EsdtLocalRoleFlags::NFT_UPDATE, } } } // TODO: can be done with macros, but I didn't find a public library that does it and is no_std // we can implement it, it's easy -const ALL_ROLES: [EsdtLocalRole; 8] = [ +const ALL_ROLES: [EsdtLocalRole; 13] = [ EsdtLocalRole::Mint, EsdtLocalRole::Burn, EsdtLocalRole::NftCreate, @@ -86,6 +111,11 @@ const ALL_ROLES: [EsdtLocalRole; 8] = [ EsdtLocalRole::NftAddUri, EsdtLocalRole::NftUpdateAttributes, EsdtLocalRole::Transfer, + EsdtLocalRole::SetNewUri, + EsdtLocalRole::ModifyRoyalties, + EsdtLocalRole::ModifyCreator, + EsdtLocalRole::NftRecreate, + EsdtLocalRole::NftUpdate, ]; impl EsdtLocalRole { @@ -106,6 +136,11 @@ impl From for EsdtLocalRole { 6 => Self::NftAddUri, 7 => Self::NftUpdateAttributes, 8 => Self::Transfer, + 9 => Self::SetNewUri, + 10 => Self::ModifyRoyalties, + 11 => Self::ModifyCreator, + 12 => Self::NftRecreate, + 13 => Self::NftUpdate, _ => Self::None, } } @@ -130,6 +165,16 @@ impl<'a> From<&'a [u8]> for EsdtLocalRole { Self::NftUpdateAttributes } else if byte_slice == ESDT_ROLE_TRANSFER.as_bytes() { Self::Transfer + } else if byte_slice == ESDT_ROLE_SET_NEW_URI.as_bytes() { + Self::SetNewUri + } else if byte_slice == ESDT_ROLE_MODIFY_ROYALTIES.as_bytes() { + Self::ModifyRoyalties + } else if byte_slice == ESDT_ROLE_MODIFY_CREATOR.as_bytes() { + Self::ModifyCreator + } else if byte_slice == ESDT_ROLE_NFT_RECREATE.as_bytes() { + Self::NftRecreate + } else if byte_slice == ESDT_ROLE_NFT_UPDATE.as_bytes() { + Self::NftUpdate } else { Self::None } diff --git a/chain/core/src/types/flags/esdt_local_role_flags.rs b/chain/core/src/types/flags/esdt_local_role_flags.rs index 29be64aba2..cac9aa6795 100644 --- a/chain/core/src/types/flags/esdt_local_role_flags.rs +++ b/chain/core/src/types/flags/esdt_local_role_flags.rs @@ -15,6 +15,11 @@ bitflags! { const NFT_ADD_URI = 0b00100000; const NFT_UPDATE_ATTRIBUTES = 0b01000000; const TRANSFER = 0b10000000; + const SET_NEW_URI = 0b00000001_00000000; + const MODIFY_ROYALTIES = 0b00000010_00000000; + const MODIFY_CREATOR = 0b00000100_00000000; + const NFT_RECREATE = 0b00001000_00000000; + const NFT_UPDATE = 0b00010000_00000000; } } diff --git a/chain/core/src/types/flags/esdt_token_type.rs b/chain/core/src/types/flags/esdt_token_type.rs index 74db07c9a6..bfa2b07192 100644 --- a/chain/core/src/types/flags/esdt_token_type.rs +++ b/chain/core/src/types/flags/esdt_token_type.rs @@ -9,6 +9,10 @@ const ESDT_TYPE_FUNGIBLE: &[u8] = b"FungibleESDT"; const ESDT_TYPE_NON_FUNGIBLE: &[u8] = b"NonFungibleESDT"; const ESDT_TYPE_SEMI_FUNGIBLE: &[u8] = b"SemiFungibleESDT"; const ESDT_TYPE_META: &[u8] = b"MetaESDT"; +const ESDT_TYPE_NON_FUNGIBLE_V2: &[u8] = b"NonFungibleESDTv2"; +const ESDT_TYPE_DYNAMIC_NON_FUNGIBLE: &[u8] = b"DynamicNonFungibleESDT"; +const ESDT_TYPE_DYNAMIC_SEMI_FUNGIBLE: &[u8] = b"DynamicSemiFungibleESDT"; +const ESDT_TYPE_DYNAMIC_META: &[u8] = b"DynamicMetaESDT"; const ESDT_TYPE_INVALID: &[u8] = &[]; // Note: In the current implementation, SemiFungible is never returned @@ -19,6 +23,10 @@ pub enum EsdtTokenType { NonFungible, SemiFungible, Meta, + NonFungibleV2, + DynamicNFT, + DynamicSFT, + DynamicMeta, Invalid, } @@ -37,7 +45,11 @@ impl EsdtTokenType { Self::NonFungible => 1, Self::SemiFungible => 2, Self::Meta => 3, - Self::Invalid => 4, + Self::NonFungibleV2 => 4, + Self::DynamicNFT => 5, + Self::DynamicSFT => 6, + Self::DynamicMeta => 7, + Self::Invalid => 8, } } @@ -47,6 +59,10 @@ impl EsdtTokenType { Self::NonFungible => ESDT_TYPE_NON_FUNGIBLE, Self::SemiFungible => ESDT_TYPE_SEMI_FUNGIBLE, Self::Meta => ESDT_TYPE_META, + Self::NonFungibleV2 => ESDT_TYPE_NON_FUNGIBLE_V2, + Self::DynamicNFT => ESDT_TYPE_DYNAMIC_NON_FUNGIBLE, + Self::DynamicSFT => ESDT_TYPE_DYNAMIC_SEMI_FUNGIBLE, + Self::DynamicMeta => ESDT_TYPE_DYNAMIC_META, Self::Invalid => ESDT_TYPE_INVALID, } } @@ -60,6 +76,10 @@ impl From for EsdtTokenType { 1 => Self::NonFungible, 2 => Self::SemiFungible, 3 => Self::Meta, + 4 => Self::NonFungibleV2, + 5 => Self::DynamicNFT, + 6 => Self::DynamicSFT, + 7 => Self::DynamicMeta, _ => Self::Invalid, } } @@ -76,6 +96,14 @@ impl<'a> From<&'a [u8]> for EsdtTokenType { Self::SemiFungible } else if byte_slice == ESDT_TYPE_META { Self::Meta + } else if byte_slice == ESDT_TYPE_NON_FUNGIBLE_V2 { + Self::NonFungibleV2 + } else if byte_slice == ESDT_TYPE_DYNAMIC_NON_FUNGIBLE { + Self::DynamicNFT + } else if byte_slice == ESDT_TYPE_DYNAMIC_SEMI_FUNGIBLE { + Self::DynamicSFT + } else if byte_slice == ESDT_TYPE_DYNAMIC_META { + Self::DynamicMeta } else { Self::Invalid } diff --git a/framework/base/src/contract_base/wrappers/send_wrapper.rs b/framework/base/src/contract_base/wrappers/send_wrapper.rs index 0c23b67cd4..468d75c92c 100644 --- a/framework/base/src/contract_base/wrappers/send_wrapper.rs +++ b/framework/base/src/contract_base/wrappers/send_wrapper.rs @@ -1,5 +1,7 @@ use core::marker::PhantomData; +use multiversx_chain_core::types::EsdtTokenType; + use crate::codec::Empty; use crate::types::ManagedRef; @@ -763,4 +765,84 @@ where .nft_update_attributes(token_id, nft_nonce, new_attributes) .sync_call() } + + /// Sets the token type for a specific token. + pub fn esdt_set_token_type(&self, token_id: &TokenIdentifier, token_type: EsdtTokenType) { + Tx::new_tx_from_sc() + .to(ToSelf) + .gas(GasLeft) + .typed(system_proxy::UserBuiltinProxy) + .esdt_set_token_type(token_id, token_type) + .sync_call() + } + + /// Modifies royalties for a specific token. + pub fn esdt_modify_royalties( + &self, + token_id: &TokenIdentifier, + nonce: u64, + new_royalty: u64, + ) { + Tx::new_tx_from_sc() + .to(ToSelf) + .gas(GasLeft) + .typed(system_proxy::UserBuiltinProxy) + .esdt_modify_royalties(token_id, nonce, new_royalty) + .sync_call() + } + + /// Sets new uris for a specific token. + pub fn esdt_nft_set_new_uris( + &self, + token_id: &TokenIdentifier, + nonce: u64, + uris: &ManagedVec>, + ) { + Tx::new_tx_from_sc() + .to(ToSelf) + .gas(GasLeft) + .typed(system_proxy::UserBuiltinProxy) + .esdt_nft_set_new_uris(token_id, nonce, uris) + .sync_call() + } + + /// Changes the creator of a specific token into the caller. + pub fn esdt_nft_modify_creator(&self, token_id: &TokenIdentifier, nonce: u64) { + Tx::new_tx_from_sc() + .to(ToSelf) + .gas(GasLeft) + .typed(system_proxy::UserBuiltinProxy) + .esdt_nft_modify_creator(token_id, nonce) + .sync_call() + } + + /// Recreates an ESDT token with the newly specified attributes. + pub fn esdt_metadata_recreate( + &self, + token_id: TokenIdentifier, + nonce: u64, + new_attributes: &T, + ) { + Tx::new_tx_from_sc() + .to(ToSelf) + .gas(GasLeft) + .typed(system_proxy::UserBuiltinProxy) + .esdt_metadata_recreate(token_id, nonce, new_attributes) + .sync_call() + } + + /// Updates an ESDT token with the newly specified attributes. + pub fn esdt_metadata_update( + &self, + token_id: &TokenIdentifier, + nonce: u64, + new_attributes: &T, + ) { + Tx::new_tx_from_sc() + .to(ToSelf) + .gas(GasLeft) + .typed(system_proxy::UserBuiltinProxy) + .esdt_metadata_update(token_id, nonce, new_attributes) + .sync_call() + } } diff --git a/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs b/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs index 1bf7c3a1fc..1612965f4b 100644 --- a/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs +++ b/framework/base/src/types/interaction/system_proxy/builtin_func_proxy.rs @@ -1,15 +1,17 @@ use multiversx_sc_codec::{Empty, TopEncode}; use crate::types::{ - BigUint, ManagedAddress, ManagedBuffer, ManagedVec, NotPayable, ProxyArg, TokenIdentifier, Tx, - TxEnv, TxFrom, TxGas, TxProxyTrait, TxTo, TxTypedCall, + BigUint, EsdtTokenType, ManagedAddress, ManagedBuffer, ManagedVec, NotPayable, ProxyArg, + TokenIdentifier, Tx, TxEnv, TxFrom, TxGas, TxProxyTrait, TxTo, TxTypedCall, }; use crate::chain_core::builtin_func_names::{ CHANGE_OWNER_BUILTIN_FUNC_NAME, CLAIM_DEVELOPER_REWARDS_FUNC_NAME, DELETE_USERNAME_FUNC_NAME, - ESDT_LOCAL_BURN_FUNC_NAME, ESDT_LOCAL_MINT_FUNC_NAME, ESDT_NFT_ADD_QUANTITY_FUNC_NAME, - ESDT_NFT_ADD_URI_FUNC_NAME, ESDT_NFT_BURN_FUNC_NAME, ESDT_NFT_CREATE_FUNC_NAME, - ESDT_NFT_UPDATE_ATTRIBUTES_FUNC_NAME, SET_USERNAME_FUNC_NAME, + ESDT_LOCAL_BURN_FUNC_NAME, ESDT_LOCAL_MINT_FUNC_NAME, ESDT_METADATA_RECREATE_FUNC_NAME, + ESDT_METADATA_UPDATE_FUNC_NAME, ESDT_MODIFY_CREATOR_FUNC_NAME, ESDT_MODIFY_ROYALTIES_FUNC_NAME, + ESDT_NFT_ADD_QUANTITY_FUNC_NAME, ESDT_NFT_ADD_URI_FUNC_NAME, ESDT_NFT_BURN_FUNC_NAME, + ESDT_NFT_CREATE_FUNC_NAME, ESDT_NFT_UPDATE_ATTRIBUTES_FUNC_NAME, ESDT_SET_NEW_URIS_FUNC_NAME, + ESDT_SET_TOKEN_TYPE_FUNC_NAME, SET_USERNAME_FUNC_NAME, }; /// Proxy describing the user builtin function signatures. @@ -214,4 +216,130 @@ where tx.original_result() } + + pub fn esdt_set_token_type< + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_id: Arg0, + token_type: Arg1, + ) -> TxTypedCall { + let tx = self + .wrapped_tx + .payment(NotPayable) + .raw_call(ESDT_SET_TOKEN_TYPE_FUNC_NAME) + .argument(&token_id) + .argument(&token_type); + + tx.original_result() + } + + pub fn esdt_modify_royalties< + Arg0: ProxyArg>, + Arg1: ProxyArg, + Arg2: ProxyArg, + >( + self, + token_id: Arg0, + nonce: Arg1, + new_royalty: Arg2, + ) -> TxTypedCall { + let tx = self + .wrapped_tx + .payment(NotPayable) + .raw_call(ESDT_MODIFY_ROYALTIES_FUNC_NAME) + .argument(&token_id) + .argument(&nonce) + .argument(&new_royalty); + + tx.original_result() + } + + pub fn esdt_nft_set_new_uris>, Arg1: ProxyArg>( + self, + token_id: Arg0, + nonce: Arg1, + uris: &ManagedVec>, + ) -> TxTypedCall { + let mut tx = self + .wrapped_tx + .payment(NotPayable) + .raw_call(ESDT_SET_NEW_URIS_FUNC_NAME) + .argument(&token_id) + .argument(&nonce); + + if uris.is_empty() { + // at least one URI is required, so we push an empty one + tx = tx.argument(&Empty); + } else { + // The API function has the last argument as variadic, + // so we top-encode each and send as separate argument + for uri in uris { + tx = tx.argument(&uri); + } + } + + tx.original_result() + } + + pub fn esdt_nft_modify_creator< + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_id: Arg0, + nonce: Arg1, + ) -> TxTypedCall { + let tx = self + .wrapped_tx + .payment(NotPayable) + .raw_call(ESDT_MODIFY_CREATOR_FUNC_NAME) + .argument(&token_id) + .argument(&nonce); + + tx.original_result() + } + + pub fn esdt_metadata_recreate< + T: TopEncode, + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_id: Arg0, + nonce: Arg1, + new_attributes: &T, + ) -> TxTypedCall { + let tx = self + .wrapped_tx + .payment(NotPayable) + .raw_call(ESDT_METADATA_RECREATE_FUNC_NAME) + .argument(&token_id) + .argument(&nonce) + .argument(&new_attributes); + + tx.original_result() + } + + pub fn esdt_metadata_update< + T: TopEncode, + Arg0: ProxyArg>, + Arg1: ProxyArg, + >( + self, + token_id: Arg0, + nonce: Arg1, + new_attributes: &T, + ) -> TxTypedCall { + let tx = self + .wrapped_tx + .payment(NotPayable) + .raw_call(ESDT_METADATA_UPDATE_FUNC_NAME) + .argument(&token_id) + .argument(&nonce) + .argument(&new_attributes); + + tx.original_result() + } } diff --git a/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs b/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs index 979f9d1d60..a68950b0f9 100644 --- a/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs +++ b/framework/base/src/types/interaction/system_proxy/esdt_system_sc_proxy.rs @@ -14,6 +14,8 @@ const ISSUE_NON_FUNGIBLE_ENDPOINT_NAME: &str = "issueNonFungible"; const ISSUE_SEMI_FUNGIBLE_ENDPOINT_NAME: &str = "issueSemiFungible"; const REGISTER_META_ESDT_ENDPOINT_NAME: &str = "registerMetaESDT"; const ISSUE_AND_SET_ALL_ROLES_ENDPOINT_NAME: &str = "registerAndSetAllRoles"; +const REGISTER_DYNAMIC_ESDT_ENDPOINT_NAME: &str = "registerDynamic"; +const REGISTER_AND_SET_ALL_ROLES_DYNAMIC_ESDT_ENDPOINT_NAME: &str = "registerAndSetAllRolesDynamic"; /// The specific `Tx` type produces by the issue operations of the ESDTSystemSCProxy. pub type IssueCall = Tx< @@ -214,11 +216,29 @@ where EsdtTokenType::NonFungible => "NFT", EsdtTokenType::SemiFungible => "SFT", EsdtTokenType::Meta => "META", + EsdtTokenType::NonFungibleV2 => "NFT", + EsdtTokenType::DynamicNFT => "NFT", + EsdtTokenType::DynamicSFT => "SFT", + EsdtTokenType::DynamicMeta => "META", + EsdtTokenType::Invalid => "", + }; + + let endpoint = match token_type { + EsdtTokenType::Fungible + | EsdtTokenType::NonFungible + | EsdtTokenType::SemiFungible + | EsdtTokenType::Meta => ISSUE_AND_SET_ALL_ROLES_ENDPOINT_NAME, + + EsdtTokenType::NonFungibleV2 + | EsdtTokenType::DynamicNFT + | EsdtTokenType::DynamicSFT + | EsdtTokenType::DynamicMeta => REGISTER_AND_SET_ALL_ROLES_DYNAMIC_ESDT_ENDPOINT_NAME, + EsdtTokenType::Invalid => "", }; self.wrapped_tx - .raw_call(ISSUE_AND_SET_ALL_ROLES_ENDPOINT_NAME) + .raw_call(endpoint) .egld(issue_cost) .argument(&token_display_name) .argument(&token_ticker) @@ -246,6 +266,10 @@ where EsdtTokenType::NonFungible => ISSUE_NON_FUNGIBLE_ENDPOINT_NAME, EsdtTokenType::SemiFungible => ISSUE_SEMI_FUNGIBLE_ENDPOINT_NAME, EsdtTokenType::Meta => REGISTER_META_ESDT_ENDPOINT_NAME, + EsdtTokenType::NonFungibleV2 + | EsdtTokenType::DynamicNFT + | EsdtTokenType::DynamicSFT + | EsdtTokenType::DynamicMeta => REGISTER_DYNAMIC_ESDT_ENDPOINT_NAME, EsdtTokenType::Invalid => "", }; diff --git a/framework/base/src/types/interaction/system_proxy/legacy_system_sc_proxy.rs b/framework/base/src/types/interaction/system_proxy/legacy_system_sc_proxy.rs index 6f74b80812..4af1f5b9b2 100644 --- a/framework/base/src/types/interaction/system_proxy/legacy_system_sc_proxy.rs +++ b/framework/base/src/types/interaction/system_proxy/legacy_system_sc_proxy.rs @@ -17,6 +17,8 @@ const ISSUE_NON_FUNGIBLE_ENDPOINT_NAME: &str = "issueNonFungible"; const ISSUE_SEMI_FUNGIBLE_ENDPOINT_NAME: &str = "issueSemiFungible"; const REGISTER_META_ESDT_ENDPOINT_NAME: &str = "registerMetaESDT"; const ISSUE_AND_SET_ALL_ROLES_ENDPOINT_NAME: &str = "registerAndSetAllRoles"; +const REGISTER_DYNAMIC_ESDT_ENDPOINT_NAME: &str = "registerDynamic"; +const REGISTER_AND_SET_ALL_ROLES_DYNAMIC_ESDT_ENDPOINT_NAME: &str = "registerAndSetAllRolesDynamic"; /// Proxy for the ESDT system smart contract. /// Unlike other contract proxies, this one has a fixed address, @@ -188,18 +190,32 @@ where EsdtTokenType::NonFungible => "NFT", EsdtTokenType::SemiFungible => "SFT", EsdtTokenType::Meta => "META", + EsdtTokenType::NonFungibleV2 => "NFT", + EsdtTokenType::DynamicNFT => "NFT", + EsdtTokenType::DynamicSFT => "SFT", + EsdtTokenType::DynamicMeta => "META", EsdtTokenType::Invalid => "", }; - ContractCallWithEgld::new( - esdt_system_sc_address, - ISSUE_AND_SET_ALL_ROLES_ENDPOINT_NAME, - issue_cost, - ) - .argument(&token_display_name) - .argument(&token_ticker) - .argument(&token_type_name) - .argument(&num_decimals) + let endpoint = match token_type { + EsdtTokenType::Fungible + | EsdtTokenType::NonFungible + | EsdtTokenType::SemiFungible + | EsdtTokenType::Meta => ISSUE_AND_SET_ALL_ROLES_ENDPOINT_NAME, + + EsdtTokenType::NonFungibleV2 + | EsdtTokenType::DynamicNFT + | EsdtTokenType::DynamicSFT + | EsdtTokenType::DynamicMeta => REGISTER_AND_SET_ALL_ROLES_DYNAMIC_ESDT_ENDPOINT_NAME, + + EsdtTokenType::Invalid => "", + }; + + ContractCallWithEgld::new(esdt_system_sc_address, endpoint, issue_cost) + .argument(&token_display_name) + .argument(&token_ticker) + .argument(&token_type_name) + .argument(&num_decimals) } /// Deduplicates code from all the possible issue functions @@ -219,6 +235,10 @@ where EsdtTokenType::NonFungible => ISSUE_NON_FUNGIBLE_ENDPOINT_NAME, EsdtTokenType::SemiFungible => ISSUE_SEMI_FUNGIBLE_ENDPOINT_NAME, EsdtTokenType::Meta => REGISTER_META_ESDT_ENDPOINT_NAME, + EsdtTokenType::NonFungibleV2 + | EsdtTokenType::DynamicNFT + | EsdtTokenType::DynamicSFT + | EsdtTokenType::DynamicMeta => REGISTER_DYNAMIC_ESDT_ENDPOINT_NAME, EsdtTokenType::Invalid => "", };