hyperledger-iroha / iroha

Iroha - A simple, enterprise-grade decentralized ledger
https://wiki.hyperledger.org/display/iroha
Apache License 2.0
438 stars 280 forks source link

refactor!: shift from `JsonString` to `JsonValue` #5012

Closed 0x009922 closed 1 month ago

0x009922 commented 2 months ago

Context

JsonString is a type in the schema for arbitrary JSON values. In SCALE it is encoded as a string (hence the name), while in JSON it is inlined as any JSON value.

There are a few issues:

This PR fixes #4900 by disallowing Option<JsonString> and essentially forcing SDKs to handle JSON values as a special case and account for its differences in SCALE vs JSON.

Solution

by these changes:

Migration Guide

There is a breaking change for SDK developers. Apart from JsonString being renamed to JsonValue, it is also no longer an alias to String type, but instead is a special type JsonValue. SDK should treat it as a special case in a way that is suitable for their platform.

Binary and JSON serialisation compatibility is not broken. However, JSON form of ExecuteTrigger instruction and ExecuteTriggerEvent changed: its args field was an Option<JsonString> with ambiguous null value. Now it is Option<JsonValueWrap>, meaning that you need to use it this way:

// Before
{ "args": null }
{ "args": 42 }

// After
{ "args": null }
{ "args": { "value": null } }
{ "args": { "value": 42 } }

Review notes

Checklist

0x009922 commented 1 month ago

Temporarily suspended in favor of #5024