From 5025eed9c1f25a80f7759f0a4b07265aa4e666ce Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Sat, 18 Nov 2023 14:56:49 +0100 Subject: [PATCH] iface: require builder asset tags to be specified upfront the state data --- src/interface/builder.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/interface/builder.rs b/src/interface/builder.rs index 76f52e4b..d27ec81c 100644 --- a/src/interface/builder.rs +++ b/src/interface/builder.rs @@ -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. @@ -431,6 +431,10 @@ impl OperationBuilder { .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) }