ssz
ssz copied to clipboard
Container Representation [Fields as an Array]
import {ContainerType, ByteVectorType} from "@chainsafe/ssz";
// Creates a "Keypair" SSZ data type (a private key of 32 bytes, a public key of 48 bytes)
const Keypair = new ContainerType({
fields: {
priv: new ByteVectorType({
length: 32,
}),
pub: new ByteVectorType({
length: 48,
}),
},
});
First off, happy holidays.
Second, does the ContainerType have plans to support the fields property as an array. I though properties of containers had to be in specific ordering, and thus an object which is non-deterministic or not always deterministically ordered (see: https://stackoverflow.com/questions/5525795/does-javascript-guarantee-object-property-order) I thought, would not be appropriate.
Wouldn't this be more appropriate?
const Keypair = new ContainerType({
fields: [
{ name: 'priv', value: new ByteVectorType({
length: 32,
}) },
{ name: 'pub', value: new ByteVectorType({
length: 48,
}) },
],
});
I think that all recent engines of Javascript do respect insertion order. Using an object lets you have some nice static typing properties which an object form won't allow. Curious to know other's opinions too
My only concern is, we are assuming this property and on older engines this might not be the case. Might want add some CI testing and engine minimum requirements. Many people still use node10 for example, so it would be good to know the tests pass on node 10.
These things can cause chaos if not tested or at least constrained.
Anyway, just a thought.
On Tue, Dec 29, 2020 at 12:08 PM Lion - dapplion [email protected] wrote:
I think that all recent engines of Javascript do respect insertion order. Using an object lets you have some nice static typing properties which an object form won't allow. Curious to know other's opinions too
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChainSafe/ssz/issues/68#issuecomment-752164143, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACK2CXSGF4UI4TLD3CUYILLSXIEH5ANCNFSM4VKHSQDA .
V8 should respect insertion order on all versions, I haven't found a case where it doesn't