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

refacto(dojo): implement interfaces for dojo-core contracts #581

Merged
merged 4 commits into from
Jun 30, 2023

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Jun 30, 2023

Few remarks on this refacto related to #578:

  1. emit method of World conflicts with EventEmitter:

    Ambiguous method call. More than one applicable trait function with a suitable self type
    was found: IWorld::emit and EventEmitter::emit. Consider adding type annotations or
    explicitly refer to the impl function.

    I see two options here:

    • Using the explicit type each time we want to emit an event in IWorld interface impl.
      EventEmitter::emit(ref self, Struct {...});

    • Rename emit -> emit_event for IWorld. (I have tried this way, let me know if you prefer the first one, as perhaps this will break the interface used by other games).

  2. During the implementation, I mostly trust the already existing code inside the contracts instead of the interfaces. And I updated the interfaces to match the contracts. Is that ok for you?

  3. Add consistency to the documentation of the functions.

@tarrencev
Copy link
Contributor

Thank you for this!

Few remarks on this refacto related to #578:

  1. emit method of World conflicts with EventEmitter:

    Ambiguous method call. More than one applicable trait function with a suitable self type
    was found: IWorld::emit and EventEmitter::emit. Consider adding type annotations or
    explicitly refer to the impl function.

    I see two options here:

    • Using the explicit type each time we want to emit an event in IWorld interface impl.
      EventEmitter::emit(ref self, Struct {...});
    • Rename emit -> emit_event for IWorld. (I have tried this way, let me know if you prefer the first one, as perhaps this will break the interface used by other games).

I would prefer the first approach here, so we can keep the public interface clean

  1. During the implementation, I mostly trust the already existing code inside the contracts instead of the interfaces. And I updated the interfaces to match the contracts. Is that ok for you?

Yup that makes sense!

  1. Add consistency to the documentation of the functions.

❤️

@glihm
Copy link
Collaborator Author

glihm commented Jun 30, 2023

@tarrencev I updated with EventEmitter to ensure that the interface is kept clean as you mentioned. 👍

ref self: T, component: felt252, key: Query, offset: u8, value: Span<felt252>
);
fn entities(self: @T, component: felt252, partition: felt252) -> (Span<felt252>, Span<Span<felt252>>);
fn execute(ref self: T, system: felt252, calldata: Span<felt252>) -> Span<felt252>;
Copy link
Contributor

Choose a reason for hiding this comment

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

As a follow up, it would be great to move these to the implementation's file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have open #588 @tarrencev to follow up this topic.

@tarrencev tarrencev merged commit 415964b into dojoengine:main Jun 30, 2023
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.

2 participants