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

Support batching multiple RPC requests of different types #461

Conversation

franciszekjob
Copy link
Contributor

@franciszekjob franciszekjob commented May 6, 2024

Describe your changes

Add support for batching requests of different type

  • add JsonRpcProvider.batchRequestsAny()
  • add HttpBatchRequest class
  • add StarknetResponse as common return type for JsonRpcProvider calls
  • add IntResponse, StringResponse
  • add inline classes as wrappers for built-in types returned by JsonRpcProvider methods and their corresponding serializers
  • add FeltArraySerializer

Allow proceeding with failure of particular requests while using batchRequests and batchRequestsAny

  • wrap values returned by send() and sendAsync() methods in Result

Update tests:

  • add batch requests any in ProviderTest
  • add rpc provider parses batch response with error in JsonRpcResponseTest
  • update JsonRpcResponseTest due to changes of JsonRpcProvider methods

Linked issues

Closes

Breaking changes

  • This issue contains breaking changes
  • Change returned type in JsonRpcProvider methods:
    • getSpecVersion(): HttpRequest<String> -> getSpecVersion(): HttpRequest<StringResponse>
    • callContract(...): HttpRequest<List<Felt>> -> callContract(...): HttpRequest<FeltArray>
    • getBlockNumber(): HttpRequest<Int> -> getBlockNumber(): HttpRequest<StarknetInt>
    • getBlockTransactionCount(...): HttpRequest<Int> -> getBlockTransactionCount(...): HttpRequest<IntResponse>
    • getEstimateFee(...): HttpRequest<List<EstimateFeeResponse>> -> getEstimateFee(...): HttpRequest<EstimateFeeResponseList>
    • simulateTransactions(...): HttpRequest<List<SimulatedTransaction>> -> simulateTransactions(...): HttpRequest<SimulatedTransactionList>

@franciszekjob franciszekjob changed the title Add batching requests with mixed types Add batching requests of different types May 7, 2024
@franciszekjob franciszekjob changed the title Add batching requests of different types Support batching multiple RPC requests of different types May 7, 2024
Copy link
Member

@THenry14 THenry14 left a comment

Choose a reason for hiding this comment

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

partial review

Comment on lines +5 to +6
import com.swmansion.starknet.data.types.TransactionExecutionStatus
import com.swmansion.starknet.data.types.TransactionStatus
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Transaction.kt and TransactionReceipt.kt files to were moved from types/transactions to types because inheritor of sealed class/interface must be in in the same package where this sealed class/interface is defined. Actually, I moved other files from types/transactions directory to types, because imo it doesn't make sense if transacion-related files are split between directory and subdirectory. Wdyt?

@franciszekjob franciszekjob merged commit 336aa42 into feat/443-batch-multiple-rpc-requests May 23, 2024
2 checks passed
THenry14 added a commit that referenced this pull request May 23, 2024
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.

None yet

4 participants