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: enable adding examples #38

Merged
merged 5 commits into from
Apr 9, 2024
Merged

feat: enable adding examples #38

merged 5 commits into from
Apr 9, 2024

Conversation

alexfertel
Copy link
Contributor

@alexfertel alexfertel commented Apr 8, 2024

Main things that change:

Sorry about making so many changes at once, but they are quite small and most of the changes are needed to enable adding examples.

As a result of setting features properly, we now have a missing docs warning that we cannot fix. See alloy-rs/core#588

@alexfertel alexfertel added priority: 3 We will resolve this first before everything else. type: test Changes to the testing suite. effort: high Large or difficult task. type: ref A code update that doesn't meaningfully change functionality. labels Apr 8, 2024
@alexfertel alexfertel added this to the Release v0.1.0 milestone Apr 8, 2024
@alexfertel alexfertel self-assigned this Apr 8, 2024
Copy link

netlify bot commented Apr 8, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit c5f8c3b
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/661539fc2dbf9a00088de03b

qalisander
qalisander previously approved these changes Apr 8, 2024
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.

Good job!
May be we should think about the name of feature since 'tests' is a bit confusing

Copy link

codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 10.00000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 80.2%. Comparing base (484dbd9) to head (c5f8c3b).

Additional details and impacted files
Files Coverage Δ
contracts/src/erc20/extensions/metadata.rs 80.9% <100.0%> (ø)
contracts/src/erc20/mod.rs 86.5% <ø> (ø)
contracts/src/lib.rs 100.0% <ø> (ø)
contracts/src/erc721/mod.rs 56.9% <0.0%> (-0.3%) ⬇️

bidzyyys
bidzyyys previously approved these changes Apr 9, 2024
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.

Good job! Left a few comments.

@@ -87,7 +87,7 @@ impl Metadata {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "tests"))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need both all(test, feature = "tests")? I am not sure about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do! Otherwise, we would have to declare dev-dependencies used only in tests as dependencies, and they will be included in the binaries.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, thanks!

license.workspace = true
repository.workspace = true
publish = false
version = "0.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not 0.0.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't plan to version examples, since I'm expecting them to be tied to the versions of contracts, but I'm not set on this, if you have a different idea lmk!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that they should follow contract's version. Just for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, that would add some maintenance burden, do you think it's worth it? i.e. we would have to keep versions up-to-date for all examples whenever we change the version of contracts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

sed command should work or check in any IDE. But we can left as it is

self.metadata.constructor(name, symbol);
}

pub fn decimals(&self) -> u8 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why decimals is not a part of Metadata here and you do not use #[inherit(ERC20, Metadata)]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this one answer your first question?

you do not use #[inherit(ERC20, Metadata)]

No real reason not to add it here!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not exactly, my question is why decimals() is not used directly from Metadata.

impl Metadata {
    pub fn decimals(&self) -> u8 {
        DECIMALS
    }
} 

Copy link
Collaborator

Choose a reason for hiding this comment

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

And then you need to show in examples how to use Metadata extension's functions to be accessible from Token

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that is just to showcase the way you override _decimals on consumers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, didn't catch this...
Maybe in this case we should have a comment that this is a way to override the default impl from Metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And then you need to show in examples how to use Metadata extension's functions to be accessible from Token

Not sure I follow, wdym? If you mean that we should show how Token now has Metadata's functions, then that's what tests are for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe in this case we should have a comment that this is a way to override the default impl from Metadata.

Ah, yeah, that makes perfect sense, I'll add it!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I follow, wdym? If you mean that we should show how Token now has Metadata's functions, then that's what tests are for.

I missed this commit -> 4fa637e
Now it does not matter.

@alexfertel alexfertel merged commit cf32874 into main Apr 9, 2024
18 checks passed
@alexfertel alexfertel deleted the erc20-example branch April 9, 2024 13:03
@alexfertel alexfertel removed this from the Release v0.1.0 milestone Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: high Large or difficult task. priority: 3 We will resolve this first before everything else. type: ref A code update that doesn't meaningfully change functionality. type: test Changes to the testing suite.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants