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

Connection.getFeeForMessage() type hints do not consider the null value #29993

Closed
PirosB3 opened this issue Jan 30, 2023 · 0 comments · Fixed by #30004
Closed

Connection.getFeeForMessage() type hints do not consider the null value #29993

PirosB3 opened this issue Jan 30, 2023 · 0 comments · Fixed by #30004
Labels
community Community contribution web3.js Related to the JavaScript client

Comments

@PirosB3
Copy link

PirosB3 commented Jan 30, 2023

Problem

The getFeeForMessage() method on the Connection class can return both a number and null value, which is inconsistent with the types defined in the TypeScript package.

Steps to reproduce:

  • Import and initialize the Connection object from the library
  • Call getFeeForMessage() on a Connection instance, and pass an expired blockhash
  • Observe that both a number and null value can be returned.

Expected outcome: The getFeeForMessage() function should only return a number, as indicated by the types defined in the TypeScript package, or throw an error.
Actual outcome: The function returns both a number and null value, causing unexpected behavior in the code.

Proposed Solution

2 Solutions come to my mind:

  • raise an error if the RPC call returns null - no need to change the types
  • change the return type from RpcResponseAndContext<number> to RpcResponseAndContext<number | null>
@PirosB3 PirosB3 added the community Community contribution label Jan 30, 2023
@PirosB3 PirosB3 changed the title Solana Connection.getFeeForMessage() type hints do not consider the null value Connection.getFeeForMessage() type hints do not consider the null value Jan 30, 2023
@steveluscher steveluscher added the web3.js Related to the JavaScript client label Jan 31, 2023
@mergify mergify bot closed this as completed in #30004 Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution web3.js Related to the JavaScript client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants