@@ -43,6 +43,62 @@ typedef struct cs_format_amount_s {
4343 uint8_t decimals ;
4444} cs_format_amount_t ;
4545
46+ // Format-specific parameters for PARAM_DATETIME. The resolved integer leaf is
47+ // divided by `ticks_per_second` to obtain Unix epoch seconds before formatting.
48+ typedef struct cs_format_datetime_s {
49+ uint32_t ticks_per_second ;
50+ } cs_format_datetime_t ;
51+
52+ // Format-specific parameters for PARAM_UNIT. The resolved integer leaf is scaled
53+ // by `decimals` and rendered with `symbol` placed before (`prefix`) or after it.
54+ #define CS_MAX_UNIT_SYMBOL 12
55+ typedef struct cs_format_unit_s {
56+ char symbol [CS_MAX_UNIT_SYMBOL ];
57+ uint8_t decimals ;
58+ bool prefix ;
59+ } cs_format_unit_t ;
60+
61+ // Text encoding applied to a PARAM_STRING leaf before display.
62+ enum cs_string_encoding {
63+ CS_STRING_ENCODING_ASCII = 0x00 ,
64+ CS_STRING_ENCODING_UTF8 = 0x01 ,
65+ CS_STRING_ENCODING_BASE58 = 0x02 ,
66+ CS_STRING_ENCODING_BASE64 = 0x03 ,
67+ CS_STRING_ENCODING_HEX = 0x04 ,
68+ };
69+
70+ // How a PARAM_STRING slice window is expressed.
71+ enum cs_slice_kind {
72+ CS_SLICE_KIND_BOUNDED = 0x00 , // [start, end)
73+ CS_SLICE_KIND_SIZED = 0x01 , // `size` units from start, or from the tail when reversed
74+ };
75+
76+ // Whether a PARAM_STRING slice operates on the raw source bytes or on the
77+ // post-encoding formatted string.
78+ enum cs_slice_applies_to {
79+ CS_SLICE_APPLIES_TO_FORMATTED = 0x00 ,
80+ CS_SLICE_APPLIES_TO_SOURCE = 0x01 ,
81+ };
82+
83+ // Format-specific parameters for PARAM_STRING. `slice_kind` selects the active
84+ // `slice` arm; `slice_start` is shared by BOUNDED and forward SIZED.
85+ typedef struct cs_format_string_s {
86+ uint8_t encoding ; // enum cs_string_encoding
87+ bool has_slice ;
88+ uint8_t slice_kind ; // enum cs_slice_kind
89+ uint8_t slice_applies_to ; // enum cs_slice_applies_to
90+ uint16_t slice_start ;
91+ union {
92+ struct {
93+ uint16_t end ; // exclusive
94+ } bounded ; // CS_SLICE_KIND_BOUNDED
95+ struct {
96+ uint16_t size ;
97+ bool reversed ; // take the trailing window
98+ } sized ; // CS_SLICE_KIND_SIZED
99+ } slice ;
100+ } cs_format_string_t ;
101+
46102// Where a TOKEN_AMOUNT's ticker/decimals metadata comes from. Exactly one
47103// applies, so contradictory combinations (native carrying a mint reference, a
48104// stale payload behind an absent reference) are unrepresentable. ARGUMENT_PATH
@@ -105,6 +161,9 @@ typedef struct cs_display_field_s {
105161 union {
106162 cs_format_amount_t amount ;
107163 cs_format_token_amount_t token_amount ;
164+ cs_format_datetime_t datetime ;
165+ cs_format_unit_t unit ;
166+ cs_format_string_t string ;
108167 } format ;
109168 } argument ;
110169 struct {
@@ -182,6 +241,21 @@ int cs_instruction_template_set_format_amount(uint8_t decimals);
182241// Returns 0 on success, -1 when no matching field is open.
183242int cs_instruction_template_set_format_token_amount (const cs_format_token_amount_t * format );
184243
244+ // Set DATETIME format parameters on the last added display field.
245+ // Must be called immediately after adding a field with param_type == DATETIME.
246+ // Returns 0 on success, -1 when no matching field is open.
247+ int cs_instruction_template_set_format_datetime (uint32_t ticks_per_second );
248+
249+ // Set UNIT format parameters on the last added display field.
250+ // Must be called immediately after adding a field with param_type == UNIT.
251+ // Returns 0 on success, -1 when no matching field is open.
252+ int cs_instruction_template_set_format_unit (const cs_format_unit_t * format );
253+
254+ // Set STRING format parameters on the last added display field.
255+ // Must be called immediately after adding a field with param_type == STRING.
256+ // Returns 0 on success, -1 when no matching field is open.
257+ int cs_instruction_template_set_format_string (const cs_format_string_t * format );
258+
185259// Set mint association indices on the in-flight builder. Both indices refer to
186260// the instruction's accounts array: `account_idx` is the token account,
187261// `mint_idx` is the mint account whose pubkey identifies the token.
0 commit comments