From 9240917a44e4ba5a3e44da5acac3a0ad9c1498df Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Thu, 17 Oct 2024 19:12:31 +0200 Subject: [PATCH] iface: add add_rights convenience method to builder --- Cargo.lock | 2 +- src/interface/builder.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 60158c23..040ef4f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -668,7 +668,7 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.9" -source = "git+https://github.com/RGB-WG/rgb-core?branch=feat/fungible-nonconf#e92e5b176886b3f04d8cfbb41714ab8f7d0b8046" +source = "git+https://github.com/RGB-WG/rgb-core?branch=feat/fungible-nonconf#9c6f3fee4ac573380c0ed8658d644fc5a7cfc533" dependencies = [ "aluvm", "amplify", diff --git a/src/interface/builder.rs b/src/interface/builder.rs index 4905aca1..76eff309 100644 --- a/src/interface/builder.rs +++ b/src/interface/builder.rs @@ -252,6 +252,16 @@ impl ContractBuilder { Ok(self) } + pub fn add_rights( + mut self, + name: impl Into, + seal: impl Into>, + attach: Option, + ) -> Result { + self.builder = self.builder.add_rights(name, seal, attach)?; + Ok(self) + } + pub fn add_owned_state( mut self, name: impl Into, @@ -513,6 +523,16 @@ impl TransitionBuilder { Ok(self) } + pub fn add_rights( + mut self, + name: impl Into, + seal: impl Into>, + attach: Option, + ) -> Result { + self.builder = self.builder.add_rights(name, seal, attach)?; + Ok(self) + } + pub fn fulfill_owned_state( mut self, type_id: AssignmentType, @@ -758,6 +778,18 @@ impl OperationBuilder { Ok(self) } + fn add_rights( + self, + name: impl Into, + seal: impl Into>, + attach: Option, + ) -> Result { + let type_id = self.assignments_type(name)?; + let mut state = State::default(); + state.attach = attach; + self.add_owned_state_raw(type_id, seal, state) + } + fn add_owned_state( self, name: impl Into,