ControllerReader {
}
#[allow(clippy::ptr_arg)]
#[allow(clippy::too_many_arguments)]
- pub fn is_owner(
- &self,
- owner_guid: &starknet::core::types::Felt,
- ) -> cainome::cairo_serde::call::FCall
{
- use cainome::cairo_serde::CairoSerde;
- let mut __calldata = vec![];
- __calldata.extend(starknet::core::types::Felt::cairo_serialize(owner_guid));
- let __call = starknet::core::types::FunctionCall {
- contract_address: self.address,
- entry_point_selector: starknet::macros::selector!("is_owner"),
- calldata: __calldata,
- };
- cainome::cairo_serde::call::FCall::new(__call, self.provider())
- }
- #[allow(clippy::ptr_arg)]
- #[allow(clippy::too_many_arguments)]
- pub fn assert_valid_owner_signature(
- &self,
- signer_signature: &SignerSignature,
- ) -> cainome::cairo_serde::call::FCall
{
- use cainome::cairo_serde::CairoSerde;
- let mut __calldata = vec![];
- __calldata.extend(SignerSignature::cairo_serialize(signer_signature));
- let __call = starknet::core::types::FunctionCall {
- contract_address: self.address,
- entry_point_selector: starknet::macros::selector!("assert_valid_owner_signature"),
- calldata: __calldata,
- };
- cainome::cairo_serde::call::FCall::new(__call, self.provider())
- }
- #[allow(clippy::ptr_arg)]
- #[allow(clippy::too_many_arguments)]
- pub fn delegate_account(
- &self,
- ) -> cainome::cairo_serde::call::FCall
{
- use cainome::cairo_serde::CairoSerde;
- let mut __calldata = vec![];
- let __call = starknet::core::types::FunctionCall {
- contract_address: self.address,
- entry_point_selector: starknet::macros::selector!("delegate_account"),
- calldata: __calldata,
- };
- cainome::cairo_serde::call::FCall::new(__call, self.provider())
- }
- #[allow(clippy::ptr_arg)]
- #[allow(clippy::too_many_arguments)]
pub fn is_valid_outside_execution_nonce(
&self,
nonce: &starknet::core::types::Felt,
@@ -2856,20 +2842,14 @@ impl ControllerReader {
}
#[allow(clippy::ptr_arg)]
#[allow(clippy::too_many_arguments)]
- pub fn is_valid_signature(
+ pub fn delegate_account(
&self,
- hash: &starknet::core::types::Felt,
- signature: &Vec,
- ) -> cainome::cairo_serde::call::FCall {
+ ) -> cainome::cairo_serde::call::FCall
{
use cainome::cairo_serde::CairoSerde;
let mut __calldata = vec![];
- __calldata.extend(starknet::core::types::Felt::cairo_serialize(hash));
- __calldata.extend(Vec::::cairo_serialize(
- signature,
- ));
let __call = starknet::core::types::FunctionCall {
contract_address: self.address,
- entry_point_selector: starknet::macros::selector!("is_valid_signature"),
+ entry_point_selector: starknet::macros::selector!("delegate_account"),
calldata: __calldata,
};
cainome::cairo_serde::call::FCall::new(__call, self.provider())
@@ -2890,4 +2870,24 @@ impl ControllerReader {
};
cainome::cairo_serde::call::FCall::new(__call, self.provider())
}
+ #[allow(clippy::ptr_arg)]
+ #[allow(clippy::too_many_arguments)]
+ pub fn is_valid_signature(
+ &self,
+ hash: &starknet::core::types::Felt,
+ signature: &Vec,
+ ) -> cainome::cairo_serde::call::FCall {
+ use cainome::cairo_serde::CairoSerde;
+ let mut __calldata = vec![];
+ __calldata.extend(starknet::core::types::Felt::cairo_serialize(hash));
+ __calldata.extend(Vec::::cairo_serialize(
+ signature,
+ ));
+ let __call = starknet::core::types::FunctionCall {
+ contract_address: self.address,
+ entry_point_selector: starknet::macros::selector!("is_valid_signature"),
+ calldata: __calldata,
+ };
+ cainome::cairo_serde::call::FCall::new(__call, self.provider())
+ }
}
diff --git a/packages/account_sdk/src/abigen/erc_20.rs b/packages/account_sdk/src/abigen/erc_20.rs
index 42ed6a401..a3da404c2 100644
--- a/packages/account_sdk/src/abigen/erc_20.rs
+++ b/packages/account_sdk/src/abigen/erc_20.rs
@@ -53,31 +53,29 @@ impl Erc20Reader {
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub struct Transfer {
- pub from: cainome::cairo_serde::ContractAddress,
- pub to: cainome::cairo_serde::ContractAddress,
- pub value: cainome::cairo_serde::U256,
+pub struct OwnershipTransferred {
+ pub previous_owner: cainome::cairo_serde::ContractAddress,
+ pub new_owner: cainome::cairo_serde::ContractAddress,
}
-impl cainome::cairo_serde::CairoSerde for Transfer {
+impl cainome::cairo_serde::CairoSerde for OwnershipTransferred {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
let mut __size = 0;
- __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.from);
- __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.to);
- __size += cainome::cairo_serde::U256::cairo_serialized_size(&__rust.value);
+ __size +=
+ cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.previous_owner);
+ __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.new_owner);
__size
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
let mut __out: Vec = vec![];
__out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
- &__rust.from,
+ &__rust.previous_owner,
));
__out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
- &__rust.to,
+ &__rust.new_owner,
));
- __out.extend(cainome::cairo_serde::U256::cairo_serialize(&__rust.value));
__out
}
fn cairo_deserialize(
@@ -85,39 +83,42 @@ impl cainome::cairo_serde::CairoSerde for Transfer {
__offset: usize,
) -> cainome::cairo_serde::Result {
let mut __offset = __offset;
- let from = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&from);
- let to = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&to);
- let value = cainome::cairo_serde::U256::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::U256::cairo_serialized_size(&value);
- Ok(Transfer { from, to, value })
+ let previous_owner =
+ cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
+ let new_owner =
+ cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
+ Ok(OwnershipTransferred {
+ previous_owner,
+ new_owner,
+ })
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub struct Approval {
- pub owner: cainome::cairo_serde::ContractAddress,
- pub spender: cainome::cairo_serde::ContractAddress,
+pub struct Transfer {
+ pub from: cainome::cairo_serde::ContractAddress,
+ pub to: cainome::cairo_serde::ContractAddress,
pub value: cainome::cairo_serde::U256,
}
-impl cainome::cairo_serde::CairoSerde for Approval {
+impl cainome::cairo_serde::CairoSerde for Transfer {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
let mut __size = 0;
- __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.owner);
- __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.spender);
+ __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.from);
+ __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.to);
__size += cainome::cairo_serde::U256::cairo_serialized_size(&__rust.value);
__size
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
let mut __out: Vec = vec![];
__out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
- &__rust.owner,
+ &__rust.from,
));
__out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
- &__rust.spender,
+ &__rust.to,
));
__out.extend(cainome::cairo_serde::U256::cairo_serialize(&__rust.value));
__out
@@ -127,25 +128,21 @@ impl cainome::cairo_serde::CairoSerde for Approval {
__offset: usize,
) -> cainome::cairo_serde::Result {
let mut __offset = __offset;
- let owner = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&owner);
- let spender = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&spender);
+ let from = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&from);
+ let to = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&to);
let value = cainome::cairo_serde::U256::cairo_deserialize(__felts, __offset)?;
__offset += cainome::cairo_serde::U256::cairo_serialized_size(&value);
- Ok(Approval {
- owner,
- spender,
- value,
- })
+ Ok(Transfer { from, to, value })
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub struct OwnershipTransferred {
+pub struct OwnershipTransferStarted {
pub previous_owner: cainome::cairo_serde::ContractAddress,
pub new_owner: cainome::cairo_serde::ContractAddress,
}
-impl cainome::cairo_serde::CairoSerde for OwnershipTransferred {
+impl cainome::cairo_serde::CairoSerde for OwnershipTransferStarted {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = None;
#[inline]
@@ -177,35 +174,29 @@ impl cainome::cairo_serde::CairoSerde for OwnershipTransferred {
let new_owner =
cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
__offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
- Ok(OwnershipTransferred {
+ Ok(OwnershipTransferStarted {
previous_owner,
new_owner,
})
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub struct OwnershipTransferStarted {
- pub previous_owner: cainome::cairo_serde::ContractAddress,
- pub new_owner: cainome::cairo_serde::ContractAddress,
+pub struct Upgraded {
+ pub class_hash: cainome::cairo_serde::ClassHash,
}
-impl cainome::cairo_serde::CairoSerde for OwnershipTransferStarted {
+impl cainome::cairo_serde::CairoSerde for Upgraded {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
let mut __size = 0;
- __size +=
- cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.previous_owner);
- __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.new_owner);
+ __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash);
__size
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
let mut __out: Vec = vec![];
- __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
- &__rust.previous_owner,
- ));
- __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
- &__rust.new_owner,
+ __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(
+ &__rust.class_hash,
));
__out
}
@@ -214,36 +205,37 @@ impl cainome::cairo_serde::CairoSerde for OwnershipTransferStarted {
__offset: usize,
) -> cainome::cairo_serde::Result {
let mut __offset = __offset;
- let previous_owner =
- cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
- let new_owner =
- cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
- Ok(OwnershipTransferStarted {
- previous_owner,
- new_owner,
- })
+ let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash);
+ Ok(Upgraded { class_hash })
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub struct Upgraded {
- pub class_hash: cainome::cairo_serde::ClassHash,
+pub struct Approval {
+ pub owner: cainome::cairo_serde::ContractAddress,
+ pub spender: cainome::cairo_serde::ContractAddress,
+ pub value: cainome::cairo_serde::U256,
}
-impl cainome::cairo_serde::CairoSerde for Upgraded {
+impl cainome::cairo_serde::CairoSerde for Approval {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
let mut __size = 0;
- __size += cainome::cairo_serde::ClassHash::cairo_serialized_size(&__rust.class_hash);
+ __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.owner);
+ __size += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&__rust.spender);
+ __size += cainome::cairo_serde::U256::cairo_serialized_size(&__rust.value);
__size
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
let mut __out: Vec = vec![];
- __out.extend(cainome::cairo_serde::ClassHash::cairo_serialize(
- &__rust.class_hash,
+ __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
+ &__rust.owner,
));
+ __out.extend(cainome::cairo_serde::ContractAddress::cairo_serialize(
+ &__rust.spender,
+ ));
+ __out.extend(cainome::cairo_serde::U256::cairo_serialize(&__rust.value));
__out
}
fn cairo_deserialize(
@@ -251,43 +243,39 @@ impl cainome::cairo_serde::CairoSerde for Upgraded {
__offset: usize,
) -> cainome::cairo_serde::Result {
let mut __offset = __offset;
- let class_hash = cainome::cairo_serde::ClassHash::cairo_deserialize(__felts, __offset)?;
- __offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash);
- Ok(Upgraded { class_hash })
+ let owner = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&owner);
+ let spender = cainome::cairo_serde::ContractAddress::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&spender);
+ let value = cainome::cairo_serde::U256::cairo_deserialize(__felts, __offset)?;
+ __offset += cainome::cairo_serde::U256::cairo_serialized_size(&value);
+ Ok(Approval {
+ owner,
+ spender,
+ value,
+ })
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub enum OwnableComponentEvent {
- OwnershipTransferred(OwnershipTransferred),
- OwnershipTransferStarted(OwnershipTransferStarted),
+pub enum UpgradeEvent {
+ Upgraded(Upgraded),
}
-impl cainome::cairo_serde::CairoSerde for OwnableComponentEvent {
+impl cainome::cairo_serde::CairoSerde for UpgradeEvent {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = std::option::Option::None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
match __rust {
- OwnableComponentEvent::OwnershipTransferred(val) => {
- OwnershipTransferred::cairo_serialized_size(val) + 1
- }
- OwnableComponentEvent::OwnershipTransferStarted(val) => {
- OwnershipTransferStarted::cairo_serialized_size(val) + 1
- }
+ UpgradeEvent::Upgraded(val) => Upgraded::cairo_serialized_size(val) + 1,
_ => 0,
}
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
match __rust {
- OwnableComponentEvent::OwnershipTransferred(val) => {
+ UpgradeEvent::Upgraded(val) => {
let mut temp = vec![];
temp.extend(usize::cairo_serialize(&0usize));
- temp.extend(OwnershipTransferred::cairo_serialize(val));
- temp
- }
- OwnableComponentEvent::OwnershipTransferStarted(val) => {
- let mut temp = vec![];
- temp.extend(usize::cairo_serialize(&1usize));
- temp.extend(OwnershipTransferStarted::cairo_serialize(val));
+ temp.extend(Upgraded::cairo_serialize(val));
temp
}
_ => vec![],
@@ -300,22 +288,20 @@ impl cainome::cairo_serde::CairoSerde for OwnableComponentEvent {
let __f = __felts[__offset];
let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap());
match __index as usize {
- 0usize => Ok(OwnableComponentEvent::OwnershipTransferred(
- OwnershipTransferred::cairo_deserialize(__felts, __offset + 1)?,
- )),
- 1usize => Ok(OwnableComponentEvent::OwnershipTransferStarted(
- OwnershipTransferStarted::cairo_deserialize(__felts, __offset + 1)?,
- )),
+ 0usize => Ok(UpgradeEvent::Upgraded(Upgraded::cairo_deserialize(
+ __felts,
+ __offset + 1,
+ )?)),
_ => {
return Err(cainome::cairo_serde::Error::Deserialize(format!(
"Index not handle for enum {}",
- "OwnableComponentEvent"
+ "UpgradeEvent"
)))
}
}
}
}
-impl TryFrom for OwnableComponentEvent {
+impl TryFrom for UpgradeEvent {
type Error = String;
fn try_from(event: starknet::core::types::EmittedEvent) -> Result {
use cainome::cairo_serde::CairoSerde;
@@ -324,85 +310,25 @@ impl TryFrom for OwnableComponentEvent {
}
let selector = event.keys[0];
if selector
- == starknet::core::utils::get_selector_from_name("OwnershipTransferred")
- .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnershipTransferred"))
- {
- let mut key_offset = 0 + 1;
- let mut data_offset = 0;
- let previous_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "previous_owner", "OwnershipTransferred", e
- ))
- }
- };
- key_offset +=
- cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
- let new_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "new_owner", "OwnershipTransferred", e
- ))
- }
- };
- key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
- return Ok(OwnableComponentEvent::OwnershipTransferred(
- OwnershipTransferred {
- previous_owner,
- new_owner,
- },
- ));
- };
- let selector = event.keys[0];
- if selector
- == starknet::core::utils::get_selector_from_name("OwnershipTransferStarted")
- .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnershipTransferStarted"))
+ == starknet::core::utils::get_selector_from_name("Upgraded")
+ .unwrap_or_else(|_| panic!("Invalid selector for {}", "Upgraded"))
{
let mut key_offset = 0 + 1;
let mut data_offset = 0;
- let previous_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "previous_owner", "OwnershipTransferStarted", e
- ))
- }
- };
- key_offset +=
- cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
- let new_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
+ let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize(
+ &event.data,
+ data_offset,
) {
Ok(v) => v,
Err(e) => {
return Err(format!(
"Could not deserialize field {} for {}: {:?}",
- "new_owner", "OwnershipTransferStarted", e
+ "class_hash", "Upgraded", e
))
}
};
- key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
- return Ok(OwnableComponentEvent::OwnershipTransferStarted(
- OwnershipTransferStarted {
- previous_owner,
- new_owner,
- },
- ));
+ data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash);
+ return Ok(UpgradeEvent::Upgraded(Upgraded { class_hash }));
};
Err(format!(
"Could not match any event from keys {:?}",
@@ -411,41 +337,33 @@ impl TryFrom for OwnableComponentEvent {
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub enum Event {
- OwnableEvent(OwnableComponentEvent),
- ERC20Event(ERC20ComponentEvent),
- UpgradeableEvent(UpgradeEvent),
+pub enum ERC20ComponentEvent {
+ Transfer(Transfer),
+ Approval(Approval),
}
-impl cainome::cairo_serde::CairoSerde for Event {
+impl cainome::cairo_serde::CairoSerde for ERC20ComponentEvent {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = std::option::Option::None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
match __rust {
- Event::OwnableEvent(val) => OwnableComponentEvent::cairo_serialized_size(val) + 1,
- Event::ERC20Event(val) => ERC20ComponentEvent::cairo_serialized_size(val) + 1,
- Event::UpgradeableEvent(val) => UpgradeEvent::cairo_serialized_size(val) + 1,
+ ERC20ComponentEvent::Transfer(val) => Transfer::cairo_serialized_size(val) + 1,
+ ERC20ComponentEvent::Approval(val) => Approval::cairo_serialized_size(val) + 1,
_ => 0,
}
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
match __rust {
- Event::OwnableEvent(val) => {
+ ERC20ComponentEvent::Transfer(val) => {
let mut temp = vec![];
temp.extend(usize::cairo_serialize(&0usize));
- temp.extend(OwnableComponentEvent::cairo_serialize(val));
+ temp.extend(Transfer::cairo_serialize(val));
temp
}
- Event::ERC20Event(val) => {
+ ERC20ComponentEvent::Approval(val) => {
let mut temp = vec![];
temp.extend(usize::cairo_serialize(&1usize));
- temp.extend(ERC20ComponentEvent::cairo_serialize(val));
- temp
- }
- Event::UpgradeableEvent(val) => {
- let mut temp = vec![];
- temp.extend(usize::cairo_serialize(&2usize));
- temp.extend(UpgradeEvent::cairo_serialize(val));
+ temp.extend(Approval::cairo_serialize(val));
temp
}
_ => vec![],
@@ -458,27 +376,24 @@ impl cainome::cairo_serde::CairoSerde for Event {
let __f = __felts[__offset];
let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap());
match __index as usize {
- 0usize => Ok(Event::OwnableEvent(
- OwnableComponentEvent::cairo_deserialize(__felts, __offset + 1)?,
- )),
- 1usize => Ok(Event::ERC20Event(ERC20ComponentEvent::cairo_deserialize(
+ 0usize => Ok(ERC20ComponentEvent::Transfer(Transfer::cairo_deserialize(
__felts,
__offset + 1,
)?)),
- 2usize => Ok(Event::UpgradeableEvent(UpgradeEvent::cairo_deserialize(
+ 1usize => Ok(ERC20ComponentEvent::Approval(Approval::cairo_deserialize(
__felts,
__offset + 1,
)?)),
_ => {
return Err(cainome::cairo_serde::Error::Deserialize(format!(
"Index not handle for enum {}",
- "Event"
+ "ERC20ComponentEvent"
)))
}
}
}
}
-impl TryFrom for Event {
+impl TryFrom for ERC20ComponentEvent {
type Error = String;
fn try_from(event: starknet::core::types::EmittedEvent) -> Result {
use cainome::cairo_serde::CairoSerde;
@@ -486,88 +401,6 @@ impl TryFrom for Event {
return Err("Event has no key".to_string());
}
let selector = event.keys[0];
- if selector
- == starknet::core::utils::get_selector_from_name("OwnershipTransferred")
- .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnershipTransferred"))
- {
- let mut key_offset = 0 + 1;
- let mut data_offset = 0;
- let previous_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "previous_owner", "OwnershipTransferred", e
- ))
- }
- };
- key_offset +=
- cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
- let new_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "new_owner", "OwnershipTransferred", e
- ))
- }
- };
- key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
- return Ok(Event::OwnableEvent(
- OwnableComponentEvent::OwnershipTransferred(OwnershipTransferred {
- previous_owner,
- new_owner,
- }),
- ));
- };
- let selector = event.keys[0];
- if selector
- == starknet::core::utils::get_selector_from_name("OwnershipTransferStarted")
- .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnershipTransferStarted"))
- {
- let mut key_offset = 0 + 1;
- let mut data_offset = 0;
- let previous_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "previous_owner", "OwnershipTransferStarted", e
- ))
- }
- };
- key_offset +=
- cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
- let new_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
- &event.keys,
- key_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "new_owner", "OwnershipTransferStarted", e
- ))
- }
- };
- key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
- return Ok(Event::OwnableEvent(
- OwnableComponentEvent::OwnershipTransferStarted(OwnershipTransferStarted {
- previous_owner,
- new_owner,
- }),
- ));
- };
- let selector = event.keys[0];
if selector
== starknet::core::utils::get_selector_from_name("Transfer")
.unwrap_or_else(|_| panic!("Invalid selector for {}", "Transfer"))
@@ -611,11 +444,7 @@ impl TryFrom for Event {
}
};
data_offset += cainome::cairo_serde::U256::cairo_serialized_size(&value);
- return Ok(Event::ERC20Event(ERC20ComponentEvent::Transfer(Transfer {
- from,
- to,
- value,
- })));
+ return Ok(ERC20ComponentEvent::Transfer(Transfer { from, to, value }));
};
let selector = event.keys[0];
if selector
@@ -661,35 +490,11 @@ impl TryFrom for Event {
}
};
data_offset += cainome::cairo_serde::U256::cairo_serialized_size(&value);
- return Ok(Event::ERC20Event(ERC20ComponentEvent::Approval(Approval {
+ return Ok(ERC20ComponentEvent::Approval(Approval {
owner,
spender,
value,
- })));
- };
- let selector = event.keys[0];
- if selector
- == starknet::core::utils::get_selector_from_name("Upgraded")
- .unwrap_or_else(|_| panic!("Invalid selector for {}", "Upgraded"))
- {
- let mut key_offset = 0 + 1;
- let mut data_offset = 0;
- let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize(
- &event.data,
- data_offset,
- ) {
- Ok(v) => v,
- Err(e) => {
- return Err(format!(
- "Could not deserialize field {} for {}: {:?}",
- "class_hash", "Upgraded", e
- ))
- }
- };
- data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash);
- return Ok(Event::UpgradeableEvent(UpgradeEvent::Upgraded(Upgraded {
- class_hash,
- })));
+ }));
};
Err(format!(
"Could not match any event from keys {:?}",
@@ -698,25 +503,37 @@ impl TryFrom for Event {
}
}
#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub enum UpgradeEvent {
- Upgraded(Upgraded),
+pub enum OwnableComponentEvent {
+ OwnershipTransferred(OwnershipTransferred),
+ OwnershipTransferStarted(OwnershipTransferStarted),
}
-impl cainome::cairo_serde::CairoSerde for UpgradeEvent {
+impl cainome::cairo_serde::CairoSerde for OwnableComponentEvent {
type RustType = Self;
const SERIALIZED_SIZE: std::option::Option = std::option::Option::None;
#[inline]
fn cairo_serialized_size(__rust: &Self::RustType) -> usize {
match __rust {
- UpgradeEvent::Upgraded(val) => Upgraded::cairo_serialized_size(val) + 1,
+ OwnableComponentEvent::OwnershipTransferred(val) => {
+ OwnershipTransferred::cairo_serialized_size(val) + 1
+ }
+ OwnableComponentEvent::OwnershipTransferStarted(val) => {
+ OwnershipTransferStarted::cairo_serialized_size(val) + 1
+ }
_ => 0,
}
}
fn cairo_serialize(__rust: &Self::RustType) -> Vec {
match __rust {
- UpgradeEvent::Upgraded(val) => {
+ OwnableComponentEvent::OwnershipTransferred(val) => {
let mut temp = vec![];
temp.extend(usize::cairo_serialize(&0usize));
- temp.extend(Upgraded::cairo_serialize(val));
+ temp.extend(OwnershipTransferred::cairo_serialize(val));
+ temp
+ }
+ OwnableComponentEvent::OwnershipTransferStarted(val) => {
+ let mut temp = vec![];
+ temp.extend(usize::cairo_serialize(&1usize));
+ temp.extend(OwnershipTransferStarted::cairo_serialize(val));
temp
}
_ => vec![],
@@ -729,20 +546,22 @@ impl cainome::cairo_serde::CairoSerde for UpgradeEvent {
let __f = __felts[__offset];
let __index = u128::from_be_bytes(__f.to_bytes_be()[16..].try_into().unwrap());
match __index as usize {
- 0usize => Ok(UpgradeEvent::Upgraded(Upgraded::cairo_deserialize(
- __felts,
- __offset + 1,
- )?)),
+ 0usize => Ok(OwnableComponentEvent::OwnershipTransferred(
+ OwnershipTransferred::cairo_deserialize(__felts, __offset + 1)?,
+ )),
+ 1usize => Ok(OwnableComponentEvent::OwnershipTransferStarted(
+ OwnershipTransferStarted::cairo_deserialize(__felts, __offset + 1)?,
+ )),
_ => {
return Err(cainome::cairo_serde::Error::Deserialize(format!(
"Index not handle for enum {}",
- "UpgradeEvent"
+ "OwnableComponentEvent"
)))
}
}
}
}
-impl TryFrom for UpgradeEvent {
+impl TryFrom for OwnableComponentEvent {
type Error = String;
fn try_from(event: starknet::core::types::EmittedEvent) -> Result {
use cainome::cairo_serde::CairoSerde;
@@ -751,60 +570,128 @@ impl TryFrom for UpgradeEvent {
}
let selector = event.keys[0];
if selector
- == starknet::core::utils::get_selector_from_name("Upgraded")
- .unwrap_or_else(|_| panic!("Invalid selector for {}", "Upgraded"))
+ == starknet::core::utils::get_selector_from_name("OwnershipTransferred")
+ .unwrap_or_else(|_| panic!("Invalid selector for {}", "OwnershipTransferred"))
{
let mut key_offset = 0 + 1;
let mut data_offset = 0;
- let class_hash = match cainome::cairo_serde::ClassHash::cairo_deserialize(
- &event.data,
- data_offset,
+ let previous_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
+ &event.keys,
+ key_offset,
) {
Ok(v) => v,
Err(e) => {
return Err(format!(
"Could not deserialize field {} for {}: {:?}",
- "class_hash", "Upgraded", e
+ "previous_owner", "OwnershipTransferred", e
))
}
};
- data_offset += cainome::cairo_serde::ClassHash::cairo_serialized_size(&class_hash);
- return Ok(UpgradeEvent::Upgraded(Upgraded { class_hash }));
+ key_offset +=
+ cainome::cairo_serde::ContractAddress::cairo_serialized_size(&previous_owner);
+ let new_owner = match cainome::cairo_serde::ContractAddress::cairo_deserialize(
+ &event.keys,
+ key_offset,
+ ) {
+ Ok(v) => v,
+ Err(e) => {
+ return Err(format!(
+ "Could not deserialize field {} for {}: {:?}",
+ "new_owner", "OwnershipTransferred", e
+ ))
+ }
+ };
+ key_offset += cainome::cairo_serde::ContractAddress::cairo_serialized_size(&new_owner);
+ return Ok(OwnableComponentEvent::OwnershipTransferred(
+ OwnershipTransferred {
+ previous_owner,
+ new_owner,
+ },
+ ));
};
- Err(format!(
- "Could not match any event from keys {:?}",
- event.keys
- ))
- }
-}
-#[derive(Debug, PartialEq, PartialOrd, Clone, serde :: Serialize, serde :: Deserialize)]
-pub enum ERC20ComponentEvent {
- Transfer(Transfer),
- Approval(Approval),
-}
-impl cainome::cairo_serde::CairoSerde for ERC20ComponentEvent {
- type RustType = Self;
- const SERIALIZED_SIZE: std::option::Option