-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
213 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,6 +1,29 @@ | ||
use anyhow::Result; | ||
use dojo_world::contracts::world::WorldContract; | ||
use dojo_world::migration::strategy::generate_salt; | ||
use starknet::accounts::ConnectedAccount; | ||
use starknet::core::types::FieldElement; | ||
|
||
pub mod auth; | ||
pub mod events; | ||
pub mod execute; | ||
pub mod migration; | ||
pub mod model; | ||
pub mod register; | ||
|
||
pub async fn get_contract_address<A: ConnectedAccount + Sync>( | ||
world: &WorldContract<A>, | ||
name_or_address: String, | ||
) -> Result<FieldElement> { | ||
if name_or_address.starts_with("0x") { | ||
FieldElement::from_hex_be(&name_or_address).map_err(anyhow::Error::from) | ||
} else { | ||
let contract_class_hash = world.base().call().await?; | ||
Ok(starknet::core::utils::get_contract_address( | ||
generate_salt(&name_or_address), | ||
contract_class_hash.into(), | ||
&[], | ||
world.address, | ||
)) | ||
} | ||
} | ||