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

[experimental] Type the RPC API with bigint at the edge #1205

Merged
merged 3 commits into from
Mar 17, 2023
Merged

Conversation

steveluscher
Copy link
Contributor

@steveluscher steveluscher commented Mar 16, 2023

[experimental] Type the RPC API with bigint at the edge

Summary

The correct thing to do is be to use bigint wherever the Solana JSON RPC specfies u64. This PR endeavours to do that.

Note: This isn't actually safe, Because of an error in the design of the RPC. See #1204 for more information.


Stack created with Sapling. Best reviewed with ReviewStack.

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple of questions

Edit: sorry, I saw this PR first and commented, when the comments should have been on #1204

@steveluscher steveluscher force-pushed the pr1204 branch 2 times, most recently from 1af8ae9 to 2d30d2f Compare March 16, 2023 20:32
## Summary

I want all mocks to restored after each test run, so that no state or implementation bleeds between tests. This is incompatible with `jest-mock-fetch`. The solution is to manually restore the fetch mock for each and every test.

## Test Plan

```
pnpm dev
```
…ed for the Solana JSON RPC

## Summary

`u64` values, in the Solana JSON RPC, are implemented as JavaScript numbers. This means that any number greater than `Number.MAX_SAFE_INTEGER` (9007199254740991) can't be trusted. This is tracked in solana-labs/solana#30741.

In this PR we create a serializer that converts `bigint` values coming in from `@solana/rpc-core` to JavaScript `number`, as a concession.

## Test Plan

```shell
pnpm test:unit:node
```
## Summary

The _correct_ thing to do is be to use `bigint` wherever the Solana JSON RPC specfies `u64`. This PR endeavours to do that.

*Note*: This isn't _actually_ safe, Because of an error in the design of the RPC. See #1204 for more information.
@github-actions
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 Mar 31, 2023
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