contractspecs

package
v0.0.0-...-2646333 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnableAllListenersKey is the key that enables all listeners in the
	// EnableListener map
	EnableAllListenersKey = "all"
)

Variables

View Source
var (
	// ContractTypeToSpecs contains a map from ContractType to the contract specs,
	// which is the location of the contract and contract ABI, along with contract
	// metadata used to generate the watchers/filterers.
	// To be kept up to date with supported contracts
	// TODO(PN): Convert this to a YAML or JSON file that loads into this spec struct
	ContractTypeToSpecs = CSpecs{
						// contains filtered or unexported fields
	}

	// DisableCrawl is a map of contract:event keys to a bool to disable
	// crawling on a particular event.  The key is to be of the format
	// <contract type name in lower>:<event name in lower>
	// ex. newsroomcontract:watchcontentpublished.
	// If true, disables tracking of that event
	//
	// Use FlagKey() to consistently create keys for this map
	//
	// NOTE: The currently disabled events match up items Civil is not processing.
	// Feel free to alter and update as needed.
	// Should be a config file or env vars in the future
	DisableCrawl = map[string]bool{
		FlagKey("CivilTCRContract", "GovernmentTransfered"): true,

		FlagKey("NewsroomContract", "ContentPublished"):   true,
		FlagKey("NewsroomContract", "OwnershipRenounced"): true,
		FlagKey("NewsroomContract", "RevisionSigned"):     true,
		FlagKey("NewsroomContract", "RoleAdded"):          true,
		FlagKey("NewsroomContract", "RoleRemoved"):        true,

		FlagKey("CVLTokenContract", "OwnershipRenounced"):   true,
		FlagKey("CVLTokenContract", "OwnershipTransferred"): true,
		FlagKey("CVLTokenContract", "Approval"):             true,

		FlagKey("ParameterizerContract", "RewardClaimed"): true,

		FlagKey("CivilPLCRVotingContract", "VotingRightsGranted"):   true,
		FlagKey("CivilPLCRVotingContract", "VotingRightsWithdrawn"): true,
	}

	// EnableListener is a map of contract:event keys to a bool to enable
	// listeners on a particular event. If DisableCrawl is set for the same event,
	// the configuration here will not be used.
	// The key is to be of the format <contract type name in lower>:<event name in lower>
	// ex. newsroomcontract:watchcontentpublished.
	// If true, enables websocket listener for that event
	//
	// Use FlagKey() to consistently create keys for this map
	//
	// To enable listeners for all the events, add an "all": true item to this
	// config map. Use the EnableAllListenersKey to set this value.
	// NOTE: The currently enabled events match up with Civil needs.
	// Feel free to alter as needed for your deployments.
	// Should be a config file or env vars in the future
	EnableListener = map[string]bool{
		FlagKey("CivilTCRContract", "AppealGranted"):                 true,
		FlagKey("CivilTCRContract", "AppealRequested"):               true,
		FlagKey("CivilTCRContract", "Application"):                   true,
		FlagKey("CivilTCRContract", "ApplicationRemoved"):            true,
		FlagKey("CivilTCRContract", "ApplicationWhitelisted"):        true,
		FlagKey("CivilTCRContract", "Challenge"):                     true,
		FlagKey("CivilTCRContract", "ChallengeFailed"):               true,
		FlagKey("CivilTCRContract", "ChallengeSucceeded"):            true,
		FlagKey("CivilTCRContract", "Deposit"):                       true,
		FlagKey("CivilTCRContract", "FailedChallengeOverturned"):     true,
		FlagKey("CivilTCRContract", "GrantedAppealChallenged"):       true,
		FlagKey("CivilTCRContract", "GrantedAppealConfirmed"):        true,
		FlagKey("CivilTCRContract", "GrantedAppealOverturned"):       true,
		FlagKey("CivilTCRContract", "ListingRemoved"):                true,
		FlagKey("CivilTCRContract", "ListingWithdrawn"):              true,
		FlagKey("CivilTCRContract", "RewardClaimed"):                 true,
		FlagKey("CivilTCRContract", "SuccessfulChallengeOverturned"): true,
		FlagKey("CivilTCRContract", "TouchAndRemoved"):               true,
		FlagKey("CivilTCRContract", "Withdrawal"):                    true,
	}

	// NameToContractTypes is the map from a simple name to ContractType
	// To be kept up to date with supported contracts
	NameToContractTypes = CTypes{}
)

