difftreelog
Merge pull request #743 from UniqueNetwork/feature/mintCross
in: master
added `mintCross` function for `UniqueExtensoins` interfaces
39 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6085,7 +6085,7 @@
[[package]]
name = "pallet-fungible"
-version = "0.1.7"
+version = "0.1.9"
dependencies = [
"ethereum 0.14.0",
"evm-coder",
@@ -6342,7 +6342,7 @@
[[package]]
name = "pallet-nonfungible"
-version = "0.1.11"
+version = "0.1.12"
dependencies = [
"ethereum 0.14.0",
"evm-coder",
@@ -6501,7 +6501,7 @@
[[package]]
name = "pallet-refungible"
-version = "0.2.10"
+version = "0.2.11"
dependencies = [
"derivative",
"ethereum 0.14.0",
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -36,7 +36,7 @@
use crate::{
Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,
eth::{
- EthCrossAccount, convert_cross_account_to_uint256, CollectionPermissions as EvmPermissions,
+ EthCrossAccount, CollectionPermissions as EvmPermissions,
CollectionLimits as EvmCollectionLimits,
},
weights::WeightInfo,
@@ -289,20 +289,13 @@
/// Get current sponsor.
///
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
- fn collection_sponsor(&self) -> Result<(address, uint256)> {
+ fn collection_sponsor(&self) -> Result<EthCrossAccount> {
let sponsor = match self.collection.sponsorship.sponsor() {
Some(sponsor) => sponsor,
None => return Ok(Default::default()),
};
- let sponsor = T::CrossAccountId::from_sub(sponsor.clone());
- let result: (address, uint256) = if sponsor.is_canonical_substrate() {
- let sponsor = convert_cross_account_to_uint256::<T>(&sponsor);
- (Default::default(), sponsor)
- } else {
- let sponsor = *sponsor.as_eth();
- (sponsor, Default::default())
- };
- Ok(result)
+
+ Ok(EthCrossAccount::from_sub::<T>(&sponsor))
}
/// Get current collection limits.
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -53,15 +53,6 @@
address[0..16] == ETH_COLLECTION_PREFIX
}
-/// Convert `CrossAccountId` to `uint256`.
-pub fn convert_cross_account_to_uint256<T: Config>(from: &T::CrossAccountId) -> uint256
-where
- T::AccountId: AsRef<[u8; 32]>,
-{
- let slice = from.as_sub().as_ref();
- uint256::from_big_endian(slice)
-}
-
/// Convert `uint256` to `CrossAccountId`.
pub fn convert_uint256_to_cross_account<T: Config>(from: uint256) -> T::CrossAccountId
where
@@ -71,46 +62,6 @@
from.to_big_endian(&mut new_admin_arr);
let account_id = T::AccountId::from(new_admin_arr);
T::CrossAccountId::from_sub(account_id)
-}
-
-/// Convert `CrossAccountId` to `(address, uint256)`.
-pub fn convert_cross_account_to_tuple<T: Config>(
- cross_account_id: &T::CrossAccountId,
-) -> (address, uint256)
-where
- T::AccountId: AsRef<[u8; 32]>,
-{
- if cross_account_id.is_canonical_substrate() {
- let sub = convert_cross_account_to_uint256::<T>(cross_account_id);
- (Default::default(), sub)
- } else {
- let eth = *cross_account_id.as_eth();
- (eth, Default::default())
- }
-}
-
-/// Convert tuple `(address, uint256)` to `CrossAccountId`.
-///
-/// If `address` in the tuple has *default* value, then the canonical form is substrate,
-/// if `uint256` has *default* value, then the ethereum form is canonical,
-/// if both values are *default* or *non default*, then this is considered an invalid address and `Error` is returned.
-pub fn convert_tuple_to_cross_account<T: Config>(
- eth_cross_account_id: (address, uint256),
-) -> evm_coder::execution::Result<T::CrossAccountId>
-where
- T::AccountId: From<[u8; 32]>,
-{
- if eth_cross_account_id == Default::default() {
- Err("All fields of cross account is zeroed".into())
- } else if eth_cross_account_id.0 == Default::default() {
- Ok(convert_uint256_to_cross_account::<T>(
- eth_cross_account_id.1,
- ))
- } else if eth_cross_account_id.1 == Default::default() {
- Ok(T::CrossAccountId::from_eth(eth_cross_account_id.0))
- } else {
- Err("All fields of cross account is non zeroed".into())
- }
}
/// Cross account struct
@@ -121,16 +72,14 @@
}
impl EthCrossAccount {
+ /// Converts `CrossAccountId` to `EthCrossAccountId`
pub fn from_sub_cross_account<T>(cross_account_id: &T::CrossAccountId) -> Self
where
T: pallet_evm::Config,
T::AccountId: AsRef<[u8; 32]>,
{
if cross_account_id.is_canonical_substrate() {
- Self {
- eth: Default::default(),
- sub: convert_cross_account_to_uint256::<T>(cross_account_id),
- }
+ Self::from_sub::<T>(cross_account_id.as_sub())
} else {
Self {
eth: *cross_account_id.as_eth(),
@@ -138,7 +87,18 @@
}
}
}
-
+ /// Creates `EthCrossAccount` from substrate account
+ pub fn from_sub<T>(account_id: &T::AccountId) -> Self
+ where
+ T: pallet_evm::Config,
+ T::AccountId: AsRef<[u8; 32]>,
+ {
+ Self {
+ eth: Default::default(),
+ sub: uint256::from_big_endian(account_id.as_ref()),
+ }
+ }
+ /// Converts `EthCrossAccount` to `CrossAccountId`
pub fn into_sub_cross_account<T>(&self) -> evm_coder::execution::Result<T::CrossAccountId>
where
T: pallet_evm::Config,
@@ -163,29 +123,41 @@
/// How many tokens can a user have on one account.
#[default]
AccountTokenOwnership,
+
/// How many bytes of data are available for sponsorship.
SponsoredDataSize,
+
/// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
SponsoredDataRateLimit,
+
/// How many tokens can be mined into this collection.
TokenLimit,
+
/// Timeouts for transfer sponsoring.
SponsorTransferTimeout,
+
/// Timeout for sponsoring an approval in passed blocks.
SponsorApproveTimeout,
+
/// Whether the collection owner of the collection can send tokens (which belong to other users).
OwnerCanTransfer,
+
/// Can the collection owner burn other people's tokens.
OwnerCanDestroy,
+
/// Is it possible to send tokens from this collection between users.
TransferEnabled,
}
+/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) fields as an enumeration.
#[derive(Default, Debug, Clone, Copy, AbiCoder)]
#[repr(u8)]
pub enum CollectionPermissions {
+ /// Owner of token can nest tokens under it.
#[default]
- CollectionAdmin,
TokenOwner,
+
+ /// Admin of token collection can nest tokens under token.
+ CollectionAdmin,
}
/// Ethereum representation of TokenPermissions (see [`up_data_structs::PropertyPermission`]) fields as an enumeration.
pallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth--- a/pallets/evm-contract-helpers/Cargo.toml
+++ b/pallets/evm-contract-helpers/Cargo.toml
@@ -50,6 +50,7 @@
"pallet-evm-coder-substrate/std",
"pallet-evm/std",
"up-sponsorship/std",
+ "pallet-common/std",
]
try-runtime = ["frame-support/try-runtime"]
-stubgen = ["evm-coder/stubgen"]
+stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -25,6 +25,7 @@
types::*,
ToLog,
};
+use pallet_common::eth::EthCrossAccount;
use pallet_evm::{
ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
account::CrossAccountId,
@@ -174,11 +175,9 @@
///
/// @param contractAddress The contract for which a sponsor is requested.
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
- fn sponsor(&self, contract_address: address) -> Result<(address, uint256)> {
- let sponsor =
- Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;
- Ok(pallet_common::eth::convert_cross_account_to_tuple::<T>(
- &sponsor,
+ fn sponsor(&self, contract_address: address) -> Result<EthCrossAccount> {
+ Ok(EthCrossAccount::from_sub_cross_account::<T>(
+ &Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?,
))
}
pallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth--- a/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
+++ b/pallets/evm-contract-helpers/src/stubs/ContractHelpers.sol
@@ -96,11 +96,11 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x766c4f37,
/// or in textual repr: sponsor(address)
- function sponsor(address contractAddress) public view returns (Tuple0 memory) {
+ function sponsor(address contractAddress) public view returns (EthCrossAccount memory) {
require(false, stub_error);
contractAddress;
dummy;
- return Tuple0(0x0000000000000000000000000000000000000000, 0);
+ return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
}
/// Check tat contract has confirmed sponsor.
@@ -265,8 +265,8 @@
}
}
-/// @dev anonymous struct
-struct Tuple0 {
- address field_0;
- uint256 field_1;
+/// @dev Cross account struct
+struct EthCrossAccount {
+ address eth;
+ uint256 sub;
}
pallets/fungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -4,6 +4,12 @@
<!-- bureaucrate goes here -->
+## [0.1.9] - 2022-12-01
+
+### Added
+
+- The functions `mintCross` to `ERC20UniqueExtensions` interface.
+
## [0.1.8] - 2022-11-18
### Added
pallets/fungible/Cargo.tomldiffbeforeafterboth--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-fungible"
-version = "0.1.7"
+version = "0.1.9"
license = "GPLv3"
edition = "2021"
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -174,6 +174,19 @@
.collect::<string>())
}
+ #[weight(<SelfWeightOf<T>>::create_item())]
+ fn mint_cross(&mut self, caller: caller, to: EthCrossAccount, amount: uint256) -> Result<bool> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = to.into_sub_cross_account::<T>()?;
+ let amount = amount.try_into().map_err(|_| "amount overflow")?;
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+ <Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(true)
+ }
+
#[weight(<SelfWeightOf<T>>::approve())]
fn approve_cross(
&mut self,
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -152,10 +152,10 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
- function collectionSponsor() public view returns (Tuple8 memory) {
+ function collectionSponsor() public view returns (EthCrossAccount memory) {
require(false, stub_error);
dummy;
- return Tuple8(0x0000000000000000000000000000000000000000, 0);
+ return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
}
/// Get current collection limits.
@@ -173,10 +173,10 @@
/// Return `false` if a limit not set.
/// @dev EVM selector for this function is: 0xf63bc572,
/// or in textual repr: collectionLimits()
- function collectionLimits() public view returns (Tuple20[] memory) {
+ function collectionLimits() public view returns (Tuple23[] memory) {
require(false, stub_error);
dummy;
- return new Tuple20[](0);
+ return new Tuple23[](0);
}
/// Set limits for the collection.
@@ -284,19 +284,19 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() public view returns (Tuple26 memory) {
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple29 memory) {
require(false, stub_error);
dummy;
- return Tuple26(false, new uint256[](0));
+ return Tuple29(false, new uint256[](0));
}
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() public view returns (Tuple29[] memory) {
+ function collectionNestingPermissions() public view returns (Tuple32[] memory) {
require(false, stub_error);
dummy;
- return new Tuple29[](0);
+ return new Tuple32[](0);
}
/// Set the collection access method.
@@ -476,13 +476,13 @@
}
/// @dev anonymous struct
-struct Tuple29 {
+struct Tuple32 {
CollectionPermissions field_0;
bool field_1;
}
/// @dev anonymous struct
-struct Tuple26 {
+struct Tuple29 {
bool field_0;
uint256[] field_1;
}
@@ -510,7 +510,7 @@
}
/// @dev anonymous struct
-struct Tuple20 {
+struct Tuple23 {
CollectionLimits field_0;
bool field_1;
uint256 field_2;
@@ -522,7 +522,7 @@
bytes value;
}
-/// @dev the ERC-165 identifier for this interface is 0x5b7038cf
+/// @dev the ERC-165 identifier for this interface is 0x7dee5997
contract ERC20UniqueExtensions is Dummy, ERC165 {
/// @notice A description for the collection.
/// @dev EVM selector for this function is: 0x7284e416,
@@ -533,6 +533,16 @@
return "";
}
+ /// @dev EVM selector for this function is: 0x269e6158,
+ /// or in textual repr: mintCross((address,uint256),uint256)
+ function mintCross(EthCrossAccount memory to, uint256 amount) public returns (bool) {
+ require(false, stub_error);
+ to;
+ amount;
+ dummy = 0;
+ return false;
+ }
+
/// @dev EVM selector for this function is: 0x0ecd0ab0,
/// or in textual repr: approveCross((address,uint256),uint256)
function approveCross(EthCrossAccount memory spender, uint256 amount) public returns (bool) {
@@ -577,7 +587,7 @@
/// @param amounts array of pairs of account address and amount
/// @dev EVM selector for this function is: 0x1acf2d55,
/// or in textual repr: mintBulk((address,uint256)[])
- function mintBulk(Tuple8[] memory amounts) public returns (bool) {
+ function mintBulk(Tuple9[] memory amounts) public returns (bool) {
require(false, stub_error);
amounts;
dummy = 0;
@@ -611,7 +621,7 @@
}
/// @dev anonymous struct
-struct Tuple8 {
+struct Tuple9 {
address field_0;
uint256 field_1;
}
pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -4,7 +4,7 @@
<!-- bureaucrate goes here -->
-## [0.1.11] - 2022-12-16
+## [0.1.12] - 2022-12-16
### Added
@@ -14,6 +14,12 @@
- Hide `setTokenPropertyPermission` function in `TokenProperties` interface.
+## [0.1.11] - 2022-12-01
+
+### Added
+
+- The functions `mintCross` to `ERC721UniqueExtensions` interface.
+
## [0.1.10] - 2022-11-18
### Added
pallets/nonfungible/Cargo.tomldiffbeforeafterboth--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-nonfungible"
-version = "0.1.11"
+version = "0.1.12"
license = "GPLv3"
edition = "2021"
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -605,7 +605,7 @@
Ok(false)
}
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
#[weight(<SelfWeightOf<T>>::create_item())]
@@ -618,7 +618,7 @@
Ok(token_id)
}
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @dev `tokenId` should be obtained with `nextTokenId` method,
/// unlike standard, you can't specify it manually
/// @param to The new owner
@@ -1069,6 +1069,58 @@
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
+
+ /// @notice Function to mint a token.
+ /// @param to The new owner crossAccountId
+ /// @param properties Properties of minted token
+ /// @return uint256 The id of the newly minted token
+ #[weight(<SelfWeightOf<T>>::create_item())]
+ fn mint_cross(
+ &mut self,
+ caller: caller,
+ to: EthCrossAccount,
+ properties: Vec<PropertyStruct>,
+ ) -> Result<uint256> {
+ let token_id = <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?;
+
+ let to = to.into_sub_cross_account::<T>()?;
+
+ let properties = properties
+ .into_iter()
+ .map(|PropertyStruct { key, value }| {
+ let key = <Vec<u8>>::from(key)
+ .try_into()
+ .map_err(|_| "key too large")?;
+
+ let value = value.0.try_into().map_err(|_| "value too large")?;
+
+ Ok(Property { key, value })
+ })
+ .collect::<Result<Vec<_>>>()?
+ .try_into()
+ .map_err(|_| Error::Revert(alloc::format!("too many properties")))?;
+
+ let caller = T::CrossAccountId::from_eth(caller);
+
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ <Pallet<T>>::create_item(
+ self,
+ &caller,
+ CreateItemData::<T> {
+ properties,
+ owner: to,
+ },
+ &budget,
+ )
+ .map_err(dispatch_to_evm::<T>)?;
+
+ Ok(token_id.into())
+ }
}
#[solidity_interface(
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -42,7 +42,7 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple59[] memory permissions) public {
+ function setTokenPropertyPermissions(Tuple61[] memory permissions) public {
require(false, stub_error);
permissions;
dummy = 0;
@@ -51,10 +51,10 @@
/// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() public view returns (Tuple59[] memory) {
+ function tokenPropertyPermissions() public view returns (Tuple61[] memory) {
require(false, stub_error);
dummy;
- return new Tuple59[](0);
+ return new Tuple61[](0);
}
// /// @notice Set token property value.
@@ -144,13 +144,13 @@
}
/// @dev anonymous struct
-struct Tuple59 {
+struct Tuple61 {
string field_0;
- Tuple57[] field_1;
+ Tuple59[] field_1;
}
/// @dev anonymous struct
-struct Tuple57 {
+struct Tuple59 {
EthTokenPermissions field_0;
bool field_1;
}
@@ -290,10 +290,10 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
- function collectionSponsor() public view returns (Tuple30 memory) {
+ function collectionSponsor() public view returns (EthCrossAccount memory) {
require(false, stub_error);
dummy;
- return Tuple30(0x0000000000000000000000000000000000000000, 0);
+ return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
}
/// Get current collection limits.
@@ -311,10 +311,10 @@
/// Return `false` if a limit not set.
/// @dev EVM selector for this function is: 0xf63bc572,
/// or in textual repr: collectionLimits()
- function collectionLimits() public view returns (Tuple33[] memory) {
+ function collectionLimits() public view returns (Tuple35[] memory) {
require(false, stub_error);
dummy;
- return new Tuple33[](0);
+ return new Tuple35[](0);
}
/// Set limits for the collection.
@@ -422,19 +422,19 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() public view returns (Tuple39 memory) {
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple41 memory) {
require(false, stub_error);
dummy;
- return Tuple39(false, new uint256[](0));
+ return Tuple41(false, new uint256[](0));
}
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() public view returns (Tuple42[] memory) {
+ function collectionNestingPermissions() public view returns (Tuple44[] memory) {
require(false, stub_error);
dummy;
- return new Tuple42[](0);
+ return new Tuple44[](0);
}
/// Set the collection access method.
@@ -614,13 +614,13 @@
}
/// @dev anonymous struct
-struct Tuple42 {
+struct Tuple44 {
CollectionPermissions field_0;
bool field_1;
}
/// @dev anonymous struct
-struct Tuple39 {
+struct Tuple41 {
bool field_0;
uint256[] field_1;
}
@@ -648,18 +648,12 @@
}
/// @dev anonymous struct
-struct Tuple33 {
+struct Tuple35 {
CollectionLimits field_0;
bool field_1;
uint256 field_2;
}
-/// @dev anonymous struct
-struct Tuple30 {
- address field_0;
- uint256 field_1;
-}
-
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
@@ -735,7 +729,7 @@
return false;
}
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
/// @dev EVM selector for this function is: 0x6a627842,
@@ -747,7 +741,7 @@
return 0;
}
- // /// @notice Function to mint token.
+ // /// @notice Function to mint a token.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
// /// @param to The new owner
@@ -804,7 +798,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xb74c26b7
+/// @dev the ERC-165 identifier for this interface is 0x0e48fdb4
contract ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -961,6 +955,7 @@
dummy;
return 0;
}
+
// /// @notice Function to mint multiple tokens.
// /// @dev `tokenIds` should be an array of consecutive numbers and first number
// /// should be obtained with `nextTokenId` method
@@ -991,6 +986,19 @@
// return false;
// }
+ /// @notice Function to mint a token.
+ /// @param to The new owner crossAccountId
+ /// @param properties Properties of minted token
+ /// @return uint256 The id of the newly minted token
+ /// @dev EVM selector for this function is: 0xb904db03,
+ /// or in textual repr: mintCross((address,uint256),(string,bytes)[])
+ function mintCross(EthCrossAccount memory to, Property[] memory properties) public returns (uint256) {
+ require(false, stub_error);
+ to;
+ properties;
+ dummy = 0;
+ return 0;
+ }
}
/// @dev anonymous struct
pallets/refungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -4,7 +4,7 @@
<!-- bureaucrate goes here -->
-## [0.2.10] - 2022-12-16
+## [0.2.11] - 2022-12-16
### Added
@@ -14,6 +14,12 @@
- Hide `setTokenPropertyPermission` function in `TokenProperties` interface.
+## [0.2.10] - 2022-12-01
+
+### Added
+
+- The functions `mintCross` to `ERC721UniqueExtensions` interface.
+
## [0.2.9] - 2022-11-18
### Added
pallets/refungible/Cargo.tomldiffbeforeafterboth--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-refungible"
-version = "0.2.10"
+version = "0.2.11"
license = "GPLv3"
edition = "2021"
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -165,9 +165,9 @@
fn map_create_data<T: Config>(
data: up_data_structs::CreateItemData,
to: &T::CrossAccountId,
-) -> Result<CreateItemData<T::CrossAccountId>, DispatchError> {
+) -> Result<CreateItemData<T>, DispatchError> {
match data {
- up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateItemData {
+ up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateItemData::<T> {
users: {
let mut out = BTreeMap::new();
out.insert(to.clone(), data.pieces);
@@ -230,7 +230,7 @@
CreateItemExData::RefungibleMultipleOwners(CreateRefungibleExMultipleOwners {
users,
properties,
- }) => vec![CreateItemData { users, properties }],
+ }) => vec![CreateItemData::<T> { users, properties }],
CreateItemExData::RefungibleMultipleItems(r) => r
.into_inner()
.into_iter()
@@ -239,7 +239,7 @@
user,
pieces,
properties,
- }| CreateItemData {
+ }| CreateItemData::<T> {
users: BTreeMap::from([(user, pieces)])
.try_into()
.expect("limit >= 1"),
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -637,7 +637,7 @@
Ok(false)
}
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
#[weight(<SelfWeightOf<T>>::create_item())]
@@ -650,7 +650,7 @@
Ok(token_id)
}
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @dev `tokenId` should be obtained with `nextTokenId` method,
/// unlike standard, you can't specify it manually
/// @param to The new owner
@@ -681,7 +681,7 @@
<Pallet<T>>::create_item(
self,
&caller,
- CreateItemData::<T::CrossAccountId> {
+ CreateItemData::<T> {
users,
properties: CollectionPropertiesVec::default(),
},
@@ -767,7 +767,7 @@
<Pallet<T>>::create_item(
self,
&caller,
- CreateItemData::<T::CrossAccountId> { users, properties },
+ CreateItemData::<T> { users, properties },
&budget,
)
.map_err(dispatch_to_evm::<T>)?;
@@ -1048,7 +1048,7 @@
.collect::<BTreeMap<_, _>>()
.try_into()
.unwrap();
- let create_item_data = CreateItemData::<T::CrossAccountId> {
+ let create_item_data = CreateItemData::<T> {
users,
properties: CollectionPropertiesVec::default(),
};
@@ -1108,7 +1108,7 @@
})
.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;
- let create_item_data = CreateItemData::<T::CrossAccountId> {
+ let create_item_data = CreateItemData::<T> {
users: users.clone(),
properties,
};
@@ -1120,6 +1120,60 @@
Ok(true)
}
+ /// @notice Function to mint a token.
+ /// @param to The new owner crossAccountId
+ /// @param properties Properties of minted token
+ /// @return uint256 The id of the newly minted token
+ #[weight(<SelfWeightOf<T>>::create_item())]
+ fn mint_cross(
+ &mut self,
+ caller: caller,
+ to: EthCrossAccount,
+ properties: Vec<PropertyStruct>,
+ ) -> Result<uint256> {
+ let token_id = <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?;
+
+ let to = to.into_sub_cross_account::<T>()?;
+
+ let properties = properties
+ .into_iter()
+ .map(|PropertyStruct { key, value }| {
+ let key = <Vec<u8>>::from(key)
+ .try_into()
+ .map_err(|_| "key too large")?;
+
+ let value = value.0.try_into().map_err(|_| "value too large")?;
+
+ Ok(Property { key, value })
+ })
+ .collect::<Result<Vec<_>>>()?
+ .try_into()
+ .map_err(|_| Error::Revert(alloc::format!("too many properties")))?;
+
+ let caller = T::CrossAccountId::from_eth(caller);
+
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ let users = [(to, 1)]
+ .into_iter()
+ .collect::<BTreeMap<_, _>>()
+ .try_into()
+ .unwrap();
+ <Pallet<T>>::create_item(
+ self,
+ &caller,
+ CreateItemData::<T> { users, properties },
+ &budget,
+ )
+ .map_err(dispatch_to_evm::<T>)?;
+
+ Ok(token_id.into())
+ }
+
/// Returns EVM address for refungible token
///
/// @param token ID of the token
pallets/refungible/src/lib.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//! # Refungible Pallet18//!19//! The Refungible pallet provides functionality for handling refungible collections and tokens.20//!21//! - [`Config`]22//! - [`RefungibleHandle`]23//! - [`Pallet`]24//! - [`CommonWeights`](common::CommonWeights)25//!26//! ## Overview27//!28//! The Refungible pallet provides functions for:29//!30//! - RFT collection creation and removal31//! - Minting and burning of RFT tokens32//! - Partition and repartition of RFT tokens33//! - Retrieving number of pieces of RFT token34//! - Retrieving account balances35//! - Transfering RFT token pieces36//! - Burning RFT token pieces37//! - Setting and checking allowance for RFT tokens38//!39//! ### Terminology40//!41//! - **RFT token:** Non fungible token that was partitioned to pieces. If an account owns all42//! of the RFT token pieces than it owns the RFT token and can repartition it.43//!44//! - **RFT Collection:** A collection of RFT tokens. All RFT tokens are part of a collection.45//! Each collection has its own settings and set of permissions.46//!47//! - **RFT token piece:** A fungible part of an RFT token.48//!49//! - **Balance:** RFT token pieces owned by an account50//!51//! - **Allowance:** Maximum number of RFT token pieces that one account is allowed to52//! transfer from the balance of another account53//!54//! - **Burning:** The process of “deleting” a token from a collection or removing token pieces from55//! an account balance.56//!57//! ### Implementations58//!59//! The Refungible pallet provides implementations for the following traits. If these traits provide60//! the functionality that you need, then you can avoid coupling with the Refungible pallet.61//!62//! - [`CommonWeightInfo`](pallet_common::CommonWeightInfo): Functions for retrieval of transaction weight63//! - [`CommonCollectionOperations`](pallet_common::CommonCollectionOperations): Functions for dealing64//! with collections65//! - [`RefungibleExtensions`](pallet_common::RefungibleExtensions): Functions specific for refungible66//! collection67//!68//! ## Interface69//!70//! ### Dispatchable Functions71//!72//! - `init_collection` - Create RFT collection. RFT collection can be configured to allow or deny access for73//! some accounts.74//! - `destroy_collection` - Destroy exising RFT collection. There should be no tokens in the collection.75//! - `burn` - Burn some amount of RFT token pieces owned by account. Burns the RFT token if no pieces left.76//! - `transfer` - Transfer some amount of RFT token pieces. Transfers should be enabled for RFT collection.77//! Nests the RFT token if RFT token pieces are sent to another token.78//! - `create_item` - Mint RFT token in collection. Sender should have permission to mint tokens.79//! - `set_allowance` - Set allowance for another account to transfer balance from sender's account.80//! - `repartition` - Repartition token to selected number of pieces. Sender should own all existing pieces.81//!82//! ## Assumptions83//!84//! * Total number of pieces for one token shouldn't exceed `up_data_structs::MAX_REFUNGIBLE_PIECES`.85//! * Total number of tokens of all types shouldn't be greater than `up_data_structs::MAX_TOKEN_PREFIX_LENGTH`.86//! * Sender should be in collection's allow list to perform operations on tokens.8788#![cfg_attr(not(feature = "std"), no_std)]8990use crate::erc_token::ERC20Events;91use crate::erc::ERC721Events;9293use codec::{Encode, Decode, MaxEncodedLen};94use core::ops::Deref;95use derivative::Derivative;96use evm_coder::ToLog;97use frame_support::{98 BoundedBTreeMap, BoundedVec, ensure, fail, storage::with_transaction, transactional,99 pallet_prelude::ConstU32,100};101use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};102use pallet_evm_coder_substrate::WithRecorder;103use pallet_common::{104 CommonCollectionOperations, Error as CommonError, eth::collection_id_to_address,105 Event as CommonEvent, Pallet as PalletCommon, erc::CollectionHelpersEvents,106};107use pallet_structure::Pallet as PalletStructure;108use scale_info::TypeInfo;109use sp_core::{Get, H160};110use sp_runtime::{ArithmeticError, DispatchError, DispatchResult, TransactionOutcome};111use sp_std::{vec::Vec, vec, collections::btree_map::BTreeMap};112use up_data_structs::{113 AccessMode, budget::Budget, CollectionId, CollectionFlags, CollectionPropertiesVec,114 CreateCollectionData, CustomDataLimit, mapping::TokenAddressMapping, MAX_ITEMS_PER_BATCH,115 MAX_REFUNGIBLE_PIECES, Property, PropertyKey, PropertyKeyPermission, PropertyPermission,116 PropertyScope, PropertyValue, TokenId, TrySetProperty, PropertiesPermissionMap,117 CreateRefungibleExMultipleOwners,118};119120pub use pallet::*;121#[cfg(feature = "runtime-benchmarks")]122pub mod benchmarking;123pub mod common;124pub mod erc;125pub mod erc_token;126pub mod weights;127128pub type CreateItemData<T> =129 CreateRefungibleExMultipleOwners<<T as pallet_evm::Config>::CrossAccountId>;130pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;131132/// Token data, stored independently from other data used to describe it133/// for the convenience of database access. Notably contains the token metadata.134#[struct_versioning::versioned(version = 2, upper)]135#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]136pub struct ItemData {137 pub const_data: BoundedVec<u8, CustomDataLimit>,138139 #[version(..2)]140 pub variable_data: BoundedVec<u8, CustomDataLimit>,141}142143#[frame_support::pallet]144pub mod pallet {145 use super::*;146 use frame_support::{147 Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key,148 traits::StorageVersion,149 };150 use frame_system::pallet_prelude::*;151 use up_data_structs::{CollectionId, TokenId};152 use super::weights::WeightInfo;153154 #[pallet::error]155 pub enum Error<T> {156 /// Not Refungible item data used to mint in Refungible collection.157 NotRefungibleDataUsedToMintFungibleCollectionToken,158 /// Maximum refungibility exceeded.159 WrongRefungiblePieces,160 /// Refungible token can't be repartitioned by user who isn't owns all pieces.161 RepartitionWhileNotOwningAllPieces,162 /// Refungible token can't nest other tokens.163 RefungibleDisallowsNesting,164 /// Setting item properties is not allowed.165 SettingPropertiesNotAllowed,166 }167168 #[pallet::config]169 pub trait Config:170 frame_system::Config + pallet_common::Config + pallet_structure::Config171 {172 type WeightInfo: WeightInfo;173 }174175 const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);176177 #[pallet::pallet]178 #[pallet::storage_version(STORAGE_VERSION)]179 #[pallet::generate_store(pub(super) trait Store)]180 pub struct Pallet<T>(_);181182 /// Total amount of minted tokens in a collection.183 #[pallet::storage]184 pub type TokensMinted<T: Config> =185 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;186187 /// Amount of tokens burnt in a collection.188 #[pallet::storage]189 pub type TokensBurnt<T: Config> =190 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;191192 /// Token data, used to partially describe a token.193 // TODO: remove194 #[pallet::storage]195 #[deprecated(since = "0.2.0", note = "ItemData is no more contains usefull data")]196 pub type TokenData<T: Config> = StorageNMap<197 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),198 Value = ItemData,199 QueryKind = ValueQuery,200 >;201202 /// Amount of pieces a refungible token is split into.203 #[pallet::storage]204 #[pallet::getter(fn token_properties)]205 pub type TokenProperties<T: Config> = StorageNMap<206 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),207 Value = up_data_structs::Properties,208 QueryKind = ValueQuery,209 OnEmpty = up_data_structs::TokenProperties,210 >;211212 /// Total amount of pieces for token213 #[pallet::storage]214 pub type TotalSupply<T: Config> = StorageNMap<215 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),216 Value = u128,217 QueryKind = ValueQuery,218 >;219220 /// Used to enumerate tokens owned by account.221 #[pallet::storage]222 pub type Owned<T: Config> = StorageNMap<223 Key = (224 Key<Twox64Concat, CollectionId>,225 Key<Blake2_128Concat, T::CrossAccountId>,226 Key<Twox64Concat, TokenId>,227 ),228 Value = bool,229 QueryKind = ValueQuery,230 >;231232 /// Amount of tokens (not pieces) partially owned by an account within a collection.233 #[pallet::storage]234 pub type AccountBalance<T: Config> = StorageNMap<235 Key = (236 Key<Twox64Concat, CollectionId>,237 // Owner238 Key<Blake2_128Concat, T::CrossAccountId>,239 ),240 Value = u32,241 QueryKind = ValueQuery,242 >;243244 /// Amount of token pieces owned by account.245 #[pallet::storage]246 pub type Balance<T: Config> = StorageNMap<247 Key = (248 Key<Twox64Concat, CollectionId>,249 Key<Twox64Concat, TokenId>,250 // Owner251 Key<Blake2_128Concat, T::CrossAccountId>,252 ),253 Value = u128,254 QueryKind = ValueQuery,255 >;256257 /// Allowance set by a token owner for another user to perform one of certain transactions on a number of pieces of a token.258 #[pallet::storage]259 pub type Allowance<T: Config> = StorageNMap<260 Key = (261 Key<Twox64Concat, CollectionId>,262 Key<Twox64Concat, TokenId>,263 // Owner264 Key<Blake2_128, T::CrossAccountId>,265 // Spender266 Key<Blake2_128Concat, T::CrossAccountId>,267 ),268 Value = u128,269 QueryKind = ValueQuery,270 >;271272 /// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.273 #[pallet::storage]274 pub type CollectionAllowance<T: Config> = StorageNMap<275 Key = (276 Key<Twox64Concat, CollectionId>,277 Key<Blake2_128Concat, T::CrossAccountId>,278 Key<Blake2_128Concat, T::CrossAccountId>,279 ),280 Value = bool,281 QueryKind = ValueQuery,282 >;283284 #[pallet::hooks]285 impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {286 fn on_runtime_upgrade() -> Weight {287 let storage_version = StorageVersion::get::<Pallet<T>>();288 if storage_version < StorageVersion::new(2) {289 #[allow(deprecated)]290 let _ = <TokenData<T>>::clear(u32::MAX, None);291 }292 StorageVersion::new(2).put::<Pallet<T>>();293294 Weight::zero()295 }296 }297}298299pub struct RefungibleHandle<T: Config>(pallet_common::CollectionHandle<T>);300impl<T: Config> RefungibleHandle<T> {301 pub fn cast(inner: pallet_common::CollectionHandle<T>) -> Self {302 Self(inner)303 }304 pub fn into_inner(self) -> pallet_common::CollectionHandle<T> {305 self.0306 }307 pub fn common_mut(&mut self) -> &mut pallet_common::CollectionHandle<T> {308 &mut self.0309 }310}311312impl<T: Config> Deref for RefungibleHandle<T> {313 type Target = pallet_common::CollectionHandle<T>;314315 fn deref(&self) -> &Self::Target {316 &self.0317 }318}319320impl<T: Config> WithRecorder<T> for RefungibleHandle<T> {321 fn recorder(&self) -> &pallet_evm_coder_substrate::SubstrateRecorder<T> {322 self.0.recorder()323 }324 fn into_recorder(self) -> pallet_evm_coder_substrate::SubstrateRecorder<T> {325 self.0.into_recorder()326 }327}328329impl<T: Config> Pallet<T> {330 /// Get number of RFT tokens in collection331 pub fn total_supply(collection: &RefungibleHandle<T>) -> u32 {332 <TokensMinted<T>>::get(collection.id) - <TokensBurnt<T>>::get(collection.id)333 }334335 /// Check that RFT token exists336 ///337 /// - `token`: Token ID.338 pub fn token_exists(collection: &RefungibleHandle<T>, token: TokenId) -> bool {339 <TotalSupply<T>>::contains_key((collection.id, token))340 }341342 pub fn set_scoped_token_property(343 collection_id: CollectionId,344 token_id: TokenId,345 scope: PropertyScope,346 property: Property,347 ) -> DispatchResult {348 TokenProperties::<T>::try_mutate((collection_id, token_id), |properties| {349 properties.try_scoped_set(scope, property.key, property.value)350 })351 .map_err(<CommonError<T>>::from)?;352353 Ok(())354 }355356 pub fn set_scoped_token_properties(357 collection_id: CollectionId,358 token_id: TokenId,359 scope: PropertyScope,360 properties: impl Iterator<Item = Property>,361 ) -> DispatchResult {362 TokenProperties::<T>::try_mutate((collection_id, token_id), |stored_properties| {363 stored_properties.try_scoped_set_from_iter(scope, properties)364 })365 .map_err(<CommonError<T>>::from)?;366367 Ok(())368 }369}370371// unchecked calls skips any permission checks372impl<T: Config> Pallet<T> {373 /// Create RFT collection374 ///375 /// `init_collection` will take non-refundable deposit for collection creation.376 ///377 /// - `data`: Contains settings for collection limits and permissions.378 pub fn init_collection(379 owner: T::CrossAccountId,380 payer: T::CrossAccountId,381 data: CreateCollectionData<T::AccountId>,382 flags: CollectionFlags,383 ) -> Result<CollectionId, DispatchError> {384 <PalletCommon<T>>::init_collection(owner, payer, data, flags)385 }386387 /// Destroy RFT collection388 ///389 /// `destroy_collection` will throw error if collection contains any tokens.390 /// Only owner can destroy collection.391 pub fn destroy_collection(392 collection: RefungibleHandle<T>,393 sender: &T::CrossAccountId,394 ) -> DispatchResult {395 let id = collection.id;396397 if Self::collection_has_tokens(id) {398 return Err(<CommonError<T>>::CantDestroyNotEmptyCollection.into());399 }400401 // =========402403 PalletCommon::destroy_collection(collection.0, sender)?;404405 <TokensMinted<T>>::remove(id);406 <TokensBurnt<T>>::remove(id);407 let _ = <TotalSupply<T>>::clear_prefix((id,), u32::MAX, None);408 let _ = <Balance<T>>::clear_prefix((id,), u32::MAX, None);409 let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);410 let _ = <Owned<T>>::clear_prefix((id,), u32::MAX, None);411 let _ = <AccountBalance<T>>::clear_prefix((id,), u32::MAX, None);412 Ok(())413 }414415 fn collection_has_tokens(collection_id: CollectionId) -> bool {416 <TotalSupply<T>>::iter_prefix((collection_id,))417 .next()418 .is_some()419 }420421 pub fn burn_token_unchecked(422 collection: &RefungibleHandle<T>,423 owner: &T::CrossAccountId,424 token_id: TokenId,425 ) -> DispatchResult {426 let burnt = <TokensBurnt<T>>::get(collection.id)427 .checked_add(1)428 .ok_or(ArithmeticError::Overflow)?;429430 <TokensBurnt<T>>::insert(collection.id, burnt);431 <TokenProperties<T>>::remove((collection.id, token_id));432 <TotalSupply<T>>::remove((collection.id, token_id));433 let _ = <Balance<T>>::clear_prefix((collection.id, token_id), u32::MAX, None);434 let _ = <Allowance<T>>::clear_prefix((collection.id, token_id), u32::MAX, None);435 <PalletEvm<T>>::deposit_log(436 ERC721Events::Transfer {437 from: *owner.as_eth(),438 to: H160::default(),439 token_id: token_id.into(),440 }441 .to_log(collection_id_to_address(collection.id)),442 );443 Ok(())444 }445446 /// Burn RFT token pieces447 ///448 /// `burn` will decrease total amount of token pieces and amount owned by sender.449 /// `burn` can be called even if there are multiple owners of the RFT token.450 /// If sender wouldn't have any pieces left after `burn` than she will stop being451 /// one of the owners of the token. If there is no account that owns any pieces of452 /// the token than token will be burned too.453 ///454 /// - `amount`: Amount of token pieces to burn.455 /// - `token`: Token who's pieces should be burned456 /// - `collection`: Collection that contains the token457 pub fn burn(458 collection: &RefungibleHandle<T>,459 owner: &T::CrossAccountId,460 token: TokenId,461 amount: u128,462 ) -> DispatchResult {463 if <Balance<T>>::get((collection.id, token, owner)) == 0 {464 return Err(<CommonError<T>>::TokenValueTooLow.into());465 }466467 let total_supply = <TotalSupply<T>>::get((collection.id, token))468 .checked_sub(amount)469 .ok_or(<CommonError<T>>::TokenValueTooLow)?;470471 // This was probally last owner of this token?472 if total_supply == 0 {473 // Ensure user actually owns this amount474 ensure!(475 <Balance<T>>::get((collection.id, token, owner)) == amount,476 <CommonError<T>>::TokenValueTooLow477 );478 let account_balance = <AccountBalance<T>>::get((collection.id, owner))479 .checked_sub(1)480 // Should not occur481 .ok_or(ArithmeticError::Underflow)?;482483 // =========484485 <Owned<T>>::remove((collection.id, owner, token));486 <PalletStructure<T>>::unnest_if_nested(owner, collection.id, token);487 <AccountBalance<T>>::insert((collection.id, owner), account_balance);488 Self::burn_token_unchecked(collection, owner, token)?;489 <PalletEvm<T>>::deposit_log(490 ERC20Events::Transfer {491 from: *owner.as_eth(),492 to: H160::default(),493 value: amount.into(),494 }495 .to_log(collection_id_to_address(collection.id)),496 );497 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(498 collection.id,499 token,500 owner.clone(),501 amount,502 ));503 return Ok(());504 }505506 let balance = <Balance<T>>::get((collection.id, token, owner))507 .checked_sub(amount)508 .ok_or(<CommonError<T>>::TokenValueTooLow)?;509 let account_balance = if balance == 0 {510 <AccountBalance<T>>::get((collection.id, owner))511 .checked_sub(1)512 // Should not occur513 .ok_or(ArithmeticError::Underflow)?514 } else {515 0516 };517518 // =========519520 if balance == 0 {521 <Owned<T>>::remove((collection.id, owner, token));522 <PalletStructure<T>>::unnest_if_nested(owner, collection.id, token);523 <Balance<T>>::remove((collection.id, token, owner));524 <AccountBalance<T>>::insert((collection.id, owner), account_balance);525526 if let Some(user) = Self::token_owner(collection.id, token) {527 <PalletEvm<T>>::deposit_log(528 ERC721Events::Transfer {529 from: erc::ADDRESS_FOR_PARTIALLY_OWNED_TOKENS,530 to: *user.as_eth(),531 token_id: token.into(),532 }533 .to_log(collection_id_to_address(collection.id)),534 );535 }536 } else {537 <Balance<T>>::insert((collection.id, token, owner), balance);538 }539 <TotalSupply<T>>::insert((collection.id, token), total_supply);540541 <PalletEvm<T>>::deposit_log(542 ERC20Events::Transfer {543 from: *owner.as_eth(),544 to: H160::default(),545 value: amount.into(),546 }547 .to_log(T::EvmTokenAddressMapping::token_to_address(548 collection.id,549 token,550 )),551 );552 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(553 collection.id,554 token,555 owner.clone(),556 amount,557 ));558 Ok(())559 }560561 #[transactional]562 fn modify_token_properties(563 collection: &RefungibleHandle<T>,564 sender: &T::CrossAccountId,565 token_id: TokenId,566 properties: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,567 is_token_create: bool,568 nesting_budget: &dyn Budget,569 ) -> DispatchResult {570 let is_collection_admin = || collection.is_owner_or_admin(sender);571 let is_token_owner = || -> Result<bool, DispatchError> {572 let balance = collection.balance(sender.clone(), token_id);573 let total_pieces: u128 =574 Self::total_pieces(collection.id, token_id).unwrap_or(u128::MAX);575 if balance != total_pieces {576 return Ok(false);577 }578579 let is_bundle_owner = <PalletStructure<T>>::check_indirectly_owned(580 sender.clone(),581 collection.id,582 token_id,583 None,584 nesting_budget,585 )?;586587 Ok(is_bundle_owner)588 };589590 for (key, value) in properties {591 let permission = <PalletCommon<T>>::property_permissions(collection.id)592 .get(&key)593 .cloned()594 .unwrap_or_else(PropertyPermission::none);595596 let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))597 .get(&key)598 .is_some();599600 match permission {601 PropertyPermission { mutable: false, .. } if is_property_exists => {602 return Err(<CommonError<T>>::NoPermission.into());603 }604605 PropertyPermission {606 collection_admin,607 token_owner,608 ..609 } => {610 //TODO: investigate threats during public minting.611 let is_token_create =612 is_token_create && (collection_admin || token_owner) && value.is_some();613 if !(is_token_create614 || (collection_admin && is_collection_admin())615 || (token_owner && is_token_owner()?))616 {617 fail!(<CommonError<T>>::NoPermission);618 }619 }620 }621622 match value {623 Some(value) => {624 <TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {625 properties.try_set(key.clone(), value)626 })627 .map_err(<CommonError<T>>::from)?;628629 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertySet(630 collection.id,631 token_id,632 key,633 ));634 }635 None => {636 <TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {637 properties.remove(&key)638 })639 .map_err(<CommonError<T>>::from)?;640641 <PalletCommon<T>>::deposit_event(CommonEvent::TokenPropertyDeleted(642 collection.id,643 token_id,644 key,645 ));646 }647 }648649 <PalletEvm<T>>::deposit_log(650 CollectionHelpersEvents::TokenChanged {651 collection_id: collection_id_to_address(collection.id),652 token_id: token_id.into(),653 }654 .to_log(T::ContractAddress::get()),655 );656 }657658 Ok(())659 }660661 pub fn set_token_properties(662 collection: &RefungibleHandle<T>,663 sender: &T::CrossAccountId,664 token_id: TokenId,665 properties: impl Iterator<Item = Property>,666 is_token_create: bool,667 nesting_budget: &dyn Budget,668 ) -> DispatchResult {669 Self::modify_token_properties(670 collection,671 sender,672 token_id,673 properties.map(|p| (p.key, Some(p.value))),674 is_token_create,675 nesting_budget,676 )677 }678679 pub fn set_token_property(680 collection: &RefungibleHandle<T>,681 sender: &T::CrossAccountId,682 token_id: TokenId,683 property: Property,684 nesting_budget: &dyn Budget,685 ) -> DispatchResult {686 let is_token_create = false;687688 Self::set_token_properties(689 collection,690 sender,691 token_id,692 [property].into_iter(),693 is_token_create,694 nesting_budget,695 )696 }697698 pub fn delete_token_properties(699 collection: &RefungibleHandle<T>,700 sender: &T::CrossAccountId,701 token_id: TokenId,702 property_keys: impl Iterator<Item = PropertyKey>,703 nesting_budget: &dyn Budget,704 ) -> DispatchResult {705 let is_token_create = false;706707 Self::modify_token_properties(708 collection,709 sender,710 token_id,711 property_keys.into_iter().map(|key| (key, None)),712 is_token_create,713 nesting_budget,714 )715 }716717 pub fn delete_token_property(718 collection: &RefungibleHandle<T>,719 sender: &T::CrossAccountId,720 token_id: TokenId,721 property_key: PropertyKey,722 nesting_budget: &dyn Budget,723 ) -> DispatchResult {724 Self::delete_token_properties(725 collection,726 sender,727 token_id,728 [property_key].into_iter(),729 nesting_budget,730 )731 }732733 /// Transfer RFT token pieces from one account to another.734 ///735 /// If the sender is no longer owns any pieces after the `transfer` than she stops being an owner of the token.736 ///737 /// - `from`: Owner of token pieces to transfer.738 /// - `to`: Recepient of transfered token pieces.739 /// - `amount`: Amount of token pieces to transfer.740 /// - `token`: Token whos pieces should be transfered741 /// - `collection`: Collection that contains the token742 pub fn transfer(743 collection: &RefungibleHandle<T>,744 from: &T::CrossAccountId,745 to: &T::CrossAccountId,746 token: TokenId,747 amount: u128,748 nesting_budget: &dyn Budget,749 ) -> DispatchResult {750 ensure!(751 collection.limits.transfers_enabled(),752 <CommonError<T>>::TransferNotAllowed753 );754755 if collection.permissions.access() == AccessMode::AllowList {756 collection.check_allowlist(from)?;757 collection.check_allowlist(to)?;758 }759 <PalletCommon<T>>::ensure_correct_receiver(to)?;760761 let initial_balance_from = <Balance<T>>::get((collection.id, token, from));762763 if initial_balance_from == 0 {764 return Err(<CommonError<T>>::TokenValueTooLow.into());765 }766767 let updated_balance_from = initial_balance_from768 .checked_sub(amount)769 .ok_or(<CommonError<T>>::TokenValueTooLow)?;770 let mut create_target = false;771 let from_to_differ = from != to;772 let updated_balance_to = if from != to && amount != 0 {773 let old_balance = <Balance<T>>::get((collection.id, token, to));774 if old_balance == 0 {775 create_target = true;776 }777 Some(778 old_balance779 .checked_add(amount)780 .ok_or(ArithmeticError::Overflow)?,781 )782 } else {783 None784 };785786 let account_balance_from = if updated_balance_from == 0 {787 Some(788 <AccountBalance<T>>::get((collection.id, from))789 .checked_sub(1)790 // Should not occur791 .ok_or(ArithmeticError::Underflow)?,792 )793 } else {794 None795 };796 // Account data is created in token, AccountBalance should be increased797 // But only if from != to as we shouldn't check overflow in this case798 let account_balance_to = if create_target && from_to_differ {799 let account_balance_to = <AccountBalance<T>>::get((collection.id, to))800 .checked_add(1)801 .ok_or(ArithmeticError::Overflow)?;802 ensure!(803 account_balance_to < collection.limits.account_token_ownership_limit(),804 <CommonError<T>>::AccountTokenLimitExceeded,805 );806807 Some(account_balance_to)808 } else {809 None810 };811812 // =========813814 if let Some(updated_balance_to) = updated_balance_to {815 // from != to && amount != 0816817 <PalletStructure<T>>::nest_if_sent_to_token(818 from.clone(),819 to,820 collection.id,821 token,822 nesting_budget,823 )?;824825 if updated_balance_from == 0 {826 <Balance<T>>::remove((collection.id, token, from));827 <PalletStructure<T>>::unnest_if_nested(from, collection.id, token);828 } else {829 <Balance<T>>::insert((collection.id, token, from), updated_balance_from);830 }831 <Balance<T>>::insert((collection.id, token, to), updated_balance_to);832 if let Some(account_balance_from) = account_balance_from {833 <AccountBalance<T>>::insert((collection.id, from), account_balance_from);834 <Owned<T>>::remove((collection.id, from, token));835 }836 if let Some(account_balance_to) = account_balance_to {837 <AccountBalance<T>>::insert((collection.id, to), account_balance_to);838 <Owned<T>>::insert((collection.id, to, token), true);839 }840 }841842 <PalletEvm<T>>::deposit_log(843 ERC20Events::Transfer {844 from: *from.as_eth(),845 to: *to.as_eth(),846 value: amount.into(),847 }848 .to_log(T::EvmTokenAddressMapping::token_to_address(849 collection.id,850 token,851 )),852 );853854 <PalletCommon<T>>::deposit_event(CommonEvent::Transfer(855 collection.id,856 token,857 from.clone(),858 to.clone(),859 amount,860 ));861862 let total_supply = <TotalSupply<T>>::get((collection.id, token));863864 if amount == total_supply {865 // if token was fully owned by `from` and will be fully owned by `to` after transfer866 <PalletEvm<T>>::deposit_log(867 ERC721Events::Transfer {868 from: *from.as_eth(),869 to: *to.as_eth(),870 token_id: token.into(),871 }872 .to_log(collection_id_to_address(collection.id)),873 );874 } else if let Some(updated_balance_to) = updated_balance_to {875 // if `from` not equals `to`. This condition is needed to avoid sending event876 // when `from` fully owns token and sends part of token pieces to itself.877 if initial_balance_from == total_supply {878 // if token was fully owned by `from` and will be only partially owned by `to`879 // and `from` after transfer880 <PalletEvm<T>>::deposit_log(881 ERC721Events::Transfer {882 from: *from.as_eth(),883 to: erc::ADDRESS_FOR_PARTIALLY_OWNED_TOKENS,884 token_id: token.into(),885 }886 .to_log(collection_id_to_address(collection.id)),887 );888 } else if updated_balance_to == total_supply {889 // if token was partially owned by `from` and will be fully owned by `to` after transfer890 <PalletEvm<T>>::deposit_log(891 ERC721Events::Transfer {892 from: erc::ADDRESS_FOR_PARTIALLY_OWNED_TOKENS,893 to: *to.as_eth(),894 token_id: token.into(),895 }896 .to_log(collection_id_to_address(collection.id)),897 );898 }899 }900901 Ok(())902 }903904 /// Batched operation to create multiple RFT tokens.905 ///906 /// Same as `create_item` but creates multiple tokens.907 ///908 /// - `data`: Same as 'data` in `create_item` but contains data for multiple tokens.909 pub fn create_multiple_items(910 collection: &RefungibleHandle<T>,911 sender: &T::CrossAccountId,912 data: Vec<CreateItemData<T>>,913 nesting_budget: &dyn Budget,914 ) -> DispatchResult {915 if !collection.is_owner_or_admin(sender) {916 ensure!(917 collection.permissions.mint_mode(),918 <CommonError<T>>::PublicMintingNotAllowed919 );920 collection.check_allowlist(sender)?;921922 for item in data.iter() {923 for user in item.users.keys() {924 collection.check_allowlist(user)?;925 }926 }927 }928929 for item in data.iter() {930 for (owner, _) in item.users.iter() {931 <PalletCommon<T>>::ensure_correct_receiver(owner)?;932 }933 }934935 // Total pieces per tokens936 let totals = data937 .iter()938 .map(|data| {939 Ok(data940 .users941 .iter()942 .map(|u| u.1)943 .try_fold(0u128, |acc, v| acc.checked_add(*v))944 .ok_or(ArithmeticError::Overflow)?)945 })946 .collect::<Result<Vec<_>, DispatchError>>()?;947 for total in &totals {948 ensure!(949 *total <= MAX_REFUNGIBLE_PIECES,950 <Error<T>>::WrongRefungiblePieces951 );952 }953954 let first_token_id = <TokensMinted<T>>::get(collection.id);955 let tokens_minted = first_token_id956 .checked_add(data.len() as u32)957 .ok_or(ArithmeticError::Overflow)?;958 ensure!(959 tokens_minted < collection.limits.token_limit(),960 <CommonError<T>>::CollectionTokenLimitExceeded961 );962963 let mut balances = BTreeMap::new();964 for data in &data {965 for owner in data.users.keys() {966 let balance = balances967 .entry(owner)968 .or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));969 *balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;970971 ensure!(972 *balance <= collection.limits.account_token_ownership_limit(),973 <CommonError<T>>::AccountTokenLimitExceeded,974 );975 }976 }977978 for (i, token) in data.iter().enumerate() {979 let token_id = TokenId(first_token_id + i as u32 + 1);980 for (to, _) in token.users.iter() {981 <PalletStructure<T>>::check_nesting(982 sender.clone(),983 to,984 collection.id,985 token_id,986 nesting_budget,987 )?;988 }989 }990991 // =========992993 with_transaction(|| {994 for (i, data) in data.iter().enumerate() {995 let token_id = first_token_id + i as u32 + 1;996 <TotalSupply<T>>::insert((collection.id, token_id), totals[i]);997998 for (user, amount) in data.users.iter() {999 if *amount == 0 {1000 continue;1001 }1002 <Balance<T>>::insert((collection.id, token_id, &user), amount);1003 <Owned<T>>::insert((collection.id, &user, TokenId(token_id)), true);1004 <PalletStructure<T>>::nest_if_sent_to_token_unchecked(1005 user,1006 collection.id,1007 TokenId(token_id),1008 );1009 }10101011 if let Err(e) = Self::set_token_properties(1012 collection,1013 sender,1014 TokenId(token_id),1015 data.properties.clone().into_iter(),1016 true,1017 nesting_budget,1018 ) {1019 return TransactionOutcome::Rollback(Err(e));1020 }1021 }1022 TransactionOutcome::Commit(Ok(()))1023 })?;10241025 <TokensMinted<T>>::insert(collection.id, tokens_minted);10261027 for (account, balance) in balances {1028 <AccountBalance<T>>::insert((collection.id, account), balance);1029 }10301031 for (i, token) in data.into_iter().enumerate() {1032 let token_id = first_token_id + i as u32 + 1;10331034 let receivers = token1035 .users1036 .into_iter()1037 .filter(|(_, amount)| *amount > 0)1038 .collect::<Vec<_>>();10391040 if let [(user, _)] = receivers.as_slice() {1041 // if there is exactly one receiver1042 <PalletEvm<T>>::deposit_log(1043 ERC721Events::Transfer {1044 from: H160::default(),1045 to: *user.as_eth(),1046 token_id: token_id.into(),1047 }1048 .to_log(collection_id_to_address(collection.id)),1049 );1050 } else if let [_, ..] = receivers.as_slice() {1051 // if there is more than one receiver1052 <PalletEvm<T>>::deposit_log(1053 ERC721Events::Transfer {1054 from: H160::default(),1055 to: erc::ADDRESS_FOR_PARTIALLY_OWNED_TOKENS,1056 token_id: token_id.into(),1057 }1058 .to_log(collection_id_to_address(collection.id)),1059 );1060 }10611062 for (user, amount) in receivers.into_iter() {1063 <PalletEvm<T>>::deposit_log(1064 ERC20Events::Transfer {1065 from: H160::default(),1066 to: *user.as_eth(),1067 value: amount.into(),1068 }1069 .to_log(T::EvmTokenAddressMapping::token_to_address(1070 collection.id,1071 TokenId(token_id),1072 )),1073 );1074 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(1075 collection.id,1076 TokenId(token_id),1077 user,1078 amount,1079 ));1080 }1081 }1082 Ok(())1083 }10841085 pub fn set_allowance_unchecked(1086 collection: &RefungibleHandle<T>,1087 sender: &T::CrossAccountId,1088 spender: &T::CrossAccountId,1089 token: TokenId,1090 amount: u128,1091 ) {1092 if amount == 0 {1093 <Allowance<T>>::remove((collection.id, token, sender, spender));1094 } else {1095 <Allowance<T>>::insert((collection.id, token, sender, spender), amount);1096 }10971098 <PalletEvm<T>>::deposit_log(1099 ERC20Events::Approval {1100 owner: *sender.as_eth(),1101 spender: *spender.as_eth(),1102 value: amount.into(),1103 }1104 .to_log(T::EvmTokenAddressMapping::token_to_address(1105 collection.id,1106 token,1107 )),1108 );1109 <PalletCommon<T>>::deposit_event(CommonEvent::Approved(1110 collection.id,1111 token,1112 sender.clone(),1113 spender.clone(),1114 amount,1115 ))1116 }11171118 /// Set allowance for the spender to `transfer` or `burn` sender's token pieces.1119 ///1120 /// - `amount`: Amount of token pieces the spender is allowed to `transfer` or `burn.1121 pub fn set_allowance(1122 collection: &RefungibleHandle<T>,1123 sender: &T::CrossAccountId,1124 spender: &T::CrossAccountId,1125 token: TokenId,1126 amount: u128,1127 ) -> DispatchResult {1128 if collection.permissions.access() == AccessMode::AllowList {1129 collection.check_allowlist(sender)?;1130 collection.check_allowlist(spender)?;1131 }11321133 <PalletCommon<T>>::ensure_correct_receiver(spender)?;11341135 if <Balance<T>>::get((collection.id, token, sender)) < amount {1136 ensure!(1137 collection.ignores_owned_amount(sender) && Self::token_exists(collection, token),1138 <CommonError<T>>::CantApproveMoreThanOwned1139 );1140 }11411142 // =========11431144 Self::set_allowance_unchecked(collection, sender, spender, token, amount);1145 Ok(())1146 }11471148 /// Returns allowance, which should be set after transaction1149 fn check_allowed(1150 collection: &RefungibleHandle<T>,1151 spender: &T::CrossAccountId,1152 from: &T::CrossAccountId,1153 token: TokenId,1154 amount: u128,1155 nesting_budget: &dyn Budget,1156 ) -> Result<Option<u128>, DispatchError> {1157 if spender.conv_eq(from) {1158 return Ok(None);1159 }1160 if collection.permissions.access() == AccessMode::AllowList {1161 // `from`, `to` checked in [`transfer`]1162 collection.check_allowlist(spender)?;1163 }1164 if let Some(source) = T::CrossTokenAddressMapping::address_to_token(from) {1165 // TODO: should collection owner be allowed to perform this transfer?1166 ensure!(1167 <PalletStructure<T>>::check_indirectly_owned(1168 spender.clone(),1169 source.0,1170 source.1,1171 None,1172 nesting_budget1173 )?,1174 <CommonError<T>>::ApprovedValueTooLow,1175 );1176 return Ok(None);1177 }1178 let allowance =1179 <Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);11801181 // Allowance (if any) would be reduced if spender is also wallet operator1182 if <CollectionAllowance<T>>::get((collection.id, from, spender)) {1183 return Ok(allowance);1184 }11851186 if allowance.is_none() {1187 ensure!(1188 collection.ignores_allowance(spender),1189 <CommonError<T>>::ApprovedValueTooLow1190 );1191 }1192 Ok(allowance)1193 }11941195 /// Transfer RFT token pieces from one account to another.1196 ///1197 /// Same as the [`transfer`] but spender doesn't needs to be an owner of the token pieces.1198 /// The owner should set allowance for the spender to transfer pieces.1199 ///1200 /// [`transfer`]: struct.Pallet.html#method.transfer1201 pub fn transfer_from(1202 collection: &RefungibleHandle<T>,1203 spender: &T::CrossAccountId,1204 from: &T::CrossAccountId,1205 to: &T::CrossAccountId,1206 token: TokenId,1207 amount: u128,1208 nesting_budget: &dyn Budget,1209 ) -> DispatchResult {1210 let allowance =1211 Self::check_allowed(collection, spender, from, token, amount, nesting_budget)?;12121213 // =========12141215 Self::transfer(collection, from, to, token, amount, nesting_budget)?;1216 if let Some(allowance) = allowance {1217 Self::set_allowance_unchecked(collection, from, spender, token, allowance);1218 }1219 Ok(())1220 }12211222 /// Burn RFT token pieces from the account.1223 ///1224 /// Same as the [`burn`] but spender doesn't need to be an owner of the token pieces. The owner should1225 /// set allowance for the spender to burn pieces1226 ///1227 /// [`burn`]: struct.Pallet.html#method.burn1228 pub fn burn_from(1229 collection: &RefungibleHandle<T>,1230 spender: &T::CrossAccountId,1231 from: &T::CrossAccountId,1232 token: TokenId,1233 amount: u128,1234 nesting_budget: &dyn Budget,1235 ) -> DispatchResult {1236 let allowance =1237 Self::check_allowed(collection, spender, from, token, amount, nesting_budget)?;12381239 // =========12401241 Self::burn(collection, from, token, amount)?;1242 if let Some(allowance) = allowance {1243 Self::set_allowance_unchecked(collection, from, spender, token, allowance);1244 }1245 Ok(())1246 }12471248 /// Create RFT token.1249 ///1250 /// The sender should be the owner/admin of the collection or collection should be configured1251 /// to allow public minting.1252 ///1253 /// - `data`: Contains list of users who will become the owners of the token pieces and amount1254 /// of token pieces they will receive.1255 pub fn create_item(1256 collection: &RefungibleHandle<T>,1257 sender: &T::CrossAccountId,1258 data: CreateItemData<T>,1259 nesting_budget: &dyn Budget,1260 ) -> DispatchResult {1261 Self::create_multiple_items(collection, sender, vec![data], nesting_budget)1262 }12631264 /// Repartition RFT token.1265 ///1266 /// `repartition` will set token balance of the sender and total amount of token pieces.1267 /// Sender should own all of the token pieces. `repartition' could be done even if some1268 /// token pieces were burned before.1269 ///1270 /// - `amount`: Total amount of token pieces that the token will have after `repartition`.1271 pub fn repartition(1272 collection: &RefungibleHandle<T>,1273 owner: &T::CrossAccountId,1274 token: TokenId,1275 amount: u128,1276 ) -> DispatchResult {1277 ensure!(1278 amount <= MAX_REFUNGIBLE_PIECES,1279 <Error<T>>::WrongRefungiblePieces1280 );1281 ensure!(amount > 0, <CommonError<T>>::TokenValueTooLow);1282 // Ensure user owns all pieces1283 let total_pieces = Self::total_pieces(collection.id, token).unwrap_or(u128::MAX);1284 let balance = <Balance<T>>::get((collection.id, token, owner));1285 ensure!(1286 total_pieces == balance,1287 <Error<T>>::RepartitionWhileNotOwningAllPieces1288 );12891290 <Balance<T>>::insert((collection.id, token, owner), amount);1291 <TotalSupply<T>>::insert((collection.id, token), amount);12921293 if amount > total_pieces {1294 let mint_amount = amount - total_pieces;1295 <PalletEvm<T>>::deposit_log(1296 ERC20Events::Transfer {1297 from: H160::default(),1298 to: *owner.as_eth(),1299 value: mint_amount.into(),1300 }1301 .to_log(T::EvmTokenAddressMapping::token_to_address(1302 collection.id,1303 token,1304 )),1305 );1306 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(1307 collection.id,1308 token,1309 owner.clone(),1310 mint_amount,1311 ));1312 } else if total_pieces > amount {1313 let burn_amount = total_pieces - amount;1314 <PalletEvm<T>>::deposit_log(1315 ERC20Events::Transfer {1316 from: *owner.as_eth(),1317 to: H160::default(),1318 value: burn_amount.into(),1319 }1320 .to_log(T::EvmTokenAddressMapping::token_to_address(1321 collection.id,1322 token,1323 )),1324 );1325 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(1326 collection.id,1327 token,1328 owner.clone(),1329 burn_amount,1330 ));1331 }13321333 Ok(())1334 }13351336 fn token_owner(collection_id: CollectionId, token_id: TokenId) -> Option<T::CrossAccountId> {1337 let mut owner = None;1338 let mut count = 0;1339 for key in Balance::<T>::iter_key_prefix((collection_id, token_id)) {1340 count += 1;1341 if count > 1 {1342 return None;1343 }1344 owner = Some(key);1345 }1346 owner1347 }13481349 fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128> {1350 <TotalSupply<T>>::try_get((collection_id, token_id)).ok()1351 }13521353 pub fn set_collection_properties(1354 collection: &RefungibleHandle<T>,1355 sender: &T::CrossAccountId,1356 properties: Vec<Property>,1357 ) -> DispatchResult {1358 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)1359 }13601361 pub fn delete_collection_properties(1362 collection: &RefungibleHandle<T>,1363 sender: &T::CrossAccountId,1364 property_keys: Vec<PropertyKey>,1365 ) -> DispatchResult {1366 <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)1367 }13681369 pub fn set_token_property_permissions(1370 collection: &RefungibleHandle<T>,1371 sender: &T::CrossAccountId,1372 property_permissions: Vec<PropertyKeyPermission>,1373 ) -> DispatchResult {1374 <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)1375 }13761377 pub fn token_property_permission(collection_id: CollectionId) -> PropertiesPermissionMap {1378 <PalletCommon<T>>::property_permissions(collection_id)1379 }13801381 pub fn set_scoped_token_property_permissions(1382 collection: &RefungibleHandle<T>,1383 sender: &T::CrossAccountId,1384 scope: PropertyScope,1385 property_permissions: Vec<PropertyKeyPermission>,1386 ) -> DispatchResult {1387 <PalletCommon<T>>::set_scoped_token_property_permissions(1388 collection,1389 sender,1390 scope,1391 property_permissions,1392 )1393 }13941395 /// Returns 10 token in no particular order.1396 ///1397 /// There is no direct way to get token holders in ascending order,1398 /// since `iter_prefix` returns values in no particular order.1399 /// Therefore, getting the 10 largest holders with a large value of holders1400 /// can lead to impact memory allocation + sorting with `n * log (n)`.1401 pub fn token_owners(1402 collection_id: CollectionId,1403 token: TokenId,1404 ) -> Option<Vec<T::CrossAccountId>> {1405 let res: Vec<T::CrossAccountId> = <Balance<T>>::iter_prefix((collection_id, token))1406 .map(|(owner, _amount)| owner)1407 .take(10)1408 .collect();14091410 if res.is_empty() {1411 None1412 } else {1413 Some(res)1414 }1415 }14161417 /// Sets or unsets the approval of a given operator.1418 ///1419 /// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.1420 /// - `owner`: Token owner1421 /// - `operator`: Operator1422 /// - `approve`: Should operator status be granted or revoked?1423 pub fn set_allowance_for_all(1424 collection: &RefungibleHandle<T>,1425 owner: &T::CrossAccountId,1426 operator: &T::CrossAccountId,1427 approve: bool,1428 ) -> DispatchResult {1429 if collection.permissions.access() == AccessMode::AllowList {1430 collection.check_allowlist(owner)?;1431 collection.check_allowlist(operator)?;1432 }14331434 <PalletCommon<T>>::ensure_correct_receiver(operator)?;14351436 // =========14371438 <CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);1439 <PalletEvm<T>>::deposit_log(1440 ERC721Events::ApprovalForAll {1441 owner: *owner.as_eth(),1442 operator: *operator.as_eth(),1443 approved: approve,1444 }1445 .to_log(collection_id_to_address(collection.id)),1446 );1447 <PalletCommon<T>>::deposit_event(CommonEvent::ApprovedForAll(1448 collection.id,1449 owner.clone(),1450 operator.clone(),1451 approve,1452 ));1453 Ok(())1454 }14551456 /// Tells whether the given `owner` approves the `operator`.1457 pub fn allowance_for_all(1458 collection: &RefungibleHandle<T>,1459 owner: &T::CrossAccountId,1460 operator: &T::CrossAccountId,1461 ) -> bool {1462 <CollectionAllowance<T>>::get((collection.id, owner, operator))1463 }14641465 pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {1466 <TokenProperties<T>>::mutate((collection.id, token), |properties| {1467 properties.recompute_consumed_space();1468 });14691470 Ok(())1471 }1472}pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -42,7 +42,7 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple58[] memory permissions) public {
+ function setTokenPropertyPermissions(Tuple60[] memory permissions) public {
require(false, stub_error);
permissions;
dummy = 0;
@@ -51,10 +51,10 @@
/// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() public view returns (Tuple58[] memory) {
+ function tokenPropertyPermissions() public view returns (Tuple60[] memory) {
require(false, stub_error);
dummy;
- return new Tuple58[](0);
+ return new Tuple60[](0);
}
// /// @notice Set token property value.
@@ -144,13 +144,13 @@
}
/// @dev anonymous struct
-struct Tuple58 {
+struct Tuple60 {
string field_0;
- Tuple56[] field_1;
+ Tuple58[] field_1;
}
/// @dev anonymous struct
-struct Tuple56 {
+struct Tuple58 {
EthTokenPermissions field_0;
bool field_1;
}
@@ -290,10 +290,10 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
- function collectionSponsor() public view returns (Tuple29 memory) {
+ function collectionSponsor() public view returns (EthCrossAccount memory) {
require(false, stub_error);
dummy;
- return Tuple29(0x0000000000000000000000000000000000000000, 0);
+ return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
}
/// Get current collection limits.
@@ -311,10 +311,10 @@
/// Return `false` if a limit not set.
/// @dev EVM selector for this function is: 0xf63bc572,
/// or in textual repr: collectionLimits()
- function collectionLimits() public view returns (Tuple32[] memory) {
+ function collectionLimits() public view returns (Tuple34[] memory) {
require(false, stub_error);
dummy;
- return new Tuple32[](0);
+ return new Tuple34[](0);
}
/// Set limits for the collection.
@@ -422,19 +422,19 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() public view returns (Tuple38 memory) {
+ function collectionNestingRestrictedCollectionIds() public view returns (Tuple40 memory) {
require(false, stub_error);
dummy;
- return Tuple38(false, new uint256[](0));
+ return Tuple40(false, new uint256[](0));
}
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() public view returns (Tuple41[] memory) {
+ function collectionNestingPermissions() public view returns (Tuple43[] memory) {
require(false, stub_error);
dummy;
- return new Tuple41[](0);
+ return new Tuple43[](0);
}
/// Set the collection access method.
@@ -614,13 +614,13 @@
}
/// @dev anonymous struct
-struct Tuple41 {
+struct Tuple43 {
CollectionPermissions field_0;
bool field_1;
}
/// @dev anonymous struct
-struct Tuple38 {
+struct Tuple40 {
bool field_0;
uint256[] field_1;
}
@@ -648,18 +648,12 @@
}
/// @dev anonymous struct
-struct Tuple32 {
+struct Tuple34 {
CollectionLimits field_0;
bool field_1;
uint256 field_2;
}
-/// @dev anonymous struct
-struct Tuple29 {
- address field_0;
- uint256 field_1;
-}
-
/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
contract ERC721Metadata is Dummy, ERC165 {
// /// @notice A descriptive name for a collection of NFTs in this contract
@@ -733,7 +727,7 @@
return false;
}
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
/// @dev EVM selector for this function is: 0x6a627842,
@@ -745,7 +739,7 @@
return 0;
}
- // /// @notice Function to mint token.
+ // /// @notice Function to mint a token.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
// /// @param to The new owner
@@ -802,7 +796,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x12f7d6c1
+/// @dev the ERC-165 identifier for this interface is 0xabf30dc2
contract ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -979,6 +973,20 @@
// return false;
// }
+ /// @notice Function to mint a token.
+ /// @param to The new owner crossAccountId
+ /// @param properties Properties of minted token
+ /// @return uint256 The id of the newly minted token
+ /// @dev EVM selector for this function is: 0xb904db03,
+ /// or in textual repr: mintCross((address,uint256),(string,bytes)[])
+ function mintCross(EthCrossAccount memory to, Property[] memory properties) public returns (uint256) {
+ require(false, stub_error);
+ to;
+ properties;
+ dummy = 0;
+ return 0;
+ }
+
/// Returns EVM address for refungible token
///
/// @param token ID of the token
tests/src/eth/abi/contractHelpers.jsondiffbeforeafterboth--- a/tests/src/eth/abi/contractHelpers.json
+++ b/tests/src/eth/abi/contractHelpers.json
@@ -223,10 +223,10 @@
"outputs": [
{
"components": [
- { "internalType": "address", "name": "field_0", "type": "address" },
- { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
],
- "internalType": "struct Tuple0",
+ "internalType": "struct EthCrossAccount",
"name": "",
"type": "tuple"
}
tests/src/eth/abi/fungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -220,7 +220,7 @@
{ "internalType": "bool", "name": "field_1", "type": "bool" },
{ "internalType": "uint256", "name": "field_2", "type": "uint256" }
],
- "internalType": "struct Tuple20[]",
+ "internalType": "struct Tuple23[]",
"name": "",
"type": "tuple[]"
}
@@ -241,7 +241,7 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple29[]",
+ "internalType": "struct Tuple32[]",
"name": "",
"type": "tuple[]"
}
@@ -262,7 +262,7 @@
"type": "uint256[]"
}
],
- "internalType": "struct Tuple26",
+ "internalType": "struct Tuple29",
"name": "",
"type": "tuple"
}
@@ -319,10 +319,10 @@
"outputs": [
{
"components": [
- { "internalType": "address", "name": "field_0", "type": "address" },
- { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
],
- "internalType": "struct Tuple8",
+ "internalType": "struct EthCrossAccount",
"name": "",
"type": "tuple"
}
@@ -408,7 +408,7 @@
{ "internalType": "address", "name": "field_0", "type": "address" },
{ "internalType": "uint256", "name": "field_1", "type": "uint256" }
],
- "internalType": "struct Tuple8[]",
+ "internalType": "struct Tuple9[]",
"name": "amounts",
"type": "tuple[]"
}
@@ -419,6 +419,24 @@
"type": "function"
},
{
+ "inputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct EthCrossAccount",
+ "name": "to",
+ "type": "tuple"
+ },
+ { "internalType": "uint256", "name": "amount", "type": "uint256" }
+ ],
+ "name": "mintCross",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [],
"name": "name",
"outputs": [{ "internalType": "string", "name": "", "type": "string" }],
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -250,7 +250,7 @@
{ "internalType": "bool", "name": "field_1", "type": "bool" },
{ "internalType": "uint256", "name": "field_2", "type": "uint256" }
],
- "internalType": "struct Tuple33[]",
+ "internalType": "struct Tuple35[]",
"name": "",
"type": "tuple[]"
}
@@ -271,7 +271,7 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple42[]",
+ "internalType": "struct Tuple44[]",
"name": "",
"type": "tuple[]"
}
@@ -292,7 +292,7 @@
"type": "uint256[]"
}
],
- "internalType": "struct Tuple39",
+ "internalType": "struct Tuple41",
"name": "",
"type": "tuple"
}
@@ -349,10 +349,10 @@
"outputs": [
{
"components": [
- { "internalType": "address", "name": "field_0", "type": "address" },
- { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
],
- "internalType": "struct Tuple30",
+ "internalType": "struct EthCrossAccount",
"name": "",
"type": "tuple"
}
@@ -478,6 +478,32 @@
},
{
"inputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct EthCrossAccount",
+ "name": "to",
+ "type": "tuple"
+ },
+ {
+ "components": [
+ { "internalType": "string", "name": "key", "type": "string" },
+ { "internalType": "bytes", "name": "value", "type": "bytes" }
+ ],
+ "internalType": "struct Property[]",
+ "name": "properties",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "mintCross",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "string", "name": "tokenUri", "type": "string" }
],
@@ -736,12 +762,12 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple57[]",
+ "internalType": "struct Tuple59[]",
"name": "field_1",
"type": "tuple[]"
}
],
- "internalType": "struct Tuple59[]",
+ "internalType": "struct Tuple61[]",
"name": "permissions",
"type": "tuple[]"
}
@@ -802,12 +828,12 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple57[]",
+ "internalType": "struct Tuple59[]",
"name": "field_1",
"type": "tuple[]"
}
],
- "internalType": "struct Tuple59[]",
+ "internalType": "struct Tuple61[]",
"name": "",
"type": "tuple[]"
}
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -232,7 +232,7 @@
{ "internalType": "bool", "name": "field_1", "type": "bool" },
{ "internalType": "uint256", "name": "field_2", "type": "uint256" }
],
- "internalType": "struct Tuple32[]",
+ "internalType": "struct Tuple34[]",
"name": "",
"type": "tuple[]"
}
@@ -253,7 +253,7 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple41[]",
+ "internalType": "struct Tuple43[]",
"name": "",
"type": "tuple[]"
}
@@ -274,7 +274,7 @@
"type": "uint256[]"
}
],
- "internalType": "struct Tuple38",
+ "internalType": "struct Tuple40",
"name": "",
"type": "tuple"
}
@@ -331,10 +331,10 @@
"outputs": [
{
"components": [
- { "internalType": "address", "name": "field_0", "type": "address" },
- { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
],
- "internalType": "struct Tuple29",
+ "internalType": "struct EthCrossAccount",
"name": "",
"type": "tuple"
}
@@ -460,6 +460,32 @@
},
{
"inputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "eth", "type": "address" },
+ { "internalType": "uint256", "name": "sub", "type": "uint256" }
+ ],
+ "internalType": "struct EthCrossAccount",
+ "name": "to",
+ "type": "tuple"
+ },
+ {
+ "components": [
+ { "internalType": "string", "name": "key", "type": "string" },
+ { "internalType": "bytes", "name": "value", "type": "bytes" }
+ ],
+ "internalType": "struct Property[]",
+ "name": "properties",
+ "type": "tuple[]"
+ }
+ ],
+ "name": "mintCross",
+ "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "string", "name": "tokenUri", "type": "string" }
],
@@ -718,12 +744,12 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple56[]",
+ "internalType": "struct Tuple58[]",
"name": "field_1",
"type": "tuple[]"
}
],
- "internalType": "struct Tuple58[]",
+ "internalType": "struct Tuple60[]",
"name": "permissions",
"type": "tuple[]"
}
@@ -793,12 +819,12 @@
},
{ "internalType": "bool", "name": "field_1", "type": "bool" }
],
- "internalType": "struct Tuple56[]",
+ "internalType": "struct Tuple58[]",
"name": "field_1",
"type": "tuple[]"
}
],
- "internalType": "struct Tuple58[]",
+ "internalType": "struct Tuple60[]",
"name": "",
"type": "tuple[]"
}
tests/src/eth/api/ContractHelpers.soldiffbeforeafterboth--- a/tests/src/eth/api/ContractHelpers.sol
+++ b/tests/src/eth/api/ContractHelpers.sol
@@ -69,7 +69,7 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x766c4f37,
/// or in textual repr: sponsor(address)
- function sponsor(address contractAddress) external view returns (Tuple0 memory);
+ function sponsor(address contractAddress) external view returns (EthCrossAccount memory);
/// Check tat contract has confirmed sponsor.
///
@@ -171,8 +171,8 @@
function toggleAllowlist(address contractAddress, bool enabled) external;
}
-/// @dev anonymous struct
-struct Tuple0 {
- address field_0;
- uint256 field_1;
+/// @dev Cross account struct
+struct EthCrossAccount {
+ address eth;
+ uint256 sub;
}
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -102,7 +102,7 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
- function collectionSponsor() external view returns (Tuple8 memory);
+ function collectionSponsor() external view returns (EthCrossAccount memory);
/// Get current collection limits.
///
@@ -119,7 +119,7 @@
/// Return `false` if a limit not set.
/// @dev EVM selector for this function is: 0xf63bc572,
/// or in textual repr: collectionLimits()
- function collectionLimits() external view returns (Tuple19[] memory);
+ function collectionLimits() external view returns (Tuple21[] memory);
/// Set limits for the collection.
/// @dev Throws error if limit not found.
@@ -191,12 +191,12 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() external view returns (Tuple24 memory);
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple26 memory);
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() external view returns (Tuple27[] memory);
+ function collectionNestingPermissions() external view returns (Tuple29[] memory);
/// Set the collection access method.
/// @param mode Access mode
@@ -311,7 +311,7 @@
}
/// @dev anonymous struct
-struct Tuple27 {
+struct Tuple29 {
CollectionPermissions field_0;
bool field_1;
}
@@ -322,7 +322,7 @@
}
/// @dev anonymous struct
-struct Tuple24 {
+struct Tuple26 {
bool field_0;
uint256[] field_1;
}
@@ -350,7 +350,7 @@
}
/// @dev anonymous struct
-struct Tuple19 {
+struct Tuple21 {
CollectionLimits field_0;
bool field_1;
uint256 field_2;
@@ -362,13 +362,17 @@
bytes value;
}
-/// @dev the ERC-165 identifier for this interface is 0x5b7038cf
+/// @dev the ERC-165 identifier for this interface is 0x7dee5997
interface ERC20UniqueExtensions is Dummy, ERC165 {
/// @notice A description for the collection.
/// @dev EVM selector for this function is: 0x7284e416,
/// or in textual repr: description()
function description() external view returns (string memory);
+ /// @dev EVM selector for this function is: 0x269e6158,
+ /// or in textual repr: mintCross((address,uint256),uint256)
+ function mintCross(EthCrossAccount memory to, uint256 amount) external returns (bool);
+
/// @dev EVM selector for this function is: 0x0ecd0ab0,
/// or in textual repr: approveCross((address,uint256),uint256)
function approveCross(EthCrossAccount memory spender, uint256 amount) external returns (bool);
@@ -395,7 +399,7 @@
/// @param amounts array of pairs of account address and amount
/// @dev EVM selector for this function is: 0x1acf2d55,
/// or in textual repr: mintBulk((address,uint256)[])
- function mintBulk(Tuple8[] memory amounts) external returns (bool);
+ function mintBulk(Tuple9[] memory amounts) external returns (bool);
/// @dev EVM selector for this function is: 0x2ada85ff,
/// or in textual repr: transferCross((address,uint256),uint256)
@@ -411,7 +415,7 @@
}
/// @dev anonymous struct
-struct Tuple8 {
+struct Tuple9 {
address field_0;
uint256 field_1;
}
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -30,12 +30,12 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple52[] memory permissions) external;
+ function setTokenPropertyPermissions(Tuple53[] memory permissions) external;
/// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() external view returns (Tuple52[] memory);
+ function tokenPropertyPermissions() external view returns (Tuple53[] memory);
// /// @notice Set token property value.
// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -97,13 +97,13 @@
}
/// @dev anonymous struct
-struct Tuple52 {
+struct Tuple53 {
string field_0;
- Tuple50[] field_1;
+ Tuple51[] field_1;
}
/// @dev anonymous struct
-struct Tuple50 {
+struct Tuple51 {
EthTokenPermissions field_0;
bool field_1;
}
@@ -198,7 +198,7 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
- function collectionSponsor() external view returns (Tuple27 memory);
+ function collectionSponsor() external view returns (EthCrossAccount memory);
/// Get current collection limits.
///
@@ -215,7 +215,7 @@
/// Return `false` if a limit not set.
/// @dev EVM selector for this function is: 0xf63bc572,
/// or in textual repr: collectionLimits()
- function collectionLimits() external view returns (Tuple30[] memory);
+ function collectionLimits() external view returns (Tuple31[] memory);
/// Set limits for the collection.
/// @dev Throws error if limit not found.
@@ -287,12 +287,12 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() external view returns (Tuple35 memory);
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple36 memory);
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() external view returns (Tuple38[] memory);
+ function collectionNestingPermissions() external view returns (Tuple39[] memory);
/// Set the collection access method.
/// @param mode Access mode
@@ -407,7 +407,7 @@
}
/// @dev anonymous struct
-struct Tuple38 {
+struct Tuple39 {
CollectionPermissions field_0;
bool field_1;
}
@@ -418,7 +418,7 @@
}
/// @dev anonymous struct
-struct Tuple35 {
+struct Tuple36 {
bool field_0;
uint256[] field_1;
}
@@ -446,18 +446,12 @@
}
/// @dev anonymous struct
-struct Tuple30 {
+struct Tuple31 {
CollectionLimits field_0;
bool field_1;
uint256 field_2;
}
-/// @dev anonymous struct
-struct Tuple27 {
- address field_0;
- uint256 field_1;
-}
-
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
@@ -512,14 +506,14 @@
/// or in textual repr: mintingFinished()
function mintingFinished() external view returns (bool);
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
/// @dev EVM selector for this function is: 0x6a627842,
/// or in textual repr: mint(address)
function mint(address to) external returns (uint256);
- // /// @notice Function to mint token.
+ // /// @notice Function to mint a token.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
// /// @param to The new owner
@@ -553,7 +547,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xb74c26b7
+/// @dev the ERC-165 identifier for this interface is 0x0e48fdb4
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -652,6 +646,7 @@
/// @dev EVM selector for this function is: 0x75794a3c,
/// or in textual repr: nextTokenId()
function nextTokenId() external view returns (uint256);
+
// /// @notice Function to mint multiple tokens.
// /// @dev `tokenIds` should be an array of consecutive numbers and first number
// /// should be obtained with `nextTokenId` method
@@ -670,6 +665,13 @@
// /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
// function mintBulkWithTokenURI(address to, Tuple13[] memory tokens) external returns (bool);
+ /// @notice Function to mint a token.
+ /// @param to The new owner crossAccountId
+ /// @param properties Properties of minted token
+ /// @return uint256 The id of the newly minted token
+ /// @dev EVM selector for this function is: 0xb904db03,
+ /// or in textual repr: mintCross((address,uint256),(string,bytes)[])
+ function mintCross(EthCrossAccount memory to, Property[] memory properties) external returns (uint256);
}
/// @dev anonymous struct
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -30,12 +30,12 @@
/// @param permissions Permissions for keys.
/// @dev EVM selector for this function is: 0xbd92983a,
/// or in textual repr: setTokenPropertyPermissions((string,(uint8,bool)[])[])
- function setTokenPropertyPermissions(Tuple51[] memory permissions) external;
+ function setTokenPropertyPermissions(Tuple52[] memory permissions) external;
/// @notice Get permissions for token properties.
/// @dev EVM selector for this function is: 0xf23d7790,
/// or in textual repr: tokenPropertyPermissions()
- function tokenPropertyPermissions() external view returns (Tuple51[] memory);
+ function tokenPropertyPermissions() external view returns (Tuple52[] memory);
// /// @notice Set token property value.
// /// @dev Throws error if `msg.sender` has no permission to edit the property.
@@ -97,13 +97,13 @@
}
/// @dev anonymous struct
-struct Tuple51 {
+struct Tuple52 {
string field_0;
- Tuple49[] field_1;
+ Tuple50[] field_1;
}
/// @dev anonymous struct
-struct Tuple49 {
+struct Tuple50 {
EthTokenPermissions field_0;
bool field_1;
}
@@ -198,7 +198,7 @@
/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
/// @dev EVM selector for this function is: 0x6ec0a9f1,
/// or in textual repr: collectionSponsor()
- function collectionSponsor() external view returns (Tuple26 memory);
+ function collectionSponsor() external view returns (EthCrossAccount memory);
/// Get current collection limits.
///
@@ -215,7 +215,7 @@
/// Return `false` if a limit not set.
/// @dev EVM selector for this function is: 0xf63bc572,
/// or in textual repr: collectionLimits()
- function collectionLimits() external view returns (Tuple29[] memory);
+ function collectionLimits() external view returns (Tuple30[] memory);
/// Set limits for the collection.
/// @dev Throws error if limit not found.
@@ -287,12 +287,12 @@
/// Returns nesting for a collection
/// @dev EVM selector for this function is: 0x22d25bfe,
/// or in textual repr: collectionNestingRestrictedCollectionIds()
- function collectionNestingRestrictedCollectionIds() external view returns (Tuple34 memory);
+ function collectionNestingRestrictedCollectionIds() external view returns (Tuple35 memory);
/// Returns permissions for a collection
/// @dev EVM selector for this function is: 0x5b2eaf4b,
/// or in textual repr: collectionNestingPermissions()
- function collectionNestingPermissions() external view returns (Tuple37[] memory);
+ function collectionNestingPermissions() external view returns (Tuple38[] memory);
/// Set the collection access method.
/// @param mode Access mode
@@ -407,7 +407,7 @@
}
/// @dev anonymous struct
-struct Tuple37 {
+struct Tuple38 {
CollectionPermissions field_0;
bool field_1;
}
@@ -418,7 +418,7 @@
}
/// @dev anonymous struct
-struct Tuple34 {
+struct Tuple35 {
bool field_0;
uint256[] field_1;
}
@@ -446,18 +446,12 @@
}
/// @dev anonymous struct
-struct Tuple29 {
+struct Tuple30 {
CollectionLimits field_0;
bool field_1;
uint256 field_2;
}
-/// @dev anonymous struct
-struct Tuple26 {
- address field_0;
- uint256 field_1;
-}
-
/// @dev the ERC-165 identifier for this interface is 0x5b5e139f
interface ERC721Metadata is Dummy, ERC165 {
// /// @notice A descriptive name for a collection of NFTs in this contract
@@ -510,14 +504,14 @@
/// or in textual repr: mintingFinished()
function mintingFinished() external view returns (bool);
- /// @notice Function to mint token.
+ /// @notice Function to mint a token.
/// @param to The new owner
/// @return uint256 The id of the newly minted token
/// @dev EVM selector for this function is: 0x6a627842,
/// or in textual repr: mint(address)
function mint(address to) external returns (uint256);
- // /// @notice Function to mint token.
+ // /// @notice Function to mint a token.
// /// @dev `tokenId` should be obtained with `nextTokenId` method,
// /// unlike standard, you can't specify it manually
// /// @param to The new owner
@@ -551,7 +545,7 @@
}
/// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x12f7d6c1
+/// @dev the ERC-165 identifier for this interface is 0xabf30dc2
interface ERC721UniqueExtensions is Dummy, ERC165 {
/// @notice A descriptive name for a collection of NFTs in this contract
/// @dev EVM selector for this function is: 0x06fdde03,
@@ -663,6 +657,14 @@
// /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
// function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);
+ /// @notice Function to mint a token.
+ /// @param to The new owner crossAccountId
+ /// @param properties Properties of minted token
+ /// @return uint256 The id of the newly minted token
+ /// @dev EVM selector for this function is: 0xb904db03,
+ /// or in textual repr: mintCross((address,uint256),(string,bytes)[])
+ function mintCross(EthCrossAccount memory to, Property[] memory properties) external returns (uint256);
+
/// Returns EVM address for refungible token
///
/// @param token ID of the token
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -116,7 +116,7 @@
await checkInterface(helper, '0x780e9d63', true, true);
});
- itEth('ERC721UniqueExtensions support', async ({helper}) => {
+ itEth.skip('ERC721UniqueExtensions support', async ({helper}) => {
await checkInterface(helper, '0xb74c26b7', true, true);
});
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -106,7 +106,7 @@
await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
const sponsorTuple = await collectionEvm.methods.collectionSponsor().call({from: owner});
- expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
+ expect(sponsorTuple.eth).to.be.eq('0x0000000000000000000000000000000000000000');
}));
[
tests/src/eth/fungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -57,7 +57,7 @@
before(async function() {
await usingEthPlaygrounds(async (helper, privateKey) => {
donor = await privateKey({filename: __filename});
- [alice, owner] = await helper.arrange.createAccounts([20n, 20n], donor);
+ [alice, owner] = await helper.arrange.createAccounts([30n, 20n], donor);
});
});
@@ -78,6 +78,25 @@
expect(event.returnValues.to).to.equal(receiver);
expect(event.returnValues.value).to.equal('100');
});
+
+
+ itEth('Can perform mintCross()', async ({helper}) => {
+ const receiverCross = helper.ethCrossAccount.fromKeyringPair(owner);
+ const ethOwner = await helper.eth.createAccountWithBalance(donor);
+ const collection = await helper.ft.mintCollection(alice);
+ await collection.addAdmin(alice, {Ethereum: ethOwner});
+
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const contract = helper.ethNativeContract.collection(collectionAddress, 'ft', ethOwner);
+
+ const result = await contract.methods.mintCross(receiverCross, 100).send();
+
+ const event = result.events.Transfer;
+ expect(event.address).to.equal(collectionAddress);
+ expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.equal(helper.address.substrateToEth(owner.address));
+ expect(event.returnValues.value).to.equal('100');
+ });
itEth('Can perform mintBulk()', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/eth/nesting/nest.test.ts
+++ b/tests/src/eth/nesting/nest.test.ts
@@ -62,9 +62,9 @@
expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, []]);
await contract.methods.setCollectionNesting(true, [unnsetedCollectionAddress]).send({from: owner});
expect(await contract.methods.collectionNestingRestrictedCollectionIds().call({from: owner})).to.be.like([true, [unnestedCollsectionId.toString()]]);
- expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['0', false], ['1', true]]);
+ expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['1', false], ['0', true]]);
await contract.methods.setCollectionNesting(false).send({from: owner});
- expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['0', false], ['1', false]]);
+ expect(await contract.methods.collectionNestingPermissions().call({from: owner})).to.be.like([['1', false], ['0', false]]);
});
itEth('NFT: allows an Owner to nest/unnest their token (Restricted nesting)', async ({helper}) => {
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -17,6 +17,7 @@
import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
+import {ITokenPropertyPermission} from '../util/playgrounds/types';
describe('NFT: Information getting', () => {
@@ -173,7 +174,58 @@
// const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
// expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);
});
+
+ itEth('Can perform mintCross()', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);
+ const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
+ const permissions: ITokenPropertyPermission[] = properties
+ .map(p => {
+ return {
+ key: p.key, permission: {
+ tokenOwner: true,
+ collectionAdmin: true,
+ mutable: true,
+ },
+ };
+ });
+
+
+ const collection = await helper.nft.mintCollection(minter, {
+ tokenPrefix: 'ethp',
+ tokenPropertyPermissions: permissions,
+ });
+ await collection.addAdmin(minter, {Ethereum: caller});
+
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', caller, true);
+ let expectedTokenId = await contract.methods.nextTokenId().call();
+ let result = await contract.methods.mintCross(receiverCross, []).send();
+ let tokenId = result.events.Transfer.returnValues.tokenId;
+ expect(tokenId).to.be.equal(expectedTokenId);
+
+ let event = result.events.Transfer;
+ expect(event.address).to.be.equal(collectionAddress);
+ expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(bob.address));
+ expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);
+
+ expectedTokenId = await contract.methods.nextTokenId().call();
+ result = await contract.methods.mintCross(receiverCross, properties).send();
+ event = result.events.Transfer;
+ expect(event.address).to.be.equal(collectionAddress);
+ expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(bob.address));
+ expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);
+
+ tokenId = result.events.Transfer.returnValues.tokenId;
+
+ expect(tokenId).to.be.equal(expectedTokenId);
+ expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
+ .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+ });
+
//TODO: CORE-302 add eth methods
itEth.skip('Can perform mintBulk()', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -17,6 +17,7 @@
import {Pallets, requirePalletsOrSkip} from '../util';
import {expect, itEth, usingEthPlaygrounds} from './util';
import {IKeyringPair} from '@polkadot/types/types';
+import {ITokenPropertyPermission} from '../util/playgrounds/types';
describe('Refungible: Information getting', () => {
let donor: IKeyringPair;
@@ -135,6 +136,50 @@
expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
});
+
+ itEth('Can perform mintCross()', async ({helper}) => {
+ const caller = await helper.eth.createAccountWithBalance(donor);
+ const receiverCross = helper.ethCrossAccount.fromKeyringPair(bob);
+ const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
+ const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
+ collectionAdmin: true,
+ mutable: true}}; });
+
+
+ const collection = await helper.rft.mintCollection(minter, {
+ tokenPrefix: 'ethp',
+ tokenPropertyPermissions: permissions,
+ });
+ await collection.addAdmin(minter, {Ethereum: caller});
+
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller, true);
+ let expectedTokenId = await contract.methods.nextTokenId().call();
+ let result = await contract.methods.mintCross(receiverCross, []).send();
+ let tokenId = result.events.Transfer.returnValues.tokenId;
+ expect(tokenId).to.be.equal(expectedTokenId);
+
+ let event = result.events.Transfer;
+ expect(event.address).to.be.equal(collectionAddress);
+ expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(bob.address));
+ expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);
+
+ expectedTokenId = await contract.methods.nextTokenId().call();
+ result = await contract.methods.mintCross(receiverCross, properties).send();
+ event = result.events.Transfer;
+ expect(event.address).to.be.equal(collectionAddress);
+ expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');
+ expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(bob.address));
+ expect(await contract.methods.properties(tokenId, []).call()).to.be.like([]);
+
+ tokenId = result.events.Transfer.returnValues.tokenId;
+
+ expect(tokenId).to.be.equal(expectedTokenId);
+
+ expect(await contract.methods.properties(tokenId, []).call()).to.be.like(properties
+ .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
+ });
itEth.skip('Can perform mintBulk()', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
tests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth--- a/tests/src/interfaces/augment-api-consts.ts
+++ b/tests/src/interfaces/augment-api-consts.ts
@@ -83,7 +83,7 @@
dayRelayBlocks: u32 & AugmentedConst<ApiType>;
defaultMinGasPrice: u64 & AugmentedConst<ApiType>;
defaultWeightToFeeCoefficient: u32 & AugmentedConst<ApiType>;
- maxOverridedAllowedLocations: u32 & AugmentedConst<ApiType>;
+ maxXcmAllowedLocations: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/