From c6f9c848be35c6307b077a99ca1f5692b8464b39 Mon Sep 17 00:00:00 2001 From: GitBolt Date: Thu, 3 Oct 2024 15:56:24 +0530 Subject: [PATCH] remove: deprecated methods --- docs/pages/clients/client.mdx | 16 +++------------- docs/pages/clients/client_async.mdx | 15 +++------------ solathon/async_client.py | 15 ++------------- solathon/client.py | 15 ++------------- solathon/core/types/block.py | 5 ++++- 5 files changed, 14 insertions(+), 52 deletions(-) diff --git a/docs/pages/clients/client.mdx b/docs/pages/clients/client.mdx index 189dcb2..0b845df 100644 --- a/docs/pages/clients/client.mdx +++ b/docs/pages/clients/client.mdx @@ -27,7 +27,6 @@ import Callout from 'nextra-theme-docs/callout' - [get_epoch_info](#get_epoch_info) - [get_epoch_schedule](#get_epoch_schedule) - [get_fee_for_message](#get_fee_for_message) -- [get_fees](#get_fees) - [get_first_available_block](#get_first_available_block) - [get_genesis_hash](#get_genesis_hash) - [get_health](#get_health) @@ -42,7 +41,7 @@ import Callout from 'nextra-theme-docs/callout' - [get_minimum_balance_for_rent_exmeption](#get_minimum_balance_for_rent_exmeption) - [get_multiple_accounts](#get_multiple_accounts) - [get_program_accounts](#get_program_accounts) -- [get_recent_blockhash](#get_recent_blockhash) +- [get_latest_blockhash](#get_latest_blockhash) - [get_recent_performance_samples](#get_recent_performance_samples) - [get_signatures_for_address](#get_signatures_for_address) - [get_signature_statuses](#get_signature_statuses) @@ -189,15 +188,6 @@ def get_fee_for_message(message: str)

This method is only available in solana-core v1.9 or newer

-#### .get_fees -Returns a recent block hash from the ledger, a fee schedule that can be used to compute the cost of submitting a transaction using it, and the last slot in which the blockhash will be valid. - - -```python -def get_fees() -``` - - #### .get_first_available_block Returns the slot of the lowest confirmed block that has not been purged from the ledger. @@ -327,12 +317,12 @@ def get_program_accounts() ``` -#### .get_recent_blockhash +#### .get_latest_blockhash Returns a recent block hash from the ledger, and a fee schedule that can be used to compute the cost of submitting a transaction using it. ```python -def get_recent_blockhash() +def get_latest_blockhash() ``` diff --git a/docs/pages/clients/client_async.mdx b/docs/pages/clients/client_async.mdx index c2c6d1b..ded314a 100644 --- a/docs/pages/clients/client_async.mdx +++ b/docs/pages/clients/client_async.mdx @@ -27,7 +27,6 @@ import Callout from 'nextra-theme-docs/callout' - [get_epoch_info](#get_epoch_info) - [get_epoch_schedule](#get_epoch_schedule) - [get_fee_for_message](#get_fee_for_message) -- [get_fees](#get_fees) - [get_first_available_block](#get_first_available_block) - [get_genesis_hash](#get_genesis_hash) - [get_health](#get_health) @@ -42,7 +41,7 @@ import Callout from 'nextra-theme-docs/callout' - [get_minimum_balance_for_rent_exmeption](#get_minimum_balance_for_rent_exmeption) - [get_multiple_accounts](#get_multiple_accounts) - [get_program_accounts](#get_program_accounts) -- [get_recent_blockhash](#get_recent_blockhash) +- [get_latest_blockhash](#get_latest_blockhash) - [get_recent_performance_samples](#get_recent_performance_samples) - [get_supply](#get_supply) - [get_token_accounts_by_owner](#get_token_accounts_by_owner) @@ -188,14 +187,6 @@ async def get_fee_for_message(message: str)

This method is only available in solana-core v1.9 or newer. For now, use get_fees method.

-#### .get_fees -Returns a recent block hash from the ledger, a fee schedule that can be used to compute the cost of submitting a transaction using it, and the last slot in which the blockhash will be valid. - - -```python -async def get_fees() -``` - #### .get_first_available_block Returns the slot of the lowest confirmed block that has not been purged from the ledger. @@ -327,12 +318,12 @@ async def get_program_accounts() ``` -#### .get_recent_blockhash +#### .get_latest_blockhash Returns a recent block hash from the ledger, and a fee schedule that can be used to compute the cost of submitting a transaction using it. ```python -async def get_recent_blockhash() +async def get_latest_blockhash() ``` diff --git a/solathon/async_client.py b/solathon/async_client.py index ab31c11..87eb136 100644 --- a/solathon/async_client.py +++ b/solathon/async_client.py @@ -191,16 +191,6 @@ async def get_fee_for_message(self, message: Text) -> RPCResponse: """ return await self.build_and_send_request_async("getFeeForMessage", [message]) - # Going to be deprecated - async def get_fees(self) -> RPCResponse: - """ - Returns the fees information. - - Returns: - - RPCResponse: The response from the Solana RPC server. - """ - return await self.build_and_send_request_async("getFees", [None]) - async def get_first_available_block(self) -> RPCResponse: """ Returns the first available block. @@ -342,14 +332,13 @@ async def get_program_accounts(self, public_key: PublicKey) -> RPCResponse: """ return await self.build_and_send_request_async("getProgramAccounts", [public_key]) - # Will switch to getFeeForMessage (latest) - async def get_recent_blockhash(self) -> RPCResponse: + async def get_latest_blockhash(self) -> RPCResponse: """ Returns a recent blockhash from the ledger. :return: RPCResponse object containing the recent blockhash. """ - return await self.build_and_send_request_async("getRecentBlockhash", [None]) + return await self.build_and_send_request_async("getLatestBlockhash", [None]) async def get_recent_performance_samples(self) -> RPCResponse: """ diff --git a/solathon/client.py b/solathon/client.py index 002f706..5e63e41 100644 --- a/solathon/client.py +++ b/solathon/client.py @@ -49,7 +49,6 @@ TransactionElementType, ) - ENDPOINTS = ( "https://api.mainnet-beta.solana.com", "https://api.devnet.solana.com", @@ -313,15 +312,6 @@ def get_fee_for_message( return response["value"] return response - # Going to be deprecated - def get_fees(self) -> RPCResponse: - """ - Returns the fees. - - Returns: - RPCResponse: The response from the RPC endpoint. - """ - return self.build_and_send_request("getFees", [None]) def get_first_available_block(self) -> RPCResponse[int] | int: """ @@ -509,8 +499,7 @@ def get_program_accounts( return [ProgramAccount(account) for account in response] return response - # Will switch to getFeeForMessage (latest) - def get_recent_blockhash( + def get_latest_blockhash( self, commitment: Optional[Commitment] = None ) -> RPCResponse[BlockHashType] | BlockHash: """ @@ -523,7 +512,7 @@ def get_recent_blockhash( RPCResponse: The response from the RPC endpoint. """ commitment = validate_commitment(commitment) if commitment else None - response = self.build_and_send_request("getRecentBlockhash", [commitment]) + response = self.build_and_send_request("getLatestBlockhash", [commitment]) if self.clean_response: return BlockHash(response["value"]) return response diff --git a/solathon/core/types/block.py b/solathon/core/types/block.py index f0e1355..72b4996 100644 --- a/solathon/core/types/block.py +++ b/solathon/core/types/block.py @@ -286,7 +286,10 @@ class BlockHash: def __init__(self, response: BlockHashType) -> None: self.blockhash = response['blockhash'] - self.fee_calculator = FeeCalculator(response['feeCalculator']) + if "feeCalculator" in response: + self.fee_calculator = FeeCalculator(response['feeCalculator']) + else: + self.fee_calculator = None def __repr__(self) -> str: return f"BlockHash(blockhash={self.blockhash!r}, fee_calculator={self.fee_calculator!r})"