Documentation
¶
Index ¶
Constants ¶
const ( // BootstrappedConfigFile points to the config file the node is bootstrapped with BootstrappedConfigFile string = "BootstrappedConfigFile" // BootstrappedConfigStorage indicates that config storage has been bootstrapped and its the key for config storage service in the bootstrap context BootstrappedConfigStorage string = "BootstrappedConfigStorage" )
Bootstrap constants are keys to the value mappings in context bootstrap.
const ( // AnchorRepo is the contract name for AnchorRepo AnchorRepo ContractName = "anchorRepository" // Identity is the contract name for Identity Identity ContractName = "identity" // IdentityFactory is the contract name for IdentityFactory IdentityFactory ContractName = "identityFactory" // IdentityRegistry is the contract name for IdentityRegistry IdentityRegistry ContractName = "identityRegistry" // InvoiceUnpaidNFT is the contract name for InvoiceUnpaidNFT InvoiceUnpaidNFT ContractName = "invoiceUnpaid" // IDCreate identity creation operation IDCreate ContractOp = "idCreate" // IDAddKey identity add key operation IDAddKey ContractOp = "idAddKey" // IDRevokeKey identity key revocation operation IDRevokeKey ContractOp = "idRevokeKey" // AnchorCommit anchor commit operation AnchorCommit ContractOp = "anchorCommit" // AnchorPreCommit anchor pre-commit operation AnchorPreCommit ContractOp = "anchorPreCommit" // NftMint nft minting operation NftMint ContractOp = "nftMint" // NftTransferFrom nft transferFrom operation NftTransferFrom ContractOp = "nftTransferFrom" // AssetStore is the operation name to store asset on chain AssetStore ContractOp = "assetStore" // PushToOracle for pushing data to oracle PushToOracle ContractOp = "pushToOracle" )
const ( // ErrConfigBootstrap used as default error type ErrConfigBootstrap = errors.Error("error when bootstrapping config") // ErrConfigFileBootstrapNotFound used when config file is not found ErrConfigFileBootstrapNotFound = errors.Error("config file hasn't been provided") // ErrConfigRetrieve must be returned when there is an error while retrieving config ErrConfigRetrieve = errors.Error("error when retrieving config") )
Variables ¶
var AccountHeaderKey struct{}
AccountHeaderKey is used as key for the account identity in the context.ContextWithValue.
Functions ¶
Types ¶
type Account ¶
type Account interface {
storage.Model
GetKeys() (map[string]IDKey, error)
SignMsg(msg []byte) (*coredocumentpb.Signature, error)
GetEthereumAccount() *AccountConfig
GetEthereumDefaultAccountName() string
GetReceiveEventNotificationEndpoint() string
GetIdentityID() []byte
GetP2PKeyPair() (pub, priv string)
GetSigningKeyPair() (pub, priv string)
GetEthereumContextWaitTimeout() time.Duration
GetPrecommitEnabled() bool
GetCentChainAccount() CentChainAccount
}
Account exposes account options
type AccountConfig ¶
AccountConfig holds the account details.
type Bootstrapper ¶
type Bootstrapper struct{}
Bootstrapper implements bootstrap.Bootstrapper to initialise config package.
func (*Bootstrapper) Bootstrap ¶
func (*Bootstrapper) Bootstrap(context map[string]interface{}) error
Bootstrap takes the passed in config file, loads the config and puts the config back into context.
type CentChainAccount ¶ added in v1.0.0
type CentChainAccount struct {
ID string `json:"id"`
Secret string `json:"secret,omitempty"`
SS58Addr string `json:"ss_58_address"`
}
CentChainAccount holds the cent chain account details.
func (CentChainAccount) KeyRingPair ¶ added in v1.0.0
func (cacc CentChainAccount) KeyRingPair() (signature.KeyringPair, error)
KeyRingPair returns the keyring pair for the given account.
type Configuration ¶
type Configuration interface {
storage.Model
// generic methods
IsSet(key string) bool
Set(key string, value interface{})
SetDefault(key string, value interface{})
SetupSmartContractAddresses(network string, smartContractAddresses *SmartContractAddresses)
Get(key string) interface{}
GetString(key string) string
GetBool(key string) bool
GetInt(key string) int
GetFloat(key string) float64
GetDuration(key string) time.Duration
GetStoragePath() string
GetConfigStoragePath() string
GetAccountsKeystore() string
GetP2PPort() int
GetP2PExternalIP() string
GetP2PConnectionTimeout() time.Duration
GetP2PResponseDelay() time.Duration
GetServerPort() int
GetServerAddress() string
GetNumWorkers() int
GetWorkerWaitTimeMS() int
GetTaskValidDuration() time.Duration
GetEthereumNodeURL() string
GetEthereumContextReadWaitTimeout() time.Duration
GetEthereumContextWaitTimeout() time.Duration
GetEthereumIntervalRetry() time.Duration
GetEthereumMaxRetries() int
GetEthereumMaxGasPrice() *big.Int
GetEthereumGasLimit(op ContractOp) uint64
GetEthereumGasMultiplier() float64
GetNetworkString() string
GetNetworkKey(k string) string
GetContractAddressString(address string) string
GetContractAddress(contractName ContractName) common.Address
GetBootstrapPeers() []string
GetNetworkID() uint32
// CentID specific configs (eg: for multi tenancy)
GetEthereumAccount(accountName string) (account *AccountConfig, err error)
GetEthereumDefaultAccountName() string
GetReceiveEventNotificationEndpoint() string
GetIdentityID() ([]byte, error)
GetP2PKeyPair() (pub, priv string)
GetSigningKeyPair() (pub, priv string)
GetPrecommitEnabled() bool
// debug specific methods
IsPProfEnabled() bool
IsDebugLogEnabled() bool
// CentChain specific details.
GetCentChainAccount() (CentChainAccount, error)
GetCentChainIntervalRetry() time.Duration
GetCentChainMaxRetries() int
GetCentChainNodeURL() string
GetCentChainAnchorLifespan() time.Duration
}
Configuration defines the methods that a config type should implement.
func LoadConfiguration ¶
func LoadConfiguration(configFile string) Configuration
LoadConfiguration loads the configuration from the given file.
func RetrieveConfig ¶ added in v1.3.0
func RetrieveConfig(dbOnly bool, ctx map[string]interface{}) (Configuration, error)
RetrieveConfig retrieves system config giving priority to db stored config
type ContractName ¶
type ContractName string
ContractName is a type to indicate a contract name parameter
func ContractNames ¶
func ContractNames() [5]ContractName
ContractNames returns the list of smart contract names currently used in the system, please update this when adding new contracts
type ContractOp ¶
type ContractOp string
ContractOp is a type to indicate a contract operation name parameter
func ContractOps ¶
func ContractOps() [8]ContractOp
ContractOps returns the list of smart contract ops currently used in the system, please update this when adding new ops
type Service ¶
type Service interface {
GetConfig() (Configuration, error)
GetAccount(identifier []byte) (Account, error)
GetAccounts() ([]Account, error)
CreateConfig(data Configuration) (Configuration, error)
CreateAccount(data Account) (Account, error)
UpdateAccount(data Account) (Account, error)
DeleteAccount(identifier []byte) error
Sign(account, payload []byte) (*coredocumentpb.Signature, error)
GenerateAccountAsync(account CentChainAccount) (did []byte, jobID []byte, err error)
}
Service exposes functions over the config objects
type SmartContractAddresses ¶
type SmartContractAddresses struct {
IdentityFactoryAddr string
}
SmartContractAddresses encapsulates the smart contract addresses