starknet-edu / starknet-cairo-101

Learn how to read Cairo code
470 stars 245 forks source link

chore: convert ex00_base to new_syntax #65

Open codeWhizperer opened 1 year ago

codeWhizperer commented 1 year ago

@omarespejel ex00_base.cairo contains internal functions, I created a separate file for its interface (Iex00_base.cairo) and its implementation is the ex00_base.cairo. The functions in the module an be referenced in other module using the dispatcher generated.

dbejarano820 commented 1 year ago

@codeWhizperer is using a dispatcher truly the behavior we want to replace using the imported functions with? Wouldn't this be an actual call instead on inheriting the logic internally?

**EDIT: Reading into it a bit more, would we use a library dispatcher instead of a contract dispatcher?

I'm trying to refactor ERC20_base which has some similar behavior, there are some internal functions which are imported directly elsewhere and used.

codeWhizperer commented 1 year ago

@dbejarano820 good observation. I think this kind of bid the question, what's exact behavior is expected whenever a call is made? Comparing contract dispatcher to library dispatcher, I understand that,

contract dispatcher executes the external contract's logic within its context, allowing state modifications, while the library dispatcher executes the call in the calling contract's context without the ability to modify the target contract's state

Chomtana commented 9 months ago

I think it should be a component instead of contract?

omarespejel commented 9 months ago

I think @Chomtana is right, we might need to convert it to a component. Thanks @codeWhizperer for the contribution and @dbejarano820 for the review.

@Chomtana @dbejarano820 do you have any further insights so we can start with the conversion?

dbejarano820 commented 9 months ago

I think @Chomtana is right, we might need to convert it to a component. Thanks @codeWhizperer for the contribution and @dbejarano820 for the review.

@Chomtana @dbejarano820 do you have any further insights so we can start with the conversion?

Yes! Now that cairo components is out, we can leverage that here