common

package
v0.23.3-patch.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLength = 8
View Source
const AddressLocationPrefix = "A"
View Source
const ComputationKindRangeStart = 1000

[1000,2000) is reserved for Cadence interpreter and runtime

View Source
const IdentifierLocationPrefix = "I"
View Source
const REPLLocationPrefix = "REPL"
View Source
const ScriptLocationPrefix = "s"
View Source
const StringLocationPrefix = "S"
View Source
const TransactionLocationPrefix = "t"

Variables

View Source
var AllPathDomainsByIdentifier = map[string]PathDomain{}

Functions

func CompositeKindCount added in v0.8.0

func CompositeKindCount() int

func DeclarationKindCount added in v0.8.0

func DeclarationKindCount() int

func EnumerateWords

func EnumerateWords(words []string, conjunction string) string

func LocationsInSameAccount added in v0.13.10

func LocationsInSameAccount(first, second Location) bool

LocationsInSameAccount returns true if both locations are nil, if both locations are address locations when both locations have the same address, or otherwise if their IDs are the same.

func LocationsMatch added in v0.12.0

func LocationsMatch(first, second Location) bool

LocationsMatch returns true if both locations are nil or their IDs are the same.

func RegisterTypeIDDecoder added in v0.12.0

func RegisterTypeIDDecoder(prefix string, decoder TypeIDDecoder)

Types

type Address

type Address [AddressLength]byte

func BytesToAddress

func BytesToAddress(b []byte) (Address, error)

BytesToAddress returns Address with value b.

If the address is too large, then the function returns an error.

func HexToAddress added in v0.17.0

func HexToAddress(h string) (Address, error)

HexToAddress converts a hex string to an Address.

func MustBytesToAddress added in v0.21.0

func MustBytesToAddress(b []byte) Address

MustBytesToAddress returns Address with value b.

If the address is too large, then the function panics.

func (Address) Bytes added in v0.2.0

func (a Address) Bytes() []byte

Bytes returns address without leading zeros. The fast path is inlined and handles the most common scenario of address having no leading zeros. Otherwise, bytes() is called to trim leading zeros.

func (Address) Hex

func (a Address) Hex() string

Hex returns the hex string representation of the address.

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b.

If b is larger than len(a) it will panic.

func (Address) ShortHexWithPrefix added in v0.9.0

func (a Address) ShortHexWithPrefix() string

func (Address) String

func (a Address) String() string

type AddressLocation added in v0.12.0

type AddressLocation struct {
	Address Address
	Name    string
}

AddressLocation is the location of a contract/contract interface at an address

func (AddressLocation) ID added in v0.12.0

func (l AddressLocation) ID() LocationID

func (AddressLocation) MarshalJSON added in v0.12.0

func (l AddressLocation) MarshalJSON() ([]byte, error)

func (AddressLocation) QualifiedIdentifier added in v0.12.0

func (l AddressLocation) QualifiedIdentifier(typeID TypeID) string

func (AddressLocation) String added in v0.12.0

func (l AddressLocation) String() string

func (AddressLocation) TypeID added in v0.12.0

func (l AddressLocation) TypeID(qualifiedIdentifier string) TypeID

type CompositeKind

type CompositeKind uint
const (
	CompositeKindUnknown CompositeKind = iota
	CompositeKindStructure
	CompositeKindResource
	CompositeKindContract
	CompositeKindEvent
	CompositeKindEnum
)

func (CompositeKind) Annotation

func (k CompositeKind) Annotation() string

func (CompositeKind) ConstructionKeyword

func (k CompositeKind) ConstructionKeyword() string

func (CompositeKind) DeclarationKind

func (k CompositeKind) DeclarationKind(isInterface bool) DeclarationKind

func (CompositeKind) DestructionKeyword

func (k CompositeKind) DestructionKeyword() interface{}

func (CompositeKind) Keyword

func (k CompositeKind) Keyword() string

func (CompositeKind) MarshalJSON added in v0.8.0

func (k CompositeKind) MarshalJSON() ([]byte, error)

func (CompositeKind) MoveOperator

func (k CompositeKind) MoveOperator() string

func (CompositeKind) Name

func (k CompositeKind) Name() string

func (CompositeKind) String

func (i CompositeKind) String() string

func (CompositeKind) SupportsInterfaces

func (k CompositeKind) SupportsInterfaces() bool

func (CompositeKind) TransferOperator

func (k CompositeKind) TransferOperator() string

type ComputationKind added in v0.23.2

type ComputationKind uint

ComputationKind captures kind of computation that would be used for metring computation

const (
	ComputationKindUnknown ComputationKind = 0
	// interpreter - base
	ComputationKindStatement ComputationKind = ComputationKindRangeStart + iota
	ComputationKindLoop
	ComputationKindFunctionInvocation

	// interpreter value operations
	ComputationKindCreateCompositeValue
	ComputationKindTransferCompositeValue
	ComputationKindDestroyCompositeValue

	ComputationKindCreateArrayValue
	ComputationKindTransferArrayValue
	ComputationKindDestroyArrayValue

	ComputationKindCreateDictionaryValue
	ComputationKindTransferDictionaryValue
	ComputationKindDestroyDictionaryValue

	// stdlibs computation kinds
	//
	ComputationKindSTDLIBPanic
	ComputationKindSTDLIBAssert
	ComputationKindSTDLIBUnsafeRandom

	// RLP
	ComputationKindSTDLIBRLPDecodeString
	ComputationKindSTDLIBRLPDecodeList
)

func (ComputationKind) String added in v0.23.2

func (i ComputationKind) String() string

type ControlStatement

type ControlStatement uint
const (
	ControlStatementUnknown ControlStatement = iota
	ControlStatementBreak
	ControlStatementContinue
)

func (ControlStatement) String

func (i ControlStatement) String() string

func (ControlStatement) Symbol

func (s ControlStatement) Symbol() string

type DeclarationKind

type DeclarationKind uint
const (
	DeclarationKindUnknown DeclarationKind = iota
	DeclarationKindValue
	DeclarationKindFunction
	DeclarationKindVariable
	DeclarationKindConstant
	DeclarationKindType
	DeclarationKindParameter
	DeclarationKindArgumentLabel
	DeclarationKindStructure
	DeclarationKindResource
	DeclarationKindContract
	DeclarationKindEvent
	DeclarationKindField
	DeclarationKindInitializer
	DeclarationKindDestructor
	DeclarationKindStructureInterface
	DeclarationKindResourceInterface
	DeclarationKindContractInterface
	DeclarationKindImport
	DeclarationKindSelf
	DeclarationKindTransaction
	DeclarationKindPrepare
	DeclarationKindExecute
	DeclarationKindTypeParameter
	DeclarationKindPragma
	DeclarationKindEnum
	DeclarationKindEnumCase
)

func (DeclarationKind) IsTypeDeclaration

func (k DeclarationKind) IsTypeDeclaration() bool

func (DeclarationKind) Keywords

func (k DeclarationKind) Keywords() string

func (DeclarationKind) MarshalJSON added in v0.8.0

func (k DeclarationKind) MarshalJSON() ([]byte, error)

func (DeclarationKind) Name

func (k DeclarationKind) Name() string

func (DeclarationKind) String

func (i DeclarationKind) String() string

type HasImportLocation added in v0.12.0

type HasImportLocation interface {
	ImportLocation() Location
}

type IdentifierLocation added in v0.12.0

type IdentifierLocation string

IdentifierLocation

func (IdentifierLocation) ID added in v0.12.0

func (IdentifierLocation) MarshalJSON added in v0.12.0

func (l IdentifierLocation) MarshalJSON() ([]byte, error)

func (IdentifierLocation) QualifiedIdentifier added in v0.12.0

func (l IdentifierLocation) QualifiedIdentifier(typeID TypeID) string

func (IdentifierLocation) String added in v0.12.0

func (l IdentifierLocation) String() string

func (IdentifierLocation) TypeID added in v0.12.0

func (l IdentifierLocation) TypeID(qualifiedIdentifier string) TypeID

type Location added in v0.12.0

type Location interface {
	fmt.Stringer
	// ID returns the canonical ID for this import location.
	ID() LocationID
	// TypeID returns a type ID for the given qualified identifier
	TypeID(qualifiedIdentifier string) TypeID
	// QualifiedIdentifier returns the qualified identifier for the given type ID
	QualifiedIdentifier(typeID TypeID) string
}

Location describes the origin of a Cadence script. This could be a file, a transaction, or a smart contract.

func DecodeTypeID added in v0.12.0

func DecodeTypeID(typeID string) (location Location, qualifiedIdentifier string, err error)

type LocationID added in v0.12.0

type LocationID string

LocationID

func NewLocationID added in v0.12.0

func NewLocationID(parts ...string) LocationID

type OperandSide

type OperandSide uint
const (
	OperandSideUnknown OperandSide = iota
	OperandSideLeft
	OperandSideRight
)

func (OperandSide) Name

func (s OperandSide) Name() string

func (OperandSide) String

func (i OperandSide) String() string

type OperationKind

type OperationKind uint
const (
	OperationKindUnknown OperationKind = iota
	OperationKindUnary
	OperationKindBinary
	OperationKindTernary
)

func (OperationKind) Name

func (k OperationKind) Name() string

func (OperationKind) String

func (i OperationKind) String() string

type PathDomain

type PathDomain uint8
const (
	PathDomainUnknown PathDomain = iota
	PathDomainStorage
	PathDomainPrivate
	PathDomainPublic
)

func PathDomainFromIdentifier

func PathDomainFromIdentifier(domain string) PathDomain

func (PathDomain) Identifier

func (i PathDomain) Identifier() string

func (PathDomain) String

func (i PathDomain) String() string

type REPLLocation added in v0.12.0

type REPLLocation struct{}

REPLLocation

func (REPLLocation) ID added in v0.12.0

func (l REPLLocation) ID() LocationID

func (REPLLocation) MarshalJSON added in v0.12.0

func (l REPLLocation) MarshalJSON() ([]byte, error)

func (REPLLocation) QualifiedIdentifier added in v0.12.0

func (l REPLLocation) QualifiedIdentifier(typeID TypeID) string

func (REPLLocation) String added in v0.12.0

func (l REPLLocation) String() string

func (REPLLocation) TypeID added in v0.12.0

func (l REPLLocation) TypeID(qualifiedIdentifier string) TypeID

type ScriptLocation added in v0.12.0

type ScriptLocation []byte

ScriptLocation

func (ScriptLocation) ID added in v0.12.0

func (l ScriptLocation) ID() LocationID

func (ScriptLocation) MarshalJSON added in v0.12.0

func (l ScriptLocation) MarshalJSON() ([]byte, error)

func (ScriptLocation) QualifiedIdentifier added in v0.12.0

func (l ScriptLocation) QualifiedIdentifier(typeID TypeID) string

func (ScriptLocation) String added in v0.12.0

func (l ScriptLocation) String() string

func (ScriptLocation) TypeID added in v0.12.0

func (l ScriptLocation) TypeID(qualifiedIdentifier string) TypeID

type StringLocation added in v0.12.0

type StringLocation string

StringLocation

func (StringLocation) ID added in v0.12.0

func (l StringLocation) ID() LocationID

func (StringLocation) MarshalJSON added in v0.12.0

func (l StringLocation) MarshalJSON() ([]byte, error)

func (StringLocation) QualifiedIdentifier added in v0.12.0

func (l StringLocation) QualifiedIdentifier(typeID TypeID) string

func (StringLocation) String added in v0.12.0

func (l StringLocation) String() string

func (StringLocation) TypeID added in v0.12.0

func (l StringLocation) TypeID(qualifiedIdentifier string) TypeID

type TransactionLocation added in v0.12.0

type TransactionLocation []byte

TransactionLocation

func (TransactionLocation) ID added in v0.12.0

func (TransactionLocation) MarshalJSON added in v0.12.0

func (l TransactionLocation) MarshalJSON() ([]byte, error)

func (TransactionLocation) QualifiedIdentifier added in v0.12.0

func (l TransactionLocation) QualifiedIdentifier(typeID TypeID) string

func (TransactionLocation) String added in v0.12.0

func (l TransactionLocation) String() string

func (TransactionLocation) TypeID added in v0.12.0

func (l TransactionLocation) TypeID(qualifiedIdentifier string) TypeID

type TypeID added in v0.12.0

type TypeID string

TypeID

func NewTypeID added in v0.12.0

func NewTypeID(parts ...string) TypeID

type TypeIDDecoder added in v0.12.0

type TypeIDDecoder func(typeID string) (location Location, qualifiedIdentifier string, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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