contractregistry

package
v0.0.0-...-d3d27b2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultABICacheSize is the number of entries we will hold in a LRU cache for ABIs
	DefaultABICacheSize = 25
	// DefaultLevelDBName is default name of the LevelDB created in the storagePath
	DefaultLevelDBName = "abidb"
)
View Source
const (
	RemoteGateway abiType = iota
	RemoteInstance
	LocalABI
)

These values will be saved with existing subscriptions. Do not remove or reorder them (only add new ones to the end).

View Source
const (
	RemoteRegistryContextKey = "isRemoteRegistry"
)

Variables

This section is empty.

Functions

func IsRemote

func IsRemote(msg messages.CommonHeaders) bool

Types

type ABIInfo

type ABIInfo struct {
	messages.TimeSorted
	ID              string `json:"id"`
	Name            string `json:"name"`
	Description     string `json:"description"`
	Path            string `json:"path"`
	Deployable      bool   `json:"deployable"`
	SwaggerURL      string `json:"openapi"`
	CompilerVersion string `json:"compilerVersion"`
}

ABIInfo is the minimal data structure we keep in memory, indexed by our own UUID

func (*ABIInfo) GetID

func (i *ABIInfo) GetID() string

type ABILocation

type ABILocation struct {
	ABIType abiType `json:"type"`
	Name    string  `json:"name"`
}

type ContractInfo

type ContractInfo struct {
	messages.TimeSorted
	Address      string `json:"address"`
	Path         string `json:"path"`
	ABI          string `json:"abi"`
	SwaggerURL   string `json:"openapi"`
	RegisteredAs string `json:"registeredAs"`
}

ContractInfo is the minimal data structure we keep in memory, indexed by address ONLY used for local registry. Remote registry handles its own storage/caching

func (*ContractInfo) GetID

func (i *ContractInfo) GetID() string

type ContractResolver

type ContractResolver interface {
	ResolveContractAddress(registeredName string) (string, error)
	GetContractByAddress(addrHex string) (*ContractInfo, error)
	GetABI(location ABILocation, refresh bool) (deployMsg *DeployContractWithAddress, err error)
	CheckNameAvailable(name string, isRemote bool) error
}

type ContractStore

type ContractStore interface {
	ContractResolver
	Init() error
	Close()
	AddContract(addrHexNo0x, abiID, pathName, registerAs string) (*ContractInfo, error)
	AddABI(id string, deployMsg *messages.DeployContract, createdTime time.Time) (*ABIInfo, error)
	AddRemoteInstance(lookupStr, address string) error
	GetLocalABIInfo(abiID string) (*ABIInfo, error)
	ListContracts() ([]messages.TimeSortable, error)
	ListABIs() ([]messages.TimeSortable, error)
}

func NewContractStore

func NewContractStore(conf *ContractStoreConf, rr RemoteRegistry) ContractStore

type ContractStoreConf

type ContractStoreConf struct {
	StoragePath  string `json:"storagePath"`
	LevelDBName  string `json:"ldbName"`
	BaseURL      string `json:"baseURL"`
	ABICacheSize *int   `json:"abiCacheSize"`
}

type DeployContractWithAddress

type DeployContractWithAddress struct {
	Contract *messages.DeployContract
	Address  string
}

type RemoteRegistry

type RemoteRegistry interface {
	LoadFactoryForGateway(lookupStr string, refresh bool) (*messages.DeployContract, error)
	LoadFactoryForInstance(lookupStr string, refresh bool) (*DeployContractWithAddress, error)
	RegisterInstance(lookupStr, address string) error
	Init() error
	Close()
}

RemoteRegistry lookup of ABI, ByteCode and DevDocs against a conformant REST API

func NewRemoteRegistry

func NewRemoteRegistry(conf *RemoteRegistryConf) RemoteRegistry

NewRemoteRegistry construtor

type RemoteRegistryConf

type RemoteRegistryConf struct {
	utils.HTTPRequesterConf
	CacheDB           string                      `json:"cacheDB"`
	GatewayURLPrefix  string                      `json:"gatewayURLPrefix"`
	InstanceURLPrefix string                      `json:"instanceURLPrefix"`
	PropNames         RemoteRegistryPropNamesConf `json:"propNames"`
}

RemoteRegistryConf configuration

type RemoteRegistryPropNamesConf

type RemoteRegistryPropNamesConf struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	ABI        string `json:"abi"`
	Bytecode   string `json:"bytecode"`
	Devdoc     string `json:"devdoc"`
	Deployable string `json:"deployable"`
	Address    string `json:"address"`
}

RemoteRegistryPropNamesConf configures the JSON property names to extract from the GET response on the API

type StoredABI

type StoredABI struct {
	ABIInfo
	DeployMsg *messages.DeployContract `json:"deployMsg"`
}

Jump to

Keyboard shortcuts

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