fix: use base64 explicitly

This commit is contained in:
smypmsa
2025-04-01 14:57:01 +00:00
parent 1064247e6d
commit c5a0258aa7
9 changed files with 15 additions and 15 deletions
@@ -46,7 +46,7 @@ def get_associated_bonding_curve_address(
async def get_bonding_curve_state(
conn: AsyncClient, curve_address: Pubkey
) -> BondingCurveState:
response = await conn.get_account_info(curve_address)
response = await conn.get_account_info(curve_address, encoding="base64")
if not response.value or not response.value.data:
raise ValueError("Invalid curve state: No data")
+1 -1
View File
@@ -24,7 +24,7 @@ async def close_account_if_exists(client: SolanaClient, wallet: Wallet, account:
"""Safely close a token account if it exists and reclaim rent."""
try:
solana_client = await client.get_client()
info = await solana_client.get_account_info(account)
info = await solana_client.get_account_info(account, encoding="base64") # base64 encoding for account data by deafult
# WARNING: This will permanently burn all tokens in the account before closing it
# Closing account is impossible if balance is positive
+1 -1
View File
@@ -38,7 +38,7 @@ class BondingCurveState:
async def get_bonding_curve_state(
conn: AsyncClient, curve_address: Pubkey
) -> BondingCurveState:
response = await conn.get_account_info(curve_address)
response = await conn.get_account_info(curve_address, encoding="base64")
if not response.value or not response.value.data:
raise ValueError("Invalid curve state: No data")
+1 -1
View File
@@ -39,7 +39,7 @@ async def get_market_address_by_base_mint(base_mint_address: Pubkey, amm_program
async def get_market_data(market_address: Pubkey):
async with AsyncClient(RPC_ENDPOINT) as client:
response = await client.get_account_info_json_parsed(market_address)
response = await client.get_account_info(market_address, encoding="base64")
data = response.value.data
parsed_data = {}
+2 -2
View File
@@ -63,7 +63,7 @@ class BondingCurveState:
async def get_pump_curve_state(
conn: AsyncClient, curve_address: Pubkey
) -> BondingCurveState:
response = await conn.get_account_info(curve_address)
response = await conn.get_account_info(curve_address, encoding="base64")
if not response.value or not response.value.data:
raise ValueError("Invalid curve state: No data")
@@ -109,7 +109,7 @@ async def buy_token(
# Create associated token account with retries
for ata_attempt in range(max_retries):
try:
account_info = await client.get_account_info(associated_token_account)
account_info = await client.get_account_info(associated_token_account, encoding="base64")
if account_info.value is None:
print(
f"Creating associated token account (Attempt {ata_attempt + 1})..."
+1 -1
View File
@@ -59,7 +59,7 @@ class BondingCurveState:
async def get_pump_curve_state(
conn: AsyncClient, curve_address: Pubkey
) -> BondingCurveState:
response = await conn.get_account_info(curve_address)
response = await conn.get_account_info(curve_address, encoding="base64")
if not response.value or not response.value.data:
raise ValueError("Invalid curve state: No data")
+3 -3
View File
@@ -19,7 +19,7 @@ load_dotenv()
# Configuration constants
RPC_ENDPOINT = os.environ.get("SOLANA_NODE_RPC_ENDPOINT")
TOKEN_MINT = Pubkey.from_string("35ySx7Rt3RqeTp75QB81FgRvPT5yDY2m5BupsUYDpump")
TOKEN_MINT = Pubkey.from_string("8XNrSusWrzYpizYXJb5yeB66AWX1cfQ86SBJFqVTpump")
PRIVATE_KEY = base58.b58decode(os.environ.get("SOLANA_PRIVATE_KEY"))
PAYER = Keypair.from_bytes(PRIVATE_KEY)
SLIPPAGE = 0.25 # Slippage tolerance (25%) - the maximum price movement you'll accept
@@ -63,7 +63,7 @@ async def get_market_address_by_base_mint(client: AsyncClient, base_mint_address
response = await client.get_program_accounts(
amm_program_id,
encoding="jsonParsed",
encoding="base64",
filters=filters
)
@@ -82,7 +82,7 @@ async def get_market_data(client: AsyncClient, market_address: Pubkey) -> dict:
Returns:
Dictionary containing the parsed market data
"""
response = await client.get_account_info_json_parsed(market_address)
response = await client.get_account_info(market_address, encoding="base64")
data = response.value.data
parsed_data: dict = {}