Open itegulov opened 2 years ago
@itegulov Do I understand it correctly that NEAR ABI does not need Borsh Schema anymore and we can close this issue? I feel Borsh Schema does not really work well, and we should potentially redesign it.
@frol nope, it does. I mean Borsh Schema is the only format we have that can represent borsh-serializable types. To be fair, Borsh is used much more rarely in contracts' public API from my experience, so I don't know how big of a deal the redesign would be from users' perspective.
what is status for this?
It would be nice to be able to (de)serialize
BorshSchemaContainer
into something human-readable. For some context, we must somehow represent a contract's borsh-serializable types in the ABI schema file. Since this file is in JSON format, we have to serialize borsh schema as JSON, which is doable in a janky way using serde's remote derivation (see https://github.com/near/near-sdk-rs/pull/872). Ideally, this logic should live in this repo, but I also recognize thatborsh
would rather not depend onserde
, so maybe this functionality can be behind an optional featureschema-serde
?As for the
BorshSchemaContainer
's format, I propose we use untaggedFields
and inline all single-fieldedDefinition
variants for the sake of readability while maintaining all other underlying type names (Struct
,Tuple
etc). Borsh schema forstruct Pair(u32, u32)
would look like:See https://github.com/near/near-sdk-rs/pull/872/commits/979b83910d49a8317d58311c5a0fad53294ea557 for more examples.
CC @austinabell