Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Add fromJson and toJson options to HTTP transport #3192

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

lorisleiva
Copy link
Contributor

@lorisleiva lorisleiva commented Sep 2, 2024

This PR adds two new optional functions to the createHttpTransport configs.

  • fromJson: When provided, replaces the logic that transforms the response from a JSON string into a JSON value.
  • toJson: When provided, replaces the logic that transforms the request payload from a JSON value into a JSON string.

This will enable us to wrap this transport and create a new Solana-RPC-specific HTTP transport that do not loose range/precision when bigint values are transmitted over the wire.

Copy link

changeset-bot bot commented Sep 2, 2024

🦋 Changeset detected

Latest commit: ea59901

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lorisleiva lorisleiva marked this pull request as ready for review September 2, 2024 11:36
@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch from 2e132bb to 6d224dd Compare September 2, 2024 15:42
@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch from 6d224dd to 56c4dbc Compare September 2, 2024 15:47
@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch from 56c4dbc to 4430dda Compare September 3, 2024 21:35
@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch from 4430dda to dd8d6b7 Compare September 3, 2024 22:11
@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch from dd8d6b7 to 70bfa6f Compare September 5, 2024 09:21
@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch from 70bfa6f to 3a681f1 Compare September 6, 2024 11:49
Comment on lines 71 to 73
statusCode: response.status,
});
}
if (fromJson) {
return fromJson(await response.text(), { methodName, params }) as TResponse;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[Re: lines +53 to +76]

Commented [here](https://app.graphite.dev/github/pr/solana-labs/solana-web3.js/3186/Make-RPC-transports-responsible-for-preparing-payloads#review-PRR_kwDOCLAddc6IhmFq). I think the base-level transport shouldn't know anything about JavaScript or JSON; it should just accept and return text.

See this comment inline on Graphite.

@lorisleiva lorisleiva force-pushed the loris/rpc-transports-responsible-for-payload-creation branch 2 times, most recently from 23f22d1 to f62ca3a Compare September 10, 2024 07:54
@lorisleiva lorisleiva force-pushed the loris/from-to-json branch 2 times, most recently from 21ecd67 to 44d491d Compare September 10, 2024 08:17
@lorisleiva lorisleiva changed the base branch from loris/rpc-transports-responsible-for-payload-creation to master September 10, 2024 08:17
Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Added via Giphy

Copy link
Contributor Author

lorisleiva commented Sep 11, 2024

Merge activity

@lorisleiva lorisleiva merged commit 422f928 into master Sep 11, 2024
9 checks passed
@lorisleiva lorisleiva deleted the loris/from-to-json branch September 11, 2024 08:12
@github-actions github-actions bot mentioned this pull request Sep 11, 2024
Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants