coreapi

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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DocumentIDParam for document_id in api path.
	DocumentIDParam = "document_id"

	// VersionIDParam for version_id in api path.
	VersionIDParam = "version_id"

	// TokenIDParam for nft tokenID
	TokenIDParam = "token_id"

	// RegistryAddressParam for nft registry path
	RegistryAddressParam = "registry_address"

	// AccountIDParam for accounts api
	AccountIDParam = "account_id"
)
View Source
const (
	// ErrInvalidDocumentID is a sentinel error for invalid document identifiers.
	ErrInvalidDocumentID = errors.Error("invalid document identifier")

	// ErrDocumentNotFound is a sentinel error for missing documents.
	ErrDocumentNotFound = errors.Error("document not found")

	// ErrAccountIDInvalid is a sentinel error for invalid account IDs.
	ErrAccountIDInvalid = errors.Error("account ID is invalid")

	// ErrAccountNotFound is a sentinel error for when account is missing.
	ErrAccountNotFound = errors.Error("account not found")
)

Variables

This section is empty.

Functions

func ToDocumentAttributes

func ToDocumentAttributes(cattrs map[string]AttributeRequest) (map[documents.AttrKey]documents.Attribute, error)

ToDocumentAttributes converts AttributeRequestMap to document attributes

func ToDocumentsCreatePayload

func ToDocumentsCreatePayload(request CreateDocumentRequest) (documents.CreatePayload, error)

ToDocumentsCreatePayload converts CoreAPI create payload to documents payload.

func ToNFTMintRequest

func ToNFTMintRequest(req MintNFTRequest, registryAddress common.Address) nft.MintNFTRequest

ToNFTMintRequest converts http request to nft mint request

func ToNFTMintRequestOnCC

func ToNFTMintRequestOnCC(req MintNFTOnCCRequest, registryAddress common.Address) nft.MintNFTOnCCRequest

ToNFTMintRequest converts http request to nft mint request

Types

type Account

type Account struct {
	EthereumAccount                  EthAccount              `json:"eth_account"`
	EthereumDefaultAccountName       string                  `json:"eth_default_account_name"`
	ReceiveEventNotificationEndpoint string                  `json:"receive_event_notification_endpoint"`
	IdentityID                       byteutils.HexBytes      `json:"identity_id" swaggertype:"primitive,string"`
	SigningKeyPair                   KeyPair                 `json:"signing_key_pair"`
	P2PKeyPair                       KeyPair                 `json:"p2p_key_pair"`
	CentChainAccount                 config.CentChainAccount `json:"centrifuge_chain_account"`
}

Account holds the single account details.

func ToClientAccount

func ToClientAccount(acc config.Account) (Account, error)

ToClientAccount converts config.Account to Account

type Accounts

type Accounts struct {
	Data []Account `json:"data"`
}

Accounts holds a list of accounts

func ToClientAccounts

func ToClientAccounts(accs []config.Account) (Accounts, error)

ToClientAccounts converts config.Account's to Account's

type AttributeMapRequest

type AttributeMapRequest map[string]AttributeRequest

AttributeMapRequest defines a map of attributes with attribute key as key

type AttributeMapResponse

type AttributeMapResponse map[string]AttributeResponse

AttributeMapResponse maps attribute label to AttributeResponse

type AttributeRequest

type AttributeRequest struct {
	Type          string         `json:"type" enums:"integer,decimal,string,bytes,timestamp,monetary"`
	Value         string         `json:"value"`
	MonetaryValue *MonetaryValue `json:"monetary_value,omitempty"`
}

AttributeRequest defines a single attribute. Type type of the attribute Value simple value of the attribute MonetaryValue value for only monetary attribute

type AttributeResponse

type AttributeResponse struct {
	AttributeRequest
	Key         byteutils.HexBytes `json:"key" swaggertype:"primitive,string"`
	SignedValue SignedValue        `json:"signed_value"`
}

AttributeResponse adds key to the attribute.

type CreateDocumentRequest

type CreateDocumentRequest struct {
	Scheme      string              `json:"scheme" enums:"generic,entity"`
	ReadAccess  []identity.DID      `json:"read_access" swaggertype:"array,string"`
	WriteAccess []identity.DID      `json:"write_access" swaggertype:"array,string"`
	Data        interface{}         `json:"data"`
	Attributes  AttributeMapRequest `json:"attributes"`
}

CreateDocumentRequest defines the payload for creating documents.

type DocumentResponse

