This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add model upgradeability checks
- Loading branch information
Showing
17 changed files
with
307 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
#[starknet::interface] | ||
pub trait IContract<T> { | ||
fn dojo_name(self: @T) -> ByteArray; | ||
} | ||
pub trait IContract<T> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use dojo::event::{Event, IEvent, EventDefinition}; | ||
use dojo::meta::{Layout, introspect::Struct}; | ||
|
||
#[starknet::embeddable] | ||
pub impl IDeployedEventImpl< | ||
TContractState, E, +Event<E> | ||
> of dojo::meta::interface::IDeployedResource<TContractState> { | ||
fn dojo_name(self: @TContractState) -> ByteArray { | ||
Event::<E>::name() | ||
} | ||
} | ||
|
||
#[starknet::embeddable] | ||
pub impl IStoredEventImpl< | ||
TContractState, E, +Event<E> | ||
> of dojo::meta::interface::IStoredResource<TContractState> { | ||
fn schema(self: @TContractState) -> Struct { | ||
Event::<E>::schema() | ||
} | ||
|
||
fn layout(self: @TContractState) -> Layout { | ||
Event::<E>::layout() | ||
} | ||
} | ||
|
||
#[starknet::embeddable] | ||
pub impl IEventImpl<TContractState, E, +Event<E>> of IEvent<TContractState> { | ||
fn definition(self: @TContractState) -> EventDefinition { | ||
Event::<E>::definition() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
use dojo::meta::Layout; | ||
use dojo::meta::introspect::Ty; | ||
use dojo::meta::introspect::Struct; | ||
|
||
#[derive(Drop, Serde, Debug, PartialEq)] | ||
pub struct EventDefinition { | ||
pub name: ByteArray, | ||
pub layout: Layout, | ||
pub schema: Ty | ||
pub schema: Struct | ||
} | ||
|
||
pub trait Event<T> { | ||
fn name() -> ByteArray; | ||
fn definition() -> EventDefinition; | ||
fn layout() -> Layout; | ||
fn schema() -> Ty; | ||
fn schema() -> Struct; | ||
fn keys(self: @T) -> Span<felt252>; | ||
fn values(self: @T) -> Span<felt252>; | ||
/// Returns the selector of the model computed for the given namespace hash. | ||
/// Returns the selector of the event computed for the given namespace hash. | ||
fn selector(namespace_hash: felt252) -> felt252; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
use dojo::meta::Layout; | ||
use dojo::meta::introspect::Ty; | ||
|
||
use super::EventDefinition; | ||
|
||
#[starknet::interface] | ||
pub trait IEvent<T> { | ||
fn dojo_name(self: @T) -> ByteArray; | ||
fn definition(self: @T) -> EventDefinition; | ||
fn layout(self: @T) -> Layout; | ||
fn schema(self: @T) -> Ty; | ||
fn definition(self: @T) -> super::EventDefinition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use dojo::meta::Layout; | ||
use dojo::meta::introspect::Struct; | ||
|
||
/// The `IDeployedResource` starknet interface. | ||
/// | ||
/// This is the interface used by offchain components and other contracts | ||
/// to get some info such Dojo name from a deployed resource. | ||
#[starknet::interface] | ||
pub trait IDeployedResource<T> { | ||
fn dojo_name(self: @T) -> ByteArray; | ||
} | ||
|
||
/// The `IStoredResource` starknet interface. | ||
/// | ||
/// This is the interface used by offchain components and other contracts | ||
/// to access to storage related data of a deployed resource. | ||
#[starknet::interface] | ||
pub trait IStoredResource<T> { | ||
fn layout(self: @T) -> Layout; | ||
fn schema(self: @T) -> Struct; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
use dojo::meta::{Layout, Ty}; | ||
use dojo::model::ModelDef; | ||
|
||
/// The `IModel` starknet interface. | ||
/// | ||
/// This is the interface used by offchain components and other contracts | ||
/// to interact with deployed models. | ||
#[starknet::interface] | ||
pub trait IModel<T> { | ||
fn dojo_name(self: @T) -> ByteArray; | ||
fn version(self: @T) -> u8; | ||
fn layout(self: @T) -> Layout; | ||
fn schema(self: @T) -> Ty; | ||
fn unpacked_size(self: @T) -> Option<usize>; | ||
fn packed_size(self: @T) -> Option<usize>; | ||
fn definition(self: @T) -> ModelDef; | ||
fn definition(self: @T) -> dojo::model::ModelDef; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.