Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] General workflow (common in all borsh implementations) of borsh #83

Open
ailisp opened this issue Aug 4, 2020 · 0 comments

Comments

@ailisp
Copy link
Member

ailisp commented Aug 4, 2020

I propose of a common set of operations that should be implemented by all borsh implementations in different programming languages. Some implementation, like rust has macros, can have additional features such as derive[BorshSerialize]

From borsh user, they're going to use borsh in this way.

  • write a borsh schema definition that would be common in any language, currently it's in json, but json isn't very friendly human writable, so we may consider yaml, toml, or a rust type definition like DSL. They're all equivalent and can trivially convert to each other. This defines type they want to serialize/deserialize.

  • borsh should be able to generate these from schema:

    • language native type definitions (class for python/js, struct for c, golang, rust, solidity)
    • function/methods to serialize and deserialize these types
  • People then use the generated source code.

With this schema based approach, each language's borsh implementation is:

  • (optional) convert between json schema to other format of borsh definition
  • cli to generate source code from schema definition
  • small util functions to deser/ser certain primitive types, strings, vecs, unsigned integers, etc.
  • (for dynamic typed languages) a dynamic version of deser/ser function that takes a schema and a bytes/object, return deserialized object/serialized bytes

@nearmax WDYT? is this how borsh schema suppose to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant