starkware-libs / cairo

Cairo is the first Turing-complete language for creating provable programs for general computation.
Apache License 2.0
1.54k stars 475 forks source link

feat: Import a library ([starknet::component]) inside another library ([starknet::component]) #4574

Open rajeebkm opened 9 months ago

rajeebkm commented 9 months ago

Feature Request

Describe the Feature Request

Import a library ([starknet::component]) inside another library ([starknet::component])

Describe Preferred Solution

It would be great if cairo supports importing library in another library. We can easily use other libraries as well.

Describe Alternatives

Related Code

use project::{interfaces::IFees, libraries::LibAsset::LibAsset as LibAssetComponent};

[starknet::component]

mod LibFees { use starknet::ContractAddress; use super::LibAssetComponent;

component!(path: LibAssetComponent, storage: libAsset, event: LibAssetEvent);

}

Additional Context

image

If the feature request is approved, would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)

tensojka commented 9 months ago

Isn't this possible already? See https://community.starknet.io/t/cairo-components/101136 , section Component dependencies

orizi commented 3 weeks ago

starting with the 2.7.* releases new style of storage pointers are available - allows to write proper generics based code - describing a general component.

following storage_node would be possibly generics - allowing easily mixing such types to share generic logics and storage across components and contracts.