458
chasmContext Context,
459
ref ComponentRef,
460
>
) (Component, error) {
tree.go
461
>
// Archetype is already validated before this method is called.
462
>
// (when the mutable state is loaded, in chasm engine implementation)
463
>
464
>
node, ok := n.findNode(ref.componentPath)
465
>
if !ok {
466
return nil, errComponentNotFound
467
}
468
469
>
if ref.componentInitialVT != nil && transitionhistory.Compare(
tree.go
470
>
ref.componentInitialVT,
471
>
node.serializedNode.Metadata.InitialVersionedTransition,
472
>
) != 0 {
473
return nil, errComponentNotFound
474
}
475
476
>
validationContext := NewContext(chasmContext.goContext(), node)
tree.go
477
>
if err := node.prepareComponentValue(validationContext); err != nil {
478
return nil, err
479
}
480
481
>
componentValue, ok := node.value.(Component)
tree.go
482
>
if !ok {
483
return nil, softassert.UnexpectedInternalErr(
484
n.logger,