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: Add UpdateAdmin and ClearAdmin constructors in the Remote #438

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

jawoznia
Copy link
Collaborator

No description provided.

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 70.37037% with 8 lines in your changes missing coverage. Please review.

Project coverage is 72.18%. Comparing base (2da70e6) to head (6fb6049).
Report is 3 commits behind head on feat/replies.

Files with missing lines Patch % Lines
sylvia/tests/remote.rs 63.63% 8 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           feat/replies     #438      +/-   ##
================================================
- Coverage         72.20%   72.18%   -0.02%     
================================================
  Files                56       56              
  Lines              3457     3484      +27     
================================================
+ Hits               2496     2515      +19     
- Misses              961      969       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jawoznia jawoznia force-pushed the jawoznia/feat/admin_management_through_remote branch from 735bfeb to 8b74359 Compare October 1, 2024 14:46
Copy link

@uint uint left a comment

Choose a reason for hiding this comment

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

LGTM! I only wonder if doc comments would be useful with these new pub methods

sylvia/tests/remote.rs Show resolved Hide resolved
sylvia/src/types.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@hashedone hashedone left a comment

Choose a reason for hiding this comment

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

One comment about API improvement.

sylvia/src/types.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@kulikthebird kulikthebird left a comment

Choose a reason for hiding this comment

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

I like this change, it's nice to have those extra methods in the Remote implementation. The only thing I spend more time was checking the remote.rs file with tests. I realized it is more complicated than it can be. I know it's not directly related to this PR, but we can do a nice improvement with low cost:

  1. unsigned_contract and signed_contract are pretty much the same - let's remove the code duplication and make a single Counter contract generic over the counter type. We can then add type SignedContract = Counter<i32>; type UnsignedContract = Counter<u32>;.
  2. Names signed and unsigned reminds me of signing something with some cryptographic tool, when in this context it means i32 and u32. Let's change it to CounterI32/CounterU32 or ContractI32/ContractU32 instead.
  3. ContractStorage is a dead code - to be removed.
  4. Remove the #[entry_points(generics<i32>)] - we don't need it in the test scenarios. Moreover it might be misleading for other devs:
  • it's only i32, but we can support many other types - better way would be to add feature flags for the contracts to choose between entry points types,
  • it gives a hint that it always should be present with sylvia contracts - it doesn't have to.

.unwrap();

// Set manager contract as an admin of the counter contract
app.app_mut()
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's create a new setup function for the admin scenarios

@jawoznia
Copy link
Collaborator Author

jawoznia commented Oct 8, 2024

I agree it could be simplified

2. Names `signed` and `unsigned` reminds me of signing something with some cryptographic tool, when in this context it means `i32` and `u32`. Let's change it to `CounterI32`/`CounterU32` or `ContractI32`/`ContractU32` instead.

I can see that. Let's change it later.

3. `ContractStorage` is a dead code - to be removed.

This is intentional. There was a bug where it was impossible to store Remote in custom storage types. A comment explaining this would be very much in place.

4. Remove the `#[entry_points(generics<i32>)]` - we don't need it in the test scenarios. Moreover it might be misleading for other devs:

It provides the coverage though.
I would prefer to move all the bloated examples to the tests and make them act as the coverage.
The examples should be refactored to provide simple single feature showcases.

@jawoznia jawoznia force-pushed the jawoznia/feat/admin_management_through_remote branch from 3aa9968 to 789266f Compare October 9, 2024 16:23
Base automatically changed from jawoznia/feat/submsg_builder to feat/replies October 11, 2024 14:19
@jawoznia jawoznia force-pushed the jawoznia/feat/admin_management_through_remote branch from 789266f to 6fb6049 Compare October 11, 2024 14:20
@jawoznia jawoznia merged commit 9e28aeb into feat/replies Oct 11, 2024
7 of 9 checks passed
@jawoznia jawoznia deleted the jawoznia/feat/admin_management_through_remote branch October 11, 2024 14:34
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.

4 participants