fiatjaf / scoin

simple bitcoin helpers for scala
Apache License 2.0
5 stars 1 forks source link

created Resources trait and associated Resources object. #28

Closed VzxPLnHqr closed 1 year ago

VzxPLnHqr commented 1 year ago

Mnemonics now work on all platforms. Accessing the wordlist resource file was not working in scoinJS or scoinNative before as far as I can tell. All tests now pass on all platforms.

VzxPLnHqr commented 1 year ago

rebased on #29 (which fixes compilation for scala 2.13.8).

VzxPLnHqr commented 1 year ago

I reworked this to be more inline with the naming of objects and files that we currently have. However, I also wanted to demonstrate how to do it in a slightly more general way without breaking existing code:

However, as we refactor things, we can/should consider pulling the functionality offered by the various toplevel objects into their own traits. Using MnemonicCode as an example, it could be rewritten to be:

abstract class MnemonicCode[F[_] : cats.MonadThrow ] {
     // all the methods currently returning a type `A` would be rewritten to return `F[A]`
}

Then an instance for any given Monad can be summoned easily (and/or specialized instances provided too).

Sorry if this is not making a lot of sense yet. Just trying to provide some motivation (but failing to make it clear) that slightly generalizing things in this way gives the end user much more flexibility (while still providing default instances so they can be productive right away).

VzxPLnHqr commented 1 year ago

will re-open and fix if it becomes more of a need/issue