Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ERC1155 #275

Merged
merged 80 commits into from
Nov 7, 2024
Merged

Conversation

programskillforverification
Copy link
Contributor

@programskillforverification programskillforverification commented Sep 4, 2024

Resolves #261

PR Checklist

  • ERC1155
  • Tests

Copy link

netlify bot commented Sep 4, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit 0b37cf5
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/672d325c2efb4f00081fbfb3

Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

You are doing great job @programskillforverification! 🚀
The structure and design look good.

Remember to add antora docs as here - https://github.com/OpenZeppelin/rust-contracts-stylus/tree/v0.1.0/docs/modules/ROOT/pages

examples/erc1155/Cargo.toml Outdated Show resolved Hide resolved
examples/erc1155/src/constructor.sol Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
contracts/src/token/erc1155/extensions/burnable.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/extensions/burnable.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 65.25573% with 197 lines in your changes missing coverage. Please review.

Project coverage is 65.3%. Comparing base (ce244e9) to head (0b37cf5).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
contracts/src/token/erc1155/mod.rs 71.9% 144 Missing ⚠️
contracts/src/token/erc1155/receiver.rs 0.0% 53 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
contracts/src/token/erc1155/receiver.rs 0.0% <0.0%> (ø)
contracts/src/token/erc1155/mod.rs 71.9% <71.9%> (ø)

@programskillforverification
Copy link
Contributor Author

You are doing great job @programskillforverification! 🚀 The structure and design look good.

Remember to add antora docs as here - https://github.com/OpenZeppelin/rust-contracts-stylus/tree/v0.1.0/docs/modules/ROOT/pages

Thanks for your review, I will fix all asap

@leeederek
Copy link

A developer is asking for an ERC1155 Stylus Rust implementation in @arbitrum_stylus TG chat.

@erayack
Copy link

erayack commented Sep 17, 2024

A developer is asking for an ERC1155 Stylus Rust implementation in @arbitrum_stylus TG chat.

Would love to hear some expected timelines but I could still use this as inspiration for my own implementation.

@programskillforverification
Copy link
Contributor Author

@bidzyyys is ERC1155 Stylus Rust implementation urgent? If so, I would to try the best finish all but antora docs by this week.

Copy link
Member

@qalisander qalisander left a comment

Choose a reason for hiding this comment

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

Great job @bidzyyys!
Thank you for pulling it up.
I think we are good to merge it.
Few minor nits I have:

contracts/src/token/erc1155/mod.rs Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Show resolved Hide resolved
/// # Arguments
///
/// * `&self` - Read access to the contract's state.
/// * `owner` - Account of the token's owner.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// * `owner` - Account of the token's owner.
/// * `account` - Account of the token's owner.

I may be out of the loop and you agreed this nit shouldn't hold the PR from being merged, but I have to do my due diligence - the wrong argument is still being described.

values,
data,
)?;
Ok(())
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: ? and Ok(()) can be omitted, since _update_with_acceptance_check's result (also Ok(())) can be propagated; same goes for a couple of other places

Don't have to change this, just noting

Copy link
Collaborator

@0xNeshi 0xNeshi left a comment

Choose a reason for hiding this comment

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

Some nits and some comment fixes

error ERC1155InvalidOperator(address operator);

/// Indicates an array length mismatch between token ids and values in a
/// [`IErc1155::safe_batch_transfer_from`] operation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically speaking, safe_batch_transfer_from is not the only operation that can return this error; it is returned in all operations that utilize fn require_equal_arrays_length, which are:

  • balance_of_batch
  • _mint_batch
  • _mint
  • safe_transfer_from
  • safe_batch_transfer_from
  • _burn
  • _burn_batch

The original comment from the Solidity version is therefore technically incorrect as well.

contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@0xNeshi 0xNeshi left a comment

Choose a reason for hiding this comment

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

Some test-related comments (include a couple of nits)

contract
.set_approval_for_all(BOB, true)
.expect("should approve Bob for operations on all Alice's tokens");
assert_eq!(contract.is_approved_for_all(alice, BOB), true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't a big deal, but all equality assertions between two boolean values could be shortened if just the regular assert!(...) is used.

assert!(contract.is_approved_for_all(alice, BOB)); // assert true
assert!(!contract.is_approved_for_all(alice, BOB)); // assert false

#[motsu::test]
fn set_approval_for_all(contract: Erc1155) {
let alice = msg::sender();
contract._operator_approvals.setter(alice).setter(BOB).set(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should already be false by default

contracts/src/token/erc1155/mod.rs Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Show resolved Hide resolved
contracts/src/token/erc1155/receiver.rs Outdated Show resolved Hide resolved
examples/erc1155/src/constructor.sol Outdated Show resolved Hide resolved
contracts/src/token/erc1155/mod.rs Show resolved Hide resolved
examples/erc1155/tests/erc1155.rs Show resolved Hide resolved
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

LGTM

@bidzyyys bidzyyys merged commit 10690f1 into OpenZeppelin:main Nov 7, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: ERC1155
7 participants