pub struct InProgressResourceBuilder<T: AnyResourceType> {
    owner_role: OwnerRole,
    resource_type: T,
    resource_roles: T::ResourceRoles,
    metadata_config: Option<ModuleConfig<MetadataInit>>,
    address_reservation: Option<GlobalAddressReservation>,
}
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_badge or set access rules individually, but not both.
  • You can complete the building process using either create_with_no_initial_supply() or mint_initial_supply(..).

§Example

use scrypto_test::prelude::*;

let bucket = ResourceBuilder::new_fungible(OwnerRole::None)
    .mint_initial_supply(5);

Fields§

§owner_role: OwnerRole§resource_type: T§resource_roles: T::ResourceRoles§metadata_config: Option<ModuleConfig<MetadataInit>>§address_reservation: Option<GlobalAddressReservation>

Implementations§

source§

impl<T: AnyResourceType> InProgressResourceBuilder<T>

source

fn new(owner_role: OwnerRole) -> Self

source§

impl<T: IsNonFungibleLocalId, D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<T, D>>

source

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>

source

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.

  • 0 means the resource is not divisible (balances are always whole numbers)
  • 18 is 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>

source

pub fn mint_initial_supply<T, Y, E>( self, amount: T, env: &mut Y ) -> Result<Bucket, E>
where T: Into<Decimal>, Y: ClientApi<E>, E: Debug,

Creates resource with the given initial supply.

§Example
use scrypto_test::prelude::*;

let bucket: Bucket = ResourceBuilder::new_fungible(OwnerRole::None)
    .mint_initial_supply(5, &mut env);
source§

impl<D: NonFungibleData> InProgressResourceBuilder<NonFungibleResourceType<StringNonFungibleLocalId, D>>

source

pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
where T: IntoIterator<Item = (StringNonFungibleLocalId, D)>, Y: ClientApi<E>, E: Debug,

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>>

source

pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
where T: IntoIterator<Item = (IntegerNonFungibleLocalId, D)>, Y: ClientApi<E>, E: Debug,

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>>

source

pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
where T: IntoIterator<Item = (BytesNonFungibleLocalId, D)>, Y: ClientApi<E>, E: Debug,

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>>

source

pub fn mint_initial_supply<T, Y, E>( self, entries: T, env: &mut Y ) -> Result<Bucket, E>
where T: IntoIterator<Item = D>, Y: ClientApi<E>, E: Debug,

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 CanCreateWithNoSupply for InProgressResourceBuilder<FungibleResourceType>

source§

impl<Y: IsNonFungibleLocalId, D: NonFungibleData> CanCreateWithNoSupply for InProgressResourceBuilder<NonFungibleResourceType<Y, D>>

source§

impl<T: AnyResourceType> CanSetAddressReservation for InProgressResourceBuilder<T>

source§

impl<T: AnyResourceType> CanSetMetadata for InProgressResourceBuilder<T>

source§

impl UpdateAuthBuilder for InProgressResourceBuilder<FungibleResourceType>

source§

fn mint_roles(self, mint_roles: Option<MintRoles<RoleDefinition>>) -> Self

Sets the resource to be mintable Read more
source§

fn burn_roles(self, burn_roles: Option<BurnRoles<RoleDefinition>>) -> Self

Sets the resource to be burnable. Read more
source§

fn recall_roles(self, recall_roles: Option<RecallRoles<RoleDefinition>>) -> Self

Sets the resource to be recallable from vaults. Read more
source§

fn freeze_roles(self, freeze_roles: Option<FreezeRoles<RoleDefinition>>) -> Self

Sets the resource to have vaults be freezable. Read more
source§

fn withdraw_roles( self, withdraw_roles: Option<WithdrawRoles<RoleDefinition>> ) -> Self

Sets the role rules of withdrawing from a vault of this resource. Read more
source§

fn deposit_roles( self, deposit_roles: Option<DepositRoles<RoleDefinition>> ) -> Self

Sets the roles rules of depositing this resource into a vault. Read more
source§

impl<T: IsNonFungibleLocalId, D: NonFungibleData> UpdateAuthBuilder for InProgressResourceBuilder<NonFungibleResourceType<T, D>>

source§

fn mint_roles(self, mint_roles: Option<MintRoles<RoleDefinition>>) -> Self

Sets the resource to be mintable Read more
source§

fn burn_roles(self, burn_roles: Option<BurnRoles<RoleDefinition>>) -> Self

Sets the resource to be burnable. Read more
source§

fn recall_roles(self, recall_roles: Option<RecallRoles<RoleDefinition>>) -> Self

Sets the resource to be recallable from vaults. Read more
source§

fn freeze_roles(self, freeze_roles: Option<FreezeRoles<RoleDefinition>>) -> Self

Sets the resource to have vaults be freezable. Read more
source§

fn withdraw_roles( self, withdraw_roles: Option<WithdrawRoles<RoleDefinition>> ) -> Self

Sets the role rules of withdrawing from a vault of this resource. Read more
source§

fn deposit_roles( self, deposit_roles: Option<DepositRoles<RoleDefinition>> ) -> Self

Sets the roles rules of depositing this resource into a vault. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<B> CreateWithNoSupplyBuilder for B

source§

fn create_with_no_initial_supply<Y, E>( self, env: &mut Y ) -> Result<ResourceManager, E>
where Y: ClientApi<E>, E: Debug,

Creates the resource with no initial supply. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<B> SetAddressReservationBuilder for B

source§

fn with_address( self, reservation: GlobalAddressReservation ) -> Self::OutputBuilder

Sets the address reservation
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<B> UpdateMetadataBuilder for B
where B: CanSetMetadata,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V