difftreelog
Merge pull request #542 from UniqueNetwork/fix/RFT_and_fractionalizer
in: master
14 files changed
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -281,15 +281,6 @@
let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;
}: {<Pallet<T>>::repartition(&collection, &owner, item, 200)?}
- set_parent_nft_unchecked {
- bench_init!{
- owner: sub; collection: collection(owner);
- sender: cross_from_sub(owner); owner: cross_sub;
- };
- let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;
-
- }: {<Pallet<T>>::set_parent_nft_unchecked(&collection, item, owner, T::CrossAccountId::from_eth(H160::default()))?}
-
token_owner {
bench_init!{
owner: sub; collection: collection(owner);
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -29,22 +29,21 @@
convert::TryInto,
ops::Deref,
};
-use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};
+use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*, weight};
use pallet_common::{
CommonWeightInfo,
- erc::{CommonEvmHandler, PrecompileResult, static_property::key},
- eth::map_eth_to_id,
+ erc::{CommonEvmHandler, PrecompileResult},
+ eth::collection_id_to_address,
};
use pallet_evm::{account::CrossAccountId, PrecompileHandle};
use pallet_evm_coder_substrate::{call, dispatch_to_evm, WithRecorder};
use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
-use sp_core::H160;
use sp_std::vec::Vec;
-use up_data_structs::{mapping::TokenAddressMapping, PropertyScope, TokenId};
+use up_data_structs::TokenId;
use crate::{
Allowance, Balance, common::CommonWeights, Config, Pallet, RefungibleHandle, SelfWeightOf,
- TokenProperties, TotalSupply, weights::WeightInfo,
+ TotalSupply, weights::WeightInfo,
};
pub struct RefungibleTokenHandle<T: Config>(pub RefungibleHandle<T>, pub TokenId);
@@ -52,63 +51,14 @@
#[solidity_interface(name = ERC1633)]
impl<T: Config> RefungibleTokenHandle<T> {
fn parent_token(&self) -> Result<address> {
- self.consume_store_reads(2)?;
- let props = <TokenProperties<T>>::get((self.id, self.1));
- let key = key::parent_nft();
-
- let key_scoped = PropertyScope::Eth
- .apply(key)
- .expect("property key shouldn't exceed length limit");
- if let Some(value) = props.get(&key_scoped) {
- Ok(H160::from_slice(value.as_slice()))
- } else {
- Ok(*T::CrossTokenAddressMapping::token_to_address(self.id, self.1).as_eth())
- }
+ Ok(collection_id_to_address(self.id))
}
fn parent_token_id(&self) -> Result<uint256> {
- self.consume_store_reads(2)?;
- let props = <TokenProperties<T>>::get((self.id, self.1));
- let key = key::parent_nft();
-
- let key_scoped = PropertyScope::Eth
- .apply(key)
- .expect("property key shouldn't exceed length limit");
- if let Some(value) = props.get(&key_scoped) {
- let nft_token_address = H160::from_slice(value.as_slice());
- let nft_token_account = T::CrossAccountId::from_eth(nft_token_address);
- let (_, token_id) = T::CrossTokenAddressMapping::address_to_token(&nft_token_account)
- .ok_or("parent NFT should contain NFT token address")?;
-
- Ok(token_id.into())
- } else {
- Ok(self.1.into())
- }
+ Ok(self.1.into())
}
}
-#[solidity_interface(name = ERC1633UniqueExtensions)]
-impl<T: Config> RefungibleTokenHandle<T> {
- #[solidity(rename_selector = "setParentNFT")]
- #[weight(<CommonWeights<T>>::token_owner() + <SelfWeightOf<T>>::set_parent_nft_unchecked())]
- fn set_parent_nft(
- &mut self,
- caller: caller,
- collection: address,
- nft_id: uint256,
- ) -> Result<bool> {
- self.consume_store_reads(1)?;
- let caller = T::CrossAccountId::from_eth(caller);
- let nft_collection = map_eth_to_id(&collection).ok_or("collection not found")?;
- let nft_token = nft_id.try_into()?;
-
- <Pallet<T>>::set_parent_nft(&self.0, self.1, caller, nft_collection, nft_token)
- .map_err(dispatch_to_evm::<T>)?;
-
- Ok(true)
- }
-}
-
#[derive(ToLog)]
pub enum ERC20Events {
/// @dev This event is emitted when the amount of tokens (value) is sent
@@ -307,7 +257,7 @@
#[solidity_interface(
name = UniqueRefungibleToken,
- is(ERC20, ERC20UniqueExtensions, ERC1633, ERC1633UniqueExtensions)
+ is(ERC20, ERC20UniqueExtensions, ERC1633)
)]
impl<T: Config> RefungibleTokenHandle<T> where T::AccountId: From<[u8; 32]> {}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -1379,68 +1379,4 @@
Some(res)
}
}
-
- /// Sets the NFT token as a parent for the RFT token
- ///
- /// Throws if `sender` is not the owner of the NFT token.
- /// Throws if `sender` is not the owner of all of the RFT token pieces.
- pub fn set_parent_nft(
- collection: &RefungibleHandle<T>,
- rft_token_id: TokenId,
- sender: T::CrossAccountId,
- nft_collection: CollectionId,
- nft_token: TokenId,
- ) -> DispatchResult {
- let handle = <CollectionHandle<T>>::try_get(nft_collection)?;
- if handle.mode != CollectionMode::NFT {
- return Err("Only NFT token could be parent to RFT".into());
- }
- let dispatch = T::CollectionDispatch::dispatch(handle);
- let dispatch = dispatch.as_dyn();
-
- let owner = dispatch.token_owner(nft_token).ok_or("owner not found")?;
- if owner != sender {
- return Err("Only owned token could be set as parent".into());
- }
-
- let nft_token_address =
- T::CrossTokenAddressMapping::token_to_address(nft_collection, nft_token);
-
- Self::set_parent_nft_unchecked(collection, rft_token_id, sender, nft_token_address)
- }
-
- /// Sets the NFT token as a parent for the RFT token
- ///
- /// `sender` should be the owner of the NFT token.
- /// Throws if `sender` is not the owner of all of the RFT token pieces.
- pub fn set_parent_nft_unchecked(
- collection: &RefungibleHandle<T>,
- rft_token_id: TokenId,
- sender: T::CrossAccountId,
- nft_token_address: T::CrossAccountId,
- ) -> DispatchResult {
- let owner_balance = <Balance<T>>::get((collection.id, rft_token_id, &sender));
- let total_supply = <TotalSupply<T>>::get((collection.id, rft_token_id));
- if total_supply != owner_balance {
- return Err("token has multiple owners".into());
- }
-
- let parent_nft_property_key = key::parent_nft();
-
- let parent_nft_property_value =
- property_value_from_bytes(&nft_token_address.as_eth().to_fixed_bytes())
- .expect("address should fit in value length limit");
-
- <Pallet<T>>::set_scoped_token_property(
- collection.id,
- rft_token_id,
- PropertyScope::Eth,
- Property {
- key: parent_nft_property_key,
- value: parent_nft_property_value,
- },
- )?;
-
- Ok(())
- }
}
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungibleToken.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8 uint8 dummy;9 string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13 function supportsInterface(bytes4 interfaceID)14 external15 view16 returns (bool)17 {18 require(false, stub_error);19 interfaceID;20 return true;21 }22}2324/// @dev the ERC-165 identifier for this interface is 0x042f110625contract ERC1633UniqueExtensions is Dummy, ERC165 {26 /// @dev EVM selector for this function is: 0x042f1106,27 /// or in textual repr: setParentNFT(address,uint256)28 function setParentNFT(address collection, uint256 nftId)29 public30 returns (bool)31 {32 require(false, stub_error);33 collection;34 nftId;35 dummy = 0;36 return false;37 }38}3940/// @dev the ERC-165 identifier for this interface is 0x5755c3f241contract ERC1633 is Dummy, ERC165 {42 /// @dev EVM selector for this function is: 0x80a54001,43 /// or in textual repr: parentToken()44 function parentToken() public view returns (address) {45 require(false, stub_error);46 dummy;47 return 0x0000000000000000000000000000000000000000;48 }4950 /// @dev EVM selector for this function is: 0xd7f083f3,51 /// or in textual repr: parentTokenId()52 function parentTokenId() public view returns (uint256) {53 require(false, stub_error);54 dummy;55 return 0;56 }57}5859/// @dev the ERC-165 identifier for this interface is 0xab8deb3760contract ERC20UniqueExtensions is Dummy, ERC165 {61 /// @dev Function that burns an amount of the token of a given account,62 /// deducting from the sender's allowance for said account.63 /// @param from The account whose tokens will be burnt.64 /// @param amount The amount that will be burnt.65 /// @dev EVM selector for this function is: 0x79cc6790,66 /// or in textual repr: burnFrom(address,uint256)67 function burnFrom(address from, uint256 amount) public returns (bool) {68 require(false, stub_error);69 from;70 amount;71 dummy = 0;72 return false;73 }7475 /// @dev Function that changes total amount of the tokens.76 /// Throws if `msg.sender` doesn't owns all of the tokens.77 /// @param amount New total amount of the tokens.78 /// @dev EVM selector for this function is: 0xd2418ca7,79 /// or in textual repr: repartition(uint256)80 function repartition(uint256 amount) public returns (bool) {81 require(false, stub_error);82 amount;83 dummy = 0;84 return false;85 }86}8788/// @dev inlined interface89contract ERC20Events {90 event Transfer(address indexed from, address indexed to, uint256 value);91 event Approval(92 address indexed owner,93 address indexed spender,94 uint256 value95 );96}9798/// @title Standard ERC20 token99///100/// @dev Implementation of the basic standard token.101/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md102/// @dev the ERC-165 identifier for this interface is 0x942e8b22103contract ERC20 is Dummy, ERC165, ERC20Events {104 /// @return the name of the token.105 /// @dev EVM selector for this function is: 0x06fdde03,106 /// or in textual repr: name()107 function name() public view returns (string memory) {108 require(false, stub_error);109 dummy;110 return "";111 }112113 /// @return the symbol of the token.114 /// @dev EVM selector for this function is: 0x95d89b41,115 /// or in textual repr: symbol()116 function symbol() public view returns (string memory) {117 require(false, stub_error);118 dummy;119 return "";120 }121122 /// @dev Total number of tokens in existence123 /// @dev EVM selector for this function is: 0x18160ddd,124 /// or in textual repr: totalSupply()125 function totalSupply() public view returns (uint256) {126 require(false, stub_error);127 dummy;128 return 0;129 }130131 /// @dev Not supported132 /// @dev EVM selector for this function is: 0x313ce567,133 /// or in textual repr: decimals()134 function decimals() public view returns (uint8) {135 require(false, stub_error);136 dummy;137 return 0;138 }139140 /// @dev Gets the balance of the specified address.141 /// @param owner The address to query the balance of.142 /// @return An uint256 representing the amount owned by the passed address.143 /// @dev EVM selector for this function is: 0x70a08231,144 /// or in textual repr: balanceOf(address)145 function balanceOf(address owner) public view returns (uint256) {146 require(false, stub_error);147 owner;148 dummy;149 return 0;150 }151152 /// @dev Transfer token for a specified address153 /// @param to The address to transfer to.154 /// @param amount The amount to be transferred.155 /// @dev EVM selector for this function is: 0xa9059cbb,156 /// or in textual repr: transfer(address,uint256)157 function transfer(address to, uint256 amount) public returns (bool) {158 require(false, stub_error);159 to;160 amount;161 dummy = 0;162 return false;163 }164165 /// @dev Transfer tokens from one address to another166 /// @param from address The address which you want to send tokens from167 /// @param to address The address which you want to transfer to168 /// @param amount uint256 the amount of tokens to be transferred169 /// @dev EVM selector for this function is: 0x23b872dd,170 /// or in textual repr: transferFrom(address,address,uint256)171 function transferFrom(172 address from,173 address to,174 uint256 amount175 ) public returns (bool) {176 require(false, stub_error);177 from;178 to;179 amount;180 dummy = 0;181 return false;182 }183184 /// @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.185 /// Beware that changing an allowance with this method brings the risk that someone may use both the old186 /// and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this187 /// race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:188 /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729189 /// @param spender The address which will spend the funds.190 /// @param amount The amount of tokens to be spent.191 /// @dev EVM selector for this function is: 0x095ea7b3,192 /// or in textual repr: approve(address,uint256)193 function approve(address spender, uint256 amount) public returns (bool) {194 require(false, stub_error);195 spender;196 amount;197 dummy = 0;198 return false;199 }200201 /// @dev Function to check the amount of tokens that an owner allowed to a spender.202 /// @param owner address The address which owns the funds.203 /// @param spender address The address which will spend the funds.204 /// @return A uint256 specifying the amount of tokens still available for the spender.205 /// @dev EVM selector for this function is: 0xdd62ed3e,206 /// or in textual repr: allowance(address,address)207 function allowance(address owner, address spender)208 public209 view210 returns (uint256)211 {212 require(false, stub_error);213 owner;214 spender;215 dummy;216 return 0;217 }218}219220contract UniqueRefungibleToken is221 Dummy,222 ERC165,223 ERC20,224 ERC20UniqueExtensions,225 ERC1633,226 ERC1633UniqueExtensions227{}1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7contract Dummy {8 uint8 dummy;9 string stub_error = "this contract is implemented in native";10}1112contract ERC165 is Dummy {13 function supportsInterface(bytes4 interfaceID)14 external15 view16 returns (bool)17 {18 require(false, stub_error);19 interfaceID;20 return true;21 }22}2324/// @dev the ERC-165 identifier for this interface is 0x5755c3f225contract ERC1633 is Dummy, ERC165 {26 /// @dev EVM selector for this function is: 0x80a54001,27 /// or in textual repr: parentToken()28 function parentToken() public view returns (address) {29 require(false, stub_error);30 dummy;31 return 0x0000000000000000000000000000000000000000;32 }3334 /// @dev EVM selector for this function is: 0xd7f083f3,35 /// or in textual repr: parentTokenId()36 function parentTokenId() public view returns (uint256) {37 require(false, stub_error);38 dummy;39 return 0;40 }41}4243/// @dev the ERC-165 identifier for this interface is 0xab8deb3744contract ERC20UniqueExtensions is Dummy, ERC165 {45 /// @dev Function that burns an amount of the token of a given account,46 /// deducting from the sender's allowance for said account.47 /// @param from The account whose tokens will be burnt.48 /// @param amount The amount that will be burnt.49 /// @dev EVM selector for this function is: 0x79cc6790,50 /// or in textual repr: burnFrom(address,uint256)51 function burnFrom(address from, uint256 amount) public returns (bool) {52 require(false, stub_error);53 from;54 amount;55 dummy = 0;56 return false;57 }5859 /// @dev Function that changes total amount of the tokens.60 /// Throws if `msg.sender` doesn't owns all of the tokens.61 /// @param amount New total amount of the tokens.62 /// @dev EVM selector for this function is: 0xd2418ca7,63 /// or in textual repr: repartition(uint256)64 function repartition(uint256 amount) public returns (bool) {65 require(false, stub_error);66 amount;67 dummy = 0;68 return false;69 }70}7172/// @dev inlined interface73contract ERC20Events {74 event Transfer(address indexed from, address indexed to, uint256 value);75 event Approval(76 address indexed owner,77 address indexed spender,78 uint256 value79 );80}8182/// @title Standard ERC20 token83///84/// @dev Implementation of the basic standard token.85/// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md86/// @dev the ERC-165 identifier for this interface is 0x942e8b2287contract ERC20 is Dummy, ERC165, ERC20Events {88 /// @return the name of the token.89 /// @dev EVM selector for this function is: 0x06fdde03,90 /// or in textual repr: name()91 function name() public view returns (string memory) {92 require(false, stub_error);93 dummy;94 return "";95 }9697 /// @return the symbol of the token.98 /// @dev EVM selector for this function is: 0x95d89b41,99 /// or in textual repr: symbol()100 function symbol() public view returns (string memory) {101 require(false, stub_error);102 dummy;103 return "";104 }105106 /// @dev Total number of tokens in existence107 /// @dev EVM selector for this function is: 0x18160ddd,108 /// or in textual repr: totalSupply()109 function totalSupply() public view returns (uint256) {110 require(false, stub_error);111 dummy;112 return 0;113 }114115 /// @dev Not supported116 /// @dev EVM selector for this function is: 0x313ce567,117 /// or in textual repr: decimals()118 function decimals() public view returns (uint8) {119 require(false, stub_error);120 dummy;121 return 0;122 }123124 /// @dev Gets the balance of the specified address.125 /// @param owner The address to query the balance of.126 /// @return An uint256 representing the amount owned by the passed address.127 /// @dev EVM selector for this function is: 0x70a08231,128 /// or in textual repr: balanceOf(address)129 function balanceOf(address owner) public view returns (uint256) {130 require(false, stub_error);131 owner;132 dummy;133 return 0;134 }135136 /// @dev Transfer token for a specified address137 /// @param to The address to transfer to.138 /// @param amount The amount to be transferred.139 /// @dev EVM selector for this function is: 0xa9059cbb,140 /// or in textual repr: transfer(address,uint256)141 function transfer(address to, uint256 amount) public returns (bool) {142 require(false, stub_error);143 to;144 amount;145 dummy = 0;146 return false;147 }148149 /// @dev Transfer tokens from one address to another150 /// @param from address The address which you want to send tokens from151 /// @param to address The address which you want to transfer to152 /// @param amount uint256 the amount of tokens to be transferred153 /// @dev EVM selector for this function is: 0x23b872dd,154 /// or in textual repr: transferFrom(address,address,uint256)155 function transferFrom(156 address from,157 address to,158 uint256 amount159 ) public returns (bool) {160 require(false, stub_error);161 from;162 to;163 amount;164 dummy = 0;165 return false;166 }167168 /// @dev Approve the passed address to spend the specified amount of tokens on behalf of `msg.sender`.169 /// Beware that changing an allowance with this method brings the risk that someone may use both the old170 /// and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this171 /// race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:172 /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729173 /// @param spender The address which will spend the funds.174 /// @param amount The amount of tokens to be spent.175 /// @dev EVM selector for this function is: 0x095ea7b3,176 /// or in textual repr: approve(address,uint256)177 function approve(address spender, uint256 amount) public returns (bool) {178 require(false, stub_error);179 spender;180 amount;181 dummy = 0;182 return false;183 }184185 /// @dev Function to check the amount of tokens that an owner allowed to a spender.186 /// @param owner address The address which owns the funds.187 /// @param spender address The address which will spend the funds.188 /// @return A uint256 specifying the amount of tokens still available for the spender.189 /// @dev EVM selector for this function is: 0xdd62ed3e,190 /// or in textual repr: allowance(address,address)191 function allowance(address owner, address spender)192 public193 view194 returns (uint256)195 {196 require(false, stub_error);197 owner;198 spender;199 dummy;200 return 0;201 }202}203204contract UniqueRefungibleToken is205 Dummy,206 ERC165,207 ERC20,208 ERC20UniqueExtensions,209 ERC1633210{}pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -53,7 +53,6 @@
fn set_token_properties(b: u32, ) -> Weight;
fn delete_token_properties(b: u32, ) -> Weight;
fn repartition_item() -> Weight;
- fn set_parent_nft_unchecked() -> Weight;
fn token_owner() -> Weight;
}
@@ -254,14 +253,6 @@
(22_356_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
- }
- // Storage: Refungible Balance (r:1 w:0)
- // Storage: Refungible TotalSupply (r:1 w:0)
- // Storage: Refungible TokenProperties (r:1 w:1)
- fn set_parent_nft_unchecked() -> Weight {
- (12_015_000 as Weight)
- .saturating_add(T::DbWeight::get().reads(3 as Weight))
- .saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Refungible Balance (r:2 w:0)
fn token_owner() -> Weight {
@@ -466,14 +457,6 @@
(22_356_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
- }
- // Storage: Refungible Balance (r:1 w:0)
- // Storage: Refungible TotalSupply (r:1 w:0)
- // Storage: Refungible TokenProperties (r:1 w:1)
- fn set_parent_nft_unchecked() -> Weight {
- (12_015_000 as Weight)
- .saturating_add(RocksDbWeight::get().reads(3 as Weight))
- .saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Refungible Balance (r:2 w:0)
fn token_owner() -> Weight {
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -154,17 +154,6 @@
Ok(data)
}
-fn parent_nft_property_permissions() -> PropertyKeyPermission {
- PropertyKeyPermission {
- key: key::parent_nft(),
- permission: PropertyPermission {
- mutable: false,
- collection_admin: false,
- token_owner: true,
- },
- }
-}
-
fn create_refungible_collection_internal<
T: Config + pallet_nonfungible::Config + pallet_refungible::Config,
>(
@@ -188,16 +177,6 @@
let collection_id = T::CollectionDispatch::create(caller.clone(), data)
.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;
-
- let handle = <CollectionHandle<T>>::try_get(collection_id).map_err(dispatch_to_evm::<T>)?;
- <PalletCommon<T>>::set_scoped_token_property_permissions(
- &handle,
- &caller,
- PropertyScope::Eth,
- vec![parent_nft_property_permissions()],
- )
- .map_err(dispatch_to_evm::<T>)?;
-
let address = pallet_common::eth::collection_id_to_address(collection_id);
Ok(address)
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -1050,7 +1050,6 @@
pub enum PropertyScope {
None,
Rmrk,
- Eth,
}
impl PropertyScope {
@@ -1059,7 +1058,6 @@
let scope_str: &[u8] = match self {
Self::None => return Ok(key),
Self::Rmrk => b"rmrk",
- Self::Eth => b"eth",
};
[scope_str, b":", key.as_slice()]
tests/src/eth/api/UniqueRefungibleToken.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungibleToken.sol
+++ b/tests/src/eth/api/UniqueRefungibleToken.sol
@@ -12,15 +12,6 @@
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
-/// @dev the ERC-165 identifier for this interface is 0x042f1106
-interface ERC1633UniqueExtensions is Dummy, ERC165 {
- /// @dev EVM selector for this function is: 0x042f1106,
- /// or in textual repr: setParentNFT(address,uint256)
- function setParentNFT(address collection, uint256 nftId)
- external
- returns (bool);
-}
-
/// @dev the ERC-165 identifier for this interface is 0x5755c3f2
interface ERC1633 is Dummy, ERC165 {
/// @dev EVM selector for this function is: 0x80a54001,
@@ -140,6 +131,5 @@
ERC165,
ERC20,
ERC20UniqueExtensions,
- ERC1633,
- ERC1633UniqueExtensions
+ ERC1633
{}
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -94,7 +94,7 @@
});
itWeb3('ERC721 support', async ({web3}) => {
- expect(await contract(web3).methods.supportsInterface('0x58800161').call()).to.be.true;
+ expect(await contract(web3).methods.supportsInterface('0x780e9d63').call()).to.be.true;
});
itWeb3('ERC721Metadata support', async ({web3}) => {
tests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -16,8 +16,8 @@
}
address rftCollection;
mapping(address => bool) nftCollectionAllowList;
- mapping(address => mapping(uint256 => uint256)) nft2rftMapping;
- mapping(address => Token) rft2nftMapping;
+ mapping(address => mapping(uint256 => uint256)) public nft2rftMapping;
+ mapping(address => Token) public rft2nftMapping;
bytes32 refungibleCollectionType = keccak256(bytes("ReFungible"));
receive() external payable onlyOwner {}
@@ -137,7 +137,6 @@
rft2nftMapping[rftTokenAddress] = Token(_collection, _token);
rftTokenContract = UniqueRefungibleToken(rftTokenAddress);
- rftTokenContract.setParentNFT(_collection, _token);
} else {
rftTokenId = nft2rftMapping[_collection][_token];
rftTokenAddress = rftCollectionContract.tokenContractAddress(rftTokenId);
tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -223,6 +223,28 @@
},
});
});
+
+ itWeb3('Test fractionalizer NFT <-> RFT mapping ', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+
+ const {fractionalizer, rftCollectionAddress} = await initFractionalizer(api, web3, privateKeyWrapper, owner);
+ const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await createRFTToken(api, web3, owner, fractionalizer, 100n);
+
+ const {collectionId, tokenId} = tokenIdFromAddress(rftTokenAddress);
+ const refungibleAddress = collectionIdToAddress(collectionId);
+ expect(rftCollectionAddress).to.be.equal(refungibleAddress);
+ const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);
+ await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send();
+
+ const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();
+ expect(rft2nft).to.be.like({
+ _collection: nftCollectionAddress,
+ _tokenId: nftTokenId,
+ });
+
+ const nft2rft = await fractionalizer.methods.nft2rftMapping(nftCollectionAddress, nftTokenId).call();
+ expect(nft2rft).to.be.eq(tokenId.toString());
+ });
});
tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -655,31 +655,6 @@
await requirePallets(this, [Pallets.ReFungible]);
});
- itWeb3('Parent NFT token address and id', async ({api, web3, privateKeyWrapper}) => {
- const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
-
- const {collectionIdAddress: nftCollectionAddress} = await createNonfungibleCollection(api, web3, owner);
- const nftContract = uniqueNFT(web3, nftCollectionAddress, owner);
- const nftTokenId = await nftContract.methods.nextTokenId().call();
- await nftContract.methods.mint(owner, nftTokenId).send();
- const nftCollectionId = collectionIdFromAddress(nftCollectionAddress);
-
- const {collectionIdAddress, collectionId} = await createRefungibleCollection(api, web3, owner);
- const refungibleContract = uniqueRefungible(web3, collectionIdAddress, owner);
- const refungibleTokenId = await refungibleContract.methods.nextTokenId().call();
- await refungibleContract.methods.mint(owner, refungibleTokenId).send();
-
- const rftTokenAddress = tokenIdToAddress(collectionId, refungibleTokenId);
- const refungibleTokenContract = uniqueRefungibleToken(web3, rftTokenAddress, owner);
- await refungibleTokenContract.methods.setParentNFT(nftCollectionAddress, nftTokenId).send();
-
- const tokenAddress = await refungibleTokenContract.methods.parentToken().call();
- const tokenId = await refungibleTokenContract.methods.parentTokenId().call();
- const nftTokenAddress = tokenIdToAddress(nftCollectionId, nftTokenId);
- expect(tokenAddress).to.be.equal(nftTokenAddress);
- expect(tokenId).to.be.equal(nftTokenId);
- });
-
itWeb3('Default parent token address and id', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
@@ -693,7 +668,7 @@
const tokenAddress = await refungibleTokenContract.methods.parentToken().call();
const tokenId = await refungibleTokenContract.methods.parentTokenId().call();
- expect(tokenAddress).to.be.equal(rftTokenAddress);
+ expect(tokenAddress).to.be.equal(collectionIdAddress);
expect(tokenId).to.be.equal(refungibleTokenId);
});
});
tests/src/eth/reFungibleTokenAbi.jsondiffbeforeafterboth--- a/tests/src/eth/reFungibleTokenAbi.json
+++ b/tests/src/eth/reFungibleTokenAbi.json
@@ -127,16 +127,6 @@
},
{
"inputs": [
- { "internalType": "address", "name": "collection", "type": "address" },
- { "internalType": "uint256", "name": "nftId", "type": "uint256" }
- ],
- "name": "setParentNFT",
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "inputs": [
{ "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }
],
"name": "supportsInterface",