Documentation ¶
Index ¶
- type CoinMetadataQueryFn
- type RepeatedValueRenderer
- type Screen
- type SignModeHandler
- func (r *SignModeHandler) DefineMessageRenderer(name protoreflect.FullName, vr ValueRenderer)
- func (r *SignModeHandler) DefineScalar(scalar string, vr ValueRendererCreator)
- func (r *SignModeHandler) GetFieldValueRenderer(fd protoreflect.FieldDescriptor) (ValueRenderer, error)
- func (r *SignModeHandler) GetMessageValueRenderer(md protoreflect.MessageDescriptor) (ValueRenderer, error)
- func (r *SignModeHandler) GetSignBytes(ctx context.Context, signerData signing.SignerData, txData signing.TxData) ([]byte, error)
- func (r *SignModeHandler) Mode() signingv1beta1.SignMode
- func (r *SignModeHandler) SpecVersion() uint64
- type SignModeOptions
- type ValueRenderer
- func NewAnyValueRenderer(t *SignModeHandler) ValueRenderer
- func NewBytesValueRenderer() ValueRenderer
- func NewCoinsValueRenderer(q CoinMetadataQueryFn) ValueRenderer
- func NewDecValueRenderer() ValueRenderer
- func NewDurationValueRenderer() ValueRenderer
- func NewEnumValueRenderer(fd protoreflect.FieldDescriptor) ValueRenderer
- func NewIntValueRenderer(fd protoreflect.FieldDescriptor) ValueRenderer
- func NewMessageValueRenderer(t *SignModeHandler, msgDesc protoreflect.MessageDescriptor) ValueRenderer
- func NewStringValueRenderer() ValueRenderer
- func NewTimestampValueRenderer() ValueRenderer
- func NewTxValueRenderer(tr *SignModeHandler) ValueRenderer
- type ValueRendererCreator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CoinMetadataQueryFn ¶
CoinMetadataQueryFn defines a function that queries state for the coin denom metadata. It is meant to be passed as an argument into `NewSignModeHandler`.
type RepeatedValueRenderer ¶
type RepeatedValueRenderer interface { ValueRenderer // FormatRepeated should render the value to a text plus annotation. FormatRepeated(context.Context, protoreflect.Value) ([]Screen, error) // ParseRepeated should be the inverse of Format. The list will be populated with the repeated values. ParseRepeated(context.Context, []Screen, protoreflect.List) error }
RepeatedValueRenderer defines an interface to produce formatted output for protobuf message fields that are repeated.
type Screen ¶
type Screen struct { // Title is the text (sequence of Unicode code points) to display first, // generally on the device's title section. It can be empty. Title string // Content is the text (sequence of Unicode code points) to display after // the Title, generally on the device's content section. It must be // non-empty. Content string // Indent is the indentation level of the screen. // Zero indicates top-level. Should be less than 16. Indent int // Expert indicates that the screen should only be displayed // via an opt-in from the user. Expert bool }
Screen is the abstract unit of Textual rendering.
type SignModeHandler ¶
type SignModeHandler struct {
// contains filtered or unexported fields
}
SignModeHandler holds the configuration for dispatching to specific value renderers for SIGN_MODE_TEXTUAL.
func NewSignModeHandler ¶
func NewSignModeHandler(o SignModeOptions) (*SignModeHandler, error)
NewSignModeHandler returns a new SignModeHandler which generates sign bytes and provides value renderers.
func (*SignModeHandler) DefineMessageRenderer ¶
func (r *SignModeHandler) DefineMessageRenderer(name protoreflect.FullName, vr ValueRenderer)
DefineMessageRenderer adds a new custom message renderer.
func (*SignModeHandler) DefineScalar ¶
func (r *SignModeHandler) DefineScalar(scalar string, vr ValueRendererCreator)
DefineScalar adds a value renderer to the given Cosmos scalar.
func (*SignModeHandler) GetFieldValueRenderer ¶
func (r *SignModeHandler) GetFieldValueRenderer(fd protoreflect.FieldDescriptor) (ValueRenderer, error)
GetFieldValueRenderer returns the value renderer for the given FieldDescriptor.
func (*SignModeHandler) GetMessageValueRenderer ¶
func (r *SignModeHandler) GetMessageValueRenderer(md protoreflect.MessageDescriptor) (ValueRenderer, error)
GetMessageValueRenderer is a specialization of GetValueRenderer for messages. It is useful when the message type is discovered outside the context of a field, e.g. when handling a google.protobuf.Any.
func (*SignModeHandler) GetSignBytes ¶
func (r *SignModeHandler) GetSignBytes(ctx context.Context, signerData signing.SignerData, txData signing.TxData) ([]byte, error)
GetSignBytes returns the transaction sign bytes.
func (*SignModeHandler) Mode ¶
func (r *SignModeHandler) Mode() signingv1beta1.SignMode
func (*SignModeHandler) SpecVersion ¶ added in v0.4.0
func (r *SignModeHandler) SpecVersion() uint64
SpecVersion returns the spec version this SignModeHandler implementation is following.
type SignModeOptions ¶ added in v0.4.0
type SignModeOptions struct { // coinMetadataQuerier defines a function to query the coin metadata from // state. It should use bank module's `DenomsMetadata` gRPC query to fetch // each denom's associated metadata, either using the bank keeper (for // server-side code) or a gRPC query client (for client-side code). CoinMetadataQuerier CoinMetadataQueryFn // FileResolver are the protobuf files to use for resolving message // descriptors. If it is nil, the global protobuf registry will be used. FileResolver signing.ProtoFileResolver // TypeResolver are the protobuf type resolvers to use for resolving message // types. If it is nil, then a dynamicpb will be used on top of FileResolver. TypeResolver protoregistry.MessageTypeResolver }
SignModeOptions are options to be passed to Textual's sign mode handler.
type ValueRenderer ¶
type ValueRenderer interface { // Format should render the value to a text plus annotation. Format(context.Context, protoreflect.Value) ([]Screen, error) // Parse should be the inverse of Format. Parse(context.Context, []Screen) (protoreflect.Value, error) }
ValueRenderer defines an interface to produce formatted output for all protobuf types as well as parse a string into those protobuf types.
The notion of "value renderer" is defined in ADR-050, and that ADR provides a default spec for value renderers. However, we define it as an interface here, so that optionally more value renderers could be built, for example, a separate one for a different language.
func NewAnyValueRenderer ¶
func NewAnyValueRenderer(t *SignModeHandler) ValueRenderer
NewAnyValueRenderer returns a ValueRenderer for google.protobuf.Any messages.
func NewBytesValueRenderer ¶
func NewBytesValueRenderer() ValueRenderer
NewBytesValueRenderer returns a ValueRenderer for Protobuf bytes, which are encoded as capital-letter hexadecimal, without the '0x' prefix.
func NewCoinsValueRenderer ¶
func NewCoinsValueRenderer(q CoinMetadataQueryFn) ValueRenderer
NewCoinsValueRenderer returns a ValueRenderer for SDK Coin and Coins.
func NewDecValueRenderer ¶
func NewDecValueRenderer() ValueRenderer
NewDecValueRenderer returns a ValueRenderer for encoding sdk.Dec cosmos scalars.
func NewDurationValueRenderer ¶
func NewDurationValueRenderer() ValueRenderer
NewDurationValueRenderer returns a ValueRenderer for protocol buffer Duration messages. It renders durations by grouping seconds into units of days (86400s), hours (3600s), and minutes(60s), plus the total seconds elapsed. E.g. a duration of 1483530s is formatted as "17 days, 4 hours, 5 minutes, 30 seconds". Note that the days are always 24 hours regardless of daylight savings changes.
func NewEnumValueRenderer ¶
func NewEnumValueRenderer(fd protoreflect.FieldDescriptor) ValueRenderer
func NewIntValueRenderer ¶
func NewIntValueRenderer(fd protoreflect.FieldDescriptor) ValueRenderer
NewIntValueRenderer returns a ValueRenderer for uint32, uint64, int32 and int64, and sdk.Int scalars.
func NewMessageValueRenderer ¶
func NewMessageValueRenderer(t *SignModeHandler, msgDesc protoreflect.MessageDescriptor) ValueRenderer
func NewStringValueRenderer ¶
func NewStringValueRenderer() ValueRenderer
NewStringValueRenderer returns a ValueRenderer for protocol buffer string values. It renders the string as-is without quotation.
func NewTimestampValueRenderer ¶
func NewTimestampValueRenderer() ValueRenderer
NewTimestampValueRenderer returns a ValueRenderer for protocol buffer Timestamp messages. It renders timestamps using the RFC 3339 format, always using UTC as the timezone. Fractional seconds are only rendered if nonzero.
func NewTxValueRenderer ¶
func NewTxValueRenderer(tr *SignModeHandler) ValueRenderer
NewTxValueRenderer returns a ValueRenderer for the protobuf TextualData type. It follows the specification defined in ADR-050. The reason we create a renderer for TextualData (and not directly Tx) is that TextualData is a single place that contains all data needed to create the `[]Screen` SignDoc.
type ValueRendererCreator ¶
type ValueRendererCreator func(protoreflect.FieldDescriptor) ValueRenderer
ValueRendererCreator is a function returning a textual.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
cbor
Package cbor implements just enough of the CBOR (Concise Binary Object Representation, RFC 8948) to deterministically encode simple data.
|
Package cbor implements just enough of the CBOR (Concise Binary Object Representation, RFC 8948) to deterministically encode simple data. |
textualpb
Package textualpb contains all protobuf definitions and generated codes used internally by Textual.
|
Package textualpb contains all protobuf definitions and generated codes used internally by Textual. |