starkware-libs / cairo

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

Dependent contract interfaces #3447

Open spapinistarkware opened 1 year ago

spapinistarkware commented 1 year ago

The way to define trait dependence in Cairo is this:

trait IA<T, impl B: IB<T>> {
}

this should be extended to #[contract_interface] of the starknet plugin:

#[starknet::interface]
trait ITestContract<TContractState, impl Y: IY<TContractState>, impl Z: IZ<TContractState>> { 
}

The starknet plugin generates a dispatcher object and a dispatcher trait for each contract_interface. In this new case, the generated dispatcher object for ITestContract should also implement the dispatcher trait for IY.

Relevant file for this is crates/cairo-lang-starknet/src/plugin/dispatcher.rs

gaetbout commented 1 year ago

Will look into this

gaetbout commented 1 year ago

Started: https://github.com/gaetbout/cairo/tree/interface

gaetbout commented 1 year ago

This feature is back to Shahar as there are some unplanned complications