setup.rs 848 B

123456789101112131415161718192021222324252627
  1. use fuels::{
  2. test_helpers::{launch_custom_provider_and_get_wallets, WalletsConfig},
  3. types::{errors::Error, ContractId},
  4. };
  5. use pyth_sdk::pyth_utils::Pyth;
  6. pub(crate) async fn setup_environment() -> Result<(ContractId, Pyth), Error> {
  7. // Launch a local network and deploy the contract
  8. let mut wallets = launch_custom_provider_and_get_wallets(
  9. WalletsConfig::new(
  10. Some(1), /* Single wallet */
  11. Some(1), /* Single coin (UTXO) */
  12. Some(1_000_000_000), /* Amount per coin */
  13. ),
  14. None,
  15. None,
  16. )
  17. .await?;
  18. let deployer_wallet = wallets
  19. .pop()
  20. .ok_or_else(|| Error::Other("No deployer wallet found".to_string()))?;
  21. let pyth = Pyth::deploy(deployer_wallet).await?;
  22. Ok((pyth.instance.contract_id().into(), pyth))
  23. }