Skip to content
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

Add RequestResult type #478

Merged
merged 8 commits into from
Jun 13, 2024
Merged

Add RequestResult type #478

merged 8 commits into from
Jun 13, 2024

Conversation

franciszekjob
Copy link
Collaborator

@franciszekjob franciszekjob commented May 27, 2024

Describe your changes

  • Add custom type RequestResult which is a wrapper for kotlin's Result

Linked issues

Closes #477

Breaking changes

  • HttpBatchRequest
    • send(): List<Result<T>> -> send(): List<RequestResult<T>>
    • sendAsync(): CompletableFuture<List<Result<T>>> -> sendAsync(): CompletableFuture<List<RequestResult<T>>>
  • This issue contains breaking changes

@franciszekjob franciszekjob changed the title Add custom StarknetResult Add StarknetResult type May 27, 2024
@franciszekjob franciszekjob changed the title Add StarknetResult type Add RequestResult type May 27, 2024
@franciszekjob franciszekjob requested a review from DelevoXDG May 27, 2024 15:23
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 66.66667% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 69.63%. Comparing base (d28b008) to head (2312ff8).
Report is 12 commits behind head on main.

Files Patch % Lines
...com/swmansion/starknet/data/types/RequestResult.kt 50.00% 4 Missing ⚠️
...starknet/provider/rpc/BuildJsonHttpDeserializer.kt 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #478      +/-   ##
==========================================
- Coverage   71.12%   69.63%   -1.49%     
==========================================
  Files          75       89      +14     
  Lines        3338     3385      +47     
  Branches      367      369       +2     
==========================================
- Hits         2374     2357      -17     
- Misses        798      867      +69     
+ Partials      166      161       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@ddoktorski ddoktorski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's wait for final approval from @DelevoXDG

Comment on lines 5 to 8
fun <T> success(value: T): RequestResult<T> = RequestResult(Result.success(value))

fun <T> failure(throwable: Throwable): RequestResult<T> =
RequestResult(Result.failure(throwable))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
fun <T> success(value: T): RequestResult<T> = RequestResult(Result.success(value))
fun <T> failure(throwable: Throwable): RequestResult<T> =
RequestResult(Result.failure(throwable))
fun <T> success(value: T) = RequestResult(Result.success(value))
fun <T> failure(throwable: Throwable) = RequestResult(Result.failure(throwable))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually in failure we have to keep RequestResult<T>, as there is not enough information to infer the type.

@franciszekjob franciszekjob merged commit 4aa9f2a into main Jun 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Result type in batching requests methods
4 participants