Skip to content

Commit

Permalink
iface: add add_rights convenience method to builder
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 17, 2024
1 parent 0bc16ef commit 9240917
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/interface/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ impl ContractBuilder {
Ok(self)
}

pub fn add_rights(
mut self,
name: impl Into<FieldName>,
seal: impl Into<BuilderSeal<GenesisSeal>>,
attach: Option<AttachId>,
) -> Result<Self, BuilderError> {
self.builder = self.builder.add_rights(name, seal, attach)?;
Ok(self)
}

pub fn add_owned_state(
mut self,
name: impl Into<FieldName>,
Expand Down Expand Up @@ -513,6 +523,16 @@ impl TransitionBuilder {
Ok(self)
}

pub fn add_rights(
mut self,
name: impl Into<FieldName>,
seal: impl Into<BuilderSeal<GraphSeal>>,
attach: Option<AttachId>,
) -> Result<Self, BuilderError> {
self.builder = self.builder.add_rights(name, seal, attach)?;
Ok(self)
}

pub fn fulfill_owned_state(
mut self,
type_id: AssignmentType,
Expand Down Expand Up @@ -758,6 +778,18 @@ impl<Seal: ExposedSeal> OperationBuilder<Seal> {
Ok(self)
}

fn add_rights(
self,
name: impl Into<FieldName>,
seal: impl Into<BuilderSeal<Seal>>,
attach: Option<AttachId>,
) -> Result<Self, BuilderError> {
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<FieldName>,
Expand Down

0 comments on commit 9240917

Please sign in to comment.