github.com/storacha/go-ucanto@v0.7.2/validator/datamodel/attestation.go (about) 1 package datamodel 2 3 import ( 4 _ "embed" 5 "fmt" 6 7 "github.com/ipld/go-ipld-prime" 8 "github.com/ipld/go-ipld-prime/schema" 9 ucanipld "github.com/storacha/go-ucanto/core/ipld" 10 ) 11 12 //go:embed attestation.ipldsch 13 var attestationsch []byte 14 var attestationTypeSystem *schema.TypeSystem 15 16 func init() { 17 ts, err := ipld.LoadSchemaBytes(attestationsch) 18 if err != nil { 19 panic(fmt.Errorf("failed to load IPLD schema: %w", err)) 20 } 21 attestationTypeSystem = ts 22 } 23 24 func AttestationType() schema.Type { 25 return attestationTypeSystem.TypeByName("Attestation") 26 } 27 28 type AttestationModel struct { 29 Proof ipld.Link 30 } 31 32 func (m AttestationModel) ToIPLD() (ipld.Node, error) { 33 return ucanipld.WrapWithRecovery(&m, AttestationType()) 34 }