feat: add ability to create unsigned txs #115
Conversation
d6a48b1
to
d6509c8
Compare
d6509c8
to
746a4ec
Compare
Codecov Report
@@ Coverage Diff @@
## master #115 +/- ##
==========================================
+ Coverage 82.76% 82.79% +0.02%
==========================================
Files 28 28
Lines 2031 2040 +9
Branches 438 444 +6
==========================================
+ Hits 1681 1689 +8
Misses 346 346
- Partials 4 5 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered creating a different builder function for unsigned transactions? i.e. makeSTXTokenTransferUnsigned()
IMO that makes it clearer. For the implementation, it can call makeSTXTokenTransfer()
with a public key.
@yknl, I did just this in my test version by copying the code. In this PR I changed it to doing it within the one function. If you reckon it's a much better API, we can do this, but it won't be as simple change as for |
Yes, if we do this the base function |
Your example code would work, you just need to type cast before the check. E.g. if ((options as SignedTokenTransferOptions).senderKey) {} |
I've got a version of this working in the multi-sig PR: https://github.com/blockstack/stacks-transactions-js/blob/feat/multi-sig-gen/src/builders.ts#L249 @kyranjamie could you take a look? |
Closing out this PR in favour of @reedrosenbluth's |
Related #112
This PR introduces additional options to
makeSTXTokenTransfer()
allowing you to pass public key rather than private, so an unsigned transaction can be created.Wanted to type this in a way the compiler can detect either
senderKey
orpublicKey
, as below, but this approach doesn't work as the compiler throws an error when checking if the prop of the other exists. For now, I've added a runtime exception if both keys are passed.This error follows an
if (options.senderKey) {}