Skip to content

Commit

Permalink
iface: require builder asset tags to be specified upfront the state data
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 18, 2023
1 parent 8614070 commit 5025eed
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/interface/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ pub enum BuilderError {
/// state `{0}` provided to the builder has invalid name.
InvalidState(AssignmentType),

/// can't add asset of type `{0}`: you need to register the type with asset
/// type firtst using `add_asset_tag` method.
AssetTagUnknown(AssignmentType),
/// asset tag for the state `{0}` must be added before any fungible state of
/// the same type.
AssetTagSet(AssignmentType),

/// interface doesn't specifies default operation name, thus an explicit
/// operation type must be provided with `set_operation_type` method.
Expand Down Expand Up @@ -431,6 +431,10 @@ impl<Seal: ExposedSeal> OperationBuilder<Seal> {
.assignments_type(&name, ty)
.ok_or(BuilderError::AssignmentNotFound(name))?;

if self.fungible.contains_key(&type_id) {
return Err(BuilderError::AssetTagSet(type_id));
}

self.asset_tags.insert(type_id, asset_tag)?;
Ok(self)
}
Expand Down

0 comments on commit 5025eed

Please sign in to comment.