Conversation
…le credit cap rejection
|
I've opened this PR to resolve #691 per your specifications:
Ready for review whenever you have time. Thank you |
EmilFattakhov
left a comment
There was a problem hiding this comment.
Thank you for your contribution @yeziR4! A couple of blocking comments that should be relatively easy to address.
| throw new CreditCapExceededError(parsed.message || 'Credit cap exceeded') | ||
| } | ||
|
|
||
| const errorMessage = parsed?.message || body |
There was a problem hiding this comment.
This only covers only covers the coded errors. Auto Drive's HttpError.handleResponse sends { error: <code>, message } when an error carries a machine-readable code, but { error: <the message> } — no message key — for every uncoded one.
| | 'EXPIRED' | ||
| | 'FAILED' | ||
| | 'OVER_CAP' | ||
| 'PENDING' | 'CONFIRMED' | 'COMPLETED' | 'EXPIRED' | 'FAILED' | 'OVER_CAP' |
There was a problem hiding this comment.
Unrelated reformat — please restore the one-member-per-line union.
| @@ -0,0 +1,13 @@ | |||
| /** @type {import('ts-jest').JestConfigWithTsJest} */ | |||
There was a problem hiding this comment.
Deviates from convention, what's this module is used for? Please drop it unless there's a clear reason
|
What would a nice addition: since #691 |
…enum formatting, and drop jest config
|
Thanks for the review @EmilFattakhov! All review comments have been addressed in commit \575ab5eb:
|
Resolves #691
Overview
This PR updates
createPaymentIntentin@autonomys/auto-driveaccording to the specifications in #691:sizeBytes, rejecting non-integers,<= 0,NaN, andInfinitywith a cleanTypeErrorinstead of leaking internalBigInterrors.requestedBytesPayload: UpdatedcreatePaymentIntentto send{ requestedBytes: sizeBytes.toString() }in thePOST /intentsrequest body so server-side credit-cap checks can be performed prior to on-chain payment.CreditCapExceededError): Created and exportedCreditCapExceededError(with code'CREDIT_CAP_EXCEEDED') allowing callers to programmatically catch and branch on over-cap rejections. Parses JSON error response bodies to surface clean error messages rather than raw JSON strings.packages/auto-drive/__test__/payment.test.tscovering validation rules, payload structure, credit cap errors, and general error handling.Verification
yarn workspace @autonomys/auto-drive buildcompiles with 0 errors.packages/auto-drive/__test__/payment.test.ts).