From 3a55edf69ea8590529b203bb1263b231869bd901 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Tue, 5 Nov 2024 11:41:24 +0300 Subject: [PATCH] manifest: add `Required` field to `Standard` `Required` contains standards that are required for this standard. Signed-off-by: Ekaterina Pavlova --- pkg/smartcontract/manifest/standard/check.go | 2 ++ pkg/smartcontract/manifest/standard/comply.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/pkg/smartcontract/manifest/standard/check.go b/pkg/smartcontract/manifest/standard/check.go index 2957c265df..9fb9a14fee 100644 --- a/pkg/smartcontract/manifest/standard/check.go +++ b/pkg/smartcontract/manifest/standard/check.go @@ -12,4 +12,6 @@ type Standard struct { // If contract contains method with the same name and parameter count, // it must have signature declared by this contract. Optional []manifest.Method + // Required contains standards that are required for this standard. + Required []string } diff --git a/pkg/smartcontract/manifest/standard/comply.go b/pkg/smartcontract/manifest/standard/comply.go index f8991c7933..ec29fff43e 100644 --- a/pkg/smartcontract/manifest/standard/comply.go +++ b/pkg/smartcontract/manifest/standard/comply.go @@ -66,6 +66,11 @@ func ComplyABI(m *manifest.Manifest, st *Standard) error { } func comply(m *manifest.Manifest, checkNames bool, st *Standard) error { + if len(st.Required) > 0 { + if err := check(m, checkNames, st.Required...); err != nil { + return fmt.Errorf("required standard '%s' is not supported: %w", st.Name, err) + } + } if st.Base != nil { if err := comply(m, checkNames, st.Base); err != nil { return err