Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeKVEntryReaderToJsonl(reader KVEntryReader, bytesWriter io.Writer) (err error)
- func ExtractBaseAddress(addr string) (string, error)
- func ExtractBaseAddressFromPacket(cdc codec.Codec, packet ibcexported.PacketI, role AddressRole, ...) (string, error)
- func JoinHookedAddress(baseAddr string, hookData []byte) (string, error)
- func NewStateChangeEvent(storeName string, subkey, value []byte) sdk.Event
- func SplitHookedAddress(addr string) (string, []byte, error)
- type AddressRole
- type KVEntry
- func (entry KVEntry) HasValue() bool
- func (entry KVEntry) IsValidKey() bool
- func (entry KVEntry) Key() string
- func (entry KVEntry) MarshalJSON() ([]byte, error)
- func (entry KVEntry) StringValue() string
- func (entry *KVEntry) UnmarshalJSON(input []byte) (err error)
- func (entry KVEntry) Value() *string
- type KVEntryReader
- func NewJsonRawMessageKVEntriesReader(jsonEntries []json.RawMessage) KVEntryReader
- func NewJsonlKVEntryDecoderReader(byteReader io.ReadCloser) KVEntryReader
- func NewKVHookingReader(reader KVEntryReader, onRead func(entry KVEntry) error, onClose func() error) KVEntryReader
- func NewKVIteratorReader(iter sdk.Iterator) KVEntryReader
- func NewSwingStoreExportDataEntriesReader(exportDataEntries []*swingsettypes.SwingStoreExportDataEntry) KVEntryReader
- func NewVstorageDataEntriesReader(vstorageDataEntries []*vstoragetypes.DataEntry) KVEntryReader
Constants ¶
const ( RoleSender AddressRole = "Sender" RoleReceiver AddressRole = "Receiver" AddressHookVersion = 0 BaseAddressLengthBytes = 2 )
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
NewKVEntry creates a KVEntry with the provided key and value
func NewKVEntryWithNoValue ¶
NewKVEntryWithNoValue creates a KVEntry with the provided key and no value
func (KVEntry) IsValidKey ¶
IsValidKey returns whether the KVEntry has a non-empty key.
func (KVEntry) MarshalJSON ¶
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 ¶
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 ¶
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.
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