Functions

func FlagKey

func FlagKey(contractName string, eventType string) string

FlagKey generates the key used for DisableCrawl and EnableListeners maps

func IsEventDisabled

func IsEventDisabled(contractName string, eventType string) bool

IsEventDisabled is a convenience func that returns true if the given contract/event type is disabled

func IsListenerEnabledForEvent

func IsListenerEnabledForEvent(contractName string, eventType string) bool

IsListenerEnabledForEvent is a convenience func that returns true if the given contract/event type is enabled for websocket/eth-subscribe

Types

type CSpecs

type CSpecs struct {
	// contains filtered or unexported fields
}

CSpecs is a struct that contains a map from ContractType to contractSpecs

func (*CSpecs) Get

func (c *CSpecs) Get(t ContractType) (*ContractSpecs, bool)

Get returns the contract specs for a given ContractType

func (*CSpecs) Types

func (c *CSpecs) Types() []ContractType

Types returns a list of available types in CSpecs specs

type CTypes

type CTypes struct {
	// contains filtered or unexported fields
}

CTypes is a struct that contains a map of readable name to a ContractType enum value

func (*CTypes) Get

func (c *CTypes) Get(name string) (ContractType, bool)

Get returns the contract type for a given contract simple name

func (*CTypes) GetFromContractName

func (c *CTypes) GetFromContractName(name string) (ContractType, bool)

GetFromContractName returns the contract type for a given contract name

func (*CTypes) Names

func (c *CTypes) Names() []string

Names returns a list of the names in NameToContractType

type ContractSpecs

type ContractSpecs struct {
	// contains filtered or unexported fields
}

ContractSpecs specifies metadata around a smart contract to be used in the crawler.

func (*ContractSpecs) AbiStr

func (c *ContractSpecs) AbiStr() string

AbiStr returns the contract ABI string

func (*ContractSpecs) ImportPath

func (c *ContractSpecs) ImportPath() string

ImportPath returns the import path to the contract

func (*ContractSpecs) Name

func (c *ContractSpecs) Name() string

Name returns the full contract name

func (*ContractSpecs) SimpleName

func (c *ContractSpecs) SimpleName() string

SimpleName returns the short contract name

func (*ContractSpecs) TypePackage

func (c *ContractSpecs) TypePackage() string

TypePackage returns the package of the smart contract

type ContractType

type ContractType int

ContractType is an enum for the Civil contract type

const (

	// InvalidContractType is the enum value for an invalid contract type.
	InvalidContractType ContractType = iota

	// CivilTcrContractType is the enum value for the Civil TCR type
	CivilTcrContractType

	// NewsroomContractType is the enum value for the Newsroom type
	NewsroomContractType

	// CivilPLCRVotingContractType is the enum value for the Civil PLCR Voting type
	CivilPLCRVotingContractType

	// CVLTokenContractType is the enum value for the CVL token type
	CVLTokenContractType

	// CivilParameterizerContractType is the enum value for the Civil Parameterizer type
	CivilParameterizerContractType

	// CivilGovernmentContractType is the enum value for the Civil Government type
	CivilGovernmentContractType

	// MultiSigWalletContractType is the enum value for the Gnosis Multi Sig Wallet type
	MultiSigWalletContractType

	// MultiSigWalletFactoryContractType is the enum value for the Multi Sig Factory type
	MultiSigWalletFactoryContractType

	// NewsroomFactoryType is the enum value for the Newsroom Factory type
	NewsroomFactoryType
)

Jump to

Keyboard shortcuts

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