type DocumentResponse struct {
	Header     ResponseHeader       `json:"header"`
	Scheme     string               `json:"scheme" enums:"generic,entity"`
	Data       interface{}          `json:"data"`
	Attributes AttributeMapResponse `json:"attributes"`
}

DocumentResponse is the common response for Document APIs.

func GetDocumentResponse

func GetDocumentResponse(model documents.Document, tokenRegistry documents.TokenRegistry,
	jobID string) (resp DocumentResponse, err error)

GetDocumentResponse converts model to a client api format.

type EthAccount

type EthAccount struct {
	Address  string `json:"address"`
	Key      string `json:"key,omitempty"`
	Password string `json:"password,omitempty"`
}

EthAccount holds address of the account.

type GenerateAccountPayload

type GenerateAccountPayload struct {
	CentChainAccount config.CentChainAccount `json:"centrifuge_chain_account"`
}

GenerateAccountPayload holds required fields to generate account with defaults.

type KeyPair

type KeyPair struct {
	Pub string `json:"pub"`
	Pvt string `json:"pvt"`
}

KeyPair represents the public and private key.

type MintNFTOnCCRequest

type MintNFTOnCCRequest struct {
	DocumentID byteutils.HexBytes `json:"document_id" swaggertype:"primitive,string"`
	// 32 byte hex encoded account id on centrifuge chain
	DepositAddress byteutils.HexBytes `json:"deposit_address" swaggertype:"primitive,string"`
	ProofFields    []string           `json:"proof_fields"`
}

MintNFTOnCCRequest holds required fields for minting NFT on centrifuge chain

type MintNFTOnCCResponse

type MintNFTOnCCResponse struct {
	Header          NFTResponseHeader  `json:"header"`
	DocumentID      byteutils.HexBytes `json:"document_id" swaggertype:"primitive,string"`
	TokenID         string             `json:"token_id"`
	RegistryAddress common.Address     `json:"registry_address" swaggertype:"primitive,string"`
	// 32 byte hex encoded account id on centrifuge chain
	DepositAddress byteutils.HexBytes `json:"deposit_address" swaggertype:"primitive,string"`
}

MintNFTOnCCResponse holds the details of the minted NFT on CC.

type MintNFTRequest

type MintNFTRequest struct {
	DocumentID          byteutils.HexBytes    `json:"document_id" swaggertype:"primitive,string"`
	DepositAddress      common.Address        `json:"deposit_address" swaggertype:"primitive,string"`
	AssetManagerAddress byteutils.OptionalHex `json:"asset_manager_address" swaggertype:"primitive,string"`
	ProofFields         []string              `json:"proof_fields"`
}

MintNFTRequest holds required fields for minting NFT

type MintNFTResponse

type MintNFTResponse struct {
	Header          NFTResponseHeader  `json:"header"`
	DocumentID      byteutils.HexBytes `json:"document_id" swaggertype:"primitive,string"`
	TokenID         string             `json:"token_id"`
	RegistryAddress common.Address     `json:"registry_address" swaggertype:"primitive,string"`
	DepositAddress  common.Address     `json:"deposit_address" swaggertype:"primitive,string"`
}

MintNFTResponse holds the details of the minted NFT.

type MonetaryValue

type MonetaryValue struct {
	Value   *documents.Decimal `json:"value" swaggertype:"primitive,string"`
	ChainID byteutils.HexBytes `json:"chain_id" swaggertype:"primitive,string"`
	ID      string             `json:"id"`
}

MonetaryValue defines user format to represent currency type Value string representation of decimal number ChainID hex bytes representing the chain where the currency is relevant ID string representing the Currency (USD|ETH|0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2(DAI)...)

type NFT

type NFT struct {
	Registry string `json:"registry"`
	Owner    string `json:"owner"`
	TokenID  string `json:"token_id"`
}

NFT defines a single NFT.

type NFTOwnerOnCCResponse

type NFTOwnerOnCCResponse struct {
	TokenID         string         `json:"token_id"`
	RegistryAddress common.Address `json:"registry_address" swaggertype:"primitive,string"`
	// 32 byte hex encoded account id on centrifuge chain
	Owner byteutils.HexBytes `json:"owner" swaggertype:"primitive,string"`
}

NFTOwnerOnCCResponse is the response for NFT owner request.

type NFTOwnerResponse

type NFTOwnerResponse struct {
	TokenID         string         `json:"token_id"`
	RegistryAddress common.Address `json:"registry_address" swaggertype:"primitive,string"`
	// 20 byte hex encoded ethereum address
	Owner common.Address `json:"owner" swaggertype:"primitive,string"`
}

NFTOwnerResponse is the response for NFT owner request.

