Documentation
¶
Overview ¶
Package values provides helper utilities for working with Canton Ledger API value types.
Index ¶
- Constants
- func ContractID(v *lapiv2.Value) string
- func ContractIDValue(v string) *lapiv2.Value
- func DecodeInstrumentId(v *lapiv2.Value) (admin, id string)
- func DecodeMetadata(v *lapiv2.Value) map[string]string
- func DecodeOptionalMetadata(v *lapiv2.Value) map[string]string
- func DecodeTextMap(v *lapiv2.Value) map[string]string
- func EmptyMetadata() *lapiv2.Value
- func EncodeExtraArgs(choiceContext map[string]string) *lapiv2.Value
- func EncodeInstrumentId(admin, id string) *lapiv2.Value
- func EncodeMetadata(kvs map[string]string) *lapiv2.Value
- func EncodeOptionalMetadata(kvs map[string]string) *lapiv2.Value
- func Int64Value(v int64) *lapiv2.Value
- func IsNone(v *lapiv2.Value) bool
- func ListValue(elements []*lapiv2.Value) *lapiv2.Value
- func MapLookupText(v *lapiv2.Value, key string) string
- func MetaSymbol(v *lapiv2.Value) string
- func MetaSymbolFromRecord(args *lapiv2.Record) string
- func NestedPartyField(v *lapiv2.Value, field string) string
- func NestedPartyFieldOK(v *lapiv2.Value, field string) (string, bool)
- func NestedTextField(v *lapiv2.Value, field string) string
- func NestedTextFieldOK(v *lapiv2.Value, field string) (string, bool)
- func NewtypeText(v *lapiv2.Value) string
- func NewtypeValue(inner *lapiv2.Value) *lapiv2.Value
- func None() *lapiv2.Value
- func Numeric(v *lapiv2.Value) string
- func NumericOK(v *lapiv2.Value) (string, bool)
- func NumericValue(v string) *lapiv2.Value
- func Optional(v *lapiv2.Value) *lapiv2.Value
- func OptionalParty(v *lapiv2.Value) string
- func OptionalRecordFields(v *lapiv2.Value) map[string]*lapiv2.Value
- func OptionalText(v *lapiv2.Value) string
- func Party(v *lapiv2.Value) string
- func PartyList(v *lapiv2.Value) []string
- func PartyOK(v *lapiv2.Value) (string, bool)
- func PartyValue(v string) *lapiv2.Value
- func RecordField(v *lapiv2.Value) map[string]*lapiv2.Value
- func RecordToMap(r *lapiv2.Record) map[string]*lapiv2.Value
- func Text(v *lapiv2.Value) string
- func TextOK(v *lapiv2.Value) (string, bool)
- func TextValue(v string) *lapiv2.Value
- func Timestamp(v *lapiv2.Value) time.Time
- func TimestampOK(v *lapiv2.Value) (time.Time, bool)
- func TimestampValue(t time.Time) *lapiv2.Value
Constants ¶
const MetaKeySymbol = "splice.chainsafe.io/symbol"
Variables ¶
This section is empty.
Functions ¶
func ContractIDValue ¶
ContractIDValue returns a contract ID ledger value.
func DecodeInstrumentId ¶
DecodeInstrumentId extracts admin and id from a Splice InstrumentId record value.
func DecodeMetadata ¶
DecodeMetadata extracts a Splice Metadata { values : TextMap Text } into a Go map.
func DecodeOptionalMetadata ¶
DecodeOptionalMetadata decodes Optional Metadata from Daml. Returns nil for None.
func DecodeTextMap ¶
DecodeTextMap extracts a Daml TextMap Text value into a Go map.
func EmptyMetadata ¶
EmptyMetadata returns an empty Splice Metadata record.
func EncodeExtraArgs ¶
EncodeExtraArgs creates a Splice ExtraArgs { context: ChoiceContext { values: TextMap }, meta: Metadata { values: TextMap } } value. If choiceContext is nil or empty, the context field contains an empty TextMap (default behavior). If choiceContext is populated (e.g., from a Transfer Factory Registry response), its entries are encoded.
func EncodeInstrumentId ¶
EncodeInstrumentId creates a Splice InstrumentId { admin : Party, id : Text } value.
func EncodeMetadata ¶
EncodeMetadata creates a Splice Metadata { values : TextMap Text } value. Keys are sorted for deterministic encoding.
func EncodeOptionalMetadata ¶
EncodeOptionalMetadata encodes Optional Metadata — None if nil/empty, Some if populated.
func MapLookupText ¶
MapLookupText looks up a string key in a DAML Map Text Text value. Handles both TextMap (DA.TextMap) and GenMap (DA.Map) encodings. Returns "" when v is nil, not a map, or the key is absent.
func MetaSymbol ¶
MetaSymbol extracts token symbol from a Splice Metadata value. Splice Metadata is a Record { values : TextMap Text }.
func MetaSymbolFromRecord ¶
MetaSymbolFromRecord extracts the token symbol from a contract's CreateArguments record by finding the "meta" field and decoding its Splice Metadata.
func NestedPartyField ¶
NestedPartyField accesses a Party field within a nested DAML Record value. Use this for fields like instrumentId.admin. Returns "" when v is nil, not a Record, or the field is absent.
func NestedPartyFieldOK ¶
NestedPartyFieldOK accesses a Party field within a nested DAML Record value and reports whether the lookup succeeded with the right type.
func NestedTextField ¶
NestedTextField accesses a Text field within a nested DAML Record value. Use this for fields like instrumentId.id where instrumentId is a Record. Returns "" when v is nil, not a Record, or the field is absent.
func NestedTextFieldOK ¶
NestedTextFieldOK accesses a Text field within a nested DAML Record value and reports whether the lookup succeeded with the right type.
func NewtypeText ¶
NewtypeText extracts the inner Text from a DAML newtype encoded as a single-field Record (e.g. EvmAddress = EvmAddress { value : Text }). The DAML Ledger API v2 returns newtype values as Records in CreatedEvent payloads. Returns "" if v is nil, not a Record, or the first field is not Text.
func NewtypeValue ¶
NewtypeValue encodes a DAML newtype as a single-field Record wrapping the inner value. Use this for types like Common.Types.EvmAddress which are defined as: newtype T = T with field : PrimType. The DAML Ledger API v2 represents newtypes as Records; passing the underlying primitive directly causes COMMAND_PREPROCESSING_FAILED.
The RecordField carries no Label: the Ledger API v2 command-preprocessing path matches newtype fields by position, not by name, so omitting the label is correct and intentional. NewtypeText decodes symmetrically via Fields[0].
func NumericValue ¶
NumericValue returns a numeric ledger value.
func OptionalParty ¶
OptionalParty extracts a Daml Optional Party value. Returns "" for None.
func OptionalRecordFields ¶
OptionalRecordFields extracts the inner Record fields from an Optional(Record) value. Returns nil when v is None or the inner value is not a Record.
func OptionalText ¶
OptionalText extracts a Daml Optional Text value. Returns "" for None.
func RecordField ¶
RecordField extracts a named field from a Record value, returning the sub-map. Returns nil when v is nil or not a Record.
func RecordToMap ¶
RecordToMap converts a Ledger API record into a map keyed by field label. Fields without labels are ignored.
func TimestampOK ¶
TimestampOK extracts a timestamp and reports whether the type matched.
Types ¶
This section is empty.