v2

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AttributeKeyParam param in the URL.
	AttributeKeyParam = "attribute_key"

	// ErrInvalidAttributeKey for invalid attribute key in the api path.
	ErrInvalidAttributeKey = errors.Error("Invalid Attribute Key")
)
View Source
const (
	// ErrInvalidJobID is the sentinel error when the job_id passed is invalid.
	ErrInvalidJobID = errors.Error("Invalid Job ID")

	// ErrJobNotFound is a sentinel error when job associated with job_id is not found.
	ErrJobNotFound = errors.Error("Job not found")
)
View Source
const (
	// ErrInvalidTokenID is a sentinel error when token ID is invalid
	ErrInvalidTokenID = errors.Error("Invalid Token ID")

	// ErrInvalidRegistryAddress is a sentinel error when registry address is invalid
	ErrInvalidRegistryAddress = errors.Error("Invalid registry address")
)
View Source
const BootstrappedService = "V2 Service"

BootstrappedService key maps to the Service implementation in Bootstrap context.

View Source
const ErrInvalidRoleID = errors.Error("Invalid RoleID")

ErrInvalidRoleID for invalid roleID in the api path.

View Source
const ErrInvalidRuleID = errors.Error("Invalid Transition Rule ID")

ErrInvalidRuleID for invalid ruleID in the api path.

View Source
const RoleIDParam = "role_id"

RoleIDParam is the key for roleID in the API path.

View Source
const RuleIDParam = "rule_id"

RuleIDParam is the key for ruleID in the API path.

Variables

This section is empty.

Functions

func Register

func Register(ctx map[string]interface{}, r chi.Router)

Register registers the core apis to the router.

func RegisterBeta

func RegisterBeta(ctx map[string]interface{}, r chi.Router)

RegisterBeta registers the beta apis to the router.

func Webhook

func Webhook(http.ResponseWriter, *http.Request)

Webhook is a place holder to describe webhook response in swagger @summary Webhook is a place holder to describe webhook response in swagger. @description Webhook is a place holder to describe webhook response in swagger. @id webhook @tags Webhook @accept json @produce json @success 200 {object} notification.Message @router /webhook [post]

Types

type AddRole

type AddRole struct {
	// Key is either hex encoded 32 byte ID or string label.
	// String label is used as a preimage to sha256 for 32 byte hash.
	Key           string         `json:"key"`
	Collaborators []identity.DID `json:"collaborators" swaggertype:"array,string"`
}

AddRole used for marshalling add request for role.

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

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

Bootstrap adds transaction.Repository into context.

type CloneDocumentRequest

type CloneDocumentRequest struct {
	Scheme string `json:"scheme" enums:"generic,entity"`
}

CloneDocumentRequest defines the payload for creating documents.

type CreateDocumentRequest

type CreateDocumentRequest struct {
	coreapi.CreateDocumentRequest
	DocumentID byteutils.OptionalHex `json:"document_id" swaggertype:"primitive,string"` // if provided, creates the next version of the document.
}

CreateDocumentRequest defines the payload for creating documents.

type GenerateAccountResponse

type GenerateAccountResponse struct {
	DID   byteutils.HexBytes `json:"did" swaggertype:"primitive,string"`
	JobID byteutils.HexBytes `json:"job_id" swaggertype:"primitive,string"`
}

GenerateAccountResponse contains the expected DID and the jobID associated with the create identity Job

type Job

type Job = gocelery.Job

Job is an alias for gocelery Job for swagger generation

type RemoveCollaboratorsRequest

type RemoveCollaboratorsRequest struct {
	Collaborators []identity.DID `json:"collaborators" swaggertype:"array,string"`
}

RemoveCollaboratorsRequest contains the list of collaborators that are to be removed from the document

type Role

type Role struct {
	ID            byteutils.HexBytes   `json:"id" swaggertype:"primitive,string"`
	Collaborators []byteutils.HexBytes `json:"collaborators" swaggertype:"array,string"`
}

Role is a single role in the document.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the entry point for all the V2 APIs.

func (Service) AddAttributes

func (s Service) AddAttributes(ctx context.Context, docID []byte, attrs []documents.Attribute) (documents.Document, error)

