Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Minor typos corrected (#115)
Browse files Browse the repository at this point in the history
* create mock and testing

* first test

* testing ethereum reserved addresses

* refactoring

* refactoring

* refactoring tests

* fmt

* erc721 starting point

* fmt

* compiling

* check selectors

* create trait Erc721

* Erc721Precompile

* set mocks

* first implermentation

* first integration of erc721 in the runtime

* fmt

* check on the collection id

* test on extract owner form asset_id

* fix tests

* test for erc721 trait

* fix compilation

* refactoring

* returning address

* return value is correctly encoded as a n Address

* is_erc721_contract is not member of PrecompoileSet

* test on precompiled contracts

* erc721 returns hardcoded address

* refactoring

* testing return of asset ownership

* fix errors

* remove unused use

* refactoring

* rewriting testing mod

* refactoring

* moving check for cllection address in pallet

* collection address prefix changed

* test passing

* test passing

* refactoring tests

* do not panic the runtime

* fmt

* solidity tokenId -> _tokenId

* erc721 functions are views

* update docs

* sp-core in std , removed duplicate function

* documentaetion

* using compilator type ifer

* Minor typos corrected

* compiler infer the size of the array

* added to std feature

* rename variable

* minor extra typo

---------

Co-authored-by: Alessandro Siniscalchi <[email protected]>
Co-authored-by: magecnion <[email protected]>
  • Loading branch information
3 people authored Aug 16, 2023
1 parent a3c9a65 commit e1c3df4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pallets/living-assets-ownership/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type AccountId = <Test as frame_system::Config>::AccountId;
const ALICE: AccountId = 0x1234;

#[test]
fn owner_of_unexistent_collection_is_none() {
fn owner_of_nonexistent_collection_is_none() {
new_test_ext().execute_with(|| {
assert_eq!(LivingAssetsModule::owner_of_collection(0), None);
assert_eq!(LivingAssetsModule::owner_of_collection(1), None);
Expand Down Expand Up @@ -62,7 +62,7 @@ fn living_assets_ownership_trait_create_new_collection() {
}

#[test]
fn living_assets_ownership_trait_owner_of_unexistent_collection_is_none() {
fn living_assets_ownership_trait_owner_of_nonexistent_collection_is_none() {
new_test_ext().execute_with(|| {
assert_eq!(
<LivingAssetsModule as CollectionManager<AccountId>>::owner_of_collection(0),
Expand Down Expand Up @@ -117,7 +117,7 @@ fn living_assets_ownership_trait_id_of_new_collection_should_be_consecutive() {
}

#[test]
fn erc721_owner_of_asset_of_unexistent_collection() {
fn erc721_owner_of_asset_of_nonexistent_collection() {
new_test_ext().execute_with(|| {
let result = <LivingAssetsModule as Erc721>::owner_of(0, 2.into());
assert_err!(result, traits::Erc721Error::UnexistentCollection);
Expand Down
8 changes: 4 additions & 4 deletions precompile/erc721/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use sp_std::{fmt::Debug, marker::PhantomData};
#[precompile_utils_macro::generate_function_selector]
#[derive(Debug, PartialEq)]
pub enum Action {
/// Get tocken URI
TockenURI = "tokenURI(uint256)",
/// Get token URI
TokenURI = "tokenURI(uint256)",
/// Owner of
OwnerOf = "ownerOf(uint256)",
}
Expand All @@ -40,12 +40,12 @@ where
let selector = handle.read_selector()?;

handle.check_function_modifier(match selector {
Action::TockenURI => FunctionModifier::View,
Action::TokenURI => FunctionModifier::View,
Action::OwnerOf => FunctionModifier::View,
})?;

match selector {
Action::TockenURI => Err(revert("not implemented")),
Action::TokenURI => Err(revert("not implemented")),
Action::OwnerOf => {
let mut input = handle.read_input()?;
input.expect_arguments(1)?;
Expand Down
2 changes: 1 addition & 1 deletion precompile/erc721/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type AddressMapping = pallet_evm::IdentityAddressMapping;
#[test]
fn check_selectors() {
assert_eq!(Action::OwnerOf as u32, 0x6352211E);
assert_eq!(Action::TockenURI as u32, 0xC87B56DD);
assert_eq!(Action::TokenURI as u32, 0xC87B56DD);
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions precompile/living-assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ fn create_collection_assign_collection_to_caller() {
}

#[test]
fn call_unexistent_selector_should_fail() {
fn call_nonexistent_selector_should_fail() {
impl_precompile_mock_simple!(Mock, Ok(0), Some(H160::from_low_u64_be(0x1234)));

let unexistent_selector =
let nonexistent_selector =
hex::decode("fb24ae530000000000000000000000000000000000000000000000000000000000000000")
.unwrap();
let mut handle = create_mock_handle_from_input(unexistent_selector);
let mut handle = create_mock_handle_from_input(nonexistent_selector);
let result = Mock::execute(&mut handle);
assert_eq!(result.unwrap_err(), revert("unknown selector"));
}
Expand Down

0 comments on commit e1c3df4

Please sign in to comment.