feat(ramps-controller): export Transak API error helpers and codes#9135
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Coordination
|
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Link the Transak API error helper changelog entry to #9135 and apply lint:misc import-order formatting for the new ramps-controller files. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Export only getTransakApiMessage and isTransakPhoneRegisteredError for mobile consumers. Drop shared error code constants and generic helpers from the public API and leave TransakService order-retry logic unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview Re-publishing after |
Keep getTransakApiMessage and isTransakPhoneRegisteredError as the only public helpers while sharing ORDER_EXISTS and PHONE_ALREADY_REGISTERED in transakErrorCodes.ts for TransakService and error utils. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@metamaskbot publish-preview After |
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@metamaskbot publish-preview After |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Explanation
Unified Buy v2 (and other
@metamask/ramps-controllerconsumers) need to detect specific Transak API failures fromTransakApiError— for example error code2020when a phone number is already registered to a different email. Today, mobile duplicated string literals and ad-hocinstanceof/ Axios-shaped parsing because ramps-controller only exportedTransakApiErroritself, not reusable helpers or known codes.This PR adds shared Transak error codes and small type guards/helpers so consumers can branch on
errorCodeand readapiMessageconsistently:TRANSAK_ERROR_CODES(ORDER_EXISTS: '4005',PHONE_ALREADY_REGISTERED: '2020') andTransakErrorCodeisTransakApiError,getTransakErrorCode,getTransakApiMessage,isTransakErrorCode,isTransakPhoneRegisteredErrorTransakServicenow usesTRANSAK_ERROR_CODES.ORDER_EXISTSinstead of a private'4005'constant so order-exists retry logic and public exports stay aligned.No breaking changes. Changelog updated under
@metamask/ramps-controllerUnreleased.References
Checklist