Skip to content

Commit

Permalink
remove: deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
GitBolt committed Oct 3, 2024
1 parent 39dd4a9 commit c6f9c84
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 52 deletions.
16 changes: 3 additions & 13 deletions docs/pages/clients/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -189,15 +188,6 @@ def get_fee_for_message(message: str)
<p style={{fontSize:"1rem"}}>This method is only available in solana-core v1.9 or newer</p>
</Callout>

#### .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.

<Code>
```python
def get_fees()
```
</Code>

#### .get_first_available_block
Returns the slot of the lowest confirmed block that has not been purged from the ledger.

Expand Down Expand Up @@ -327,12 +317,12 @@ def get_program_accounts()
```
</Code>

#### .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.

<Code>
```python
def get_recent_blockhash()
def get_latest_blockhash()
```
</Code>

Expand Down
15 changes: 3 additions & 12 deletions docs/pages/clients/client_async.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -188,14 +187,6 @@ async def get_fee_for_message(message: str)
<p style={{fontSize:"1rem"}}>This method is only available in solana-core v1.9 or newer. For now, use get_fees method.</p>
</Callout>

#### .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.

<Code>
```python
async def get_fees()
```
</Code>

#### .get_first_available_block
Returns the slot of the lowest confirmed block that has not been purged from the ledger.
Expand Down Expand Up @@ -327,12 +318,12 @@ async def get_program_accounts()
```
</Code>

#### .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.

<Code>
```python
async def get_recent_blockhash()
async def get_latest_blockhash()
```
</Code>

Expand Down
15 changes: 2 additions & 13 deletions solathon/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
"""
Expand Down
15 changes: 2 additions & 13 deletions solathon/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
TransactionElementType,
)


ENDPOINTS = (
"https://api.mainnet-beta.solana.com",
"https://api.devnet.solana.com",
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion solathon/core/types/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})"

0 comments on commit c6f9c84

Please sign in to comment.