difftreelog
Merge remote-tracking branch 'origin/feature/add_collection_sponsor_substrate' into develop
in: master
32 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5510,7 +5510,7 @@
[[package]]
name = "pallet-common"
-version = "0.1.7"
+version = "0.1.8"
dependencies = [
"ethereum",
"evm-coder",
@@ -5748,7 +5748,7 @@
[[package]]
name = "pallet-fungible"
-version = "0.1.3"
+version = "0.1.4"
dependencies = [
"ethereum",
"evm-coder",
@@ -5990,7 +5990,7 @@
[[package]]
name = "pallet-nonfungible"
-version = "0.1.4"
+version = "0.1.5"
dependencies = [
"ethereum",
"evm-coder",
@@ -6112,7 +6112,7 @@
[[package]]
name = "pallet-refungible"
-version = "0.2.3"
+version = "0.2.4"
dependencies = [
"derivative",
"ethereum",
crates/evm-coder/CHANGELOG.mddiffbeforeafterboth--- a/crates/evm-coder/CHANGELOG.md
+++ b/crates/evm-coder/CHANGELOG.md
@@ -1,6 +1,8 @@
# Change Log
All notable changes to this project will be documented in this file.
+
+<!-- bureaucrate goes here -->
## [v0.1.2] 2022-08-19
### Added
crates/evm-coder/src/solidity.rsdiffbeforeafterboth--- a/crates/evm-coder/src/solidity.rs
+++ b/crates/evm-coder/src/solidity.rs
@@ -479,7 +479,7 @@
}
}
-#[impl_for_tuples(0, 24)]
+#[impl_for_tuples(0, 48)]
impl SolidityFunctions for Tuple {
for_tuples!( where #( Tuple: SolidityFunctions ),* );
pallets/common/CHANGELOG.mddiffbeforeafterboth--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -2,6 +2,16 @@
All notable changes to this project will be documented in this file.
+## [0.1.8] - 2022-08-24
+
+## Added
+ - Eth methods for collection
+ + set_collection_sponsor_substrate
+ + has_collection_pending_sponsor
+ + remove_collection_sponsor
+ + get_collection_sponsor
+- Add convert function from `uint256` to `CrossAccountId`.
+
## [0.1.7] - 2022-08-19
### Added
pallets/common/Cargo.tomldiffbeforeafterboth--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pallet-common"
-version = "0.1.7"
+version = "0.1.8"
license = "GPLv3"
edition = "2021"
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -26,13 +26,13 @@
use sp_std::vec::Vec;
use up_data_structs::{
AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,
- SponsoringRateLimit,
+ SponsoringRateLimit, SponsorshipState,
};
use alloc::format;
use crate::{
Pallet, CollectionHandle, Config, CollectionProperties,
- eth::convert_substrate_address_to_cross_account_id,
+ eth::{convert_cross_account_to_uint256, convert_uint256_to_cross_account},
};
/// Events for ethereum collection helper.
@@ -63,7 +63,7 @@
#[solidity_interface(name = Collection)]
impl<T: Config> CollectionHandle<T>
where
- T::AccountId: From<[u8; 32]>,
+ T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
{
/// Set collection property.
///
@@ -128,6 +128,32 @@
save(self)
}
+ /// Set the substrate sponsor of the collection.
+ ///
+ /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ ///
+ /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
+ fn set_collection_sponsor_substrate(
+ &mut self,
+ caller: caller,
+ sponsor: uint256,
+ ) -> Result<void> {
+ check_is_owner_or_admin(caller, self)?;
+
+ let sponsor = convert_uint256_to_cross_account::<T>(sponsor);
+ self.set_sponsor(sponsor.as_sub().clone())
+ .map_err(dispatch_to_evm::<T>)?;
+ save(self)
+ }
+
+ // /// Whether there is a pending sponsor.
+ fn has_collection_pending_sponsor(&self) -> Result<bool> {
+ Ok(matches!(
+ self.collection.sponsorship,
+ SponsorshipState::Unconfirmed(_)
+ ))
+ }
+
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
@@ -142,6 +168,32 @@
save(self)
}
+ /// Remove collection sponsor.
+ fn remove_collection_sponsor(&mut self, caller: caller) -> Result<void> {
+ check_is_owner_or_admin(caller, self)?;
+ self.remove_sponsor().map_err(dispatch_to_evm::<T>)?;
+ save(self)
+ }
+
+ /// 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 get_collection_sponsor(&self) -> Result<(address, uint256)> {
+ 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)
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -235,7 +287,7 @@
new_admin: uint256,
) -> Result<void> {
let caller = T::CrossAccountId::from_eth(caller);
- let new_admin = convert_substrate_address_to_cross_account_id::<T>(new_admin);
+ let new_admin = convert_uint256_to_cross_account::<T>(new_admin);
<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -248,7 +300,7 @@
admin: uint256,
) -> Result<void> {
let caller = T::CrossAccountId::from_eth(caller);
- let admin = convert_substrate_address_to_cross_account_id::<T>(admin);
+ let admin = convert_uint256_to_cross_account::<T>(admin);
<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -422,7 +474,7 @@
/// @param user account to verify
/// @return "true" if account is the owner or admin
fn is_owner_or_admin_substrate(&self, user: uint256) -> Result<bool> {
- let user = convert_substrate_address_to_cross_account_id::<T>(user);
+ let user = convert_uint256_to_cross_account::<T>(user);
Ok(self.is_owner_or_admin(&user))
}
@@ -455,7 +507,7 @@
/// @param newOwner new owner substrate account
fn set_owner_substrate(&mut self, caller: caller, new_owner: uint256) -> Result<void> {
let caller = T::CrossAccountId::from_eth(caller);
- let new_owner = convert_substrate_address_to_cross_account_id::<T>(new_owner);
+ let new_owner = convert_uint256_to_cross_account::<T>(new_owner);
self.set_owner_internal(caller, new_owner)
.map_err(dispatch_to_evm::<T>)
}
pallets/common/src/eth.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -59,15 +59,13 @@
uint256::from_big_endian(slice)
}
-/// Converts Substrate address to CrossAccountId
-pub fn convert_substrate_address_to_cross_account_id<T: Config>(
- address: uint256,
-) -> T::CrossAccountId
+/// Convert `uint256` to `CrossAccountId`.
+pub fn convert_uint256_to_cross_account<T: Config>(from: uint256) -> T::CrossAccountId
where
T::AccountId: From<[u8; 32]>,
{
- let mut address_arr: [u8; 32] = Default::default();
- address.to_big_endian(&mut address_arr);
- let account_id = T::AccountId::from(address_arr);
+ let mut new_admin_arr = [0_u8; 32];
+ from.to_big_endian(&mut new_admin_arr);
+ let account_id = T::AccountId::from(new_admin_arr);
T::CrossAccountId::from_sub(account_id)
}
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -231,6 +231,12 @@
Ok(true)
}
+ /// Remove collection sponsor.
+ pub fn remove_sponsor(&mut self) -> DispatchResult {
+ self.collection.sponsorship = SponsorshipState::Disabled;
+ Ok(())
+ }
+
/// Checks that the collection was created with, and must be operated upon through **Unique API**.
/// Now check only the `external_collection` flag and if it's **true**, then return [`Error::CollectionIsExternal`] error.
pub fn check_is_internal(&self) -> DispatchResult {
@@ -732,12 +738,7 @@
/// Get the effective limits for the collection.
pub fn effective_collection_limits(collection: CollectionId) -> Option<CollectionLimits> {
- let collection = <CollectionById<T>>::get(collection);
- if collection.is_none() {
- return None;
- }
-
- let collection = collection.unwrap();
+ let collection = <CollectionById<T>>::get(collection)?;
let limits = collection.limits;
let effective_limits = CollectionLimits {
account_token_ownership_limit: Some(limits.account_token_ownership_limit()),
pallets/fungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
+## [v0.1.4] - 2022-08-24
+
+### Change
+ - Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.
+
<!-- bureaucrate goes here -->
## [v0.1.3] 2022-08-16
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.3"
+version = "0.1.4"
license = "GPLv3"
edition = "2021"
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -154,14 +154,14 @@
Collection(common_mut, CollectionHandle<T>),
)
)]
-impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> {}
+impl<T: Config> FungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}
generate_stubgen!(gen_impl, UniqueFungibleCall<()>, true);
generate_stubgen!(gen_iface, UniqueFungibleCall<()>, false);
impl<T: Config> CommonEvmHandler for FungibleHandle<T>
where
- T::AccountId: From<[u8; 32]>,
+ T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
{
const CODE: &'static [u8] = include_bytes!("./stubs/UniqueFungible.raw");
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
@@ -22,7 +22,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xffe4da23
+/// @dev the ERC-165 identifier for this interface is 0xe54be640
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -82,6 +82,27 @@
dummy = 0;
}
+ /// Set the substrate sponsor of the collection.
+ ///
+ /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ ///
+ /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
+ /// @dev EVM selector for this function is: 0xc74d6751,
+ /// or in textual repr: setCollectionSponsorSubstrate(uint256)
+ function setCollectionSponsorSubstrate(uint256 sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ /// @dev EVM selector for this function is: 0x058ac185,
+ /// or in textual repr: hasCollectionPendingSponsor()
+ function hasCollectionPendingSponsor() public view returns (bool) {
+ require(false, stub_error);
+ dummy;
+ return false;
+ }
+
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
@@ -92,6 +113,25 @@
dummy = 0;
}
+ /// Remove collection sponsor.
+ /// @dev EVM selector for this function is: 0x6e0326a3,
+ /// or in textual repr: removeCollectionSponsor()
+ function removeCollectionSponsor() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ /// Get current sponsor.
+ ///
+ /// @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: 0xb66bbc14,
+ /// or in textual repr: getCollectionSponsor()
+ function getCollectionSponsor() public view returns (Tuple6 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple6(0x0000000000000000000000000000000000000000, 0);
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -310,6 +350,12 @@
}
}
+/// @dev anonymous struct
+struct Tuple6 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @dev the ERC-165 identifier for this interface is 0x79cc6790
contract ERC20UniqueExtensions is Dummy, ERC165 {
/// @dev EVM selector for this function is: 0x79cc6790,
pallets/nonfungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
+## [v0.1.5] - 2022-08-24
+
+### Change
+ - Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.
+
<!-- bureaucrate goes here -->
## [v0.1.4] 2022-08-16
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.4"
+version = "0.1.5"
license = "GPLv3"
edition = "2021"
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -740,7 +740,7 @@
TokenProperties,
)
)]
-impl<T: Config> NonfungibleHandle<T> where T::AccountId: From<[u8; 32]> {}
+impl<T: Config> NonfungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}
// Not a tests, but code generators
generate_stubgen!(gen_impl, UniqueNFTCall<()>, true);
@@ -748,7 +748,7 @@
impl<T: Config> CommonEvmHandler for NonfungibleHandle<T>
where
- T::AccountId: From<[u8; 32]>,
+ T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
{
const CODE: &'static [u8] = include_bytes!("./stubs/UniqueNFT.raw");
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
@@ -99,7 +99,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xffe4da23
+/// @dev the ERC-165 identifier for this interface is 0xe54be640
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -159,6 +159,27 @@
dummy = 0;
}
+ /// Set the substrate sponsor of the collection.
+ ///
+ /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ ///
+ /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
+ /// @dev EVM selector for this function is: 0xc74d6751,
+ /// or in textual repr: setCollectionSponsorSubstrate(uint256)
+ function setCollectionSponsorSubstrate(uint256 sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ /// @dev EVM selector for this function is: 0x058ac185,
+ /// or in textual repr: hasCollectionPendingSponsor()
+ function hasCollectionPendingSponsor() public view returns (bool) {
+ require(false, stub_error);
+ dummy;
+ return false;
+ }
+
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
@@ -169,6 +190,25 @@
dummy = 0;
}
+ /// Remove collection sponsor.
+ /// @dev EVM selector for this function is: 0x6e0326a3,
+ /// or in textual repr: removeCollectionSponsor()
+ function removeCollectionSponsor() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ /// Get current sponsor.
+ ///
+ /// @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: 0xb66bbc14,
+ /// or in textual repr: getCollectionSponsor()
+ function getCollectionSponsor() public view returns (Tuple17 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple17(0x0000000000000000000000000000000000000000, 0);
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -387,6 +427,12 @@
}
}
+/// @dev anonymous struct
+struct Tuple17 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @title ERC721 Token that can be irreversibly burned (destroyed).
/// @dev the ERC-165 identifier for this interface is 0x42966c68
contract ERC721Burnable is Dummy, ERC165 {
pallets/refungible/CHANGELOG.mddiffbeforeafterboth--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
+## [v0.2.4] - 2022-08-24
+
+### Change
+ - Add bound `AsRef<[u8; 32]>` to `T::CrossAccountId`.
+
<!-- bureaucrate goes here -->
## [v0.2.3] 2022-08-16
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.3"
+version = "0.2.4"
license = "GPLv3"
edition = "2021"
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -789,7 +789,7 @@
TokenProperties,
)
)]
-impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> {}
+impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}
// Not a tests, but code generators
generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);
@@ -797,7 +797,7 @@
impl<T: Config> CommonEvmHandler for RefungibleHandle<T>
where
- T::AccountId: From<[u8; 32]>,
+ T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
{
const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");
fn call(
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
@@ -99,7 +99,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xffe4da23
+/// @dev the ERC-165 identifier for this interface is 0xe54be640
contract Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -159,6 +159,27 @@
dummy = 0;
}
+ /// Set the substrate sponsor of the collection.
+ ///
+ /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ ///
+ /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
+ /// @dev EVM selector for this function is: 0xc74d6751,
+ /// or in textual repr: setCollectionSponsorSubstrate(uint256)
+ function setCollectionSponsorSubstrate(uint256 sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ /// @dev EVM selector for this function is: 0x058ac185,
+ /// or in textual repr: hasCollectionPendingSponsor()
+ function hasCollectionPendingSponsor() public view returns (bool) {
+ require(false, stub_error);
+ dummy;
+ return false;
+ }
+
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
@@ -169,6 +190,25 @@
dummy = 0;
}
+ /// Remove collection sponsor.
+ /// @dev EVM selector for this function is: 0x6e0326a3,
+ /// or in textual repr: removeCollectionSponsor()
+ function removeCollectionSponsor() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ /// Get current sponsor.
+ ///
+ /// @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: 0xb66bbc14,
+ /// or in textual repr: getCollectionSponsor()
+ function getCollectionSponsor() public view returns (Tuple17 memory) {
+ require(false, stub_error);
+ dummy;
+ return Tuple17(0x0000000000000000000000000000000000000000, 0);
+ }
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -387,6 +427,12 @@
}
}
+/// @dev anonymous struct
+struct Tuple17 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @title ERC721 Token that can be irreversibly burned (destroyed).
/// @dev the ERC-165 identifier for this interface is 0x42966c68
contract ERC721Burnable is Dummy, ERC165 {
runtime/common/dispatch.rsdiffbeforeafterboth--- a/runtime/common/dispatch.rs
+++ b/runtime/common/dispatch.rs
@@ -124,7 +124,7 @@
+ pallet_fungible::Config
+ pallet_nonfungible::Config
+ pallet_refungible::Config,
- T::AccountId: From<[u8; 32]>,
+ T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
{
fn is_reserved(target: &H160) -> bool {
map_eth_to_id(target).is_some()
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7interface Dummy {89}1011interface ERC165 is Dummy {12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}1415/// @title A contract that allows you to work with collections.16/// @dev the ERC-165 identifier for this interface is 0xffe4da2317interface Collection is Dummy, ERC165 {18 /// Set collection property.19 ///20 /// @param key Property key.21 /// @param value Propery value.22 /// @dev EVM selector for this function is: 0x2f073f66,23 /// or in textual repr: setCollectionProperty(string,bytes)24 function setCollectionProperty(string memory key, bytes memory value)25 external;2627 /// Delete collection property.28 ///29 /// @param key Property key.30 /// @dev EVM selector for this function is: 0x7b7debce,31 /// or in textual repr: deleteCollectionProperty(string)32 function deleteCollectionProperty(string memory key) external;3334 /// Get collection property.35 ///36 /// @dev Throws error if key not found.37 ///38 /// @param key Property key.39 /// @return bytes The property corresponding to the key.40 /// @dev EVM selector for this function is: 0xcf24fd6d,41 /// or in textual repr: collectionProperty(string)42 function collectionProperty(string memory key)43 external44 view45 returns (bytes memory);4647 /// Set the sponsor of the collection.48 ///49 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.50 ///51 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.52 /// @dev EVM selector for this function is: 0x7623402e,53 /// or in textual repr: setCollectionSponsor(address)54 function setCollectionSponsor(address sponsor) external;5556 /// Collection sponsorship confirmation.57 ///58 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.59 /// @dev EVM selector for this function is: 0x3c50e97a,60 /// or in textual repr: confirmCollectionSponsorship()61 function confirmCollectionSponsorship() external;6263 /// Set limits for the collection.64 /// @dev Throws error if limit not found.65 /// @param limit Name of the limit. Valid names:66 /// "accountTokenOwnershipLimit",67 /// "sponsoredDataSize",68 /// "sponsoredDataRateLimit",69 /// "tokenLimit",70 /// "sponsorTransferTimeout",71 /// "sponsorApproveTimeout"72 /// @param value Value of the limit.73 /// @dev EVM selector for this function is: 0x6a3841db,74 /// or in textual repr: setCollectionLimit(string,uint32)75 function setCollectionLimit(string memory limit, uint32 value) external;7677 /// Set limits for the collection.78 /// @dev Throws error if limit not found.79 /// @param limit Name of the limit. Valid names:80 /// "ownerCanTransfer",81 /// "ownerCanDestroy",82 /// "transfersEnabled"83 /// @param value Value of the limit.84 /// @dev EVM selector for this function is: 0x993b7fba,85 /// or in textual repr: setCollectionLimit(string,bool)86 function setCollectionLimit(string memory limit, bool value) external;8788 /// Get contract address.89 /// @dev EVM selector for this function is: 0xf6b4dfb4,90 /// or in textual repr: contractAddress()91 function contractAddress() external view returns (address);9293 /// Add collection admin by substrate address.94 /// @param newAdmin Substrate administrator address.95 /// @dev EVM selector for this function is: 0x5730062b,96 /// or in textual repr: addCollectionAdminSubstrate(uint256)97 function addCollectionAdminSubstrate(uint256 newAdmin) external;9899 /// Remove collection admin by substrate address.100 /// @param admin Substrate administrator address.101 /// @dev EVM selector for this function is: 0x4048fcf9,102 /// or in textual repr: removeCollectionAdminSubstrate(uint256)103 function removeCollectionAdminSubstrate(uint256 admin) external;104105 /// Add collection admin.106 /// @param newAdmin Address of the added administrator.107 /// @dev EVM selector for this function is: 0x92e462c7,108 /// or in textual repr: addCollectionAdmin(address)109 function addCollectionAdmin(address newAdmin) external;110111 /// Remove collection admin.112 ///113 /// @param admin Address of the removed administrator.114 /// @dev EVM selector for this function is: 0xfafd7b42,115 /// or in textual repr: removeCollectionAdmin(address)116 function removeCollectionAdmin(address admin) external;117118 /// Toggle accessibility of collection nesting.119 ///120 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'121 /// @dev EVM selector for this function is: 0x112d4586,122 /// or in textual repr: setCollectionNesting(bool)123 function setCollectionNesting(bool enable) external;124125 /// Toggle accessibility of collection nesting.126 ///127 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'128 /// @param collections Addresses of collections that will be available for nesting.129 /// @dev EVM selector for this function is: 0x64872396,130 /// or in textual repr: setCollectionNesting(bool,address[])131 function setCollectionNesting(bool enable, address[] memory collections)132 external;133134 /// Set the collection access method.135 /// @param mode Access mode136 /// 0 for Normal137 /// 1 for AllowList138 /// @dev EVM selector for this function is: 0x41835d4c,139 /// or in textual repr: setCollectionAccess(uint8)140 function setCollectionAccess(uint8 mode) external;141142 /// Add the user to the allowed list.143 ///144 /// @param user Address of a trusted user.145 /// @dev EVM selector for this function is: 0x67844fe6,146 /// or in textual repr: addToCollectionAllowList(address)147 function addToCollectionAllowList(address user) external;148149 /// Remove the user from the allowed list.150 ///151 /// @param user Address of a removed user.152 /// @dev EVM selector for this function is: 0x85c51acb,153 /// or in textual repr: removeFromCollectionAllowList(address)154 function removeFromCollectionAllowList(address user) external;155156 /// Switch permission for minting.157 ///158 /// @param mode Enable if "true".159 /// @dev EVM selector for this function is: 0x00018e84,160 /// or in textual repr: setCollectionMintMode(bool)161 function setCollectionMintMode(bool mode) external;162163 /// Check that account is the owner or admin of the collection164 ///165 /// @param user account to verify166 /// @return "true" if account is the owner or admin167 /// @dev EVM selector for this function is: 0x9811b0c7,168 /// or in textual repr: isOwnerOrAdmin(address)169 function isOwnerOrAdmin(address user) external view returns (bool);170171 /// Check that substrate account is the owner or admin of the collection172 ///173 /// @param user account to verify174 /// @return "true" if account is the owner or admin175 /// @dev EVM selector for this function is: 0x68910e00,176 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)177 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);178179 /// Returns collection type180 ///181 /// @return `Fungible` or `NFT` or `ReFungible`182 /// @dev EVM selector for this function is: 0xd34b55b8,183 /// or in textual repr: uniqueCollectionType()184 function uniqueCollectionType() external returns (string memory);185186 /// Changes collection owner to another account187 ///188 /// @dev Owner can be changed only by current owner189 /// @param newOwner new owner account190 /// @dev EVM selector for this function is: 0x13af4035,191 /// or in textual repr: setOwner(address)192 function setOwner(address newOwner) external;193194 /// Changes collection owner to another substrate account195 ///196 /// @dev Owner can be changed only by current owner197 /// @param newOwner new owner substrate account198 /// @dev EVM selector for this function is: 0xb212138f,199 /// or in textual repr: setOwnerSubstrate(uint256)200 function setOwnerSubstrate(uint256 newOwner) external;201}202203/// @dev the ERC-165 identifier for this interface is 0x79cc6790204interface ERC20UniqueExtensions is Dummy, ERC165 {205 /// @dev EVM selector for this function is: 0x79cc6790,206 /// or in textual repr: burnFrom(address,uint256)207 function burnFrom(address from, uint256 amount) external returns (bool);208}209210/// @dev inlined interface211interface ERC20Events {212 event Transfer(address indexed from, address indexed to, uint256 value);213 event Approval(214 address indexed owner,215 address indexed spender,216 uint256 value217 );218}219220/// @dev the ERC-165 identifier for this interface is 0x942e8b22221interface ERC20 is Dummy, ERC165, ERC20Events {222 /// @dev EVM selector for this function is: 0x06fdde03,223 /// or in textual repr: name()224 function name() external view returns (string memory);225226 /// @dev EVM selector for this function is: 0x95d89b41,227 /// or in textual repr: symbol()228 function symbol() external view returns (string memory);229230 /// @dev EVM selector for this function is: 0x18160ddd,231 /// or in textual repr: totalSupply()232 function totalSupply() external view returns (uint256);233234 /// @dev EVM selector for this function is: 0x313ce567,235 /// or in textual repr: decimals()236 function decimals() external view returns (uint8);237238 /// @dev EVM selector for this function is: 0x70a08231,239 /// or in textual repr: balanceOf(address)240 function balanceOf(address owner) external view returns (uint256);241242 /// @dev EVM selector for this function is: 0xa9059cbb,243 /// or in textual repr: transfer(address,uint256)244 function transfer(address to, uint256 amount) external returns (bool);245246 /// @dev EVM selector for this function is: 0x23b872dd,247 /// or in textual repr: transferFrom(address,address,uint256)248 function transferFrom(249 address from,250 address to,251 uint256 amount252 ) external returns (bool);253254 /// @dev EVM selector for this function is: 0x095ea7b3,255 /// or in textual repr: approve(address,uint256)256 function approve(address spender, uint256 amount) external returns (bool);257258 /// @dev EVM selector for this function is: 0xdd62ed3e,259 /// or in textual repr: allowance(address,address)260 function allowance(address owner, address spender)261 external262 view263 returns (uint256);264}265266interface UniqueFungible is267 Dummy,268 ERC165,269 ERC20,270 ERC20UniqueExtensions,271 Collection272{}1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56/// @dev common stubs holder7interface Dummy {89}1011interface ERC165 is Dummy {12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}1415/// @title A contract that allows you to work with collections.16/// @dev the ERC-165 identifier for this interface is 0xe54be64017interface Collection is Dummy, ERC165 {18 /// Set collection property.19 ///20 /// @param key Property key.21 /// @param value Propery value.22 /// @dev EVM selector for this function is: 0x2f073f66,23 /// or in textual repr: setCollectionProperty(string,bytes)24 function setCollectionProperty(string memory key, bytes memory value)25 external;2627 /// Delete collection property.28 ///29 /// @param key Property key.30 /// @dev EVM selector for this function is: 0x7b7debce,31 /// or in textual repr: deleteCollectionProperty(string)32 function deleteCollectionProperty(string memory key) external;3334 /// Get collection property.35 ///36 /// @dev Throws error if key not found.37 ///38 /// @param key Property key.39 /// @return bytes The property corresponding to the key.40 /// @dev EVM selector for this function is: 0xcf24fd6d,41 /// or in textual repr: collectionProperty(string)42 function collectionProperty(string memory key)43 external44 view45 returns (bytes memory);4647 /// Set the sponsor of the collection.48 ///49 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.50 ///51 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.52 /// @dev EVM selector for this function is: 0x7623402e,53 /// or in textual repr: setCollectionSponsor(address)54 function setCollectionSponsor(address sponsor) external;5556 /// Set the substrate sponsor of the collection.57 ///58 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.59 ///60 /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.61 /// @dev EVM selector for this function is: 0xc74d6751,62 /// or in textual repr: setCollectionSponsorSubstrate(uint256)63 function setCollectionSponsorSubstrate(uint256 sponsor) external;6465 /// @dev EVM selector for this function is: 0x058ac185,66 /// or in textual repr: hasCollectionPendingSponsor()67 function hasCollectionPendingSponsor() external view returns (bool);6869 /// Collection sponsorship confirmation.70 ///71 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.72 /// @dev EVM selector for this function is: 0x3c50e97a,73 /// or in textual repr: confirmCollectionSponsorship()74 function confirmCollectionSponsorship() external;7576 /// Remove collection sponsor.77 /// @dev EVM selector for this function is: 0x6e0326a3,78 /// or in textual repr: removeCollectionSponsor()79 function removeCollectionSponsor() external;8081 /// Get current sponsor.82 ///83 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.84 /// @dev EVM selector for this function is: 0xb66bbc14,85 /// or in textual repr: getCollectionSponsor()86 function getCollectionSponsor() external view returns (Tuple6 memory);8788 /// Set limits for the collection.89 /// @dev Throws error if limit not found.90 /// @param limit Name of the limit. Valid names:91 /// "accountTokenOwnershipLimit",92 /// "sponsoredDataSize",93 /// "sponsoredDataRateLimit",94 /// "tokenLimit",95 /// "sponsorTransferTimeout",96 /// "sponsorApproveTimeout"97 /// @param value Value of the limit.98 /// @dev EVM selector for this function is: 0x6a3841db,99 /// or in textual repr: setCollectionLimit(string,uint32)100 function setCollectionLimit(string memory limit, uint32 value) external;101102 /// Set limits for the collection.103 /// @dev Throws error if limit not found.104 /// @param limit Name of the limit. Valid names:105 /// "ownerCanTransfer",106 /// "ownerCanDestroy",107 /// "transfersEnabled"108 /// @param value Value of the limit.109 /// @dev EVM selector for this function is: 0x993b7fba,110 /// or in textual repr: setCollectionLimit(string,bool)111 function setCollectionLimit(string memory limit, bool value) external;112113 /// Get contract address.114 /// @dev EVM selector for this function is: 0xf6b4dfb4,115 /// or in textual repr: contractAddress()116 function contractAddress() external view returns (address);117118 /// Add collection admin by substrate address.119 /// @param newAdmin Substrate administrator address.120 /// @dev EVM selector for this function is: 0x5730062b,121 /// or in textual repr: addCollectionAdminSubstrate(uint256)122 function addCollectionAdminSubstrate(uint256 newAdmin) external;123124 /// Remove collection admin by substrate address.125 /// @param admin Substrate administrator address.126 /// @dev EVM selector for this function is: 0x4048fcf9,127 /// or in textual repr: removeCollectionAdminSubstrate(uint256)128 function removeCollectionAdminSubstrate(uint256 admin) external;129130 /// Add collection admin.131 /// @param newAdmin Address of the added administrator.132 /// @dev EVM selector for this function is: 0x92e462c7,133 /// or in textual repr: addCollectionAdmin(address)134 function addCollectionAdmin(address newAdmin) external;135136 /// Remove collection admin.137 ///138 /// @param admin Address of the removed administrator.139 /// @dev EVM selector for this function is: 0xfafd7b42,140 /// or in textual repr: removeCollectionAdmin(address)141 function removeCollectionAdmin(address admin) external;142143 /// Toggle accessibility of collection nesting.144 ///145 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'146 /// @dev EVM selector for this function is: 0x112d4586,147 /// or in textual repr: setCollectionNesting(bool)148 function setCollectionNesting(bool enable) external;149150 /// Toggle accessibility of collection nesting.151 ///152 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'153 /// @param collections Addresses of collections that will be available for nesting.154 /// @dev EVM selector for this function is: 0x64872396,155 /// or in textual repr: setCollectionNesting(bool,address[])156 function setCollectionNesting(bool enable, address[] memory collections)157 external;158159 /// Set the collection access method.160 /// @param mode Access mode161 /// 0 for Normal162 /// 1 for AllowList163 /// @dev EVM selector for this function is: 0x41835d4c,164 /// or in textual repr: setCollectionAccess(uint8)165 function setCollectionAccess(uint8 mode) external;166167 /// Add the user to the allowed list.168 ///169 /// @param user Address of a trusted user.170 /// @dev EVM selector for this function is: 0x67844fe6,171 /// or in textual repr: addToCollectionAllowList(address)172 function addToCollectionAllowList(address user) external;173174 /// Remove the user from the allowed list.175 ///176 /// @param user Address of a removed user.177 /// @dev EVM selector for this function is: 0x85c51acb,178 /// or in textual repr: removeFromCollectionAllowList(address)179 function removeFromCollectionAllowList(address user) external;180181 /// Switch permission for minting.182 ///183 /// @param mode Enable if "true".184 /// @dev EVM selector for this function is: 0x00018e84,185 /// or in textual repr: setCollectionMintMode(bool)186 function setCollectionMintMode(bool mode) external;187188 /// Check that account is the owner or admin of the collection189 ///190 /// @param user account to verify191 /// @return "true" if account is the owner or admin192 /// @dev EVM selector for this function is: 0x9811b0c7,193 /// or in textual repr: isOwnerOrAdmin(address)194 function isOwnerOrAdmin(address user) external view returns (bool);195196 /// Check that substrate account is the owner or admin of the collection197 ///198 /// @param user account to verify199 /// @return "true" if account is the owner or admin200 /// @dev EVM selector for this function is: 0x68910e00,201 /// or in textual repr: isOwnerOrAdminSubstrate(uint256)202 function isOwnerOrAdminSubstrate(uint256 user) external view returns (bool);203204 /// Returns collection type205 ///206 /// @return `Fungible` or `NFT` or `ReFungible`207 /// @dev EVM selector for this function is: 0xd34b55b8,208 /// or in textual repr: uniqueCollectionType()209 function uniqueCollectionType() external returns (string memory);210211 /// Changes collection owner to another account212 ///213 /// @dev Owner can be changed only by current owner214 /// @param newOwner new owner account215 /// @dev EVM selector for this function is: 0x13af4035,216 /// or in textual repr: setOwner(address)217 function setOwner(address newOwner) external;218219 /// Changes collection owner to another substrate account220 ///221 /// @dev Owner can be changed only by current owner222 /// @param newOwner new owner substrate account223 /// @dev EVM selector for this function is: 0xb212138f,224 /// or in textual repr: setOwnerSubstrate(uint256)225 function setOwnerSubstrate(uint256 newOwner) external;226}227228/// @dev anonymous struct229struct Tuple6 {230 address field_0;231 uint256 field_1;232}233234/// @dev the ERC-165 identifier for this interface is 0x79cc6790235interface ERC20UniqueExtensions is Dummy, ERC165 {236 /// @dev EVM selector for this function is: 0x79cc6790,237 /// or in textual repr: burnFrom(address,uint256)238 function burnFrom(address from, uint256 amount) external returns (bool);239}240241/// @dev inlined interface242interface ERC20Events {243 event Transfer(address indexed from, address indexed to, uint256 value);244 event Approval(245 address indexed owner,246 address indexed spender,247 uint256 value248 );249}250251/// @dev the ERC-165 identifier for this interface is 0x942e8b22252interface ERC20 is Dummy, ERC165, ERC20Events {253 /// @dev EVM selector for this function is: 0x06fdde03,254 /// or in textual repr: name()255 function name() external view returns (string memory);256257 /// @dev EVM selector for this function is: 0x95d89b41,258 /// or in textual repr: symbol()259 function symbol() external view returns (string memory);260261 /// @dev EVM selector for this function is: 0x18160ddd,262 /// or in textual repr: totalSupply()263 function totalSupply() external view returns (uint256);264265 /// @dev EVM selector for this function is: 0x313ce567,266 /// or in textual repr: decimals()267 function decimals() external view returns (uint8);268269 /// @dev EVM selector for this function is: 0x70a08231,270 /// or in textual repr: balanceOf(address)271 function balanceOf(address owner) external view returns (uint256);272273 /// @dev EVM selector for this function is: 0xa9059cbb,274 /// or in textual repr: transfer(address,uint256)275 function transfer(address to, uint256 amount) external returns (bool);276277 /// @dev EVM selector for this function is: 0x23b872dd,278 /// or in textual repr: transferFrom(address,address,uint256)279 function transferFrom(280 address from,281 address to,282 uint256 amount283 ) external returns (bool);284285 /// @dev EVM selector for this function is: 0x095ea7b3,286 /// or in textual repr: approve(address,uint256)287 function approve(address spender, uint256 amount) external returns (bool);288289 /// @dev EVM selector for this function is: 0xdd62ed3e,290 /// or in textual repr: allowance(address,address)291 function allowance(address owner, address spender)292 external293 view294 returns (uint256);295}296297interface UniqueFungible is298 Dummy,299 ERC165,300 ERC20,301 ERC20UniqueExtensions,302 Collection303{}tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -65,7 +65,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xffe4da23
+/// @dev the ERC-165 identifier for this interface is 0xe54be640
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -105,6 +105,19 @@
/// or in textual repr: setCollectionSponsor(address)
function setCollectionSponsor(address sponsor) external;
+ /// Set the substrate sponsor of the collection.
+ ///
+ /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ ///
+ /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
+ /// @dev EVM selector for this function is: 0xc74d6751,
+ /// or in textual repr: setCollectionSponsorSubstrate(uint256)
+ function setCollectionSponsorSubstrate(uint256 sponsor) external;
+
+ /// @dev EVM selector for this function is: 0x058ac185,
+ /// or in textual repr: hasCollectionPendingSponsor()
+ function hasCollectionPendingSponsor() external view returns (bool);
+
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
@@ -112,6 +125,18 @@
/// or in textual repr: confirmCollectionSponsorship()
function confirmCollectionSponsorship() external;
+ /// Remove collection sponsor.
+ /// @dev EVM selector for this function is: 0x6e0326a3,
+ /// or in textual repr: removeCollectionSponsor()
+ function removeCollectionSponsor() external;
+
+ /// Get current sponsor.
+ ///
+ /// @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: 0xb66bbc14,
+ /// or in textual repr: getCollectionSponsor()
+ function getCollectionSponsor() external view returns (Tuple17 memory);
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -252,6 +277,12 @@
function setOwnerSubstrate(uint256 newOwner) external;
}
+/// @dev anonymous struct
+struct Tuple17 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @title ERC721 Token that can be irreversibly burned (destroyed).
/// @dev the ERC-165 identifier for this interface is 0x42966c68
interface ERC721Burnable is Dummy, ERC165 {
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -65,7 +65,7 @@
}
/// @title A contract that allows you to work with collections.
-/// @dev the ERC-165 identifier for this interface is 0xffe4da23
+/// @dev the ERC-165 identifier for this interface is 0xe54be640
interface Collection is Dummy, ERC165 {
/// Set collection property.
///
@@ -105,6 +105,19 @@
/// or in textual repr: setCollectionSponsor(address)
function setCollectionSponsor(address sponsor) external;
+ /// Set the substrate sponsor of the collection.
+ ///
+ /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+ ///
+ /// @param sponsor Substrate address of the sponsor from whose account funds will be debited for operations with the contract.
+ /// @dev EVM selector for this function is: 0xc74d6751,
+ /// or in textual repr: setCollectionSponsorSubstrate(uint256)
+ function setCollectionSponsorSubstrate(uint256 sponsor) external;
+
+ /// @dev EVM selector for this function is: 0x058ac185,
+ /// or in textual repr: hasCollectionPendingSponsor()
+ function hasCollectionPendingSponsor() external view returns (bool);
+
/// Collection sponsorship confirmation.
///
/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
@@ -112,6 +125,18 @@
/// or in textual repr: confirmCollectionSponsorship()
function confirmCollectionSponsorship() external;
+ /// Remove collection sponsor.
+ /// @dev EVM selector for this function is: 0x6e0326a3,
+ /// or in textual repr: removeCollectionSponsor()
+ function removeCollectionSponsor() external;
+
+ /// Get current sponsor.
+ ///
+ /// @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: 0xb66bbc14,
+ /// or in textual repr: getCollectionSponsor()
+ function getCollectionSponsor() external view returns (Tuple17 memory);
+
/// Set limits for the collection.
/// @dev Throws error if limit not found.
/// @param limit Name of the limit. Valid names:
@@ -252,6 +277,12 @@
function setOwnerSubstrate(uint256 newOwner) external;
}
+/// @dev anonymous struct
+struct Tuple17 {
+ address field_0;
+ uint256 field_1;
+}
+
/// @title ERC721 Token that can be irreversibly burned (destroyed).
/// @dev the ERC-165 identifier for this interface is 0x42966c68
interface ERC721Burnable is Dummy, ERC165 {
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -1,8 +1,10 @@
-import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers';
-import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub} from './util/helpers';
+import {addToAllowListExpectSuccess, bigIntToSub, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers';
+import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub, subToEth} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
import {expect} from 'chai';
import {evmToAddress} from '@polkadot/util-crypto';
+import {submitTransactionAsync} from '../substrate/substrate-api';
+import getBalance from '../substrate/get-balance';
describe('evm collection sponsoring', () => {
itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {
@@ -38,6 +40,47 @@
]);
});
+ itWeb3('Set substrate sponsor', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const collectionHelpers = evmCollectionHelpers(web3, owner);
+ let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+ const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+ const sponsor = privateKeyWrapper('//Alice');
+ const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
+
+ expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
+ result = await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});
+ expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
+
+ const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);
+ await submitTransactionAsync(sponsor, confirmTx);
+ expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
+
+ const sponsorTuple = await collectionEvm.methods.getCollectionSponsor().call({from: owner});
+ expect(bigIntToSub(api, BigInt(sponsorTuple[1]))).to.be.eq(sponsor.address);
+ });
+
+ itWeb3('Remove sponsor', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const collectionHelpers = evmCollectionHelpers(web3, owner);
+ let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+ const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+ const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
+
+ expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
+ result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
+ expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.true;
+
+ await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
+ expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
+
+ await collectionEvm.methods.removeCollectionSponsor().send({from: owner});
+
+ const sponsorTuple = await collectionEvm.methods.getCollectionSponsor().call({from: owner});
+ expect(sponsorTuple.field_0).to.be.eq('0x0000000000000000000000000000000000000000');
+ });
+
itWeb3('Sponsoring collection from evm address via access list', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
@@ -107,6 +150,61 @@
}
});
+ itWeb3('Sponsoring collection from substrate address via access list', async ({api, web3, privateKeyWrapper}) => {
+ const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const collectionHelpers = evmCollectionHelpers(web3, owner);
+ const result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+ const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+ const sponsor = privateKeyWrapper('//Alice');
+ const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
+
+ await collectionEvm.methods.setCollectionSponsorSubstrate(sponsor.addressRaw).send({from: owner});
+
+ const confirmTx = await api.tx.unique.confirmSponsorship(collectionId);
+ await submitTransactionAsync(sponsor, confirmTx);
+
+ const user = createEthAccount(web3);
+ const nextTokenId = await collectionEvm.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+
+ await collectionEvm.methods.setCollectionAccess(1 /*'AllowList'*/).send({from: owner});
+ await collectionEvm.methods.addToCollectionAllowList(user).send({from: owner});
+ await collectionEvm.methods.setCollectionMintMode(true).send({from: owner});
+
+ const ownerBalanceBefore = await ethBalanceViaSub(api, owner);
+ const sponsorBalanceBefore = (await getBalance(api, [sponsor.address]))[0];
+
+ {
+ const nextTokenId = await collectionEvm.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const result = await collectionEvm.methods.mintWithTokenURI(
+ user,
+ nextTokenId,
+ 'Test URI',
+ ).send({from: user});
+ const events = normalizeEvents(result.events);
+
+ expect(events).to.be.deep.equal([
+ {
+ address: collectionIdAddress,
+ event: 'Transfer',
+ args: {
+ from: '0x0000000000000000000000000000000000000000',
+ to: user,
+ tokenId: nextTokenId,
+ },
+ },
+ ]);
+
+ const ownerBalanceAfter = await ethBalanceViaSub(api, owner);
+ const sponsorBalanceAfter = (await getBalance(api, [sponsor.address]))[0];
+
+ expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+ expect(ownerBalanceBefore).to.be.eq(ownerBalanceAfter);
+ expect(sponsorBalanceBefore > sponsorBalanceAfter).to.be.true;
+ }
+ });
+
itWeb3('Check that transaction via EVM spend money from sponsor address', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
tests/src/eth/fungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/fungibleAbi.json
+++ b/tests/src/eth/fungibleAbi.json
@@ -151,6 +151,30 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "getCollectionSponsor",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "field_0", "type": "address" },
+ { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ ],
+ "internalType": "struct Tuple6",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "hasCollectionPendingSponsor",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" }
],
@@ -194,6 +218,13 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "removeCollectionSponsor",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" }
],
@@ -278,6 +309,15 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "sponsor", "type": "uint256" }
+ ],
+ "name": "setCollectionSponsorSubstrate",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "setOwner",
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -200,6 +200,30 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "getCollectionSponsor",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "field_0", "type": "address" },
+ { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ ],
+ "internalType": "struct Tuple17",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "hasCollectionPendingSponsor",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "address", "name": "operator", "type": "address" }
@@ -335,6 +359,13 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "removeCollectionSponsor",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" }
],
@@ -452,6 +483,15 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "sponsor", "type": "uint256" }
+ ],
+ "name": "setCollectionSponsorSubstrate",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "setOwner",
tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/reFungibleAbi.json
+++ b/tests/src/eth/reFungibleAbi.json
@@ -200,6 +200,30 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "getCollectionSponsor",
+ "outputs": [
+ {
+ "components": [
+ { "internalType": "address", "name": "field_0", "type": "address" },
+ { "internalType": "uint256", "name": "field_1", "type": "uint256" }
+ ],
+ "internalType": "struct Tuple17",
+ "name": "",
+ "type": "tuple"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [],
+ "name": "hasCollectionPendingSponsor",
+ "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "owner", "type": "address" },
{ "internalType": "address", "name": "operator", "type": "address" }
@@ -335,6 +359,13 @@
"type": "function"
},
{
+ "inputs": [],
+ "name": "removeCollectionSponsor",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "user", "type": "address" }
],
@@ -452,6 +483,15 @@
},
{
"inputs": [
+ { "internalType": "uint256", "name": "sponsor", "type": "uint256" }
+ ],
+ "name": "setCollectionSponsorSubstrate",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "newOwner", "type": "address" }
],
"name": "setOwner",
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -99,6 +99,10 @@
}
}
+export function bigIntToSub(api: ApiPromise, number: bigint) {
+ return api.registry.createType('AccountId', '0x' + number.toString(16).padStart(64, '0')).toJSON();
+}
+
export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
if (typeof input === 'string') {
if (input.length >= 47) {