entity

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BootstrappedEntityHandler maps to grpc handler for entities
	BootstrappedEntityHandler string = "BootstrappedEntityHandler"

	// BootstrappedEntityService maps to the service for entities
	BootstrappedEntityService string = "BootstrappedEntityService"
)

Variables

This section is empty.

Functions

func CreateValidator

func CreateValidator(factory identity.Factory) documents.ValidatorGroup

CreateValidator returns a validator group that should be run before creating the entity and persisting it to DB

func GRPCHandler

func GRPCHandler(config config.Service, srv Service) cliententitypb.EntityServiceServer

GRPCHandler returns an implementation of entity.DocumentServiceServer

func UpdateValidator

func UpdateValidator(factory identity.Factory) documents.ValidatorGroup

UpdateValidator returns a validator group that should be run before updating the entity

Types

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error

Bootstrap sets the required storage and registers

type Entity

type Entity struct {
	*documents.CoreDocument

	Identity  *identity.DID
	LegalName string
	// address
	Addresses []*entitypb.Address
	// tax information
	PaymentDetails []*entitypb.PaymentDetail
	// Entity contact list
	Contacts []*entitypb.Contact
}

Entity implements the documents.Model keeps track of entity related fields and state

func (*Entity) AddNFT

func (e *Entity) AddNFT(grantReadAccess bool, registry common.Address, tokenID []byte) error

AddNFT adds NFT to the Entity.

func (*Entity) CalculateDataRoot

func (e *Entity) CalculateDataRoot() ([]byte, error)

CalculateDataRoot calculates the data root and sets the root to core document.

func (*Entity) CalculateDocumentRoot

func (e *Entity) CalculateDocumentRoot() ([]byte, error)

CalculateDocumentRoot calculates the document root

func (*Entity) CalculateSigningRoot

func (e *Entity) CalculateSigningRoot() ([]byte, error)

CalculateSigningRoot calculates the signing root of the document.

func (*Entity) CollaboratorCanUpdate

func (e *Entity) CollaboratorCanUpdate(updated documents.Model, collaborator identity.DID) error

CollaboratorCanUpdate checks if the collaborator can update the document.

func (*Entity) CreateNFTProofs

func (e *Entity) CreateNFTProofs(
	account identity.DID,
	registry common.Address,
	tokenID []byte,
	nftUniqueProof, readAccessProof bool) (proofs []*proofspb.Proof, err error)

CreateNFTProofs creates proofs specific to NFT minting.

func (*Entity) CreateProofs

func (e *Entity) CreateProofs(fields []string) (proofs []*proofspb.Proof, err error)

CreateProofs generates proofs for given fields.

func (*Entity) DocumentRootTree

func (e *Entity) DocumentRootTree() (tree *proofs.DocumentTree, err error)

DocumentRootTree creates and returns the document root tree

func (*Entity) DocumentType

func (*Entity) DocumentType() string

DocumentType returns the entity document type.

func (*Entity) FromJSON

func (e *Entity) FromJSON(jsonData []byte) error

FromJSON unmarshals the json bytes into Entity

func (*Entity) InitEntityInput

func (e *Entity) InitEntityInput(payload *cliententitypb.EntityCreatePayload, self identity.DID) error

InitEntityInput initialize the model based on the received parameters from the rest api call

func (*Entity) JSON

func (e *Entity) JSON() ([]byte, error)

JSON marshals Entity into a json bytes

func (*Entity) PackCoreDocument

func (e *Entity) PackCoreDocument() (cd coredocumentpb.CoreDocument, err error)

PackCoreDocument packs the Entity into a CoreDocument.

func (*Entity) PrepareNewVersion

func (e *Entity) PrepareNewVersion(old documents.Model, data *cliententitypb.EntityData, collaborators documents.CollaboratorsAccess) error

PrepareNewVersion prepares new version from the old entity.

func (*Entity) Type

func (e *Entity) Type() reflect.Type

Type gives the Entity type

func (*Entity) UnpackCoreDocument

func (e *Entity) UnpackCoreDocument(cd coredocumentpb.CoreDocument) error

UnpackCoreDocument unpacks the core document into Entity.

type Service

type Service interface {
	documents.Service

	// DeriveFromPayload derives Entity from clientPayload
	DeriveFromCreatePayload(ctx context.Context, payload *cliententitypb.EntityCreatePayload) (documents.Model, error)

	// DeriveFromUpdatePayload derives entity model from update payload
	DeriveFromUpdatePayload(ctx context.Context, payload *cliententitypb.EntityUpdatePayload) (documents.Model, error)

	// DeriveEntityData returns the entity data as client data
	DeriveEntityData(entity documents.Model) (*cliententitypb.EntityData, error)

	// DeriveEntityResponse returns the entity model in our standard client format
	DeriveEntityResponse(ctx context.Context, entity documents.Model) (*cliententitypb.EntityResponse, error)

	// ListEntityRelationships lists all the relationships associated with the passed in entity identifier
	ListEntityRelationships(ctx context.Context, entityIdentifier []byte) (documents.Model, []documents.Model, error)

	// GetEntityByRelationship returns the entity model from database or requests from granter
	GetEntityByRelationship(ctx context.Context, relationshipIdentifier []byte) (documents.Model, error)

	// DeriveFromSharePayload derives the entity relationship from the relationship payload
	DeriveFromSharePayload(ctx context.Context, payload *cliententitypb.RelationshipPayload) (documents.Model, error)

	// Share takes an entity relationship, validates it, and tries to persist it to the DB
	Share(ctx context.Context, entityRelationship documents.Model) (documents.Model, jobs.JobID, chan bool, error)

	// DeriveFromRevokePayload derives the revoked entity relationship from the relationship payload
	DeriveFromRevokePayload(ctx context.Context, payload *cliententitypb.RelationshipPayload) (documents.Model, error)

	// Revoke takes a revoked entity relationship, validates it, and tries to persist it to the DB
	Revoke(ctx context.Context, entityRelationship documents.Model) (documents.Model, jobs.JobID, chan bool, error)

	// DeriveEntityRelationshipResponse returns create response from entity relationship model
	DeriveEntityRelationshipResponse(model documents.Model) (*cliententitypb.RelationshipResponse, error)
}

Service defines specific functions for entity

func DefaultService

func DefaultService(
	srv documents.Service,
	repo documents.Repository,
	queueSrv queue.TaskQueuer,
	jobManager jobs.Manager,
	factory identity.Factory,
	erService entityrelationship.Service,
	idService identity.ServiceDID,
	anchorRepo anchors.AnchorRepository,
	processor documents.DocumentRequestProcessor,
	receivedEntityValidator func() documents.ValidatorGroup,
) Service

DefaultService returns the default implementation of the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL