types

package
v0.0.0-...-837776e Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleSender   AddressRole = "Sender"
	RoleReceiver AddressRole = "Receiver"

	AddressHookVersion     = 0
	BaseAddressLengthBytes = 2
)
View Source
const (
	EventTypeStateChange = "state_change"

	AttributeKeyStoreName     = "store"
	AttributeKeyStoreSubkey   = "key"
	AttributeKeyAnchoredKey   = "anckey"
	AttributeKeyUnprovedValue = "value"

	// We chose \1 so that it is not a valid character in a vstorage path.
	AnchoredKeyStart = "\x01"
	AnchoredKeyEnd   = AnchoredKeyStart
)

Variables

View Source
var AddressHookBytePrefix = []byte{0x78, 0xf1, 0x70}

AddressHookBytePrefix is a magic prefix that identifies a hooked address. Chosen to make bech32 address hooks that look like "agoric10rch..."

Functions

func EncodeKVEntryReaderToJsonl

func EncodeKVEntryReaderToJsonl(reader KVEntryReader, bytesWriter io.Writer) (err error)

EncodeKVEntryReaderToJsonl consumes a KVEntryReader and JSON encodes each KVEntry, terminating by new lines. It will not Close the Reader when done

func ExtractBaseAddress

func ExtractBaseAddress(addr string) (string, error)

ExtractBaseAddress extracts the base address from an Address Hook. It returns addr verbatim if it is not an Address Hook.

func ExtractBaseAddressFromPacket

func ExtractBaseAddressFromPacket(cdc codec.Codec, packet ibcexported.PacketI, role AddressRole, newPacket *channeltypes.Packet) (string, error)

ExtractBaseAddressFromPacket returns the base address from a transfer packet's data, either Sender (if role is RoleSender) or Receiver (if role is RoleReceiver). Errors in determining the base address are ignored... we then assume the base address is exactly the original address. If newPacket is not nil, it is populated with a new transfer packet whose corresponding Sender or Receiver is replaced with the extracted base address.

func JoinHookedAddress

func JoinHookedAddress(baseAddr string, hookData []byte) (string, error)

JoinHookedAddress joins a base bech32 address with hook data to create a hooked bech32 address. For the JS implementation, look at @agoric/cosmic-proto/src/address-hooks.js

func NewStateChangeEvent

func NewStateChangeEvent(storeName string, subkey, value []byte) sdk.Event

func SplitHookedAddress

func SplitHookedAddress(addr string) (string, []byte, error)

SplitHookedAddress splits a hooked address into its base address and hook data. For the JS implementation, look at @agoric/cosmic-proto/src/address-hooks.js.

Types

type AddressRole

type AddressRole string

type KVEntry

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

KVEntry represents a string key / string value pair, where the value may be missing, which is different from an empty value. The semantics of a missing value are purpose-dependent rather than specified here, but frequently correspond with deletion/incompleteness/etc. A KVEntry with an empty key is considered invalid.

func NewKVEntry

func NewKVEntry(key string, value string) KVEntry

NewKVEntry creates a KVEntry with the provided key and value

func NewKVEntryWithNoValue

func NewKVEntryWithNoValue(key string) KVEntry

NewKVEntryWithNoValue creates a KVEntry with the provided key and no value

func (KVEntry) HasValue

func (entry KVEntry) HasValue() bool

HasValue returns whether the KVEntry has a value or not.

func (KVEntry) IsValidKey

func (entry KVEntry) IsValidKey() bool

IsValidKey returns whether the KVEntry has a non-empty key.

func (KVEntry) Key

func (entry KVEntry) Key() string

Key returns the string key.

func (KVEntry) MarshalJSON

func (entry KVEntry) MarshalJSON() ([]byte, error)

MarshalJSON encodes the KVEntry into a JSON array of [key: string, value?: string], with the value missing (array length of 1) if the entry has no value.

Implements json.Marshaler

func (KVEntry) StringValue

func (entry KVEntry) StringValue() string

StringValue returns the string value, or the empty string if the entry has no value. Note that the result therefore does not differentiate an empty string value from no value.

func (*KVEntry) UnmarshalJSON

func (entry *KVEntry) UnmarshalJSON(input []byte) (err error)

UnmarshalJSON updates a KVEntry from JSON text corresponding with a [key: string, value?: string | null] shape, or returns an error indicating invalid input. The key must be a non-empty string, and the value (if present) must be a string or null.

Implements json.Unmarshaler Note: unlike other methods, this accepts a pointer to satisfy the Unmarshaler semantics.

func (KVEntry) Value

func (entry KVEntry) Value() *string

Value returns a pointer to the string value or nil if the entry has no value.

type KVEntryReader

type KVEntryReader interface {
	// Read returns the next KVEntry, or an error.
	// An `io.EOF` error indicates that the previous Read() returned the final KVEntry.
	Read() (KVEntry, error)
	// Close frees the underlying resource (such as a slice or file descriptor).
	Close() error
}

KVEntryReader is an abstraction for iteratively reading KVEntry data.

func NewJsonRawMessageKVEntriesReader

func NewJsonRawMessageKVEntriesReader(jsonEntries []json.RawMessage) KVEntryReader

NewJsonRawMessageKVEntriesReader creates a KVEntryReader backed by a json.RawMessage slice

func NewJsonlKVEntryDecoderReader

func NewJsonlKVEntryDecoderReader(byteReader io.ReadCloser) KVEntryReader

NewJsonlKVEntryDecoderReader creates a KVEntryReader over a byte stream reader that decodes each line as a json encoded KVEntry. The entries are yielded in order they're present in the stream.

func NewKVHookingReader

func NewKVHookingReader(reader KVEntryReader, onRead func(entry KVEntry) error, onClose func() error) KVEntryReader

NewKVHookingReader returns a KVEntryReader backed by another KVEntryReader

func NewKVIteratorReader

func NewKVIteratorReader(iter sdk.Iterator) KVEntryReader

NewKVIteratorReader returns a KVEntryReader backed by an sdk.Iterator.

func NewSwingStoreExportDataEntriesReader

func NewSwingStoreExportDataEntriesReader(exportDataEntries []*swingsettypes.SwingStoreExportDataEntry) KVEntryReader

NewSwingStoreExportDataEntriesReader creates a KVEntryReader backed by a SwingStoreExportDataEntry slice

func NewVstorageDataEntriesReader

func NewVstorageDataEntriesReader(vstorageDataEntries []*vstoragetypes.DataEntry) KVEntryReader

NewVstorageDataEntriesReader creates a KVEntryReader backed by a vstorage DataEntry slice

Jump to

Keyboard shortcuts

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