config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
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"
)
View Source
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

View Source
var AccountHeaderKey struct{}

AccountHeaderKey is used as key for the account identity in the context.ContextWithValue.

Functions

func CreateConfigFile

func CreateConfigFile(args map[string]interface{}) (*viper.Viper, error)

CreateConfigFile creates minimum config file with arguments

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

type AccountConfig struct {
	Address  string
	Key      string
	Password string
}

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

	// GetLowEntropyNFTTokenEnabled enables low entropy token IDs.
	// The Dharma NFT Collateralizer and other contracts require tokenIds that are shorter than
	// the ERC721 standard bytes32. This option reduces the maximum value of the tokenId.
	// There are security implications of doing this. Specifically the risk of two users picking the
	// same token id and minting it at the same time goes up and it theoretically could lead to a loss of an
	// NFT with large enough NFTRegistries (>100'000 tokens). It is not recommended to use this option.
	GetLowEntropyNFTTokenEnabled() 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.

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 IDKey

type IDKey struct {
	PublicKey  []byte
	PrivateKey []byte
}

IDKey represents a key pair

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)
	GenerateAccount(CentChainAccount) (Account, error)
	UpdateAccount(data Account) (Account, error)
	DeleteAccount(identifier []byte) error
	Sign(account, payload []byte) (*coredocumentpb.Signature, error)
}

Service exposes functions over the config objects

type SmartContractAddresses

type SmartContractAddresses struct {
	IdentityFactoryAddr string
}

SmartContractAddresses encapsulates the smart contract addresses

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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