difftreelog
CORE-386 Implement eth methods
in: master
5 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -253,6 +253,42 @@
save(self);
Ok(())
}
+
+ fn set_access(&mut self, caller: caller, mode: string) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ self.check_is_owner_or_admin(&caller)
+ .map_err(dispatch_to_evm::<T>)?;
+ self.collection.permissions.access = Some(match mode.as_str() {
+ "Normal" => AccessMode::Normal,
+ "AllowList" => AccessMode::AllowList,
+ _ => return Err("Not supported access mode".into()),
+ });
+ save(self);
+ Ok(())
+ }
+
+ fn add_to_allow_list(&self, caller: caller, user: address) -> Result<void> {
+ let caller = check_is_owner_or_admin(caller, self)?;
+ let user = T::CrossAccountId::from_eth(user);
+ <Pallet<T>>::toggle_allowlist(self, &caller, &user, true)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
+ fn remove_from_allow_list(&self, caller: caller, user: address) -> Result<void> {
+ let caller = check_is_owner_or_admin(caller, self)?;
+ let user = T::CrossAccountId::from_eth(user);
+ <Pallet<T>>::toggle_allowlist(self, &caller, &user, false)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
+ fn set_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {
+ check_is_owner_or_admin(caller, self)?;
+ self.collection.permissions.mint_mode = Some(mode);
+ save(self);
+ Ok(())
+ }
}
fn check_is_owner<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<void> {
@@ -263,10 +299,7 @@
Ok(())
}
-fn check_is_owner_or_admin<T: Config>(
- caller: caller,
- collection: &CollectionHandle<T>,
-) -> Result<T::CrossAccountId> {
+fn check_is_owner_or_admin<T: Config>(caller: caller, collection: &CollectionHandle<T>) -> Result<T::CrossAccountId> {
let caller = T::CrossAccountId::from_eth(caller);
collection
.check_is_owner_or_admin(&caller)
@@ -274,11 +307,7 @@
Ok(caller)
}
-fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {
- // TODO possibly delete for the lack of transaction
- collection
- .check_is_internal()
- .map_err(dispatch_to_evm::<T>)?;
+fn save<T: Config>(collection: &CollectionHandle<T>) {
<crate::CollectionById<T>>::insert(collection.id, collection.collection.clone());
Ok(())
}
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -51,105 +51,6 @@
event MintingFinished();
}
-// Selector: 3a54513b
-contract Collection is Dummy, ERC165 {
- // Selector: setCollectionProperty(string,bytes) 2f073f66
- function setCollectionProperty(string memory key, bytes memory value)
- public
- {
- require(false, stub_error);
- key;
- value;
- dummy = 0;
- }
-
- // Selector: deleteCollectionProperty(string) 7b7debce
- function deleteCollectionProperty(string memory key) public {
- require(false, stub_error);
- key;
- dummy = 0;
- }
-
- // Throws error if key not found
- //
- // Selector: collectionProperty(string) cf24fd6d
- function collectionProperty(string memory key)
- public
- view
- returns (bytes memory)
- {
- require(false, stub_error);
- key;
- dummy;
- return hex"";
- }
-
- // Selector: ethSetSponsor(address) 8f9af356
- function ethSetSponsor(address sponsor) public {
- require(false, stub_error);
- sponsor;
- dummy = 0;
- }
-
- // Selector: ethConfirmSponsorship() a8580d1a
- function ethConfirmSponsorship() public {
- require(false, stub_error);
- dummy = 0;
- }
-
- // Selector: setLimit(string,uint32) 68db30ca
- function setLimit(string memory limit, uint32 value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Selector: setLimit(string,bool) ea67e4c2
- function setLimit(string memory limit, bool value) public {
- require(false, stub_error);
- limit;
- value;
- dummy = 0;
- }
-
- // Selector: contractAddress() f6b4dfb4
- function contractAddress() public view returns (address) {
- require(false, stub_error);
- dummy;
- return 0x0000000000000000000000000000000000000000;
- }
-
- // Selector: addAdmin(address) 70480275
- function addAdmin(address newAdmin) public view {
- require(false, stub_error);
- newAdmin;
- dummy;
- }
-
- // Selector: removeAdmin(address) 1785f53c
- function removeAdmin(address admin) public view {
- require(false, stub_error);
- admin;
- dummy;
- }
-
- // Selector: setNesting(bool) e8fc50dd
- function setNesting(bool enable) public {
- require(false, stub_error);
- enable;
- dummy = 0;
- }
-
- // Selector: setNesting(bool,address[]) 7df12a9a
- function setNesting(bool enable, address[] memory collections) public {
- require(false, stub_error);
- enable;
- collections;
- dummy = 0;
- }
-}
-
// Selector: 41369377
contract TokenProperties is Dummy, ERC165 {
// Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa
@@ -479,6 +380,133 @@
}
}
+// Selector: f56cd7fa
+contract Collection is Dummy, ERC165 {
+ // Selector: setCollectionProperty(string,bytes) 2f073f66
+ function setCollectionProperty(string memory key, bytes memory value)
+ public
+ {
+ require(false, stub_error);
+ key;
+ value;
+ dummy = 0;
+ }
+
+ // Selector: deleteCollectionProperty(string) 7b7debce
+ function deleteCollectionProperty(string memory key) public {
+ require(false, stub_error);
+ key;
+ dummy = 0;
+ }
+
+ // Throws error if key not found
+ //
+ // Selector: collectionProperty(string) cf24fd6d
+ function collectionProperty(string memory key)
+ public
+ view
+ returns (bytes memory)
+ {
+ require(false, stub_error);
+ key;
+ dummy;
+ return hex"";
+ }
+
+ // Selector: ethSetSponsor(address) 8f9af356
+ function ethSetSponsor(address sponsor) public {
+ require(false, stub_error);
+ sponsor;
+ dummy = 0;
+ }
+
+ // Selector: ethConfirmSponsorship() a8580d1a
+ function ethConfirmSponsorship() public {
+ require(false, stub_error);
+ dummy = 0;
+ }
+
+ // Selector: setLimit(string,uint32) 68db30ca
+ function setLimit(string memory limit, uint32 value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Selector: setLimit(string,bool) ea67e4c2
+ function setLimit(string memory limit, bool value) public {
+ require(false, stub_error);
+ limit;
+ value;
+ dummy = 0;
+ }
+
+ // Selector: contractAddress() f6b4dfb4
+ function contractAddress() public view returns (address) {
+ require(false, stub_error);
+ dummy;
+ return 0x0000000000000000000000000000000000000000;
+ }
+
+ // Selector: addAdmin(address) 70480275
+ function addAdmin(address newAdmin) public view {
+ require(false, stub_error);
+ newAdmin;
+ dummy;
+ }
+
+ // Selector: removeAdmin(address) 1785f53c
+ function removeAdmin(address admin) public view {
+ require(false, stub_error);
+ admin;
+ dummy;
+ }
+
+ // Selector: setNesting(bool) e8fc50dd
+ function setNesting(bool enable) public {
+ require(false, stub_error);
+ enable;
+ dummy = 0;
+ }
+
+ // Selector: setNesting(bool,address[]) 7df12a9a
+ function setNesting(bool enable, address[] memory collections) public {
+ require(false, stub_error);
+ enable;
+ collections;
+ dummy = 0;
+ }
+
+ // Selector: setAccess(string) 488f56aa
+ function setAccess(string memory mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+
+ // Selector: addToAllowList(address) 31f59102
+ function addToAllowList(address user) public view {
+ require(false, stub_error);
+ user;
+ dummy;
+ }
+
+ // Selector: removeFromAllowList(address) eba8dabc
+ function removeFromAllowList(address user) public view {
+ require(false, stub_error);
+ user;
+ dummy;
+ }
+
+ // Selector: setMintMode(bool) 5dea9bd5
+ function setMintMode(bool mode) public {
+ require(false, stub_error);
+ mode;
+ dummy = 0;
+ }
+}
+
contract UniqueNFT is
Dummy,
ERC165,
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}1112// Common stubs holder13interface Dummy {1415}1617interface ERC165 is Dummy {18 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}2021// Inline22interface ERC721Events {23 event Transfer(24 address indexed from,25 address indexed to,26 uint256 indexed tokenId27 );28 event Approval(29 address indexed owner,30 address indexed approved,31 uint256 indexed tokenId32 );33 event ApprovalForAll(34 address indexed owner,35 address indexed operator,36 bool approved37 );38}3940// Inline41interface ERC721MintableEvents {42 event MintingFinished();43}4445// Selector: 3a54513b46interface Collection is Dummy, ERC165 {47 // Selector: setCollectionProperty(string,bytes) 2f073f6648 function setCollectionProperty(string memory key, bytes memory value)49 external;5051 // Selector: deleteCollectionProperty(string) 7b7debce52 function deleteCollectionProperty(string memory key) external;5354 // Throws error if key not found55 //56 // Selector: collectionProperty(string) cf24fd6d57 function collectionProperty(string memory key)58 external59 view60 returns (bytes memory);6162 // Selector: ethSetSponsor(address) 8f9af35663 function ethSetSponsor(address sponsor) external;6465 // Selector: ethConfirmSponsorship() a8580d1a66 function ethConfirmSponsorship() external;6768 // Selector: setLimit(string,uint32) 68db30ca69 function setLimit(string memory limit, uint32 value) external;7071 // Selector: setLimit(string,bool) ea67e4c272 function setLimit(string memory limit, bool value) external;7374 // Selector: contractAddress() f6b4dfb475 function contractAddress() external view returns (address);7677 // Selector: addAdmin(address) 7048027578 function addAdmin(address newAdmin) external view;7980 // Selector: removeAdmin(address) 1785f53c81 function removeAdmin(address admin) external view;8283 // Selector: setNesting(bool) e8fc50dd84 function setNesting(bool enable) external;8586 // Selector: setNesting(bool,address[]) 7df12a9a87 function setNesting(bool enable, address[] memory collections) external;88}8990// Selector: 4136937791interface TokenProperties is Dummy, ERC165 {92 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa93 function setTokenPropertyPermission(94 string memory key,95 bool isMutable,96 bool collectionAdmin,97 bool tokenOwner98 ) external;99100 // Selector: setProperty(uint256,string,bytes) 1752d67b101 function setProperty(102 uint256 tokenId,103 string memory key,104 bytes memory value105 ) external;106107 // Selector: deleteProperty(uint256,string) 066111d1108 function deleteProperty(uint256 tokenId, string memory key) external;109110 // Throws error if key not found111 //112 // Selector: property(uint256,string) 7228c327113 function property(uint256 tokenId, string memory key)114 external115 view116 returns (bytes memory);117}118119// Selector: 42966c68120interface ERC721Burnable is Dummy, ERC165 {121 // Selector: burn(uint256) 42966c68122 function burn(uint256 tokenId) external;123}124125// Selector: 58800161126interface ERC721 is Dummy, ERC165, ERC721Events {127 // Selector: balanceOf(address) 70a08231128 function balanceOf(address owner) external view returns (uint256);129130 // Selector: ownerOf(uint256) 6352211e131 function ownerOf(uint256 tokenId) external view returns (address);132133 // Not implemented134 //135 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672136 function safeTransferFromWithData(137 address from,138 address to,139 uint256 tokenId,140 bytes memory data141 ) external;142143 // Not implemented144 //145 // Selector: safeTransferFrom(address,address,uint256) 42842e0e146 function safeTransferFrom(147 address from,148 address to,149 uint256 tokenId150 ) external;151152 // Selector: transferFrom(address,address,uint256) 23b872dd153 function transferFrom(154 address from,155 address to,156 uint256 tokenId157 ) external;158159 // Selector: approve(address,uint256) 095ea7b3160 function approve(address approved, uint256 tokenId) external;161162 // Not implemented163 //164 // Selector: setApprovalForAll(address,bool) a22cb465165 function setApprovalForAll(address operator, bool approved) external;166167 // Not implemented168 //169 // Selector: getApproved(uint256) 081812fc170 function getApproved(uint256 tokenId) external view returns (address);171172 // Not implemented173 //174 // Selector: isApprovedForAll(address,address) e985e9c5175 function isApprovedForAll(address owner, address operator)176 external177 view178 returns (address);179}180181// Selector: 5b5e139f182interface ERC721Metadata is Dummy, ERC165 {183 // Selector: name() 06fdde03184 function name() external view returns (string memory);185186 // Selector: symbol() 95d89b41187 function symbol() external view returns (string memory);188189 // Returns token's const_metadata190 //191 // Selector: tokenURI(uint256) c87b56dd192 function tokenURI(uint256 tokenId) external view returns (string memory);193}194195// Selector: 68ccfe89196interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {197 // Selector: mintingFinished() 05d2035b198 function mintingFinished() external view returns (bool);199200 // `token_id` should be obtained with `next_token_id` method,201 // unlike standard, you can't specify it manually202 //203 // Selector: mint(address,uint256) 40c10f19204 function mint(address to, uint256 tokenId) external returns (bool);205206 // `token_id` should be obtained with `next_token_id` method,207 // unlike standard, you can't specify it manually208 //209 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f210 function mintWithTokenURI(211 address to,212 uint256 tokenId,213 string memory tokenUri214 ) external returns (bool);215216 // Not implemented217 //218 // Selector: finishMinting() 7d64bcb4219 function finishMinting() external returns (bool);220}221222// Selector: 780e9d63223interface ERC721Enumerable is Dummy, ERC165 {224 // Selector: tokenByIndex(uint256) 4f6ccce7225 function tokenByIndex(uint256 index) external view returns (uint256);226227 // Not implemented228 //229 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59230 function tokenOfOwnerByIndex(address owner, uint256 index)231 external232 view233 returns (uint256);234235 // Selector: totalSupply() 18160ddd236 function totalSupply() external view returns (uint256);237}238239// Selector: d74d154f240interface ERC721UniqueExtensions is Dummy, ERC165 {241 // Selector: transfer(address,uint256) a9059cbb242 function transfer(address to, uint256 tokenId) external;243244 // Selector: burnFrom(address,uint256) 79cc6790245 function burnFrom(address from, uint256 tokenId) external;246247 // Selector: nextTokenId() 75794a3c248 function nextTokenId() external view returns (uint256);249250 // Selector: mintBulk(address,uint256[]) 44a9945e251 function mintBulk(address to, uint256[] memory tokenIds)252 external253 returns (bool);254255 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006256 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)257 external258 returns (bool);259}260261interface UniqueNFT is262 Dummy,263 ERC165,264 ERC721,265 ERC721Metadata,266 ERC721Enumerable,267 ERC721UniqueExtensions,268 ERC721Mintable,269 ERC721Burnable,270 Collection,271 TokenProperties272{}1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}1112// Common stubs holder13interface Dummy {1415}1617interface ERC165 is Dummy {18 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}2021// Inline22interface ERC721Events {23 event Transfer(24 address indexed from,25 address indexed to,26 uint256 indexed tokenId27 );28 event Approval(29 address indexed owner,30 address indexed approved,31 uint256 indexed tokenId32 );33 event ApprovalForAll(34 address indexed owner,35 address indexed operator,36 bool approved37 );38}3940// Inline41interface ERC721MintableEvents {42 event MintingFinished();43}4445// Selector: 4136937746interface TokenProperties is Dummy, ERC165 {47 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa48 function setTokenPropertyPermission(49 string memory key,50 bool isMutable,51 bool collectionAdmin,52 bool tokenOwner53 ) external;5455 // Selector: setProperty(uint256,string,bytes) 1752d67b56 function setProperty(57 uint256 tokenId,58 string memory key,59 bytes memory value60 ) external;6162 // Selector: deleteProperty(uint256,string) 066111d163 function deleteProperty(uint256 tokenId, string memory key) external;6465 // Throws error if key not found66 //67 // Selector: property(uint256,string) 7228c32768 function property(uint256 tokenId, string memory key)69 external70 view71 returns (bytes memory);72}7374// Selector: 42966c6875interface ERC721Burnable is Dummy, ERC165 {76 // Selector: burn(uint256) 42966c6877 function burn(uint256 tokenId) external;78}7980// Selector: 5880016181interface ERC721 is Dummy, ERC165, ERC721Events {82 // Selector: balanceOf(address) 70a0823183 function balanceOf(address owner) external view returns (uint256);8485 // Selector: ownerOf(uint256) 6352211e86 function ownerOf(uint256 tokenId) external view returns (address);8788 // Not implemented89 //90 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a1167291 function safeTransferFromWithData(92 address from,93 address to,94 uint256 tokenId,95 bytes memory data96 ) external;9798 // Not implemented99 //100 // Selector: safeTransferFrom(address,address,uint256) 42842e0e101 function safeTransferFrom(102 address from,103 address to,104 uint256 tokenId105 ) external;106107 // Selector: transferFrom(address,address,uint256) 23b872dd108 function transferFrom(109 address from,110 address to,111 uint256 tokenId112 ) external;113114 // Selector: approve(address,uint256) 095ea7b3115 function approve(address approved, uint256 tokenId) external;116117 // Not implemented118 //119 // Selector: setApprovalForAll(address,bool) a22cb465120 function setApprovalForAll(address operator, bool approved) external;121122 // Not implemented123 //124 // Selector: getApproved(uint256) 081812fc125 function getApproved(uint256 tokenId) external view returns (address);126127 // Not implemented128 //129 // Selector: isApprovedForAll(address,address) e985e9c5130 function isApprovedForAll(address owner, address operator)131 external132 view133 returns (address);134}135136// Selector: 5b5e139f137interface ERC721Metadata is Dummy, ERC165 {138 // Selector: name() 06fdde03139 function name() external view returns (string memory);140141 // Selector: symbol() 95d89b41142 function symbol() external view returns (string memory);143144 // Returns token's const_metadata145 //146 // Selector: tokenURI(uint256) c87b56dd147 function tokenURI(uint256 tokenId) external view returns (string memory);148}149150// Selector: 68ccfe89151interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {152 // Selector: mintingFinished() 05d2035b153 function mintingFinished() external view returns (bool);154155 // `token_id` should be obtained with `next_token_id` method,156 // unlike standard, you can't specify it manually157 //158 // Selector: mint(address,uint256) 40c10f19159 function mint(address to, uint256 tokenId) external returns (bool);160161 // `token_id` should be obtained with `next_token_id` method,162 // unlike standard, you can't specify it manually163 //164 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f165 function mintWithTokenURI(166 address to,167 uint256 tokenId,168 string memory tokenUri169 ) external returns (bool);170171 // Not implemented172 //173 // Selector: finishMinting() 7d64bcb4174 function finishMinting() external returns (bool);175}176177// Selector: 780e9d63178interface ERC721Enumerable is Dummy, ERC165 {179 // Selector: tokenByIndex(uint256) 4f6ccce7180 function tokenByIndex(uint256 index) external view returns (uint256);181182 // Not implemented183 //184 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59185 function tokenOfOwnerByIndex(address owner, uint256 index)186 external187 view188 returns (uint256);189190 // Selector: totalSupply() 18160ddd191 function totalSupply() external view returns (uint256);192}193194// Selector: d74d154f195interface ERC721UniqueExtensions is Dummy, ERC165 {196 // Selector: transfer(address,uint256) a9059cbb197 function transfer(address to, uint256 tokenId) external;198199 // Selector: burnFrom(address,uint256) 79cc6790200 function burnFrom(address from, uint256 tokenId) external;201202 // Selector: nextTokenId() 75794a3c203 function nextTokenId() external view returns (uint256);204205 // Selector: mintBulk(address,uint256[]) 44a9945e206 function mintBulk(address to, uint256[] memory tokenIds)207 external208 returns (bool);209210 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006211 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)212 external213 returns (bool);214}215216// Selector: f56cd7fa217interface Collection is Dummy, ERC165 {218 // Selector: setCollectionProperty(string,bytes) 2f073f66219 function setCollectionProperty(string memory key, bytes memory value)220 external;221222 // Selector: deleteCollectionProperty(string) 7b7debce223 function deleteCollectionProperty(string memory key) external;224225 // Throws error if key not found226 //227 // Selector: collectionProperty(string) cf24fd6d228 function collectionProperty(string memory key)229 external230 view231 returns (bytes memory);232233 // Selector: ethSetSponsor(address) 8f9af356234 function ethSetSponsor(address sponsor) external;235236 // Selector: ethConfirmSponsorship() a8580d1a237 function ethConfirmSponsorship() external;238239 // Selector: setLimit(string,uint32) 68db30ca240 function setLimit(string memory limit, uint32 value) external;241242 // Selector: setLimit(string,bool) ea67e4c2243 function setLimit(string memory limit, bool value) external;244245 // Selector: contractAddress() f6b4dfb4246 function contractAddress() external view returns (address);247248 // Selector: addAdmin(address) 70480275249 function addAdmin(address newAdmin) external view;250251 // Selector: removeAdmin(address) 1785f53c252 function removeAdmin(address admin) external view;253254 // Selector: setNesting(bool) e8fc50dd255 function setNesting(bool enable) external;256257 // Selector: setNesting(bool,address[]) 7df12a9a258 function setNesting(bool enable, address[] memory collections) external;259260 // Selector: setAccess(string) 488f56aa261 function setAccess(string memory mode) external;262263 // Selector: addToAllowList(address) 31f59102264 function addToAllowList(address user) external view;265266 // Selector: removeFromAllowList(address) eba8dabc267 function removeFromAllowList(address user) external view;268269 // Selector: setMintMode(bool) 5dea9bd5270 function setMintMode(bool mode) external;271}272273interface UniqueNFT is274 Dummy,275 ERC165,276 ERC721,277 ERC721Metadata,278 ERC721Enumerable,279 ERC721UniqueExtensions,280 ERC721Mintable,281 ERC721Burnable,282 Collection,283 TokenProperties284{}tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -221,6 +221,7 @@
expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');
});
+ //TODO: CORE-302 add eth methods
itWeb3('Sponsoring collection from evm address via access list', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const collectionHelpers = evmCollectionHelpers(web3, owner);
@@ -228,65 +229,60 @@
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const sponsor = await createEthAccountWithBalance(api, web3);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
- result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
+ result = await collectionEvm.methods.ethSetSponsor(sponsor).send({from: owner});
let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
- await collectionEvm.methods.confirmCollectionSponsorship().send({from: sponsor});
+ await collectionEvm.methods.ethConfirmSponsorship().send({from: sponsor});
collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
expect(collectionSub.sponsorship.isConfirmed).to.be.true;
expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
const user = createEthAccount(web3);
- let nextTokenId = await collectionEvm.methods.nextTokenId().call();
+ const nextTokenId = await collectionEvm.methods.nextTokenId().call();
expect(nextTokenId).to.be.equal('1');
const oldPermissions = (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
expect(oldPermissions.mintMode).to.be.false;
expect(oldPermissions.access).to.be.equal('Normal');
- //TODO: change value, when enum generated
- 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});
+ await collectionEvm.methods.setAccess('AllowList').send({from: owner});
+ await collectionEvm.methods.addToAllowList(user).send({from: owner});
+ await collectionEvm.methods.setMintMode(true).send({from: owner});
const newPermissions = (await getDetailedCollectionInfo(api, collectionId))!.permissions.toHuman();
expect(newPermissions.mintMode).to.be.true;
expect(newPermissions.access).to.be.equal('AllowList');
- const ownerBalanceBefore = await ethBalanceViaSub(api, owner);
- const sponsorBalanceBefore = await ethBalanceViaSub(api, sponsor);
+ // const [alicesBalanceBefore] = await getBalance(api, [alicesPublicKey]);
- nextTokenId = await collectionEvm.methods.nextTokenId().call({from: user});
- expect(nextTokenId).to.be.equal('1');
- result = await collectionEvm.methods.mintWithTokenURI(
- user,
- nextTokenId,
- 'Test URI',
- ).send({from: user});
- const events = normalizeEvents(result.events);
- events[0].address = events[0].address.toLocaleLowerCase();
+ {
+ const nextTokenId = await collectionEvm.methods.nextTokenId().call();
+ expect(nextTokenId).to.be.equal('1');
+ const result = await collectionEvm.methods.mintWithTokenURI(
+ user,
+ nextTokenId,
+ 'Test URI',
+ ).call({from: user});
+ console.log(result);
+ const events = normalizeEvents(result.events);
- expect(events).to.be.deep.equal([
- {
- address: collectionIdAddress.toLocaleLowerCase(),
- event: 'Transfer',
- args: {
- from: '0x0000000000000000000000000000000000000000',
- to: user,
- tokenId: nextTokenId,
+ expect(events).to.be.deep.equal([
+ {
+ collectionIdAddress,
+ event: 'Transfer',
+ args: {
+ from: '0x0000000000000000000000000000000000000000',
+ to: user,
+ tokenId: nextTokenId,
+ },
},
- },
- ]);
-
- expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+ ]);
- const ownerBalanceAfter = await ethBalanceViaSub(api, owner);
- expect(ownerBalanceAfter).to.be.eq(ownerBalanceBefore);
- const sponsorBalanceAfter = await ethBalanceViaSub(api, sponsor);
- expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
+ expect(await collectionEvm.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
+ }
});
itWeb3('Check that transaction via EVM spend money from sponsor address', async ({api, web3}) => {
@@ -296,22 +292,23 @@
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const sponsor = await createEthAccountWithBalance(api, web3);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
- result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();
+ result = await collectionEvm.methods.ethSetSponsor(sponsor).send();
let collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
expect(collectionSub.sponsorship.isUnconfirmed).to.be.true;
expect(collectionSub.sponsorship.asUnconfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
- await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
+ await expect(collectionEvm.methods.ethConfirmSponsorship().call()).to.be.rejectedWith('Caller is not set as sponsor');
const sponsorCollection = evmCollection(web3, sponsor, collectionIdAddress);
- await sponsorCollection.methods.confirmCollectionSponsorship().send();
+ await sponsorCollection.methods.ethConfirmSponsorship().send();
collectionSub = (await getDetailedCollectionInfo(api, collectionId))!;
expect(collectionSub.sponsorship.isConfirmed).to.be.true;
expect(collectionSub.sponsorship.asConfirmed.toHuman()).to.be.eq(evmToAddress(sponsor));
const user = createEthAccount(web3);
- await collectionEvm.methods.addCollectionAdmin(user).send();
+ await collectionEvm.methods.addAdmin(user).send();
const ownerBalanceBefore = await ethBalanceViaSub(api, owner);
const sponsorBalanceBefore = await ethBalanceViaSub(api, sponsor);
+
const userCollectionEvm = evmCollection(web3, user, collectionIdAddress);
const nextTokenId = await userCollectionEvm.methods.nextTokenId().call();
tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth--- a/tests/src/eth/nonFungibleAbi.json
+++ b/tests/src/eth/nonFungibleAbi.json
@@ -91,6 +91,15 @@
},
{
"inputs": [
+ { "internalType": "address", "name": "user", "type": "address" }
+ ],
+ "name": "addToAllowList",
+ "outputs": [],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "approved", "type": "address" },
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
],
@@ -291,6 +300,15 @@
},
{
"inputs": [
+ { "internalType": "address", "name": "user", "type": "address" }
+ ],
+ "name": "removeFromAllowList",
+ "outputs": [],
+ "stateMutability": "view",
+ "type": "function"
+ },
+ {
+ "inputs": [
{ "internalType": "address", "name": "from", "type": "address" },
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }
@@ -313,6 +331,13 @@
"type": "function"
},
{
+ "inputs": [{ "internalType": "string", "name": "mode", "type": "string" }],
+ "name": "setAccess",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "address", "name": "operator", "type": "address" },
{ "internalType": "bool", "name": "approved", "type": "bool" }
@@ -397,6 +422,13 @@
"type": "function"
},
{
+ "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],
+ "name": "setMintMode",
+ "outputs": [],
+ "stateMutability": "nonpayable",
+ "type": "function"
+ },
+ {
"inputs": [
{ "internalType": "bool", "name": "enable", "type": "bool" },
{