Open TomKaltz opened 3 months ago
@TomKaltz, you can continue using the v1 package. I made a breaking v2 release to prevent projects from accidentally updating to the new API. I will accept pull requests to the v1 package and continue maintaining it. I'm moving Sia to my startup (it will stay an open-source community project forever; the IP won't be transferred to the startup).
V2 will have a low-level and a high-level API; the high-level API will be similar to v1. The low-level API is meant to be used in scenarios where:
It's also possible to make the low-level API a compiler target, similar to how Protobuf and Cap'n Proto turn schema into code. There will be a massive network of developers and applications that will use Sia, so it'll be well-maintained.
See an example of the new V2 low-level syntax:
In go:
func (s *Signer) Sia() *sia.Sia {
return new(sia.Sia).
AddString8(s.Name).
AddString8(s.EvmWallet).
AddByteArray8(s.PublicKey[:]).
AddByteArray8(s.ShortPublicKey[:])
}
func (s *Signer) DeSia(sia *sia.Sia) *Signer {
s.Name = sia.ReadString8()
s.EvmWallet = sia.ReadString8()
copy(s.PublicKey[:], sia.ReadByteArray8())
copy(s.ShortPublicKey[:], sia.ReadByteArray8())
return s
}
in TypeScript/JavaScript:
// serialize
const byteArray = new Sia()
.addString8(hello.name)
.addString8(hello.evmWallet)
.addByteArray8(hello.publicKey)
.addByteArray8(hello.shortPublicKey)
.content
// deserialize
const sia = new Sia().setContent(byteArray)
const deserialized = {
name: sia.readString8(),
evmWallet: sia.readString8(),
publicKey: sia.readByteArray8(),
shortPublicKey: sia.readByteArray8()
}
I keep this issue open for discussion.
Will the v2 high level api change from the current v1 api?
@TomKaltz, the API will remain similar to v1, but the serialized data won't be compatible with v1.
How is work going on V2?
I have been using this library in a POC I'm building so that I can send complex objects through redis. It has been working great. I just noticed that you changed the README to mention that the library is getting a full re-write. Is there any reason to stop using the current package as-is?