stacks-archive / stacks-transactions-js

The JavaScript library for generating Stacks 2.0 transactions
19 stars 17 forks source link

Deserialization Refactor #42

Closed reedrosenbluth closed 4 years ago

reedrosenbluth commented 4 years ago

This PR refactors most of the classes in this library to be readonly interfaces with functions for constructing and serializing/deserializing them. This should make deserialization easier/clearer.

I didn't change the Authorization classes as this PR was starting to feel pretty large. I can submit a followup PR with that refactor if deemed necessary, though I think we can probably leave them as is.

I've also mostly left the StacksTransaction class as is, but have made all of the fields non-nullable. I'd be open to breaking this into smaller classes joined by a type union...

Further description here: https://github.com/blockstack/stacks-transactions-js/issues/30

Review by commit.

yknl commented 4 years ago

Can you provide some updated usage descriptions for the new deserialization methods?

The naming of the creator functions seems a bit unclear to me. Could they be more descriptive if we added a prefix? i.e. smartContractPayload()-> makeSmartContractPayload() or createSmartContractPayload()

Looks good otherwise 👍

reedrosenbluth commented 4 years ago

@hstove thanks for taking a look! I've actually made that change locally and was planning on pushing it, along with some README updates, in a bit. Hopefully we can merge this in the next day or two.