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

spl-token, did rentEpoch go beyond js Number limits? #7635

Closed
backmeupplz opened this issue Jan 7, 2025 · 8 comments
Closed

spl-token, did rentEpoch go beyond js Number limits? #7635

backmeupplz opened this issue Jan 7, 2025 · 8 comments

Comments

@backmeupplz
Copy link

Hi there! Trying to get an account's balance in USDC on the mainnet. Getting this error:

Error checking deposits on Solana Error: failed to get info about account 7U2h7yfqnZAdZyhT8Ty5V61Jp9L8EhF2p1faGTKRw5K8: StructError: At path: value.rentEpoch -- Expected a number, but received: 18446744073709551615

I feel like there's an issue in serializing the response, and hence the getOrCreateAssociatedTokenAccount operation fails?

Here's the code I use:

const connection = new Connection(env.SOLANA_RPC_URL, 'finalized') // from Alchemy
const treasuryKeypair = Keypair.fromSecretKey(
  base58.decode(env.TREASURY_PRIVATE_KEY_SOLANA)
)
const USDC_SOLANA = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
const SOLANA_USDC_MINT = new PublicKey(USDC_SOLANA)
const depositPubKey = new PublicKey('7U2h7yfqnZAdZyhT8Ty5V61Jp9L8EhF2p1faGTKRw5K8')
const depositATA = await getOrCreateAssociatedTokenAccount(
  connection,
  treasuryKeypair,
  SOLANA_USDC_MINT,
  depositPubKey
)

This exact code has created the ATA (https://solscan.io/tx/2CLKuPkRFDtL7CAd5Qb3oEJ8ZXuHGQN5V8cdC1Ymb2xGUT6Fg2nGmWcXnNsWmqEqtmvjCE51guRswkEiArjoxQUw), and it seems to be getting the account response back, it's just that JS doesn't seem to be able to serialize 18446744073709551615 into a Number? Which would make sense, because it's a bit longer than the max int: 9007199254740991.

Can you recommend any fixes?

@backmeupplz
Copy link
Author

Hm, I can actually see this number mentioned here:

@backmeupplz
Copy link
Author

huh lol it's actually 2^64 - 1, that's why it looked familiar! https://stackoverflow.com/questions/40608111/why-is-18446744073709551615-1-true

@backmeupplz
Copy link
Author

Getting the same error when using https://api.mainnet-beta.solana.com, so it isn't Alchemy

@backmeupplz
Copy link
Author

Oh, this is a usual underflow value (-1), makes sense, now I need to figure out how in the hell I got underflow by trying to get an account lol

@backmeupplz
Copy link
Author

Image

huh, would you look at that, RPC actually does respond with this value for rentEpoch!

@backmeupplz
Copy link
Author

omfg this actually fixed everything:
Image

@SMSDAO
Copy link

SMSDAO commented Jan 9, 2025

Fix it

@buffalojoec
Copy link
Contributor

Hey guys, I'm going to close this issue since we know the fix belongs in @solana/web3.js, therefore we can continue discussion on solana-labs/solana-web3.js#3719. Thanks!

@buffalojoec buffalojoec closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants