pub struct MintAssets(_);

Implementations§

Examples found in repository?
src/lib.rs (line 3493)
3492
3493
3494
3495
3496
    pub fn new_from_entry(key: &AssetName, value: Int) -> Self {
        let mut ma = MintAssets::new();
        ma.insert(key, value);
        ma
    }
More examples
Hide additional examples
src/tx_builder/mint_builder.rs (line 111)
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    pub fn build(&self) -> Mint {
        let mut mint = Mint::new();
        for (_, script_mint) in self.mints.iter() {
            match script_mint {
                ScriptMint::Native(native_mints) => {
                    let mut mint_asset = MintAssets::new();
                    for (asset_name, amount) in &native_mints.mints {
                        mint_asset.insert(asset_name, amount.clone());
                    }
                    mint.insert(&native_mints.script.hash(), &mint_asset);
                },
                ScriptMint::Plutus(plutus_mints) => {
                    for (_, redeemer_mints) in &plutus_mints.redeemer_mints {
                        let mut mint_asset = MintAssets::new();
                        for (asset_name, amount) in redeemer_mints {
                            mint_asset.insert(asset_name, amount.clone());

                        }
                        mint.insert(&plutus_mints.script.script_hash(), &mint_asset);
                    }
                }
            }
        }
        mint
    }
source

pub fn new_from_entry(key: &AssetName, value: Int) -> Self

Examples found in repository?
src/tx_builder.rs (line 1185)
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
    pub fn add_mint_asset_and_output(
        &mut self,
        policy_script: &NativeScript,
        asset_name: &AssetName,
        amount: Int,
        output_builder: &TransactionOutputAmountBuilder,
        output_coin: &Coin,
    ) -> Result<(), JsError> {
        if !amount.is_positive() {
            return Err(JsError::from_str("Output value must be positive!"));
        }
        let policy_id: PolicyID = policy_script.hash();
        self.add_mint_asset(policy_script, asset_name, amount.clone());
        let multiasset = Mint::new_from_entry(
            &policy_id,
            &MintAssets::new_from_entry(asset_name, amount.clone()),
        )
        .as_positive_multiasset();

        self.add_output(
            &output_builder
                .with_coin_and_asset(&output_coin, &multiasset)
                .build()?,
        )
    }

    /// Add a mint entry together with an output to this builder
    /// Using a PolicyID, AssetName, Int for amount, and Address objects
    /// The asset will be securely added to existing or new Mint in this builder
    /// A new output will be added with the specified Address and the minted asset
    /// The output will be set to contain the minimum required amount of Coin
    pub fn add_mint_asset_and_output_min_required_coin(
        &mut self,
        policy_script: &NativeScript,
        asset_name: &AssetName,
        amount: Int,
        output_builder: &TransactionOutputAmountBuilder,
    ) -> Result<(), JsError> {
        if !amount.is_positive() {
            return Err(JsError::from_str("Output value must be positive!"));
        }
        let policy_id: PolicyID = policy_script.hash();
        self.add_mint_asset(policy_script, asset_name, amount.clone());
        let multiasset = Mint::new_from_entry(
            &policy_id,
            &MintAssets::new_from_entry(asset_name, amount.clone()),
        )
        .as_positive_multiasset();

        self.add_output(
            &output_builder
                .with_asset_and_min_required_coin_by_utxo_cost(
                    &multiasset,
                    &self.config.utxo_cost(),
                )?
                .build()?,
        )
    }
Examples found in repository?
src/lib.rs (line 3494)
3492
3493
3494
3495
3496
    pub fn new_from_entry(key: &AssetName, value: Int) -> Self {
        let mut ma = MintAssets::new();
        ma.insert(key, value);
        ma
    }
More examples
Hide additional examples
src/tx_builder/mint_builder.rs (line 113)
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    pub fn build(&self) -> Mint {
        let mut mint = Mint::new();
        for (_, script_mint) in self.mints.iter() {
            match script_mint {
                ScriptMint::Native(native_mints) => {
                    let mut mint_asset = MintAssets::new();
                    for (asset_name, amount) in &native_mints.mints {
                        mint_asset.insert(asset_name, amount.clone());
                    }
                    mint.insert(&native_mints.script.hash(), &mint_asset);
                },
                ScriptMint::Plutus(plutus_mints) => {
                    for (_, redeemer_mints) in &plutus_mints.redeemer_mints {
                        let mut mint_asset = MintAssets::new();
                        for (asset_name, amount) in redeemer_mints {
                            mint_asset.insert(asset_name, amount.clone());

                        }
                        mint.insert(&plutus_mints.script.script_hash(), &mint_asset);
                    }
                }
            }
        }
        mint
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
The name of the generated JSON Schema. Read more
Generates a JSON Schema for this type. Read more
Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.