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" )
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, error) GetP2PKeyPair() (pub, priv string) GetSigningKeyPair() (pub, priv string) GetEthereumContextWaitTimeout() time.Duration GetPrecommitEnabled() bool // CreateProtobuf creates protobuf CreateProtobuf() (*accountpb.AccountData, error) }
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 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 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 GetTaskRetries() int GetEthereumNodeURL() string GetEthereumContextReadWaitTimeout() time.Duration GetEthereumContextWaitTimeout() time.Duration GetEthereumIntervalRetry() time.Duration GetEthereumMaxRetries() int GetEthereumMaxGasPrice() *big.Int GetEthereumGasLimit(op ContractOp) uint64 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 }
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() [7]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) GetAllAccounts() ([]Account, error) CreateConfig(data Configuration) (Configuration, error) CreateAccount(data Account) (Account, error) GenerateAccount() (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, AnchorRepositoryAddr, InvoiceUnpaidAddr string
}
SmartContractAddresses encapsulates the smart contract addresses