manifest: add Required field to Standard

`Required` contains standards that are required for this standard.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-11-05 11:41:24 +03:00
parent 57eec71101
commit 54e3708566
2 changed files with 7 additions and 0 deletions

View file

@ -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
}

View file

@ -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