type NFTResponseHeader

type NFTResponseHeader struct {
	JobID string `json:"job_id"`
}

NFTResponseHeader holds the NFT mint job ID.

type ProofResponseHeader

type ProofResponseHeader struct {
	DocumentID byteutils.HexBytes `json:"document_id" swaggertype:"primitive,string"`
	VersionID  byteutils.HexBytes `json:"version_id" swaggertype:"primitive,string"`
	State      string             `json:"state"`
}

ProofResponseHeader holds the document details.

type ProofsRequest

type ProofsRequest struct {
	Fields []string `json:"fields"`
}

ProofsRequest holds the fields for which proofs are generated.

type ProofsResponse

type ProofsResponse struct {
	Header      ProofResponseHeader `json:"header"`
	FieldProofs []documents.Proof   `json:"field_proofs"`
}

ProofsResponse holds the proofs for the fields given for a document.

func ConvertProofs

func ConvertProofs(proof *documents.DocumentProof) ProofsResponse

ConvertProofs converts documents.DocumentProof to ProofsResponse

type ResponseHeader

type ResponseHeader struct {
	DocumentID        string             `json:"document_id"`
	PreviousVersionID string             `json:"previous_version_id"`
	VersionID         string             `json:"version_id"`
	NextVersionID     string             `json:"next_version_id"`
	Author            string             `json:"author"`
	CreatedAt         string             `json:"created_at"`
	ReadAccess        []identity.DID     `json:"read_access" swaggertype:"array,string"`
	WriteAccess       []identity.DID     `json:"write_access" swaggertype:"array,string"`
	JobID             string             `json:"job_id,omitempty"`
	NFTs              []NFT              `json:"nfts"`
	Status            string             `json:"status,omitempty"`
	Fingerprint       byteutils.HexBytes `json:"fingerprint,omitempty" swaggertype:"primitive,string"`
}

ResponseHeader holds the common response header fields

func DeriveResponseHeader

func DeriveResponseHeader(tokenRegistry documents.TokenRegistry, model documents.Document,
	jobID string) (response ResponseHeader, err error)

DeriveResponseHeader derives an appropriate response header

type SignRequest

type SignRequest struct {
	Payload byteutils.HexBytes `json:"payload" swaggertype:"primitive,string"`
}

SignRequest holds the payload to be signed.

type SignResponse

type SignResponse struct {
	Payload   byteutils.HexBytes `json:"payload" swaggertype:"primitive,string"`
	Signature byteutils.HexBytes `json:"signature" swaggertype:"primitive,string"`
	PublicKey byteutils.HexBytes `json:"public_key" swaggertype:"primitive,string"`
	SignerID  byteutils.HexBytes `json:"signer_id" swaggertype:"primitive,string"`
}

SignResponse holds the signature, pk and Payload for the Sign request.

type SignedValue

type SignedValue struct {
	Identity identity.DID       `json:"identity" swaggertype:"primitive,string"`
	Value    byteutils.HexBytes `json:"value" swaggertype:"primitive,string"`
}

SignedValue contains the Identity of who signed the attribute and value which was signed

type TransferNFTOnCCRequest

type TransferNFTOnCCRequest struct {
	// 32 byte hex encoded account id on centrifuge chain
	To byteutils.HexBytes `json:"to" swaggertype:"primitive,string"`
}

TransferNFTOnCCRequest holds Registry Address and To address for NFT transfer

type TransferNFTOnCCResponse

type TransferNFTOnCCResponse struct {
	Header          NFTResponseHeader `json:"header"`
	TokenID         string            `json:"token_id"`
	RegistryAddress common.Address    `json:"registry_address" swaggertype:"primitive,string"`
	// 32 byte hex encoded account id on centrifuge chain
	To byteutils.HexBytes `json:"to" swaggertype:"primitive,string"`
}

TransferNFTResponse is the response for NFT transfer.

type TransferNFTRequest

type TransferNFTRequest struct {
	// 20 byte hex encoded ethereum address
	To common.Address `json:"to" swaggertype:"primitive,string"`
}

TransferNFTRequest holds Registry Address and To address for NFT transfer

type TransferNFTResponse

type TransferNFTResponse struct {
	Header          NFTResponseHeader `json:"header"`
	TokenID         string            `json:"token_id"`
	RegistryAddress common.Address    `json:"registry_address" swaggertype:"primitive,string"`
	// 20 byte hex encoded ethereum address
	To common.Address `json:"to" swaggertype:"primitive,string"`
}

TransferNFTResponse is the response for NFT transfer.

Jump to

Keyboard shortcuts

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