diff --git a/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs b/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs index 44febbf0..bc7cde17 100644 --- a/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs +++ b/radix-engine-toolkit-uniffi/src/builder/manifest_builder/builder.rs @@ -563,7 +563,8 @@ impl ManifestBuilder { //===================== /* Faucet */ - pub fn free_xrd_from_faucet(self: Arc) -> Result> { + + pub fn faucet_free_xrd(self: Arc) -> Result> { builder_arc_map(self, |builder| { let instruction = NativeInstruction::CallMethod { address: NativeDynamicGlobalAddress::Static(NATIVE_FAUCET.into()), @@ -575,6 +576,18 @@ impl ManifestBuilder { }) } + pub fn faucet_lock_fee(self: Arc) -> Result> { + builder_arc_map(self, |builder| { + let instruction = NativeInstruction::CallMethod { + address: NativeDynamicGlobalAddress::Static(NATIVE_FAUCET.into()), + method_name: "lock_fee".to_owned(), + args: manifest_args!(NativeDecimal::from_str("100").unwrap()).into(), + }; + builder.instructions.push(instruction); + Ok(()) + }) + } + /* Account */ pub fn create_account_advanced(self: Arc, owner_role: OwnerRole) -> Result> { @@ -839,6 +852,57 @@ impl ManifestBuilder { }) } + pub fn mint_fungible( + self: Arc, + resource_address: Arc
, + amount: Arc, + ) -> Result> { + builder_arc_map(self, |builder| { + let resource_address = NativeResourceAddress::try_from(*resource_address)?; + let amount = amount.0; + + let instruction = NativeInstruction::CallMethod { + address: NativeDynamicGlobalAddress::Static(resource_address.into()), + method_name: NATIVE_FUNGIBLE_RESOURCE_MANAGER_MINT_IDENT.to_owned(), + args: native_to_manifest_value_and_unwrap!( + &NativeFungibleResourceManagerMintInput { amount } + ), + }; + builder.instructions.push(instruction); + + Ok(()) + }) + } + + /* Access Rule */ + + pub fn set_role( + self: Arc, + address: Arc
, + module: ObjectModuleId, + role_key: String, + rule: Arc, + ) -> Result> { + builder_arc_map(self, |builder| { + let address = NativeGlobalAddress::try_from(*address)?; + let module = NativeObjectModuleId::from(module); + let rule = rule.0.clone(); + + let instruction = NativeInstruction::CallAccessRulesMethod { + address: NativeDynamicGlobalAddress::Static(address), + method_name: NATIVE_ACCESS_RULES_SET_ROLE_IDENT.to_owned(), + args: native_to_manifest_value_and_unwrap!(&NativeAccessRulesSetRoleInput { + module, + role_key: NativeRoleKey { key: role_key }, + rule + }), + }; + builder.instructions.push(instruction); + + Ok(()) + }) + } + //================= // Builder Methods //================= diff --git a/radix-engine-toolkit-uniffi/src/common/access_rules.rs b/radix-engine-toolkit-uniffi/src/common/access_rules.rs index 4ff37ecd..476e9c99 100644 --- a/radix-engine-toolkit-uniffi/src/common/access_rules.rs +++ b/radix-engine-toolkit-uniffi/src/common/access_rules.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +use radix_engine::types::FromPublicKey; + use crate::prelude::*; #[derive(Clone, Debug, Object)] @@ -63,6 +65,24 @@ impl AccessRule { Ok(Arc::new(Self(access_rule))) } + #[uniffi::constructor] + pub fn require_virtual_signature(public_key: PublicKey) -> Result> { + let public_key = NativePublicKey::try_from(public_key)?; + let non_fungible_global_id = NativeNonFungibleGlobalId::from_public_key(&public_key); + let access_rule = native_rule!(native_require(non_fungible_global_id)); + Ok(Arc::new(Self(access_rule))) + } + + #[uniffi::constructor] + pub fn allow_all() -> Arc { + Arc::new(Self(NativeAccessRule::AllowAll)) + } + + #[uniffi::constructor] + pub fn deny_all() -> Arc { + Arc::new(Self(NativeAccessRule::DenyAll)) + } + pub fn or(&self, other: Arc) -> Arc { let access_rule = match (&self.0, &other.0) { (NativeAccessRule::AllowAll, _) | (_, NativeAccessRule::AllowAll) => { diff --git a/radix-engine-toolkit-uniffi/src/internal_prelude.rs b/radix-engine-toolkit-uniffi/src/internal_prelude.rs index a81bba66..b3b891df 100644 --- a/radix-engine-toolkit-uniffi/src/internal_prelude.rs +++ b/radix-engine-toolkit-uniffi/src/internal_prelude.rs @@ -267,7 +267,7 @@ mod native { RoleDefinition as NativeRoleDefinition, manifest_args as native_manifest_args, rule as native_rule, - require as native_require + require as native_require, }; pub use scrypto::address::{ AddressBech32Decoder as NativeAddressBech32Decoder, @@ -460,6 +460,19 @@ mod native { pub use radix_engine_interface::types::{ KeyValueStoreInitEntry as NativeKeyValueStoreInitEntry, }; + pub use radix_engine_interface::api::node_modules::auth::{ + AccessRulesCreateInput as NativeAccessRulesCreateInput, + AccessRulesSetRoleInput as NativeAccessRulesSetRoleInput, + AccessRulesSetOwnerRoleInput as NativeAccessRulesSetOwnerRoleInput, + AccessRulesLockOwnerRoleInput as NativeAccessRulesLockOwnerRoleInput, + AccessRulesGetRoleInput as NativeAccessRulesGetRoleInput, + ACCESS_RULES_BLUEPRINT as NATIVE_ACCESS_RULES_BLUEPRINT, + ACCESS_RULES_CREATE_IDENT as NATIVE_ACCESS_RULES_CREATE_IDENT, + ACCESS_RULES_SET_ROLE_IDENT as NATIVE_ACCESS_RULES_SET_ROLE_IDENT, + ACCESS_RULES_SET_OWNER_ROLE_IDENT as NATIVE_ACCESS_RULES_SET_OWNER_ROLE_IDENT, + ACCESS_RULES_LOCK_OWNER_ROLE_IDENT as NATIVE_ACCESS_RULES_LOCK_OWNER_ROLE_IDENT, + ACCESS_RULES_GET_ROLE_IDENT as NATIVE_ACCESS_RULES_GET_ROLE_IDENT, + }; pub use radix_engine_interface::blueprints::access_controller::{ AccessControllerCreateGlobalInput as NativeAccessControllerCreateGlobalInput, AccessControllerCreateProofInput as NativeAccessControllerCreateProofInput, diff --git a/radix-engine-toolkit-uniffi/src/lib.rs b/radix-engine-toolkit-uniffi/src/lib.rs index 35207026..ae9c9595 100644 --- a/radix-engine-toolkit-uniffi/src/lib.rs +++ b/radix-engine-toolkit-uniffi/src/lib.rs @@ -115,6 +115,7 @@ pub mod prelude { /* Often needed */ pub(crate) use std::collections::{BTreeMap, HashMap}; + pub(crate) use std::str::FromStr; pub(crate) use std::sync::Arc; pub(crate) use thiserror::Error as ThisError; pub(crate) use uniffi::{Enum, Error, Object, Record};