AddAttributes add attributes to pending document

func (Service) AddRole

func (s Service) AddRole(ctx context.Context, docID []byte, roleKey string, dids []identity.DID) (*coredocumentpb.Role, error)

AddRole adds a new role to the document

func (Service) AddSignedAttribute

func (s Service) AddSignedAttribute(ctx context.Context, docID []byte, label string, payload []byte, valType documents.AttributeType) (documents.Document, error)

AddSignedAttribute signs the payload with acc signing key and add it the document associated with docID.

func (Service) AddTransitionRules

func (s Service) AddTransitionRules(
	ctx context.Context, docID []byte, addRules pending.AddTransitionRules) ([]*coredocumentpb.TransitionRule, error)

AddTransitionRules adds new rules to the document

func (Service) CloneDocument

func (s Service) CloneDocument(ctx context.Context, payload documents.ClonePayload) (documents.Document, error)

CloneDocument creates a new cloned document from the template (docID specified in payload).

func (Service) Commit

func (s Service) Commit(ctx context.Context, docID []byte) (documents.Document, gocelery.JobID, error)

Commit creates a document out of a pending document.

func (Service) CreateDocument

func (s Service) CreateDocument(ctx context.Context, req documents.UpdatePayload) (documents.Document, error)

CreateDocument creates a pending document from the given payload. if the document_id is provided, next version of the document is created.

func (Service) DeleteAttribute

func (s Service) DeleteAttribute(ctx context.Context, docID []byte, key documents.AttrKey) (documents.Document, error)

DeleteAttribute deletes attribute on a pending document

func (Service) DeleteTransitionRule

func (s Service) DeleteTransitionRule(ctx context.Context, docID, ruleID []byte) error

DeleteTransitionRule deletes the transition rule associated with ruleID from the document.

func (Service) GenerateAccount

func (s Service) GenerateAccount(acc config.CentChainAccount) (did, jobID byteutils.HexBytes, err error)

GenerateAccount generates a new account

func (Service) GenerateProofs

func (s Service) GenerateProofs(ctx context.Context, docID []byte, fields []string) (*documents.DocumentProof, error)

GenerateProofs returns the proofs for the latest version of the document.

func (Service) GenerateProofsForVersion

func (s Service) GenerateProofsForVersion(ctx context.Context, docID, versionID []byte, fields []string) (*documents.DocumentProof, error)

GenerateProofsForVersion returns the proofs for the specific version of the document.

func (Service) GetAccount

func (s Service) GetAccount(accountID []byte) (config.Account, error)

GetAccount returns the Account associated with accountID

func (Service) GetAccounts

func (s Service) GetAccounts() ([]config.Account, error)

GetAccounts returns all the accounts.

func (Service) GetDocument

func (s Service) GetDocument(ctx context.Context, docID []byte, status documents.Status) (documents.Document, error)

GetDocument returns the document associated with docID and status.

func (Service) GetDocumentVersion

func (s Service) GetDocumentVersion(ctx context.Context, docID, versionID []byte) (documents.Document, error)

GetDocumentVersion returns the specific version of the document.

func (Service) GetEntityByRelationship

func (s Service) GetEntityByRelationship(ctx context.Context, docID []byte) (documents.Document, error)

GetEntityByRelationship returns an entity through a relationship ID.

func (Service) GetEntityRelationShips

func (s Service) GetEntityRelationShips(ctx context.Context, entityID []byte) ([]documents.Document, error)

GetEntityRelationShips returns the entity relationships under the given entity

func (Service) GetRole

func (s Service) GetRole(ctx context.Context, docID, roleID []byte) (*coredocumentpb.Role, error)

GetRole gets the role from the document

func (Service) GetTransitionRule

func (s Service) GetTransitionRule(ctx context.Context, docID, ruleID []byte) (*coredocumentpb.TransitionRule, error)

GetTransitionRule returns the transition rule associated with ruleID in the document.

func (Service) Job

func (s Service) Job(accID identity.DID, jobID []byte) (*gocelery.Job, error)

Job returns the job details

func (Service) MintNFT

