stacks.js icon indicating copy to clipboard operation
stacks.js copied to clipboard

Add missing `undefined` check

Open aryzing opened this issue 1 year ago • 2 comments

What version of Stacks.js are you using?

7.0.3

Describe the bug

Seems the makeUnsignedSTXTokenTransfer builder is missing an undefined check for automatically setting the fee and nonce,

https://github.com/hirosystems/stacks.js/blob/2cf886b6419232dbb54caccf5216b4f42605f3ad/packages/transactions/src/builders.ts#L181-L191

in contrast to,

https://github.com/hirosystems/stacks.js/blob/2cf886b6419232dbb54caccf5216b4f42605f3ad/packages/transactions/src/builders.ts#L388-L398

Expected behavior

All builders should have both null + undef check to when auto-setting fee & nonce

aryzing avatar Nov 21 '24 10:11 aryzing

My bad, didn't realize it was using the == operator instead of ===, which does match undefined to null. Maybe worth using something more explicit?

  • like Leather's isUndefined
  • or something like isNullish (inspired by nullish) to check for either undefined or null?

aryzing avatar Nov 21 '24 10:11 aryzing

Yes thanks for noting there's a few less explicit uses like this. Will add to the refactoring roadmap

janniks avatar Dec 16 '24 16:12 janniks