difftreelog
refactor rename function
in: master
11 files changed
pallets/unique/src/eth/mod.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation of CollectionHelpers contract.1819use core::marker::PhantomData;20use ethereum as _;21use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};22use frame_support::traits::Get;23use pallet_common::{24 CollectionById, CollectionHandle,25 dispatch::CollectionDispatch,26 erc::{27 CollectionHelpersEvents,28 static_property::{key, value as property_value},29 },30 Pallet as PalletCommon,31};32use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm_coder_substrate::dispatch_to_evm;35use up_data_structs::{36 CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,37 CollectionMode, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue,38};3940use crate::{Config, SelfWeightOf, weights::WeightInfo};4142use sp_std::{vec, vec::Vec};43use alloc::format;4445/// See [`CollectionHelpersCall`]46pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);47impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {48 fn recorder(&self) -> &SubstrateRecorder<T> {49 &self.050 }5152 fn into_recorder(self) -> SubstrateRecorder<T> {53 self.054 }55}5657fn convert_data<T: Config>(58 caller: caller,59 name: string,60 description: string,61 token_prefix: string,62 base_uri: string,63) -> Result<(64 T::CrossAccountId,65 CollectionName,66 CollectionDescription,67 CollectionTokenPrefix,68 PropertyValue,69)> {70 let caller = T::CrossAccountId::from_eth(caller);71 let name = name72 .encode_utf16()73 .collect::<Vec<u16>>()74 .try_into()75 .map_err(|_| error_field_too_long(stringify!(name), CollectionName::bound()))?;76 let description = description77 .encode_utf16()78 .collect::<Vec<u16>>()79 .try_into()80 .map_err(|_| {81 error_field_too_long(stringify!(description), CollectionDescription::bound())82 })?;83 let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {84 error_field_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())85 })?;86 let base_uri_value = base_uri87 .into_bytes()88 .try_into()89 .map_err(|_| error_field_too_long(stringify!(token_prefix), PropertyValue::bound()))?;90 Ok((caller, name, description, token_prefix, base_uri_value))91}9293fn make_data<T: Config>(94 name: CollectionName,95 mode: CollectionMode,96 description: CollectionDescription,97 token_prefix: CollectionTokenPrefix,98 base_uri_value: PropertyValue,99 add_properties: bool,100) -> Result<CreateCollectionData<T::AccountId>> {101 let mut properties = up_data_structs::CollectionPropertiesVec::default();102 let mut token_property_permissions =103 up_data_structs::CollectionPropertiesPermissionsVec::default();104105 token_property_permissions106 .try_push(up_data_structs::PropertyKeyPermission {107 key: key::url(),108 permission: up_data_structs::PropertyPermission {109 mutable: false,110 collection_admin: true,111 token_owner: false,112 },113 })114 .map_err(|e| Error::Revert(format!("{:?}", e)))?;115116 if add_properties {117 token_property_permissions118 .try_push(up_data_structs::PropertyKeyPermission {119 key: key::suffix(),120 permission: up_data_structs::PropertyPermission {121 mutable: false,122 collection_admin: true,123 token_owner: false,124 },125 })126 .map_err(|e| Error::Revert(format!("{:?}", e)))?;127128 properties129 .try_push(up_data_structs::Property {130 key: key::schema_name(),131 value: property_value::erc721(),132 })133 .map_err(|e| Error::Revert(format!("{:?}", e)))?;134135 if !base_uri_value.is_empty() {136 properties137 .try_push(up_data_structs::Property {138 key: key::base_uri(),139 value: base_uri_value,140 })141 .map_err(|e| Error::Revert(format!("{:?}", e)))?;142 }143 }144145 let data = CreateCollectionData {146 name,147 mode,148 description,149 token_prefix,150 token_property_permissions,151 properties,152 ..Default::default()153 };154 Ok(data)155}156157fn create_refungible_collection_internal<158 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,159>(160 caller: caller,161 name: string,162 description: string,163 token_prefix: string,164 base_uri: string,165 add_properties: bool,166) -> Result<address> {167 let (caller, name, description, token_prefix, base_uri_value) =168 convert_data::<T>(caller, name, description, token_prefix, base_uri)?;169 let data = make_data::<T>(170 name,171 CollectionMode::ReFungible,172 description,173 token_prefix,174 base_uri_value,175 add_properties,176 )?;177178 let collection_id = T::CollectionDispatch::create(caller.clone(), data)179 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;180 let address = pallet_common::eth::collection_id_to_address(collection_id);181 Ok(address)182}183184/// @title Contract, which allows users to operate with collections185#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]186impl<T> EvmCollectionHelpers<T>187where188 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,189{190 /// Create an NFT collection191 /// @param name Name of the collection192 /// @param description Informative description of the collection193 /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications194 /// @return address Address of the newly created collection195 #[weight(<SelfWeightOf<T>>::create_collection())]196 fn create_nonfungible_collection(197 &mut self,198 caller: caller,199 name: string,200 description: string,201 token_prefix: string,202 ) -> Result<address> {203 let (caller, name, description, token_prefix, _base_uri_value) =204 convert_data::<T>(caller, name, description, token_prefix, "".into())?;205 let data = make_data::<T>(206 name,207 CollectionMode::NFT,208 description,209 token_prefix,210 Default::default(),211 false,212 )?;213 let collection_id = T::CollectionDispatch::create(caller, data)214 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;215216 let address = pallet_common::eth::collection_id_to_address(collection_id);217 Ok(address)218 }219220 #[weight(<SelfWeightOf<T>>::create_collection())]221 #[solidity(rename_selector = "createERC721MetadataCompatibleCollection")]222 fn create_nonfungible_collection_with_properties(223 &mut self,224 caller: caller,225 name: string,226 description: string,227 token_prefix: string,228 base_uri: string,229 ) -> Result<address> {230 let (caller, name, description, token_prefix, base_uri_value) =231 convert_data::<T>(caller, name, description, token_prefix, base_uri)?;232 let data = make_data::<T>(233 name,234 CollectionMode::NFT,235 description,236 token_prefix,237 base_uri_value,238 true,239 )?;240 let collection_id = T::CollectionDispatch::create(caller, data)241 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;242243 let address = pallet_common::eth::collection_id_to_address(collection_id);244 Ok(address)245 }246247 #[weight(<SelfWeightOf<T>>::create_collection())]248 fn create_refungible_collection(249 &mut self,250 caller: caller,251 name: string,252 description: string,253 token_prefix: string,254 ) -> Result<address> {255 create_refungible_collection_internal::<T>(256 caller,257 name,258 description,259 token_prefix,260 Default::default(),261 false,262 )263 }264265 #[weight(<SelfWeightOf<T>>::create_collection())]266 #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]267 fn create_refungible_collection_with_properties(268 &mut self,269 caller: caller,270 name: string,271 description: string,272 token_prefix: string,273 base_uri: string,274 ) -> Result<address> {275 create_refungible_collection_internal::<T>(276 caller,277 name,278 description,279 token_prefix,280 base_uri,281 true,282 )283 }284285 /// Check if a collection exists286 /// @param collectionAddress Address of the collection in question287 /// @return bool Does the collection exist?288 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {289 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {290 let collection_id = id;291 return Ok(<CollectionById<T>>::contains_key(collection_id));292 }293294 Ok(false)295 }296}297298/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]299pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);300impl<T: Config + pallet_nonfungible::Config + pallet_refungible::Config> OnMethodCall<T>301 for CollectionHelpersOnMethodCall<T>302{303 fn is_reserved(contract: &sp_core::H160) -> bool {304 contract == &T::ContractAddress::get()305 }306307 fn is_used(contract: &sp_core::H160) -> bool {308 contract == &T::ContractAddress::get()309 }310311 fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {312 if handle.code_address() != T::ContractAddress::get() {313 return None;314 }315316 let helpers =317 EvmCollectionHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));318 pallet_evm_coder_substrate::call(handle, helpers)319 }320321 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {322 (contract == &T::ContractAddress::get())323 .then(|| include_bytes!("./stubs/CollectionHelpers.raw").to_vec())324 }325}326327generate_stubgen!(collection_helper_impl, CollectionHelpersCall<()>, true);328generate_stubgen!(collection_helper_iface, CollectionHelpersCall<()>, false);329330fn error_field_too_long(feild: &str, bound: usize) -> Error {331 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))332}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617//! Implementation of CollectionHelpers contract.1819use core::marker::PhantomData;20use ethereum as _;21use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};22use frame_support::traits::Get;23use pallet_common::{24 CollectionById, CollectionHandle,25 dispatch::CollectionDispatch,26 erc::{27 CollectionHelpersEvents,28 static_property::{key, value as property_value},29 },30 Pallet as PalletCommon,31};32use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};33use pallet_evm::{account::CrossAccountId, OnMethodCall, PrecompileHandle, PrecompileResult};34use pallet_evm_coder_substrate::dispatch_to_evm;35use up_data_structs::{36 CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,37 CollectionMode, PropertyKeyPermission, PropertyPermission, PropertyScope, PropertyValue,38};3940use crate::{Config, SelfWeightOf, weights::WeightInfo};4142use sp_std::{vec, vec::Vec};43use alloc::format;4445/// See [`CollectionHelpersCall`]46pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);47impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {48 fn recorder(&self) -> &SubstrateRecorder<T> {49 &self.050 }5152 fn into_recorder(self) -> SubstrateRecorder<T> {53 self.054 }55}5657fn convert_data<T: Config>(58 caller: caller,59 name: string,60 description: string,61 token_prefix: string,62 base_uri: string,63) -> Result<(64 T::CrossAccountId,65 CollectionName,66 CollectionDescription,67 CollectionTokenPrefix,68 PropertyValue,69)> {70 let caller = T::CrossAccountId::from_eth(caller);71 let name = name72 .encode_utf16()73 .collect::<Vec<u16>>()74 .try_into()75 .map_err(|_| error_field_too_long(stringify!(name), CollectionName::bound()))?;76 let description = description77 .encode_utf16()78 .collect::<Vec<u16>>()79 .try_into()80 .map_err(|_| {81 error_field_too_long(stringify!(description), CollectionDescription::bound())82 })?;83 let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {84 error_field_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())85 })?;86 let base_uri_value = base_uri87 .into_bytes()88 .try_into()89 .map_err(|_| error_field_too_long(stringify!(token_prefix), PropertyValue::bound()))?;90 Ok((caller, name, description, token_prefix, base_uri_value))91}9293fn make_data<T: Config>(94 name: CollectionName,95 mode: CollectionMode,96 description: CollectionDescription,97 token_prefix: CollectionTokenPrefix,98 base_uri_value: PropertyValue,99 add_properties: bool,100) -> Result<CreateCollectionData<T::AccountId>> {101 let mut properties = up_data_structs::CollectionPropertiesVec::default();102 let mut token_property_permissions =103 up_data_structs::CollectionPropertiesPermissionsVec::default();104105 token_property_permissions106 .try_push(up_data_structs::PropertyKeyPermission {107 key: key::url(),108 permission: up_data_structs::PropertyPermission {109 mutable: false,110 collection_admin: true,111 token_owner: false,112 },113 })114 .map_err(|e| Error::Revert(format!("{:?}", e)))?;115116 if add_properties {117 token_property_permissions118 .try_push(up_data_structs::PropertyKeyPermission {119 key: key::suffix(),120 permission: up_data_structs::PropertyPermission {121 mutable: false,122 collection_admin: true,123 token_owner: false,124 },125 })126 .map_err(|e| Error::Revert(format!("{:?}", e)))?;127128 properties129 .try_push(up_data_structs::Property {130 key: key::schema_name(),131 value: property_value::erc721(),132 })133 .map_err(|e| Error::Revert(format!("{:?}", e)))?;134135 if !base_uri_value.is_empty() {136 properties137 .try_push(up_data_structs::Property {138 key: key::base_uri(),139 value: base_uri_value,140 })141 .map_err(|e| Error::Revert(format!("{:?}", e)))?;142 }143 }144145 let data = CreateCollectionData {146 name,147 mode,148 description,149 token_prefix,150 token_property_permissions,151 properties,152 ..Default::default()153 };154 Ok(data)155}156157fn create_refungible_collection_internal<158 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,159>(160 caller: caller,161 name: string,162 description: string,163 token_prefix: string,164 base_uri: string,165 add_properties: bool,166) -> Result<address> {167 let (caller, name, description, token_prefix, base_uri_value) =168 convert_data::<T>(caller, name, description, token_prefix, base_uri)?;169 let data = make_data::<T>(170 name,171 CollectionMode::ReFungible,172 description,173 token_prefix,174 base_uri_value,175 add_properties,176 )?;177178 let collection_id = T::CollectionDispatch::create(caller.clone(), data)179 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;180 let address = pallet_common::eth::collection_id_to_address(collection_id);181 Ok(address)182}183184/// @title Contract, which allows users to operate with collections185#[solidity_interface(name = CollectionHelpers, events(CollectionHelpersEvents))]186impl<T> EvmCollectionHelpers<T>187where188 T: Config + pallet_nonfungible::Config + pallet_refungible::Config,189{190 /// Create an NFT collection191 /// @param name Name of the collection192 /// @param description Informative description of the collection193 /// @param tokenPrefix Token prefix to represent the collection tokens in UI and user applications194 /// @return address Address of the newly created collection195 #[weight(<SelfWeightOf<T>>::create_collection())]196 fn create_nonfungible_collection(197 &mut self,198 caller: caller,199 name: string,200 description: string,201 token_prefix: string,202 ) -> Result<address> {203 let (caller, name, description, token_prefix, _base_uri_value) =204 convert_data::<T>(caller, name, description, token_prefix, "".into())?;205 let data = make_data::<T>(206 name,207 CollectionMode::NFT,208 description,209 token_prefix,210 Default::default(),211 false,212 )?;213 let collection_id = T::CollectionDispatch::create(caller, data)214 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;215216 let address = pallet_common::eth::collection_id_to_address(collection_id);217 Ok(address)218 }219220 #[weight(<SelfWeightOf<T>>::create_collection())]221 #[solidity(rename_selector = "createERC721MetadataCompatibleCollection")]222 fn create_nonfungible_collection_with_properties(223 &mut self,224 caller: caller,225 name: string,226 description: string,227 token_prefix: string,228 base_uri: string,229 ) -> Result<address> {230 let (caller, name, description, token_prefix, base_uri_value) =231 convert_data::<T>(caller, name, description, token_prefix, base_uri)?;232 let data = make_data::<T>(233 name,234 CollectionMode::NFT,235 description,236 token_prefix,237 base_uri_value,238 true,239 )?;240 let collection_id = T::CollectionDispatch::create(caller, data)241 .map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;242243 let address = pallet_common::eth::collection_id_to_address(collection_id);244 Ok(address)245 }246247 #[weight(<SelfWeightOf<T>>::create_collection())]248 #[solidity(rename_selector = "createRFTCollection")]249 fn create_refungible_collection(250 &mut self,251 caller: caller,252 name: string,253 description: string,254 token_prefix: string,255 ) -> Result<address> {256 create_refungible_collection_internal::<T>(257 caller,258 name,259 description,260 token_prefix,261 Default::default(),262 false,263 )264 }265266 #[weight(<SelfWeightOf<T>>::create_collection())]267 #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]268 fn create_refungible_collection_with_properties(269 &mut self,270 caller: caller,271 name: string,272 description: string,273 token_prefix: string,274 base_uri: string,275 ) -> Result<address> {276 create_refungible_collection_internal::<T>(277 caller,278 name,279 description,280 token_prefix,281 base_uri,282 true,283 )284 }285286 /// Check if a collection exists287 /// @param collectionAddress Address of the collection in question288 /// @return bool Does the collection exist?289 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {290 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {291 let collection_id = id;292 return Ok(<CollectionById<T>>::contains_key(collection_id));293 }294295 Ok(false)296 }297}298299/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]300pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);301impl<T: Config + pallet_nonfungible::Config + pallet_refungible::Config> OnMethodCall<T>302 for CollectionHelpersOnMethodCall<T>303{304 fn is_reserved(contract: &sp_core::H160) -> bool {305 contract == &T::ContractAddress::get()306 }307308 fn is_used(contract: &sp_core::H160) -> bool {309 contract == &T::ContractAddress::get()310 }311312 fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {313 if handle.code_address() != T::ContractAddress::get() {314 return None;315 }316317 let helpers =318 EvmCollectionHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));319 pallet_evm_coder_substrate::call(handle, helpers)320 }321322 fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {323 (contract == &T::ContractAddress::get())324 .then(|| include_bytes!("./stubs/CollectionHelpers.raw").to_vec())325 }326}327328generate_stubgen!(collection_helper_impl, CollectionHelpersCall<()>, true);329generate_stubgen!(collection_helper_iface, CollectionHelpersCall<()>, false);330331fn error_field_too_long(feild: &str, bound: usize) -> Error {332 Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))333}pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth--- a/pallets/unique/src/eth/stubs/CollectionHelpers.sol
+++ b/pallets/unique/src/eth/stubs/CollectionHelpers.sol
@@ -30,7 +30,7 @@
}
/// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x675f3074
+/// @dev the ERC-165 identifier for this interface is 0x88ee8ef1
contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
/// Create an NFT collection
/// @param name Name of the collection
@@ -69,9 +69,9 @@
return 0x0000000000000000000000000000000000000000;
}
- /// @dev EVM selector for this function is: 0x44a68ad5,
- /// or in textual repr: createRefungibleCollection(string,string,string)
- function createRefungibleCollection(
+ /// @dev EVM selector for this function is: 0xab173450,
+ /// or in textual repr: createRFTCollection(string,string,string)
+ function createRFTCollection(
string memory name,
string memory description,
string memory tokenPrefix
tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth--- a/tests/src/eth/api/CollectionHelpers.sol
+++ b/tests/src/eth/api/CollectionHelpers.sol
@@ -21,7 +21,7 @@
}
/// @title Contract, which allows users to operate with collections
-/// @dev the ERC-165 identifier for this interface is 0x675f3074
+/// @dev the ERC-165 identifier for this interface is 0x88ee8ef1
interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {
/// Create an NFT collection
/// @param name Name of the collection
@@ -45,9 +45,9 @@
string memory baseUri
) external returns (address);
- /// @dev EVM selector for this function is: 0x44a68ad5,
- /// or in textual repr: createRefungibleCollection(string,string,string)
- function createRefungibleCollection(
+ /// @dev EVM selector for this function is: 0xab173450,
+ /// or in textual repr: createRFTCollection(string,string,string)
+ function createRFTCollection(
string memory name,
string memory description,
string memory tokenPrefix
tests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth--- a/tests/src/eth/collectionHelpersAbi.json
+++ b/tests/src/eth/collectionHelpersAbi.json
@@ -59,7 +59,7 @@
{ "internalType": "string", "name": "description", "type": "string" },
{ "internalType": "string", "name": "tokenPrefix", "type": "string" }
],
- "name": "createRefungibleCollection",
+ "name": "createRFTCollection",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "nonpayable",
"type": "function"
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -41,7 +41,7 @@
const collectionCountBefore = await getCreatedCollectionCount(api);
const result = await collectionHelper.methods
- .createRefungibleCollection(collectionName, description, tokenPrefix)
+ .createRFTCollection(collectionName, description, tokenPrefix)
.send();
const collectionCountAfter = await getCreatedCollectionCount(api);
@@ -65,7 +65,7 @@
.call()).to.be.false;
await collectionHelpers.methods
- .createRefungibleCollection('A', 'A', 'A')
+ .createRFTCollection('A', 'A', 'A')
.send();
expect(await collectionHelpers.methods
@@ -76,7 +76,7 @@
itWeb3('Set sponsorship', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- let result = await collectionHelpers.methods.createRefungibleCollection('Sponsor collection', '1', '1').send();
+ let result = await collectionHelpers.methods.createRFTCollection('Sponsor collection', '1', '1').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
@@ -96,7 +96,7 @@
itWeb3('Set limits', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- const result = await collectionHelpers.methods.createRefungibleCollection('Const collection', '5', '5').send();
+ const result = await collectionHelpers.methods.createRFTCollection('Const collection', '5', '5').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const limits = {
accountTokenOwnershipLimit: 1000,
@@ -141,7 +141,7 @@
.isCollectionExist(collectionAddressForNonexistentCollection).call())
.to.be.false;
- const result = await collectionHelpers.methods.createRefungibleCollection('Collection address exist', '7', '7').send();
+ const result = await collectionHelpers.methods.createRFTCollection('Collection address exist', '7', '7').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
expect(await collectionHelpers.methods
.isCollectionExist(collectionIdAddress).call())
@@ -164,7 +164,7 @@
const tokenPrefix = 'A';
await expect(helper.methods
- .createRefungibleCollection(collectionName, description, tokenPrefix)
+ .createRFTCollection(collectionName, description, tokenPrefix)
.call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGHT);
}
@@ -174,7 +174,7 @@
const description = 'A'.repeat(MAX_DESCRIPTION_LENGHT + 1);
const tokenPrefix = 'A';
await expect(helper.methods
- .createRefungibleCollection(collectionName, description, tokenPrefix)
+ .createRFTCollection(collectionName, description, tokenPrefix)
.call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGHT);
}
{
@@ -183,7 +183,7 @@
const description = 'A';
const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGHT + 1);
await expect(helper.methods
- .createRefungibleCollection(collectionName, description, tokenPrefix)
+ .createRFTCollection(collectionName, description, tokenPrefix)
.call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGHT);
}
});
@@ -196,7 +196,7 @@
const tokenPrefix = 'A';
await expect(helper.methods
- .createRefungibleCollection(collectionName, description, tokenPrefix)
+ .createRFTCollection(collectionName, description, tokenPrefix)
.call()).to.be.rejectedWith('NotSufficientFounds');
});
@@ -204,7 +204,7 @@
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const notOwner = createEthAccount(web3);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- const result = await collectionHelpers.methods.createRefungibleCollection('A', 'A', 'A').send();
+ const result = await collectionHelpers.methods.createRFTCollection('A', 'A', 'A').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contractEvmFromNotOwner = evmCollection(web3, notOwner, collectionIdAddress, {type: 'ReFungible'});
const EXPECTED_ERROR = 'NoPermission';
@@ -229,7 +229,7 @@
itWeb3('(!negative test!) Set limits', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- const result = await collectionHelpers.methods.createRefungibleCollection('Schema collection', 'A', 'A').send();
+ const result = await collectionHelpers.methods.createRFTCollection('Schema collection', 'A', 'A').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
await expect(collectionEvm.methods
tests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -25,7 +25,9 @@
/// @dev Method modifier to only allow contract owner to call it.
modifier onlyOwner() {
address contracthelpersAddress = 0x842899ECF380553E8a4de75bF534cdf6fBF64049;
- ContractHelpers contractHelpers = ContractHelpers(contracthelpersAddress);
+ ContractHelpers contractHelpers = ContractHelpers(
+ contracthelpersAddress
+ );
address contractOwner = contractHelpers.contractOwner(address(this));
require(msg.sender == contractOwner, "Only owner can");
_;
@@ -38,10 +40,19 @@
event AllowListSet(address _collection, bool _status);
/// @dev This emits when NFT token is fractionalized by contract.
- event Fractionalized(address _collection, uint256 _tokenId, address _rftToken, uint128 _amount);
+ event Fractionalized(
+ address _collection,
+ uint256 _tokenId,
+ address _rftToken,
+ uint128 _amount
+ );
/// @dev This emits when NFT token is defractionalized by contract.
- event Defractionalized(address _rftToken, address _nftCollection, uint256 _nftTokenId);
+ event Defractionalized(
+ address _rftToken,
+ address _nftCollection,
+ uint256 _nftTokenId
+ );
/// Set RFT collection that contract will work with. RFT tokens for fractionalized NFT tokens
/// would be created in this collection.
@@ -52,13 +63,11 @@
/// Can only be called by contract owner.
/// @param _collection address of RFT collection.
function setRFTCollection(address _collection) public onlyOwner {
- require(
- rftCollection == address(0),
- "RFT collection is already set"
- );
+ require(rftCollection == address(0), "RFT collection is already set");
UniqueRefungible refungibleContract = UniqueRefungible(_collection);
- string memory collectionType = refungibleContract.uniqueCollectionType();
-
+ string memory collectionType = refungibleContract
+ .uniqueCollectionType();
+
require(
keccak256(bytes(collectionType)) == refungibleCollectionType,
"Wrong collection type. Collection is not refungible."
@@ -78,13 +87,15 @@
/// @param _name name for created RFT collection.
/// @param _description description for created RFT collection.
/// @param _tokenPrefix token prefix for created RFT collection.
- function createAndSetRFTCollection(string calldata _name, string calldata _description, string calldata _tokenPrefix) public onlyOwner {
- require(
- rftCollection == address(0),
- "RFT collection is already set"
- );
+ function createAndSetRFTCollection(
+ string calldata _name,
+ string calldata _description,
+ string calldata _tokenPrefix
+ ) public onlyOwner {
+ require(rftCollection == address(0), "RFT collection is already set");
address collectionHelpers = 0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F;
- rftCollection = CollectionHelpers(collectionHelpers).createRefungibleCollection(_name, _description, _tokenPrefix);
+ rftCollection = CollectionHelpers(collectionHelpers)
+ .createRFTCollection(_name, _description, _tokenPrefix);
emit RFTCollectionSet(rftCollection);
}
@@ -92,7 +103,10 @@
/// @dev Can only be called by contract owner.
/// @param collection NFT token address.
/// @param status `true` to allow and `false` to disallow NFT token.
- function setNftCollectionIsAllowed(address collection, bool status) public onlyOwner {
+ function setNftCollectionIsAllowed(address collection, bool status)
+ public
+ onlyOwner
+ {
nftCollectionAllowList[collection] = status;
emit AllowListSet(collection, status);
}
@@ -107,12 +121,15 @@
/// @param _collection NFT collection address
/// @param _token id of NFT token to be fractionalized
/// @param _pieces number of pieces new RFT token would have
- function nft2rft(address _collection, uint256 _token, uint128 _pieces) public {
- require(
- rftCollection != address(0),
- "RFT collection is not set"
+ function nft2rft(
+ address _collection,
+ uint256 _token,
+ uint128 _pieces
+ ) public {
+ require(rftCollection != address(0), "RFT collection is not set");
+ UniqueRefungible rftCollectionContract = UniqueRefungible(
+ rftCollection
);
- UniqueRefungible rftCollectionContract = UniqueRefungible(rftCollection);
require(
nftCollectionAllowList[_collection] == true,
"Fractionalization of this collection is not allowed by admin"
@@ -121,25 +138,25 @@
UniqueNFT(_collection).ownerOf(_token) == msg.sender,
"Only token owner could fractionalize it"
);
- UniqueNFT(_collection).transferFrom(
- msg.sender,
- address(this),
- _token
- );
+ UniqueNFT(_collection).transferFrom(msg.sender, address(this), _token);
uint256 rftTokenId;
address rftTokenAddress;
UniqueRefungibleToken rftTokenContract;
if (nft2rftMapping[_collection][_token] == 0) {
rftTokenId = rftCollectionContract.nextTokenId();
rftCollectionContract.mint(address(this), rftTokenId);
- rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
+ rftTokenAddress = rftCollectionContract.tokenContractAddress(
+ rftTokenId
+ );
nft2rftMapping[_collection][_token] = rftTokenId;
rft2nftMapping[rftTokenAddress] = Token(_collection, _token);
rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
} else {
rftTokenId = nft2rftMapping[_collection][_token];
- rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
+ rftTokenAddress = rftCollectionContract.tokenContractAddress(
+ rftTokenId
+ );
rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
}
rftTokenContract.repartition(_pieces);
@@ -157,24 +174,25 @@
/// @param _collection RFT collection address
/// @param _token id of RFT token
function rft2nft(address _collection, uint256 _token) public {
- require(
- rftCollection != address(0),
- "RFT collection is not set"
+ require(rftCollection != address(0), "RFT collection is not set");
+ require(rftCollection == _collection, "Wrong RFT collection");
+ UniqueRefungible rftCollectionContract = UniqueRefungible(
+ rftCollection
);
- require(
- rftCollection == _collection,
- "Wrong RFT collection"
+ address rftTokenAddress = rftCollectionContract.tokenContractAddress(
+ _token
);
- UniqueRefungible rftCollectionContract = UniqueRefungible(rftCollection);
- address rftTokenAddress = rftCollectionContract.tokenContractAddress(_token);
Token memory nftToken = rft2nftMapping[rftTokenAddress];
require(
nftToken._collection != address(0),
"No corresponding NFT token found"
);
- UniqueRefungibleToken rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
+ UniqueRefungibleToken rftTokenContract = UniqueRefungibleToken(
+ rftTokenAddress
+ );
require(
- rftTokenContract.balanceOf(msg.sender) == rftTokenContract.totalSupply(),
+ rftTokenContract.balanceOf(msg.sender) ==
+ rftTokenContract.totalSupply(),
"Not all pieces are owned by the caller"
);
rftCollectionContract.transferFrom(msg.sender, address(this), _token);
@@ -183,6 +201,10 @@
msg.sender,
nftToken._tokenId
);
- emit Defractionalized(rftTokenAddress, nftToken._collection, nftToken._tokenId);
+ emit Defractionalized(
+ rftTokenAddress,
+ nftToken._collection,
+ nftToken._tokenId
+ );
}
-}
\ No newline at end of file
+}
tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -21,7 +21,7 @@
import {readFile} from 'fs/promises';
import {executeTransaction, submitTransactionAsync} from '../../substrate/substrate-api';
import {getCreateCollectionResult, getCreateItemResult, UNIQUE, requirePallets, Pallets} from '../../util/helpers';
-import {collectionIdToAddress, CompiledContract, createEthAccountWithBalance, createNonfungibleCollection, createRefungibleCollection, GAS_ARGS, itWeb3, tokenIdFromAddress, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from '../util/helpers';
+import {collectionIdToAddress, CompiledContract, createEthAccountWithBalance, createNonfungibleCollection, createRFTCollection, GAS_ARGS, itWeb3, tokenIdFromAddress, uniqueNFT, uniqueRefungible, uniqueRefungibleToken} from '../util/helpers';
import {Contract} from 'web3-eth-contract';
import * as solc from 'solc';
@@ -123,7 +123,7 @@
itWeb3('Set RFT collection', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const fractionalizer = await deployFractionalizer(web3, owner);
- const {collectionIdAddress} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress} = await createRFTCollection(api, web3, owner);
const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
await refungibleContract.methods.addCollectionAdmin(fractionalizer.options.address).send();
const result = await fractionalizer.methods.setRFTCollection(collectionIdAddress).send();
@@ -256,7 +256,7 @@
itWeb3('call setRFTCollection twice', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
- const {collectionIdAddress} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress} = await createRFTCollection(api, web3, owner);
const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
const fractionalizer = await deployFractionalizer(web3, owner);
@@ -282,7 +282,7 @@
itWeb3('call setRFTCollection while not collection admin', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const fractionalizer = await deployFractionalizer(web3, owner);
- const {collectionIdAddress} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress} = await createRFTCollection(api, web3, owner);
await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())
.to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);
@@ -368,7 +368,7 @@
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const fractionalizer = await deployFractionalizer(web3, owner);
- const {collectionIdAddress: rftCollectionAddress} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);
const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);
const rftTokenId = await refungibleContract.methods.nextTokenId().call();
await refungibleContract.methods.mint(owner, rftTokenId).send();
@@ -381,7 +381,7 @@
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const {fractionalizer} = await initFractionalizer(api, web3, privateKeyWrapper, owner);
- const {collectionIdAddress: rftCollectionAddress} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);
const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);
const rftTokenId = await refungibleContract.methods.nextTokenId().call();
await refungibleContract.methods.mint(owner, rftTokenId).send();
@@ -392,7 +392,7 @@
itWeb3('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
- const {collectionIdAddress: rftCollectionAddress} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress: rftCollectionAddress} = await createRFTCollection(api, web3, owner);
const fractionalizer = await deployFractionalizer(web3, owner);
const refungibleContract = uniqueRefungible(web3, rftCollectionAddress, owner);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -26,7 +26,7 @@
itWeb3('totalSupply', async ({api, web3, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
const nextTokenId = await contract.methods.nextTokenId().call();
@@ -38,7 +38,7 @@
itWeb3('balanceOf', async ({api, web3, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -63,7 +63,7 @@
itWeb3('ownerOf', async ({api, web3, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -79,7 +79,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const receiver = createEthAccount(web3);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -103,7 +103,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const receiver = createEthAccount(web3);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -130,7 +130,7 @@
itWeb3('Can perform mint()', async ({web3, api, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, owner);
- let result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ let result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const receiver = createEthAccount(web3);
const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
@@ -163,7 +163,7 @@
itWeb3('Can perform mintBulk()', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -221,7 +221,7 @@
itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -247,7 +247,7 @@
itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -304,7 +304,7 @@
itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -344,7 +344,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const receiver = createEthAccount(web3);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -376,7 +376,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const receiver = createEthAccount(web3);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -413,7 +413,7 @@
itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -430,7 +430,7 @@
itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -15,7 +15,7 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE, requirePallets, Pallets} from '../util/helpers';
-import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createRefungibleCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, createRFTCollection, evmCollection, evmCollectionHelpers, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth, uniqueRefungible, uniqueRefungibleToken} from './util/helpers';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -458,7 +458,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const receiver = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const helper = evmCollectionHelpers(web3, caller);
- const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const result = await helper.methods.createRFTCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
@@ -658,7 +658,7 @@
itWeb3('Default parent token address and id', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
- const {collectionIdAddress, collectionId} = await createRefungibleCollection(api, web3, owner);
+ const {collectionIdAddress, collectionId} = await createRFTCollection(api, web3, owner);
const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
const refungibleTokenId = await refungibleContract.methods.nextTokenId().call();
await refungibleContract.methods.mint(owner, refungibleTokenId).send();
tests/src/eth/util/helpers.tsdiffbeforeafterboth--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -141,10 +141,10 @@
expect(result.success).to.be.true;
}
-export async function createRefungibleCollection(api: ApiPromise, web3: Web3, owner: string) {
+export async function createRFTCollection(api: ApiPromise, web3: Web3, owner: string) {
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
- .createRefungibleCollection('A', 'B', 'C')
+ .createRFTCollection('A', 'B', 'C')
.send();
return await getCollectionAddressFromResult(api, result);
}