Struct scrypto_test::sdk::InProgressResourceBuilder
source · pub struct InProgressResourceBuilder<T: AnyResourceType> { /* private fields */ }Expand description
Utility for setting up a new resource, which has building in progress.
- You start the building process with one of the methods starting with
ResourceBuilder::new_. - The allowed methods change depending on which methods have already been called. For example,
you can either use
owner_non_fungible_badgeor set access rules individually, but not both. - You can complete the building process using either
create_with_no_initial_supply()ormint_initial_supply(..).
§Example
use scrypto_test::prelude::*;
let bucket = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(5);Implementations§
source§impl<T: IsNonFungibleLocalId, D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<T, D>>
impl<T: IsNonFungibleLocalId, D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<T, D>>
sourcepub fn non_fungible_data_update_roles(
self,
non_fungible_data_update_roles: Option<NonFungibleDataUpdateRoles<RoleDefinition>>
) -> Self
pub fn non_fungible_data_update_roles( self, non_fungible_data_update_roles: Option<NonFungibleDataUpdateRoles<RoleDefinition>> ) -> Self
Sets how each non-fungible’s mutable data can be updated.
- The first parameter is the access rule which allows updating the mutable data of each non-fungible.
- The second parameter is the mutability / access rule which controls if and how the access rule can be updated.
§Examples
use radix_engine_interface::non_fungible_data_update_roles;
use scrypto_test::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
// Permits the updating of non-fungible mutable data with a proof of a specific resource, and this is locked forever.
ResourceBuilder::new_ruid_non_fungible::<NFData>(OwnerRole::None)
.non_fungible_data_update_roles(non_fungible_data_update_roles! {
non_fungible_data_updater => rule!(require(resource_address));
non_fungible_data_updater_updater => rule!(deny_all);
});
// Does not currently permit the updating of non-fungible mutable data, but this is can be changed in future by the second rule.
ResourceBuilder::new_ruid_non_fungible::<NFData>(OwnerRole::None)
.non_fungible_data_update_roles(non_fungible_data_update_roles! {
non_fungible_data_updater => rule!(deny_all);
non_fungible_data_updater_updater => rule!(require(resource_address));
});source§impl InProgressResourceBuilder<FungibleResourceType>
impl InProgressResourceBuilder<FungibleResourceType>
sourcepub fn divisibility(self, divisibility: u8) -> Self
pub fn divisibility(self, divisibility: u8) -> Self
Set the resource’s divisibility: the number of digits of precision after the decimal point in its balances.
0means the resource is not divisible (balances are always whole numbers)18is the maximum divisibility, and the default.
§Examples
use scrypto_test::prelude::*;
// Only permits whole-number balances.
ResourceBuilder::new_fungible(OwnerRole::None)
.divisibility(0);
// Only permits balances to 3 decimal places.
ResourceBuilder::new_fungible(OwnerRole::None)
.divisibility(3);source§impl InProgressResourceBuilder<FungibleResourceType>
impl InProgressResourceBuilder<FungibleResourceType>
source§impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<StringNonFungibleLocalId, D>>
impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<StringNonFungibleLocalId, D>>
sourcepub fn mint_initial_supply<T, Y, E>(
self,
entries: T,
env: &mut Y
) -> Result<Bucket, E>
pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
Creates the non-fungible resource, and mints an individual non-fungible for each key/data pair provided.
§Example
use scrypto_test::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: Bucket = ResourceBuilder::new_string_non_fungible::<NFData>(OwnerRole::None)
.mint_initial_supply([
("One".try_into().unwrap(), NFData { name: "NF One".to_owned(), flag: true }),
("Two".try_into().unwrap(), NFData { name: "NF Two".to_owned(), flag: true }),
&mut env
]);source§impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<IntegerNonFungibleLocalId, D>>
impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<IntegerNonFungibleLocalId, D>>
sourcepub fn mint_initial_supply<T, Y, E>(
self,
entries: T,
env: &mut Y
) -> Result<Bucket, E>
pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
Creates the non-fungible resource, and mints an individual non-fungible for each key/data pair provided.
§Example
use scrypto_test::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: Bucket = ResourceBuilder::new_integer_non_fungible(OwnerRole::None)
.mint_initial_supply([
(1u64.into(), NFData { name: "NF One".to_owned(), flag: true }),
(2u64.into(), NFData { name: "NF Two".to_owned(), flag: true }),
&mut env
]);source§impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<BytesNonFungibleLocalId, D>>
impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<BytesNonFungibleLocalId, D>>
sourcepub fn mint_initial_supply<T, Y, E>(
self,
entries: T,
env: &mut Y
) -> Result<Bucket, E>
pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
Creates the non-fungible resource, and mints an individual non-fungible for each key/data pair provided.
§Example
use scrypto_test::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: Bucket = ResourceBuilder::new_bytes_non_fungible::<NFData>(OwnerRole::None)
.mint_initial_supply([
(vec![1u8].try_into().unwrap(), NFData { name: "NF One".to_owned(), flag: true }),
(vec![2u8].try_into().unwrap(), NFData { name: "NF Two".to_owned(), flag: true }),
&mut env
]);source§impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<RUIDNonFungibleLocalId, D>>
impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<RUIDNonFungibleLocalId, D>>
sourcepub fn mint_initial_supply<T, Y, E>(
self,
entries: T,
env: &mut Y
) -> Result<Bucket, E>
pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
Creates the RUID non-fungible resource, and mints an individual non-fungible for each piece of data provided.
The system automatically generates a new RUID NonFungibleLocalId for each non-fungible,
and assigns the given data to each.
§Example
use scrypto_test::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: Bucket = ResourceBuilder::new_ruid_non_fungible::<NFData>(OwnerRole::None)
.mint_initial_supply([
(NFData { name: "NF One".to_owned(), flag: true }),
(NFData { name: "NF Two".to_owned(), flag: true }),
&mut env
]);Trait Implementations§
source§impl UpdateAuthBuilder for InProgressResourceBuilder<FungibleResourceType>
impl UpdateAuthBuilder for InProgressResourceBuilder<FungibleResourceType>
source§fn mint_roles(self, mint_roles: Option<MintRoles<RoleDefinition>>) -> Self
fn mint_roles(self, mint_roles: Option<MintRoles<RoleDefinition>>) -> Self
source§fn burn_roles(self, burn_roles: Option<BurnRoles<RoleDefinition>>) -> Self
fn burn_roles(self, burn_roles: Option<BurnRoles<RoleDefinition>>) -> Self
source§fn recall_roles(self, recall_roles: Option<RecallRoles<RoleDefinition>>) -> Self
fn recall_roles(self, recall_roles: Option<RecallRoles<RoleDefinition>>) -> Self
source§fn freeze_roles(self, freeze_roles: Option<FreezeRoles<RoleDefinition>>) -> Self
fn freeze_roles(self, freeze_roles: Option<FreezeRoles<RoleDefinition>>) -> Self
source§fn withdraw_roles(
self,
withdraw_roles: Option<WithdrawRoles<RoleDefinition>>
) -> Self
fn withdraw_roles( self, withdraw_roles: Option<WithdrawRoles<RoleDefinition>> ) -> Self
source§fn deposit_roles(
self,
deposit_roles: Option<DepositRoles<RoleDefinition>>
) -> Self
fn deposit_roles( self, deposit_roles: Option<DepositRoles<RoleDefinition>> ) -> Self
source§impl<T: IsNonFungibleLocalId, D: NonFungibleData> UpdateAuthBuilder for InProgressResourceBuilder<NonFungibleResourceType<T, D>>
impl<T: IsNonFungibleLocalId, D: NonFungibleData> UpdateAuthBuilder for InProgressResourceBuilder<NonFungibleResourceType<T, D>>
source§fn mint_roles(self, mint_roles: Option<MintRoles<RoleDefinition>>) -> Self
fn mint_roles(self, mint_roles: Option<MintRoles<RoleDefinition>>) -> Self
source§fn burn_roles(self, burn_roles: Option<BurnRoles<RoleDefinition>>) -> Self
fn burn_roles(self, burn_roles: Option<BurnRoles<RoleDefinition>>) -> Self
source§fn recall_roles(self, recall_roles: Option<RecallRoles<RoleDefinition>>) -> Self
fn recall_roles(self, recall_roles: Option<RecallRoles<RoleDefinition>>) -> Self
source§fn freeze_roles(self, freeze_roles: Option<FreezeRoles<RoleDefinition>>) -> Self
fn freeze_roles(self, freeze_roles: Option<FreezeRoles<RoleDefinition>>) -> Self
source§fn withdraw_roles(
self,
withdraw_roles: Option<WithdrawRoles<RoleDefinition>>
) -> Self
fn withdraw_roles( self, withdraw_roles: Option<WithdrawRoles<RoleDefinition>> ) -> Self
source§fn deposit_roles(
self,
deposit_roles: Option<DepositRoles<RoleDefinition>>
) -> Self
fn deposit_roles( self, deposit_roles: Option<DepositRoles<RoleDefinition>> ) -> Self
Auto Trait Implementations§
impl<T> Freeze for InProgressResourceBuilder<T>
impl<T> RefUnwindSafe for InProgressResourceBuilder<T>
impl<T> Send for InProgressResourceBuilder<T>
impl<T> Sync for InProgressResourceBuilder<T>
impl<T> Unpin for InProgressResourceBuilder<T>
impl<T> UnwindSafe for InProgressResourceBuilder<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<B> CreateWithNoSupplyBuilder for Bwhere
B: CanCreateWithNoSupply,
impl<B> CreateWithNoSupplyBuilder for Bwhere
B: CanCreateWithNoSupply,
source§fn create_with_no_initial_supply<Y, E>(
self,
env: &mut Y
) -> Result<ResourceManager, E>
fn create_with_no_initial_supply<Y, E>( self, env: &mut Y ) -> Result<ResourceManager, E>
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more