func (s Service) MintNFT(ctx context.Context, request nft.MintNFTRequest) (*nft.TokenResponse, error)

MintNFT mints an NFT.

func (Service) MintNFTOnCC

func (s Service) MintNFTOnCC(ctx context.Context, request nft.MintNFTOnCCRequest) (*nft.TokenResponse, error)

MintNFTOnCC mints an NFT on centrifuge chain.

func (Service) OwnerOfNFT

func (s Service) OwnerOfNFT(registry common.Address, tokenID nft.TokenID) (common.Address, error)

OwnerOfNFT returns the owner of the NFT.

func (Service) OwnerOfNFTOnCC

func (s Service) OwnerOfNFTOnCC(registry common.Address, tokenID nft.TokenID) (types.AccountID, error)

OwnerOfNFTOnCC returns the owner of the NFT on Centrifuge chain.

func (Service) PushAttributeToOracle

func (s Service) PushAttributeToOracle(
	ctx context.Context, docID []byte, req oracle.PushAttributeToOracleRequest) (*oracle.PushToOracleResponse, error)

PushAttributeToOracle pushes a given attribute in a given document to the oracle

func (Service) RemoveCollaborators

func (s Service) RemoveCollaborators(ctx context.Context, docID []byte, dids []identity.DID) (documents.Document, error)

RemoveCollaborators removes collaborators from the document.

func (Service) SignPayload

func (s Service) SignPayload(accountID, payload []byte) (*coredocumentpb.Signature, error)

SignPayload uses the accountID's secret key to sign the payload and returns the signature

func (Service) TransferNFT

func (s Service) TransferNFT(ctx context.Context, to, registry common.Address, tokenID nft.TokenID) (*nft.TokenResponse, error)

TransferNFT transfers NFT with tokenID in a given registry to `to` address.

func (Service) TransferNFTOnCC

func (s Service) TransferNFTOnCC(ctx context.Context, registry common.Address, tokenID nft.TokenID,
	to types.AccountID) (*nft.TokenResponse, error)

TransferNFTOnCC transfers NFT on Centrifuge chain with tokenID in a given registry to `to` address.

func (Service) UpdateDocument

func (s Service) UpdateDocument(ctx context.Context, req documents.UpdatePayload) (documents.Document, error)

UpdateDocument updates a pending document with the given payload

func (Service) UpdateRole

func (s Service) UpdateRole(ctx context.Context, docID, roleID []byte, dids []identity.DID) (*coredocumentpb.Role, error)

UpdateRole updates the role in the document

type SignedAttributeRequest

type SignedAttributeRequest struct {
	Label   string `json:"label"`
	Type    string `json:"type" enums:"integer,string,bytes,timestamp"`
	Payload string `json:"payload"`
}

SignedAttributeRequest contains the payload to be signed and added to the document.

type TransitionRule

type TransitionRule struct {
	RuleID               byteutils.HexBytes   `json:"rule_id" swaggertype:"primitive,string"`
	Action               string               `json:"action"`
	Roles                []byteutils.HexBytes `json:"roles,omitempty" swaggertype:"array,string"`
	Field                byteutils.HexBytes   `json:"field,omitempty" swaggertype:"primitive,string"`
	AttributeLabels      []byteutils.HexBytes `json:"attribute_labels,omitempty" swaggertype:"array,string"`
	Wasm                 byteutils.HexBytes   `json:"wasm,omitempty" swaggertype:"primitive,string"`
	TargetAttributeLabel string               `json:"target_attribute_label,omitempty"`
}

TransitionRule holds the ruleID, roles, and fields in hex format

type TransitionRules

type TransitionRules struct {
	Rules []TransitionRule `json:"rules"`
}

TransitionRules holds the list of transition rule.

type UpdateDocumentRequest

type UpdateDocumentRequest struct {
	coreapi.CreateDocumentRequest
}

UpdateDocumentRequest defines the payload to patch an existing document.

type UpdateRole

type UpdateRole struct {
	Collaborators []identity.DID `json:"collaborators" swaggertype:"array,string"`
}

UpdateRole holds the collaborators that are to be replaced with older one in the role.

Jump to

Keyboard shortcuts

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