scrypto_test/sdk/resource/
proof_factory.rs1use crate::prelude::*;
2
3pub struct ProofFactory;
5
6impl ProofFactory {
7 pub fn create_fungible_proof<S>(
8 resource_address: ResourceAddress,
9 amount: Decimal,
10 creation_strategy: CreationStrategy,
11 env: &mut TestEnvironment<S>,
12 ) -> Result<FungibleProof, RuntimeError>
13 where
14 S: SubstateDatabase + CommittableSubstateDatabase + 'static,
15 {
16 BucketFactory::create_fungible_bucket(resource_address, amount, creation_strategy, env)
17 .and_then(|bucket| bucket.create_proof_of_all(env))
18 }
19
20 pub fn create_non_fungible_proof<I, D, S>(
21 resource_address: ResourceAddress,
22 non_fungibles: I,
23 creation_strategy: CreationStrategy,
24 env: &mut TestEnvironment<S>,
25 ) -> Result<NonFungibleProof, RuntimeError>
26 where
27 I: IntoIterator<Item = (NonFungibleLocalId, D)>,
28 D: ScryptoEncode,
29 S: SubstateDatabase + CommittableSubstateDatabase + 'static,
30 {
31 BucketFactory::create_non_fungible_bucket(
32 resource_address,
33 non_fungibles,
34 creation_strategy,
35 env,
36 )
37 .and_then(|bucket| bucket.create_proof_of_all(env))
38 }
39
40 pub fn create_proof<S>(
41 resource_specifier: FactoryResourceSpecifier,
42 creation_strategy: CreationStrategy,
43 env: &mut TestEnvironment<S>,
44 ) -> Result<Proof, RuntimeError>
45 where
46 S: SubstateDatabase + CommittableSubstateDatabase + 'static,
47 {
48 BucketFactory::create_bucket(resource_specifier, creation_strategy, env)
49 .and_then(|bucket| bucket.create_proof_of_all(env))
50 }
51}