hirosystems / stacks.js

JavaScript libraries for identity, auth, storage and transactions on the Stacks blockchain.
https://stacks.js.org
MIT License
949 stars 309 forks source link

Rename pox address helpers #1691

Open aryzing opened 4 months ago

aryzing commented 4 months ago

Problem

If I understood correctly, the poxAddressToTuple() and poxAddressToBtcAddress() methods convert a bitcoin pox address b/w the string format and the tupleCV format used by the pox-4 contract.

Going by the name alone, I wouldn't say that's obvious. They also take different amounts of args, not sure if it would make sense for both to default to mainnet?

Solution

Rename the methods and have them accept the same number of args if possible. Since they perform inverse operations, I'd imagine that we could have something like the following

const poxAddress = "bc1...";

poxContractAddressCVToPoxAddress(poxAddressToPoxContractAddressCV(poxAddress)) === poxAddress;

wdyt?

janniks commented 4 months ago

Nice idea!

Right now I'm thinking more in the direction of adding it to the Cl. namespace object. Cl.poxAddressTuple("string") but that would just be an alias to another function, so that should definitely be inverseable 👍 and pull them down from the stacking package into transactions probably.