unlock icon indicating copy to clipboard operation
unlock copied to clipboard

Remove @unlock-protocol/types package and move updated type definition to unlock-js

Open searchableguy opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. The unlock types package is outdated. Due to this, we have duplicate types in our apps.

Describe the solution you'd like Remove the package entirely. It is extra maintenance for a single file which overlaps a lot with frequently updated unlockjs. Unlockjs already generates many types so I think it would be good to move the definitions there.

Describe alternatives you've considered Continue to update the type definitions in the type package but I suspect this won't work in the long term as it hasn't so far. If the package isn't directly providing functionality, it is easy to forget to update it.

Many types are needed by external applications as well and we don't publish the type package.

searchableguy avatar May 10 '22 19:05 searchableguy

can we build the package from the unlock-js repo? it is useful to have the unlock types as a package for other things like the hardhat plugin or the contracts package

clemsos avatar May 12 '22 11:05 clemsos

You can import types directly from the unlockjs package.

If you use import type {} from "unlockjs". Then unlockjs won't be bundled. All the types will be stripped after compilation.

Another idea 💡 we could fiddle around is auto generating the types based on contracts and use that whenever applicable. This means types are always in sync with the contract.

searchableguy avatar May 12 '22 11:05 searchableguy

sounds good !

regarding generating the types from the contract, that should be doable using the ABI - already in unlockjs. However the current versions for the actual contract are untyped in unlockjs, so not sure how useful that will be (at least internally). But agree that will be a cool one :)

clemsos avatar May 12 '22 11:05 clemsos

The last bit that would be missing is the paywall config. Since we now use zod, it would be fine, but we don't export from unlock-app (not a package) so we should consider moving the zod stuff to unlockjs and then we can get rid of this package.

julien51 avatar Nov 10 '22 14:11 julien51

Created a core package containing zod definition which we can share with other utilities. Closing this.

searchableguy avatar Feb 27 '23 09:02 searchableguy