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

solidity create collection return an ethereum address #103

Merged

Conversation

asiniscalchi
Copy link
Member

@asiniscalchi asiniscalchi commented Aug 3, 2023

  • create collection return address to ERC721
  • create collection emit event
  • removed owner of
    image

@asiniscalchi asiniscalchi changed the title Feature/solidity create collection return an address solidity create collection return an ethereum address Aug 3, 2023
@asiniscalchi asiniscalchi linked an issue Aug 3, 2023 that may be closed by this pull request
@asiniscalchi asiniscalchi marked this pull request as ready for review August 4, 2023 12:53
/// `from_low_u64_be` method to convert the `u64` value into the lower 64 bits of the `H160`.
/// Additionally, the function sets the first bit of the resulting `H160` to 1, which can be used to
/// distinguish addresses created by this function from other addresses.
pub fn collection_id_to_address(collection_id: CollectionId) -> H160 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would suggest refactoring it to a trait with default implementation. this way it looks nicer and will be more extensible

pub trait CollectonIdToAddress {
   fn collection_id_to_address(collection_id: CollectionId) -> H160 {
      let mut address = H160::from_low_u64_be(collection_id);
	  address.0[0] |= 0x80; // Set the first bit to 1
	  address
   }
}

Copy link
Member Author

@asiniscalchi asiniscalchi Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you'd think that way, but for now, I'm not inclined to generalize this part of the code. I usually prefer to keep things simple until there's a real need to make them more complex. If someone needs to extend this in the future, they can take care of it then.

By the way, you were spot on about the public visibility. That was a mistake on my part, and I'll be fixing it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was suggesting it mainly because it's not idiomatic to do conversions with a regular function, instead use an existing trait (From, Into, sp_runtime::Convert), or declare new one. I am ok with this way of doing it of course, just looks a bit odd to me

@asiniscalchi asiniscalchi requested a review from tonimateos August 4, 2023 14:36
@asiniscalchi asiniscalchi requested a review from a user August 4, 2023 15:10
@asiniscalchi asiniscalchi merged commit a6633f5 into dev Aug 5, 2023
@asiniscalchi asiniscalchi deleted the feature/solidity_create_collection_return_an_address branch August 5, 2023 04:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create collection in Ownchain
2 participants