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_badge
or 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::prelude::*;
let bucket = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(5);
Implementations§
Source§impl<T: AnyResourceType> InProgressResourceBuilder<T>
impl<T: AnyResourceType> InProgressResourceBuilder<T>
Source§impl<T: IsNonFungibleLocalId, D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<T, D, S>>
impl<T: IsNonFungibleLocalId, D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<T, D, S>>
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::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 create_with_no_initial_supply(self) -> FungibleResourceManager
pub fn create_with_no_initial_supply(self) -> FungibleResourceManager
Creates the fungible resource with no initial supply.
The fungible resource’s manager is returned.
It is easily convertible to generic resource manager.
One just can use .into()
method.
§Example
let resource_manager = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_roles(mint_roles! {
minter => rule!(deny_all);
minter_updater => rule!(deny_all);
})
.metadata(metadata! {
init {
"name" => "Super Admin Badge", locked;
}
})
.with_address(address_reservation)
.create_with_no_initial_supply();
Source§impl<Y: IsNonFungibleLocalId, D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<Y, D, S>>
impl<Y: IsNonFungibleLocalId, D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<Y, D, S>>
Sourcepub fn create_with_no_initial_supply(self) -> NonFungibleResourceManager
pub fn create_with_no_initial_supply(self) -> NonFungibleResourceManager
Creates the non-fungible resource with no initial supply.
The non-fungible resource’s manager is returned.
It is easily convertible to the generic resource manager.
One just can use .into()
method.
§Example
#[derive(ScryptoSbor, NonFungibleData)]
struct Sandwich {
name: String,
with_ham: bool,
}
let resource_manager: ResourceManager =
ResourceBuilder::new_ruid_non_fungible::<Sandwich>(OwnerRole::None)
.mint_roles(mint_roles! {
minter => rule!(allow_all);
minter_updater => rule!(deny_all);
})
.create_with_no_initial_supply()
.into();
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.
0
means the resource is not divisible (balances are always whole numbers)18
is the maximum divisibility, and the default.
§Examples
// 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>
Sourcepub fn mint_initial_supply<T: Into<Decimal>>(self, amount: T) -> FungibleBucket
pub fn mint_initial_supply<T: Into<Decimal>>(self, amount: T) -> FungibleBucket
Creates resource with the given initial supply.
§Example
use scrypto::prelude::*;
let bucket: FungibleBucket = ResourceBuilder::new_fungible(OwnerRole::None)
.mint_initial_supply(5);
Source§impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<StringNonFungibleLocalId, D, S>>
impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<StringNonFungibleLocalId, D, S>>
Sourcepub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = (StringNonFungibleLocalId, D)>,
pub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = (StringNonFungibleLocalId, D)>,
Creates the non-fungible resource, and mints an individual non-fungible for each key/data pair provided.
§Example
use scrypto::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: NonFungibleBucket = 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 }),
]);
Source§impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<IntegerNonFungibleLocalId, D, S>>
impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<IntegerNonFungibleLocalId, D, S>>
Sourcepub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = (IntegerNonFungibleLocalId, D)>,
pub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = (IntegerNonFungibleLocalId, D)>,
Creates the non-fungible resource, and mints an individual non-fungible for each key/data pair provided.
§Example
use scrypto::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: NonFungibleBucket = 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 }),
]);
Source§impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<BytesNonFungibleLocalId, D, S>>
impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<BytesNonFungibleLocalId, D, S>>
Sourcepub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = (BytesNonFungibleLocalId, D)>,
pub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = (BytesNonFungibleLocalId, D)>,
Creates the non-fungible resource, and mints an individual non-fungible for each key/data pair provided.
§Example
use scrypto::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: NonFungibleBucket = 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 }),
]);
Source§impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<RUIDNonFungibleLocalId, D, S>>
impl<D: NonFungibleData, S: ScryptoCategorize + ScryptoEncode + ScryptoDecode> InProgressResourceBuilder<NonFungibleResourceType<RUIDNonFungibleLocalId, D, S>>
Sourcepub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = D>,
D: ScryptoEncode,
pub fn mint_initial_supply<T>(self, entries: T) -> NonFungibleBucketwhere
T: IntoIterator<Item = D>,
D: ScryptoEncode,
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::prelude::*;
#[derive(ScryptoSbor, NonFungibleData)]
struct NFData {
pub name: String,
#[mutable]
pub flag: bool,
}
let bucket: NonFungibleBucket = 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 }),
]);