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

Consolidate poxAddress type

Open friedger opened this issue 2 years ago • 3 comments

Problem

extractPoxAddressFromClarityValue and DelegationInfo define different poxAddress types

Type error like the one below happen when using DelegationInfo and the result of extractPoxAddressFromClarityValue: Type '{ version: number; hashBytes: Uint8Array; } | undefined' is not assignable to type '{ version: Uint8Array; hashbytes: Uint8Array; } | undefined'.

Solution

Define type PoxAddress as { version: number; hashBytes: Uint8Array; } and use it everywhere.

Alternatives

  • write another extractPoxAddressFromClarityValue2 function that returns a different type - that will confuse developers even more
  • define type PoxAddress as { version: Uint8Array; hashbytes: Uint8Array; } - Btc addresses use type number for version, therefore PoxAddress should adopt type number as well. PoXAddressVersion uses number as well.

friedger avatar Jun 20 '23 07:06 friedger

Will do. I wholeheartedly agree 🙏🏻

janniks avatar Jun 20 '23 07:06 janniks

This work is complete. It will be released when we do a next major version release.

smcclellan avatar Jul 25 '23 18:07 smcclellan

@janniks has this been released? if so lets close this issue

andresgalante avatar Oct 24 '23 16:10 andresgalante