Skip to content

Commit

Permalink
add convertion for basic starknet type to FieldElement
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Oct 11, 2023
1 parent 272310d commit e735878
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/abigen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use starknet::{
contract::abi::ContractAddress,
core::{chain_id, types::FieldElement},
macros::abigen,
providers::{Provider, SequencerGatewayProvider},
providers::SequencerGatewayProvider,
signers::{LocalWallet, SigningKey},
};

Expand Down
18 changes: 18 additions & 0 deletions starknet-contract/src/abi/cairo_types/types/starknet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ impl From<FieldElement> for ContractAddress {
}
}

impl From<ContractAddress> for FieldElement {
fn from(item: ContractAddress) -> Self {
item.0
}
}

impl CairoType for ContractAddress {
type RustType = Self;

Expand All @@ -36,6 +42,12 @@ impl From<FieldElement> for ClassHash {
}
}

impl From<ClassHash> for FieldElement {
fn from(item: ClassHash) -> Self {
item.0
}
}

impl CairoType for ClassHash {
type RustType = Self;

Expand All @@ -58,6 +70,12 @@ impl From<FieldElement> for EthAddress {
}
}

impl From<EthAddress> for FieldElement {
fn from(item: EthAddress) -> Self {
item.0
}
}

impl CairoType for EthAddress {
type RustType = Self;

Expand Down

0 comments on commit e735878

Please sign in to comment.