-
Notifications
You must be signed in to change notification settings - Fork 88
Feature/lit 3580 refactor js sdk change all enums to constants #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/lit 3580 refactor js sdk change all enums to constants #579
Conversation
…s-sdk-change-all-enums-to-constants-v7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! - Just one tiny suggested change on the comment.
EDITED:
- Awaiting migration guide for these changes, re-review required.
| StytchWhatsAppFactorOtp: 12, | ||
| StytchTotpFactorOtp: 13, | ||
| } as const; | ||
| export type AuthMethodType_TYPE = keyof typeof AuthMethodType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because we want to maintain the original name in camel case AuthMethodType and adding our new naming convention _TYPE and _VALUES like LIT_NETWORK_TYPES?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use this chance to unify all constants naming conventions and expose the previous names as deprecated values so we end up with proper names but breaking as little as possible
…e-all-enums-to-constants-v7 # Conflicts: # packages/auth-helpers/src/lib/recap/utils.ts # packages/auth-helpers/src/lib/resources.ts # packages/constants/src/lib/errors.ts # packages/constants/src/lib/interfaces/i-errors.ts # packages/constants/src/lib/utils/utils.ts # packages/core/src/lib/lit-core.ts # packages/crypto/src/lib/crypto.ts # packages/lit-auth-client/src/lib/providers/AppleProvider.ts # packages/lit-auth-client/src/lib/providers/BaseProvider.ts # packages/lit-auth-client/src/lib/providers/DiscordProvider.ts # packages/lit-auth-client/src/lib/providers/EthWalletProvider.ts # packages/lit-auth-client/src/lib/providers/GoogleProvider.ts # packages/lit-auth-client/src/lib/providers/StytchAuthFactorOtp.ts # packages/lit-auth-client/src/lib/providers/StytchOtpProvider.ts # packages/lit-auth-client/src/lib/providers/WebAuthnProvider.ts # packages/lit-auth-client/src/lib/utils.ts # packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts # packages/misc/src/lib/misc.ts
Description
This PR changes all the enums used around the SDK to literal types and their derived types in order to improve type and values definitions and their imports on other packages
Migration guide
Several enums have been moved or replaced by others in
@lit-protocol/constantsas constant values that behave similarly to enums.They also export types representing their keys and values, with suffixes
_TYPEand_VALUErespectively in order to be able to use them in type-safe manner.For example, the
LitNetworkenum has been replaced byLIT_NETWORKconstant, with the correspondingLIT_NETWORK_TYPESandLIT_NETWORK_VALUEStypes.The following table gives a detail of all the constants changed or removed.
@lit-protocol/auth-browserWALLET_ERROR@lit-protocol/auth-helpersLitAbilityLIT_ABILITYin constants package.@lit-protocol/auth-helpersLitNamespaceLIT_NAMESPACEin constants package.@lit-protocol/auth-helpersLitRecapAbilityLIT_RECAP_ABILITYin constants package.@lit-protocol/auth-helpersLitResourcePrefixLIT_RESOURCE_PREFIXin constants package.@lit-protocol/constantsAuthMethodScopeAUTH_METHOD_SCOPEin constants package.@lit-protocol/constantsAuthMethodTypeAUTH_METHOD_TYPEin constants package.@lit-protocol/constantsCENTRALISATION_BY_NETWORKlocalhostanymore. UseCENTRALISATION_BY_NETWORK.Custominstead.@lit-protocol/constantsEITHER_TYPEEITHER_TYPEin constants package.@lit-protocol/constantsGENERAL_WORKER_URL_BY_NETWORKlocalhostanymore. UseLIT_NETWORKS.Custominstead.@lit-protocol/constantsHTTP_BY_NETWORKlocalhostnorinternalDevanymore. UseHTTP_BY_NETWORK.Custominstead.@lit-protocol/constantsLIT_CURVELIT_CURVEin constants package.@lit-protocol/constantsLIT_ENDPOINT_VERSION@lit-protocol/constantsLIT_NETWORKSlocalhostnorinternalDevanymore. UseLIT_NETWORKS.Custominstead.@lit-protocol/constantsLitErrorKindLIT_ERROR_KINDin constants package.@lit-protocol/constantsLitNetworkLIT_NETWORKin constants package@lit-protocol/constantsMETAMASK_CHAIN_INFO_BY_NETWORKlocalhostanymore. UseMETAMASK_CHAIN_INFO_BY_NETWORK.Custominstead.@lit-protocol/constantsProviderTypePROVIDER_TYPEin constants package.@lit-protocol/constantsRELAYER_URL_BY_NETWORKlocalhostanymore. UseRELAYER_URL_BY_NETWORK.Custominstead.@lit-protocol/constantsRPC_URL_BY_NETWORKlocalhostanymore. UseRPC_URL_BY_NETWORK.Custominstead.@lit-protocol/constantsStakingStatesSTAKING_STATESin constants package.@lit-protocol/constantsVMTYPEVMTYPEin constants package.@lit-protocol/constantsmetamaskChainInfoMETAMASK_CHAIN_INFOin constants package.@lit-protocol/loggerLogLevelLOG_LEVELin constants package.@lit-protocol/typesAuthMethodTypeAUTH_METHOD_TYPEin constants package.@lit-protocol/typesIRelayAuthStatusRELAY_AUTH_STATUSin constants package.@lit-protocol/typesLitAbilityLIT_ABILITYin constants package.@lit-protocol/typesLitResourcePrefixLIT_RESOURCE_PREFIXin constants package.AuthMethodTypeAUTH_METHOD_TYPEin constants package.LIT_RPCRPC_URL_BY_NETWORKin constants package.LIT_TESTNETLIT_NETWORKin constants package.LIT_TESTNET.LOCALCHAINshould be replaced withLIT_NETWORK.CustomRPC_MAPRPC_URL_BY_NETWORKin constants package.Backwards compatibility
The
@lit-protocol/constantspackage does however, also export the new constants under the old names for backwards compatibility and to ease migration.However, it is recommended to use the new constants instead as this will be removed in the future.
Following the example, you can also import the
LitNetworkconstant, which is an alias forLIT_NETWORK.Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: