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 macros for shared interfaces #105

Merged
merged 33 commits into from
Dec 10, 2024
Merged

Conversation

milapsheth
Copy link
Member

@milapsheth milapsheth commented Dec 8, 2024

AXE-6852

Shared interfaces can now be implemented via derive macros:

use axelar_soroban_std::{Operatable, Ownable, Upgradable};

#[contract]
#[derive(Operatable, Ownable, Upgradable)]
pub struct AxelarGateway;

@milapsheth milapsheth requested a review from a team as a code owner December 8, 2024 07:55
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2024

Codecov Report

Attention: Patch coverage is 83.58209% with 22 lines in your changes missing coverage. Please review.

Project coverage is 95.26%. Comparing base (bdf9443) to head (912e8dc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/axelar-soroban-std-derive/src/lib.rs 84.42% 19 Missing ⚠️
contracts/axelar-gas-service/src/contract.rs 0.00% 1 Missing ⚠️
contracts/interchain-token-service/src/contract.rs 0.00% 1 Missing ⚠️
contracts/interchain-token/src/contract.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #105      +/-   ##
==========================================
+ Coverage   93.74%   95.26%   +1.52%     
==========================================
  Files          47       48       +1     
  Lines        3053     3083      +30     
==========================================
+ Hits         2862     2937      +75     
+ Misses        191      146      -45     

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

Copy link
Contributor

@cgorenflo cgorenflo left a comment

Choose a reason for hiding this comment

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

I do like the approach, but a few notes:

  • I'd prefer if contracts don't have to depend directly on the derive crate, instead have an indirect import (potentially with feature flag "derive") in the axelar-soroban-sdk. See the amplifier repo for how to do that
  • remove the leading :: in paths, it makes the code much more brittle, like with goldie, and you have to define the import at the root level, it won't look at the local relative context
  • you only showed the trivial migration data example, how does it work with more complex data?
  • Are you sure that the contract proc macro actually picks up on the generated code and creates entrypoints for it?

packages/axelar-soroban-std-derive/src/lib.rs Outdated Show resolved Hide resolved
@milapsheth
Copy link
Member Author

milapsheth commented Dec 10, 2024

remove the leading :: in paths, it makes the code much more brittle, like with goldie, and you have to define the import at the root level, it won't look at the local relative context

The Rust doc recommended the :: prefix to avoid collisions, but your point regarding goldie is valid, and collisions are unlikely in this case

@milapsheth
Copy link
Member Author

I'd prefer if contracts don't have to depend directly on the derive crate, instead have an indirect import (potentially with feature flag "derive") in the axelar-soroban-sdk. See the amplifier repo for how to do that

Yeah, forgot about that. Refactored

@milapsheth milapsheth enabled auto-merge (squash) December 10, 2024 23:36
@milapsheth milapsheth merged commit 4f513f9 into main Dec 10, 2024
5 checks passed
@milapsheth milapsheth deleted the refactor/interface-macros branch December 10, 2024 23:40
@ahramy ahramy mentioned this pull request Jan 21, 2025
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