Support typed JSON values in transaction metadata#5587
Merged
Conversation
e1ae716 to
3237047
Compare
Replace Map<String, String> with Map<String, JsonValue> so metadata can carry JSON numbers and booleans alongside strings. Iroha rejects gas_limit encoded as a JSON string; the new JsonValue.number() emits a raw JSON number on the wire. Signed-off-by: Dmitry Selivanov <diselivanov@gmail.com>
3237047 to
25635c1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TransactionPayload.metadatawasMap<String, String>. TheMetadataEntryAdapteralways wrapped every value throughencodeJsonString(), producing JSON strings on the wire. Iroha's executor rejects transactions whosegas_limitis a JSON string ("1000") — it requires a JSON number (1000).Changes
JsonValueinline value class (core/model/JsonValue.kt) — wraps a raw JSON literal with factory methods:string()(quotes + escapes),number()(bare digits),bool(),raw()TransactionPayload.metadatatype changed fromMap<String, String>toMap<String, JsonValue>TransactionPayloadAdapter— replacedJsonAdapter/JsonStringAdapterwithJsonValueFieldAdapterthat writesrawJsondirectly throughSTRING_ADAPTER. RemovedencodeJsonString,decodeJsonString,parseJsonString,hexNibble,HEX_DIGITS(all now unused)JsonValue.string()/JsonValue.number()where metadata is constructedWire format
String values produce identical bytes —
JsonValue.string("hello").rawJsonis"hello"(with quotes), same as the oldencodeJsonString("hello"). Number values likeJsonValue.number(1000)emit1000(4 bytes, no quotes) instead of the old"1000"(6 bytes with quotes).Usage