populateMaterials populates the materials in the attestation result regardless of where they are defined (contract schema or inline in the attestation)
(craftingState *v1.CraftingState, res *AttestationStatusResult)
| 209 | // populateMaterials populates the materials in the attestation result regardless of where they are defined |
| 210 | // (contract schema or inline in the attestation) |
| 211 | func populateMaterials(craftingState *v1.CraftingState, res *AttestationStatusResult) error { |
| 212 | visitedMaterials := make(map[string]struct{}) |
| 213 | attsMaterials := craftingState.GetAttestation().GetMaterials() |
| 214 | inputSchemaMaterials := craftingState.GetMaterials() |
| 215 | |
| 216 | if err := populateContractMaterials(inputSchemaMaterials, attsMaterials, res, visitedMaterials); err != nil { |
| 217 | return fmt.Errorf("adding materials from the contract: %w", err) |
| 218 | } |
| 219 | |
| 220 | if err := populateAdditionalMaterials(attsMaterials, res, visitedMaterials); err != nil { |
| 221 | return fmt.Errorf("adding materials outside the contract: %w", err) |
| 222 | } |
| 223 | |
| 224 | return nil |
| 225 | } |
| 226 | |
| 227 | // populateContractMaterials populates the materials that are defined in the contract schema |
| 228 | func populateContractMaterials(inputSchemaMaterials []*pbc.CraftingSchema_Material, attsMaterial map[string]*v1.Attestation_Material, res *AttestationStatusResult, visitedMaterials map[string]struct{}) error { |