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

Fix rent epoch type #3719

Open
wants to merge 1 commit into
base: maintenance/v1.x
Choose a base branch
from

Conversation

backmeupplz
Copy link

So, for some reason rpc's return 2 ^ 64 - 1 as rentEpoch. Obviously, this is larger than Number in JS, so I switched the types to bigint and it all works now.

I'm a newby in Solana and have no idea why this works.

See solana-labs/solana-program-library#7635 for the reference.

Copy link

changeset-bot bot commented Jan 7, 2025

⚠️ No Changeset found

Latest commit: 15cbdec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

@mergify mergify bot added the community label Jan 7, 2025
@backmeupplz
Copy link
Author

#3133 is relevant to this discussion too

@backmeupplz
Copy link
Author

I can see that you guys are working on the new version of the package, but when the mainnet RPC returns a bigint for one of the account fields, it breaks everything and you can't even use getOrCreateAssociatedTokenAccount 💀

@backmeupplz
Copy link
Author

Maybe other number checks for rentEpoch should also be changed to bigint though

Copy link
Contributor

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

@backmeupplz good spot. This is because the default value for rentEpoch is now being set to Rust's u64::MAX, as the concept of rent-paying accounts is being phased out.

This change causes actual valid JS numbers to break the struct validation, though. I think what we really want is this:

coerce(bigint(), number(), (value) => BigInt(value))

cc @steveluscher for review and to determine release process. Changing the type is a breaking change afaict, so can we sneak this into the next minor?

@backmeupplz
Copy link
Author

@buffalojoec imo whether it breaks the implementation or not depends on the types of values passed to rentEpoch

from what i've seen it's only ever been an int, so switching it all to bigint might be ok

however, again, this is debatable as the feature is being phased out

the thing that bugs me is that like... am i the first one to notice? 🥲 this literally breaks types in spl-token package making it virtually unusable (as getAccountInfo is broken)... is no one else using it? 😰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants