From 0fec9ddcd0aaa8da09a7e8d17faba32f86988251 Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 10:40:45 -0400 Subject: [PATCH 01/10] Remove unsupported methods, update chain list --- README.md | 80 +--- ankr/advanced_apis.py | 81 ---- ankr/types.py | 950 ++++++++++++------------------------------ 3 files changed, 283 insertions(+), 828 deletions(-) diff --git a/README.md b/README.md index 0243148..04106ad 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Mainnet - Flare: `"flare"` - Gnosis Chain: `"gnosis"` - Scroll: `"scroll"` +- Stellar: `"stellar"` - Linea: `"linea"` - Xai: `"xai"` - Xlayer: `"xlayer"` @@ -118,19 +119,15 @@ Testnet - Ethereum Holesky: `"eth_holesky"` - Avalanche Fuji: `"avalanche_fuji"` - Polygon Amoy: `"polygon_amoy"` -- Optimism Testnet: `"optimism_testnet"` +- Optimism Sepolia: `"optimism_sepolia"` - Base Sepolia: `"base_sepolia"` - -Appchain - -- META Apes: `"bas_metaapes"` +- Neura Devnet `"neura_devnet"` +- Neura Testnet `"neura_testnet_v1"` Appchain Testnet -- META Apes Testnet: `"bas_metaapes_testnet"` -- Neura Devnet `"neura_devnet"` -- Neura Testnet `"neura_testnet_v1"` -- Incentiv Devnet `"incentiv_devnet"` +- Incentiv Devnet `"incentiv_devnet_v3"` +- Incentiv Testnet `"incentiv_testnet"` When passing blockchain, you can use one available from `types.py` (preferred) or just a string value. @@ -141,9 +138,6 @@ When passing blockchain, you can use one available from `types.py` (preferred) o Early Access - [`get_token_price_history`](#gettokenpricehistory--gettokenpricehistoryraw) -- [`get_account_balance_historical`](#getaccountbalancehistorical--getaccountbalancehistoricalraw) -- [`get_internal_transactions_by_block_number`](#getinternaltransactionsbyblocknumber--getinternaltransactionsbyblocknumberraw) -- [`get_internal_transactions_by_parent_hash`](#getinternaltransactionsbyparenthash--getinternaltransactionsbyparenthashraw) Token API @@ -208,68 +202,6 @@ result = advancedAPI.get_token_price_history( print(result) ``` -#### `get_account_balance_historical` / `get_account_balance_historical_raw` - -Get the coin and token balances of the wallet at specified block. - -```python3 -from ankr import AnkrAdvancedAPI -from ankr.types import Blockchain, GetAccountBalanceHistoricalRequest - -advancedAPI = AnkrAdvancedAPI("YOUR-TOKEN") - -result = advancedAPI.get_account_balance_historical( - request=GetAccountBalanceHistoricalRequest( - blockchain=Blockchain.Eth, - walletAddress='vitalik.eth', - onlyWhitelisted=False, - blockHeight=17967813, - ) -) -print(result) -``` - -#### `get_internal_transactions_by_block_number` / `get_internal_transactions_by_block_number_raw` - -Get a list of internal transactions in the block. - -```python3 -from ankr import AnkrAdvancedAPI -from ankr.types import Blockchain, GetInternalTransactionsByBlockNumberRequest - -advancedAPI = AnkrAdvancedAPI("YOUR-TOKEN") - -result = advancedAPI.get_internal_transactions_by_block_number( - request=GetInternalTransactionsByBlockNumberRequest( - blockchain=Blockchain.Eth, - blockNumber=10000000, - onlyWithValue=True, - ) -) -for transaction in result: - print(transaction) -``` - -#### `get_internal_transactions_by_parent_hash` / `get_internal_transactions_by_parent_hash_raw` - -Get a list of internal transactions in the transaction. - -```python3 -from ankr import AnkrAdvancedAPI -from ankr.types import Blockchain, GetInternalTransactionsByParentHashRequest - -advancedAPI = AnkrAdvancedAPI("YOUR-TOKEN") - -result = advancedAPI.get_internal_transactions_by_parent_hash( - request=GetInternalTransactionsByParentHashRequest( - blockchain=Blockchain.Eth, - parentTransactionHash='0xa50f8744e65cb76f66f9d54499d5401866a75d93db2e784952f55205afc3acc5', - onlyWithValue=True, - ) -) -for transaction in result: - print(transaction) -``` ### Token API diff --git a/ankr/advanced_apis.py b/ankr/advanced_apis.py index d08d388..5751917 100644 --- a/ankr/advanced_apis.py +++ b/ankr/advanced_apis.py @@ -44,87 +44,6 @@ def get_token_price_history_raw( return reply - def get_account_balance_historical( - self, - request: types.GetAccountBalanceHistoricalRequest, - limit: Optional[int] = None, - ) -> Iterable[types.Balance]: - for asset in self.provider.call_method_paginated( - rpc="ankr_getAccountBalanceHistorical", - request=request, - reply=types.GetAccountBalanceHistoricalReply, - iterable_name="assets", - iterable_type=types.Balance, - limit=limit, - ): - yield asset - - def get_account_balance_historical_raw( - self, - request: types.GetAccountBalanceHistoricalRequest, - ) -> types.GetAccountBalanceHistoricalReply: - reply = self.provider.call_method( - rpc="ankr_getAccountBalanceHistorical", - request=request, - reply=types.GetAccountBalanceReply, - ) - - return reply - - def get_internal_transactions_by_block_number( - self, - request: types.GetInternalTransactionsByBlockNumberRequest, - limit: Optional[int] = None, - ) -> Iterable[types.InternalTransaction]: - for asset in self.provider.call_method_paginated( - rpc="ankr_getInternalTransactionsByBlockNumber", - request=request, - reply=types.GetInternalTransactionsReply, - iterable_name="internalTransactions", - iterable_type=types.InternalTransaction, - limit=limit, - ): - yield asset - - def get_internal_transactions_by_block_number_raw( - self, - request: types.GetInternalTransactionsByBlockNumberRequest, - ) -> types.GetInternalTransactionsReply: - reply = self.provider.call_method( - rpc="ankr_getInternalTransactionsByBlockNumber", - request=request, - reply=types.GetInternalTransactionsReply, - ) - - return reply - - def get_internal_transactions_by_parent_hash( - self, - request: types.GetInternalTransactionsByParentHashRequest, - limit: Optional[int] = None, - ) -> Iterable[types.InternalTransaction]: - for asset in self.provider.call_method_paginated( - rpc="ankr_getInternalTransactionsByParentHash", - request=request, - reply=types.GetInternalTransactionsReply, - iterable_name="internalTransactions", - iterable_type=types.InternalTransaction, - limit=limit, - ): - yield asset - - def get_internal_transactions_by_parent_hash_raw( - self, - request: types.GetInternalTransactionsByBlockNumberRequest, - ) -> types.GetInternalTransactionsReply: - reply = self.provider.call_method( - rpc="ankr_getInternalTransactionsByParentHash", - request=request, - reply=types.GetInternalTransactionsReply, - ) - - return reply - class AnkrQueryAPI(AnkrMultichainAPI): def get_logs( diff --git a/ankr/types.py b/ankr/types.py index b20d0a2..3478f8d 100644 --- a/ankr/types.py +++ b/ankr/types.py @@ -1,10 +1,10 @@ # THIS FILE IS AUTOGENERATED # TO FIX ISSUE RELATED TO THIS FILE -# PLEASE FILE AN ISSUE ON https://github.com/Ankr-network/ankr-python-sdk/issues +# PLEASE FILE AN ISSUE ON https://github.com/Asphere-xyz/ankr-python-sdk/issues from __future__ import annotations from enum import Enum -from typing import Literal, List, Dict +from typing import Literal, Any, List, Dict class SyncStatus: @@ -22,330 +22,20 @@ def from_dict(cls, **data): ) -class MethodInput: - def __init__(self, name: str, size: float, type: str, valueDecoded: str): - self.name = name - self.size = size - self.type = type - self.valueDecoded = valueDecoded - - @classmethod - def from_dict(cls, **data): - return cls( - name=data.get("name"), - size=data.get("size"), - type=data.get("type"), - valueDecoded=data.get("valueDecoded"), - ) - - -class Method: - def __init__( - self, - id: str, - inputs: List[MethodInput], - name: str, - signature: str, - string: str, - verified: bool, - ): - self.id = id - self.inputs = inputs - self.name = name - self.signature = signature - self.string = string - self.verified = verified - - @classmethod - def from_dict(cls, **data): - return cls( - id=data.get("id"), - inputs=[ - MethodInput.from_dict(**methodinput_data) - for methodinput_data in data.get("inputs", []) - ], - name=data.get("name"), - signature=data.get("signature"), - string=data.get("string"), - verified=data.get("verified"), - ) - - -class EventInput: - def __init__( - self, indexed: bool, name: str, size: float, type: str, valueDecoded: str - ): - self.indexed = indexed - self.name = name - self.size = size - self.type = type - self.valueDecoded = valueDecoded - - @classmethod - def from_dict(cls, **data): - return cls( - indexed=data.get("indexed"), - name=data.get("name"), - size=data.get("size"), - type=data.get("type"), - valueDecoded=data.get("valueDecoded"), - ) - - -class Event: - def __init__( - self, - anonymous: bool, - id: str, - inputs: List[EventInput], - name: str, - signature: str, - string: str, - verified: bool, - ): - self.anonymous = anonymous - self.id = id - self.inputs = inputs - self.name = name - self.signature = signature - self.string = string - self.verified = verified - - @classmethod - def from_dict(cls, **data): - return cls( - anonymous=data.get("anonymous"), - id=data.get("id"), - inputs=[ - EventInput.from_dict(**eventinput_data) - for eventinput_data in data.get("inputs", []) - ], - name=data.get("name"), - signature=data.get("signature"), - string=data.get("string"), - verified=data.get("verified"), - ) - - -class Log: - def __init__( - self, - address: str, - blockHash: str, - blockNumber: str, - blockchain: Blockchain, - data: str, - logIndex: str, - removed: bool, - topics: List[str], - transactionHash: str, - transactionIndex: str, - event: Event = None, - ): - self.address = address - self.blockHash = blockHash - self.blockNumber = blockNumber - self.blockchain = blockchain - self.data = data - self.logIndex = logIndex - self.removed = removed - self.topics = topics - self.transactionHash = transactionHash - self.transactionIndex = transactionIndex - self.event = event - - @classmethod - def from_dict(cls, **data): - return cls( - address=data.get("address"), - blockHash=data.get("blockHash"), - blockNumber=data.get("blockNumber"), - blockchain=Blockchain(data.get("blockchain")), - data=data.get("data"), - logIndex=data.get("logIndex"), - removed=data.get("removed"), - topics=data.get("topics"), - transactionHash=data.get("transactionHash"), - transactionIndex=data.get("transactionIndex"), - event=Event.from_dict(**data.get("event")) - if data.get("event") is not None - else None, - ) - - -class Transaction: - def __init__( - self, - blockHash: str, - blockNumber: str, - from_: str, - transactionIndex: str, - value: str, - gasPrice: str = None, - gas: str = None, - contractAddress: str = None, - cumulativeGasUsed: str = None, - input: str = None, - v: str = None, - r: str = None, - s: str = None, - method: Method = None, - to: str = None, - nonce: str = None, - gasUsed: str = None, - logs: List[Log] = None, - hash: str = None, - status: str = None, - blockchain: str = None, - timestamp: str = None, - type: str = None, - ): - self.blockHash = blockHash - self.blockNumber = blockNumber - self.from_ = from_ - self.transactionIndex = transactionIndex - self.value = value - self.gasPrice = gasPrice - self.gas = gas - self.contractAddress = contractAddress - self.cumulativeGasUsed = cumulativeGasUsed - self.input = input - self.v = v - self.r = r - self.s = s - self.method = method - self.to = to - self.nonce = nonce - self.gasUsed = gasUsed - self.logs = logs - self.hash = hash - self.status = status - self.blockchain = blockchain - self.timestamp = timestamp - self.type = type - - @classmethod - def from_dict(cls, **data): - return cls( - blockHash=data.get("blockHash"), - blockNumber=data.get("blockNumber"), - from_=data.get("from"), - transactionIndex=data.get("transactionIndex"), - value=data.get("value"), - gasPrice=data.get("gasPrice"), - gas=data.get("gas"), - contractAddress=data.get("contractAddress"), - cumulativeGasUsed=data.get("cumulativeGasUsed"), - input=data.get("input"), - v=data.get("v"), - r=data.get("r"), - s=data.get("s"), - method=Method.from_dict(**data.get("method")) - if data.get("method") is not None - else None, - to=data.get("to"), - nonce=data.get("nonce"), - gasUsed=data.get("gasUsed"), - logs=[Log.from_dict(**log_data) for log_data in data.get("logs", [])], - hash=data.get("hash"), - status=data.get("status"), - blockchain=data.get("blockchain"), - timestamp=data.get("timestamp"), - type=data.get("type"), - ) - - -class Block: - def __init__( - self, - difficulty: str, - extraData: str, - gasLimit: str, - gasUsed: str, - hash: str, - logsBloom: str, - miner: str, - mixHash: str, - nonce: str, - number: str, - parentHash: str, - receiptsRoot: str, - sha3Uncles: str, - size: str, - stateRoot: str, - timestamp: str, - totalDifficulty: str, - transactions: List[Transaction], - transactionsRoot: str, - uncles: List[str], - blockchain: str = None, - ): - self.difficulty = difficulty - self.extraData = extraData - self.gasLimit = gasLimit - self.gasUsed = gasUsed - self.hash = hash - self.logsBloom = logsBloom - self.miner = miner - self.mixHash = mixHash - self.nonce = nonce - self.number = number - self.parentHash = parentHash - self.receiptsRoot = receiptsRoot - self.sha3Uncles = sha3Uncles - self.size = size - self.stateRoot = stateRoot - self.timestamp = timestamp - self.totalDifficulty = totalDifficulty - self.transactions = transactions - self.transactionsRoot = transactionsRoot - self.uncles = uncles - self.blockchain = blockchain - - @classmethod - def from_dict(cls, **data): - return cls( - difficulty=data.get("difficulty"), - extraData=data.get("extraData"), - gasLimit=data.get("gasLimit"), - gasUsed=data.get("gasUsed"), - hash=data.get("hash"), - logsBloom=data.get("logsBloom"), - miner=data.get("miner"), - mixHash=data.get("mixHash"), - nonce=data.get("nonce"), - number=data.get("number"), - parentHash=data.get("parentHash"), - receiptsRoot=data.get("receiptsRoot"), - sha3Uncles=data.get("sha3Uncles"), - size=data.get("size"), - stateRoot=data.get("stateRoot"), - timestamp=data.get("timestamp"), - totalDifficulty=data.get("totalDifficulty"), - transactions=[ - Transaction.from_dict(**transaction_data) - for transaction_data in data.get("transactions", []) - ], - transactionsRoot=data.get("transactionsRoot"), - uncles=data.get("uncles"), - blockchain=data.get("blockchain"), - ) - - class GetBlocksReply: - def __init__(self, blocks: List[Block], syncStatus: SyncStatus = None): + def __init__(self, blocks: List[Any], syncStatus: SyncStatus = None): self.blocks = blocks self.syncStatus = syncStatus @classmethod def from_dict(cls, **data): return cls( - blocks=[ - Block.from_dict(**block_data) for block_data in data.get("blocks", []) - ], - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + blocks=[Any.from_dict(**any_data) for any_data in data.get("blocks", [])], + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -353,12 +43,12 @@ class GetBlocksRequest: def __init__( self, blockchain: Blockchain, - fromBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, + fromBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, descOrder: bool = None, includeLogs: bool = None, includeTxs: bool = None, @@ -402,7 +92,7 @@ def to_dict(self): class GetTransactionsByHashReply: - def __init__(self, transactions: List[Transaction], syncStatus: SyncStatus = None): + def __init__(self, transactions: List[Any], syncStatus: SyncStatus = None): self.transactions = transactions self.syncStatus = syncStatus @@ -410,12 +100,13 @@ def __init__(self, transactions: List[Transaction], syncStatus: SyncStatus = Non def from_dict(cls, **data): return cls( transactions=[ - Transaction.from_dict(**transaction_data) - for transaction_data in data.get("transactions", []) + Any.from_dict(**any_data) for any_data in data.get("transactions", []) ], - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -460,10 +151,7 @@ def to_dict(self): class GetTransactionsByAddressReply: def __init__( - self, - nextPageToken: str, - transactions: List[Transaction], - syncStatus: SyncStatus = None, + self, nextPageToken: str, transactions: List[Any], syncStatus: SyncStatus = None ): self.nextPageToken = nextPageToken self.transactions = transactions @@ -474,12 +162,13 @@ def from_dict(cls, **data): return cls( nextPageToken=data.get("nextPageToken"), transactions=[ - Transaction.from_dict(**transaction_data) - for transaction_data in data.get("transactions", []) + Any.from_dict(**any_data) for any_data in data.get("transactions", []) ], - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -488,18 +177,18 @@ def __init__( self, address: List[str], blockchain: Blockchain | List[Blockchain], - fromBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - fromTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, + fromBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + fromTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, pageToken: str = None, pageSize: float = None, descOrder: bool = None, @@ -545,6 +234,113 @@ def to_dict(self): } +class EventInput: + def __init__( + self, indexed: bool, name: str, size: float, type: str, valueDecoded: str + ): + self.indexed = indexed + self.name = name + self.size = size + self.type = type + self.valueDecoded = valueDecoded + + @classmethod + def from_dict(cls, **data): + return cls( + indexed=data.get("indexed"), + name=data.get("name"), + size=data.get("size"), + type=data.get("type"), + valueDecoded=data.get("valueDecoded"), + ) + + +class Event: + def __init__( + self, + anonymous: bool, + id: str, + inputs: List[EventInput], + name: str, + signature: str, + string: str, + verified: bool, + ): + self.anonymous = anonymous + self.id = id + self.inputs = inputs + self.name = name + self.signature = signature + self.string = string + self.verified = verified + + @classmethod + def from_dict(cls, **data): + return cls( + anonymous=data.get("anonymous"), + id=data.get("id"), + inputs=[ + EventInput.from_dict(**eventinput_data) + for eventinput_data in data.get("inputs", []) + ], + name=data.get("name"), + signature=data.get("signature"), + string=data.get("string"), + verified=data.get("verified"), + ) + + +class Log: + def __init__( + self, + address: str, + blockHash: str, + blockNumber: str, + blockchain: Blockchain, + data: str, + logIndex: str, + removed: bool, + topics: List[str], + transactionHash: str, + transactionIndex: str, + event: Event = None, + timestamp: str = None, + ): + self.address = address + self.blockHash = blockHash + self.blockNumber = blockNumber + self.blockchain = blockchain + self.data = data + self.logIndex = logIndex + self.removed = removed + self.topics = topics + self.transactionHash = transactionHash + self.transactionIndex = transactionIndex + self.event = event + self.timestamp = timestamp + + @classmethod + def from_dict(cls, **data): + return cls( + address=data.get("address"), + blockHash=data.get("blockHash"), + blockNumber=data.get("blockNumber"), + blockchain=Blockchain(data.get("blockchain")), + data=data.get("data"), + logIndex=data.get("logIndex"), + removed=data.get("removed"), + topics=data.get("topics"), + transactionHash=data.get("transactionHash"), + transactionIndex=data.get("transactionIndex"), + event=( + Event.from_dict(**data.get("event")) + if data.get("event") is not None + else None + ), + timestamp=data.get("timestamp"), + ) + + class GetLogsReply: def __init__( self, logs: List[Log], nextPageToken: str = None, syncStatus: SyncStatus = None @@ -558,9 +354,11 @@ def from_dict(cls, **data): return cls( logs=[Log.from_dict(**log_data) for log_data in data.get("logs", [])], nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -568,18 +366,18 @@ class GetLogsRequest: def __init__( self, blockchain: Blockchain | List[Blockchain], - fromBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - fromTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, + fromBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + fromTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, address: List[str] = None, topics: List[str | List[str]] = None, pageToken: str = None, @@ -670,9 +468,11 @@ def from_dict(cls, **data): BlockchainStats.from_dict(**blockchainstats_data) for blockchainstats_data in data.get("stats", []) ], - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -710,9 +510,11 @@ def __init__(self, blockchains: List[str], syncStatus: SyncStatus = None): def from_dict(cls, **data): return cls( blockchains=data.get("blockchains"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -800,9 +602,11 @@ def from_dict(cls, **data): totalBalanceUsd=data.get("totalBalanceUsd"), totalCount=data.get("totalCount"), nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -867,9 +671,11 @@ def from_dict(cls, **data): blockchain=Blockchain(data.get("blockchain")), usdPrice=data.get("usdPrice"), contractAddress=data.get("contractAddress"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -949,9 +755,11 @@ def from_dict(cls, **data): holdersCount=data.get("holdersCount"), nextPageToken=data.get("nextPageToken"), tokenDecimals=data.get("tokenDecimals"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1045,9 +853,11 @@ def from_dict(cls, **data): latestHoldersCount=data.get("latestHoldersCount"), nextPageToken=data.get("nextPageToken"), tokenDecimals=data.get("tokenDecimals"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1130,9 +940,11 @@ def from_dict(cls, **data): CurrencyDetailsExtended.from_dict(**currencydetailsextended_data) for currencydetailsextended_data in data.get("currencies", []) ], - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1231,9 +1043,11 @@ def from_dict(cls, **data): for tokentransfer_data in data.get("transfers", []) ], nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1241,18 +1055,18 @@ class GetTransfersRequest: def __init__( self, blockchain: Blockchain | List[Blockchain], - fromBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toBlock: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - fromTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, + fromBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toBlock: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + fromTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, address: List[str] = None, pageToken: str = None, pageSize: float = None, @@ -1376,9 +1190,11 @@ def from_dict(cls, **data): assets=[Nft.from_dict(**nft_data) for nft_data in data.get("assets", [])], nextPageToken=data.get("nextPageToken"), owner=data.get("owner"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1499,15 +1315,21 @@ def __init__( @classmethod def from_dict(cls, **data): return cls( - metadata=NftMetadata.from_dict(**data.get("metadata")) - if data.get("metadata") is not None - else None, - attributes=NftAttributes.from_dict(**data.get("attributes")) - if data.get("attributes") is not None - else None, - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + metadata=( + NftMetadata.from_dict(**data.get("metadata")) + if data.get("metadata") is not None + else None + ), + attributes=( + NftAttributes.from_dict(**data.get("attributes")) + if data.get("attributes") is not None + else None + ), + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1560,9 +1382,11 @@ def from_dict(cls, **data): return cls( holders=data.get("holders"), nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1674,9 +1498,11 @@ def from_dict(cls, **data): for nfttransfer_data in data.get("transfers", []) ], nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1759,9 +1585,11 @@ def from_dict(cls, **data): tokenName=data.get("tokenName"), tokenSymbol=data.get("tokenSymbol"), spenderAddress=data.get("spenderAddress"), - rawLog=Log.from_dict(**data.get("rawLog")) - if data.get("rawLog") is not None - else None, + rawLog=( + Log.from_dict(**data.get("rawLog")) + if data.get("rawLog") is not None + else None + ), ) @@ -1784,12 +1612,12 @@ def __init__( self, blockchain: Blockchain, contractAddress: str, - fromTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - toTimestamp: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, + fromTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, + toTimestamp: ( + float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] + ) = None, interval: float = None, limit: float = None, syncCheck: bool = None, @@ -1851,9 +1679,11 @@ def from_dict(cls, **data): quotes=[ Quote.from_dict(**quote_data) for quote_data in data.get("quotes", []) ], - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, + syncStatus=( + SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None + ), ) @@ -1973,12 +1803,16 @@ def from_dict(cls, **data): PriceEstimate.from_dict(**priceestimate_data) for priceestimate_data in data.get("priceEstimates", []) ], - token0=ExplainTokenPriceTokenDetails.from_dict(**data.get("token0")) - if data.get("token0") is not None - else None, - token1=ExplainTokenPriceTokenDetails.from_dict(**data.get("token1")) - if data.get("token1") is not None - else None, + token0=( + ExplainTokenPriceTokenDetails.from_dict(**data.get("token0")) + if data.get("token0") is not None + else None + ), + token1=( + ExplainTokenPriceTokenDetails.from_dict(**data.get("token1")) + if data.get("token1") is not None + else None + ), ) @@ -2013,238 +1847,6 @@ def from_dict(cls, **data): ) -class GetInternalTransactionsByParentHashRequest: - def __init__( - self, - blockchain: Blockchain, - onlyWithValue: bool, - parentTransactionHash: str, - syncCheck: bool = None, - ): - self.blockchain = blockchain - self.onlyWithValue = onlyWithValue - self.parentTransactionHash = parentTransactionHash - self.syncCheck = syncCheck - - def to_dict(self): - if isinstance(self.blockchain, str): - blockchain_value = self.blockchain - elif isinstance(self.blockchain, list): - blockchain_value = [ - block.value if isinstance(block, Blockchain) else block - for block in self.blockchain - ] - elif self.blockchain is not None: - blockchain_value = self.blockchain.value - else: - blockchain_value = None - return { - "blockchain": blockchain_value, - "onlyWithValue": self.onlyWithValue, - "parentTransactionHash": self.parentTransactionHash, - "syncCheck": self.syncCheck, - } - - -class GetInternalTransactionsByBlockNumberRequest: - def __init__( - self, - blockNumber: float, - blockchain: Blockchain, - onlyWithValue: bool, - syncCheck: bool = None, - ): - self.blockNumber = blockNumber - self.blockchain = blockchain - self.onlyWithValue = onlyWithValue - self.syncCheck = syncCheck - - def to_dict(self): - if isinstance(self.blockchain, str): - blockchain_value = self.blockchain - elif isinstance(self.blockchain, list): - blockchain_value = [ - block.value if isinstance(block, Blockchain) else block - for block in self.blockchain - ] - elif self.blockchain is not None: - blockchain_value = self.blockchain.value - else: - blockchain_value = None - return { - "blockNumber": self.blockNumber, - "blockchain": blockchain_value, - "onlyWithValue": self.onlyWithValue, - "syncCheck": self.syncCheck, - } - - -class InternalTransaction: - def __init__( - self, - blockHash: str, - blockHeight: float, - blockchain: Blockchain, - callType: str, - fromAddress: str, - gas: float, - gasUsed: float, - input: str, - output: str, - timestamp: str, - toAddress: str, - transactionHash: str, - transactionIndex: float, - value: str, - callPath: str = None, - callStack: List[float] = None, - error: str = None, - contractAddress: str = None, - ): - self.blockHash = blockHash - self.blockHeight = blockHeight - self.blockchain = blockchain - self.callType = callType - self.fromAddress = fromAddress - self.gas = gas - self.gasUsed = gasUsed - self.input = input - self.output = output - self.timestamp = timestamp - self.toAddress = toAddress - self.transactionHash = transactionHash - self.transactionIndex = transactionIndex - self.value = value - self.callPath = callPath - self.callStack = callStack - self.error = error - self.contractAddress = contractAddress - - @classmethod - def from_dict(cls, **data): - return cls( - blockHash=data.get("blockHash"), - blockHeight=data.get("blockHeight"), - blockchain=Blockchain(data.get("blockchain")), - callType=data.get("callType"), - fromAddress=data.get("fromAddress"), - gas=data.get("gas"), - gasUsed=data.get("gasUsed"), - input=data.get("input"), - output=data.get("output"), - timestamp=data.get("timestamp"), - toAddress=data.get("toAddress"), - transactionHash=data.get("transactionHash"), - transactionIndex=data.get("transactionIndex"), - value=data.get("value"), - callPath=data.get("callPath"), - callStack=data.get("callStack"), - error=data.get("error"), - contractAddress=data.get("contractAddress"), - ) - - -class GetInternalTransactionsReply: - def __init__( - self, internalTransactions: List[InternalTransaction], nextPageToken: str = None - ): - self.internalTransactions = internalTransactions - self.nextPageToken = nextPageToken - - @classmethod - def from_dict(cls, **data): - return cls( - internalTransactions=[ - InternalTransaction.from_dict(**internaltransaction_data) - for internaltransaction_data in data.get("internalTransactions", []) - ], - nextPageToken=data.get("nextPageToken"), - ) - - -class GetAccountBalanceHistoricalRequest: - def __init__( - self, - walletAddress: str, - blockchain: Blockchain | List[Blockchain] = None, - onlyWhitelisted: bool = None, - nativeFirst: bool = None, - pageToken: str = None, - pageSize: float = None, - blockHeight: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - syncCheck: bool = None, - ): - self.walletAddress = walletAddress - self.blockchain = blockchain - self.onlyWhitelisted = onlyWhitelisted - self.nativeFirst = nativeFirst - self.pageToken = pageToken - self.pageSize = pageSize - self.blockHeight = blockHeight - self.syncCheck = syncCheck - - def to_dict(self): - if isinstance(self.blockchain, str): - blockchain_value = self.blockchain - elif isinstance(self.blockchain, list): - blockchain_value = [ - block.value if isinstance(block, Blockchain) else block - for block in self.blockchain - ] - elif self.blockchain is not None: - blockchain_value = self.blockchain.value - else: - blockchain_value = None - return { - "walletAddress": self.walletAddress, - "blockchain": blockchain_value, - "onlyWhitelisted": self.onlyWhitelisted, - "nativeFirst": self.nativeFirst, - "pageToken": self.pageToken, - "pageSize": self.pageSize, - "blockHeight": self.blockHeight, - "syncCheck": self.syncCheck, - } - - -class GetAccountBalanceHistoricalReply: - def __init__( - self, - assets: List[Balance], - totalBalanceUsd: str, - totalCount: float, - nextPageToken: str = None, - syncStatus: SyncStatus = None, - blockHeight: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - ): - self.assets = assets - self.totalBalanceUsd = totalBalanceUsd - self.totalCount = totalCount - self.nextPageToken = nextPageToken - self.syncStatus = syncStatus - self.blockHeight = blockHeight - - @classmethod - def from_dict(cls, **data): - return cls( - assets=[ - Balance.from_dict(**balance_data) - for balance_data in data.get("assets", []) - ], - totalBalanceUsd=data.get("totalBalanceUsd"), - totalCount=data.get("totalCount"), - nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, - blockHeight=data.get("blockHeight"), - ) - - class Blockchain(Enum): Arbitrum = "arbitrum" Avalanche = "avalanche" @@ -2258,17 +1860,19 @@ class Blockchain(Enum): Fantom = "fantom" Flare = "flare" Gnosis = "gnosis" - Incentiv_devnet = "incentiv_devnet" + Incentiv_devnet_v3 = "incentiv_devnet_v3" + Incentiv_testnet = "incentiv_testnet" Linea = "linea" Neura_devnet = "neura_devnet" Neura_testnet_v1 = "neura_testnet_v1" Optimism = "optimism" - Optimism_testnet = "optimism_testnet" + Optimism_sepolia = "optimism_sepolia" Polygon = "polygon" Polygon_amoy = "polygon_amoy" Polygon_zkevm = "polygon_zkevm" Rollux = "rollux" Scroll = "scroll" + Stellar = "stellar" Syscoin = "syscoin" Telos = "telos" Xai = "xai" From 081ea8f34d6c738cb43fbc9303b97e21b174744a Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 10:42:19 -0400 Subject: [PATCH 02/10] Fix naming --- ankr/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ankr/types.py b/ankr/types.py index 3478f8d..fec58b0 100644 --- a/ankr/types.py +++ b/ankr/types.py @@ -1,6 +1,6 @@ # THIS FILE IS AUTOGENERATED # TO FIX ISSUE RELATED TO THIS FILE -# PLEASE FILE AN ISSUE ON https://github.com/Asphere-xyz/ankr-python-sdk/issues +# PLEASE FILE AN ISSUE ON https://github.com/Ankr-network/ankr-python-sdk/issues from __future__ import annotations from enum import Enum From 9fd4f67604d8f15ce8107fdb82e131b177c75f40 Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 10:44:36 -0400 Subject: [PATCH 03/10] update cache version --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 21590c8..6ad6f3d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,7 @@ jobs: #---------------------------------------------- # load pip cache if cache exists #---------------------------------------------- - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip From 34fbe7738c785b05993ce3f3c5289e7183d7f233 Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 10:46:02 -0400 Subject: [PATCH 04/10] update cache version --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6ad6f3d..a14e997 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -61,7 +61,7 @@ jobs: #---------------------------------------------- - name: Load cached venv id: cached-poetry-dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: .venv key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} From 9bbe229e487f504a21b6cf25f6521611d4580242 Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 10:55:06 -0400 Subject: [PATCH 05/10] rm 3.8 python --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a14e997..5eac568 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -35,7 +35,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: [ "3.8", "3.9", "3.10", "3.11" ] + python-version: [ "3.9", "3.10", "3.11" ] runs-on: "ubuntu-latest" steps: #---------------------------------------------- From 0d3c9d176c36e9eb41ea1ebb4803dd9e6eddb65a Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 11:14:32 -0400 Subject: [PATCH 06/10] revert types.py --- ankr/types.py | 948 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 672 insertions(+), 276 deletions(-) diff --git a/ankr/types.py b/ankr/types.py index fec58b0..b20d0a2 100644 --- a/ankr/types.py +++ b/ankr/types.py @@ -4,7 +4,7 @@ from __future__ import annotations from enum import Enum -from typing import Literal, Any, List, Dict +from typing import Literal, List, Dict class SyncStatus: @@ -22,20 +22,330 @@ def from_dict(cls, **data): ) +class MethodInput: + def __init__(self, name: str, size: float, type: str, valueDecoded: str): + self.name = name + self.size = size + self.type = type + self.valueDecoded = valueDecoded + + @classmethod + def from_dict(cls, **data): + return cls( + name=data.get("name"), + size=data.get("size"), + type=data.get("type"), + valueDecoded=data.get("valueDecoded"), + ) + + +class Method: + def __init__( + self, + id: str, + inputs: List[MethodInput], + name: str, + signature: str, + string: str, + verified: bool, + ): + self.id = id + self.inputs = inputs + self.name = name + self.signature = signature + self.string = string + self.verified = verified + + @classmethod + def from_dict(cls, **data): + return cls( + id=data.get("id"), + inputs=[ + MethodInput.from_dict(**methodinput_data) + for methodinput_data in data.get("inputs", []) + ], + name=data.get("name"), + signature=data.get("signature"), + string=data.get("string"), + verified=data.get("verified"), + ) + + +class EventInput: + def __init__( + self, indexed: bool, name: str, size: float, type: str, valueDecoded: str + ): + self.indexed = indexed + self.name = name + self.size = size + self.type = type + self.valueDecoded = valueDecoded + + @classmethod + def from_dict(cls, **data): + return cls( + indexed=data.get("indexed"), + name=data.get("name"), + size=data.get("size"), + type=data.get("type"), + valueDecoded=data.get("valueDecoded"), + ) + + +class Event: + def __init__( + self, + anonymous: bool, + id: str, + inputs: List[EventInput], + name: str, + signature: str, + string: str, + verified: bool, + ): + self.anonymous = anonymous + self.id = id + self.inputs = inputs + self.name = name + self.signature = signature + self.string = string + self.verified = verified + + @classmethod + def from_dict(cls, **data): + return cls( + anonymous=data.get("anonymous"), + id=data.get("id"), + inputs=[ + EventInput.from_dict(**eventinput_data) + for eventinput_data in data.get("inputs", []) + ], + name=data.get("name"), + signature=data.get("signature"), + string=data.get("string"), + verified=data.get("verified"), + ) + + +class Log: + def __init__( + self, + address: str, + blockHash: str, + blockNumber: str, + blockchain: Blockchain, + data: str, + logIndex: str, + removed: bool, + topics: List[str], + transactionHash: str, + transactionIndex: str, + event: Event = None, + ): + self.address = address + self.blockHash = blockHash + self.blockNumber = blockNumber + self.blockchain = blockchain + self.data = data + self.logIndex = logIndex + self.removed = removed + self.topics = topics + self.transactionHash = transactionHash + self.transactionIndex = transactionIndex + self.event = event + + @classmethod + def from_dict(cls, **data): + return cls( + address=data.get("address"), + blockHash=data.get("blockHash"), + blockNumber=data.get("blockNumber"), + blockchain=Blockchain(data.get("blockchain")), + data=data.get("data"), + logIndex=data.get("logIndex"), + removed=data.get("removed"), + topics=data.get("topics"), + transactionHash=data.get("transactionHash"), + transactionIndex=data.get("transactionIndex"), + event=Event.from_dict(**data.get("event")) + if data.get("event") is not None + else None, + ) + + +class Transaction: + def __init__( + self, + blockHash: str, + blockNumber: str, + from_: str, + transactionIndex: str, + value: str, + gasPrice: str = None, + gas: str = None, + contractAddress: str = None, + cumulativeGasUsed: str = None, + input: str = None, + v: str = None, + r: str = None, + s: str = None, + method: Method = None, + to: str = None, + nonce: str = None, + gasUsed: str = None, + logs: List[Log] = None, + hash: str = None, + status: str = None, + blockchain: str = None, + timestamp: str = None, + type: str = None, + ): + self.blockHash = blockHash + self.blockNumber = blockNumber + self.from_ = from_ + self.transactionIndex = transactionIndex + self.value = value + self.gasPrice = gasPrice + self.gas = gas + self.contractAddress = contractAddress + self.cumulativeGasUsed = cumulativeGasUsed + self.input = input + self.v = v + self.r = r + self.s = s + self.method = method + self.to = to + self.nonce = nonce + self.gasUsed = gasUsed + self.logs = logs + self.hash = hash + self.status = status + self.blockchain = blockchain + self.timestamp = timestamp + self.type = type + + @classmethod + def from_dict(cls, **data): + return cls( + blockHash=data.get("blockHash"), + blockNumber=data.get("blockNumber"), + from_=data.get("from"), + transactionIndex=data.get("transactionIndex"), + value=data.get("value"), + gasPrice=data.get("gasPrice"), + gas=data.get("gas"), + contractAddress=data.get("contractAddress"), + cumulativeGasUsed=data.get("cumulativeGasUsed"), + input=data.get("input"), + v=data.get("v"), + r=data.get("r"), + s=data.get("s"), + method=Method.from_dict(**data.get("method")) + if data.get("method") is not None + else None, + to=data.get("to"), + nonce=data.get("nonce"), + gasUsed=data.get("gasUsed"), + logs=[Log.from_dict(**log_data) for log_data in data.get("logs", [])], + hash=data.get("hash"), + status=data.get("status"), + blockchain=data.get("blockchain"), + timestamp=data.get("timestamp"), + type=data.get("type"), + ) + + +class Block: + def __init__( + self, + difficulty: str, + extraData: str, + gasLimit: str, + gasUsed: str, + hash: str, + logsBloom: str, + miner: str, + mixHash: str, + nonce: str, + number: str, + parentHash: str, + receiptsRoot: str, + sha3Uncles: str, + size: str, + stateRoot: str, + timestamp: str, + totalDifficulty: str, + transactions: List[Transaction], + transactionsRoot: str, + uncles: List[str], + blockchain: str = None, + ): + self.difficulty = difficulty + self.extraData = extraData + self.gasLimit = gasLimit + self.gasUsed = gasUsed + self.hash = hash + self.logsBloom = logsBloom + self.miner = miner + self.mixHash = mixHash + self.nonce = nonce + self.number = number + self.parentHash = parentHash + self.receiptsRoot = receiptsRoot + self.sha3Uncles = sha3Uncles + self.size = size + self.stateRoot = stateRoot + self.timestamp = timestamp + self.totalDifficulty = totalDifficulty + self.transactions = transactions + self.transactionsRoot = transactionsRoot + self.uncles = uncles + self.blockchain = blockchain + + @classmethod + def from_dict(cls, **data): + return cls( + difficulty=data.get("difficulty"), + extraData=data.get("extraData"), + gasLimit=data.get("gasLimit"), + gasUsed=data.get("gasUsed"), + hash=data.get("hash"), + logsBloom=data.get("logsBloom"), + miner=data.get("miner"), + mixHash=data.get("mixHash"), + nonce=data.get("nonce"), + number=data.get("number"), + parentHash=data.get("parentHash"), + receiptsRoot=data.get("receiptsRoot"), + sha3Uncles=data.get("sha3Uncles"), + size=data.get("size"), + stateRoot=data.get("stateRoot"), + timestamp=data.get("timestamp"), + totalDifficulty=data.get("totalDifficulty"), + transactions=[ + Transaction.from_dict(**transaction_data) + for transaction_data in data.get("transactions", []) + ], + transactionsRoot=data.get("transactionsRoot"), + uncles=data.get("uncles"), + blockchain=data.get("blockchain"), + ) + + class GetBlocksReply: - def __init__(self, blocks: List[Any], syncStatus: SyncStatus = None): + def __init__(self, blocks: List[Block], syncStatus: SyncStatus = None): self.blocks = blocks self.syncStatus = syncStatus @classmethod def from_dict(cls, **data): return cls( - blocks=[Any.from_dict(**any_data) for any_data in data.get("blocks", [])], - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + blocks=[ + Block.from_dict(**block_data) for block_data in data.get("blocks", []) + ], + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -43,12 +353,12 @@ class GetBlocksRequest: def __init__( self, blockchain: Blockchain, - fromBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, + fromBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, descOrder: bool = None, includeLogs: bool = None, includeTxs: bool = None, @@ -92,7 +402,7 @@ def to_dict(self): class GetTransactionsByHashReply: - def __init__(self, transactions: List[Any], syncStatus: SyncStatus = None): + def __init__(self, transactions: List[Transaction], syncStatus: SyncStatus = None): self.transactions = transactions self.syncStatus = syncStatus @@ -100,13 +410,12 @@ def __init__(self, transactions: List[Any], syncStatus: SyncStatus = None): def from_dict(cls, **data): return cls( transactions=[ - Any.from_dict(**any_data) for any_data in data.get("transactions", []) + Transaction.from_dict(**transaction_data) + for transaction_data in data.get("transactions", []) ], - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -151,7 +460,10 @@ def to_dict(self): class GetTransactionsByAddressReply: def __init__( - self, nextPageToken: str, transactions: List[Any], syncStatus: SyncStatus = None + self, + nextPageToken: str, + transactions: List[Transaction], + syncStatus: SyncStatus = None, ): self.nextPageToken = nextPageToken self.transactions = transactions @@ -162,13 +474,12 @@ def from_dict(cls, **data): return cls( nextPageToken=data.get("nextPageToken"), transactions=[ - Any.from_dict(**any_data) for any_data in data.get("transactions", []) + Transaction.from_dict(**transaction_data) + for transaction_data in data.get("transactions", []) ], - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -177,18 +488,18 @@ def __init__( self, address: List[str], blockchain: Blockchain | List[Blockchain], - fromBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - fromTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, + fromBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + fromTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, pageToken: str = None, pageSize: float = None, descOrder: bool = None, @@ -234,113 +545,6 @@ def to_dict(self): } -class EventInput: - def __init__( - self, indexed: bool, name: str, size: float, type: str, valueDecoded: str - ): - self.indexed = indexed - self.name = name - self.size = size - self.type = type - self.valueDecoded = valueDecoded - - @classmethod - def from_dict(cls, **data): - return cls( - indexed=data.get("indexed"), - name=data.get("name"), - size=data.get("size"), - type=data.get("type"), - valueDecoded=data.get("valueDecoded"), - ) - - -class Event: - def __init__( - self, - anonymous: bool, - id: str, - inputs: List[EventInput], - name: str, - signature: str, - string: str, - verified: bool, - ): - self.anonymous = anonymous - self.id = id - self.inputs = inputs - self.name = name - self.signature = signature - self.string = string - self.verified = verified - - @classmethod - def from_dict(cls, **data): - return cls( - anonymous=data.get("anonymous"), - id=data.get("id"), - inputs=[ - EventInput.from_dict(**eventinput_data) - for eventinput_data in data.get("inputs", []) - ], - name=data.get("name"), - signature=data.get("signature"), - string=data.get("string"), - verified=data.get("verified"), - ) - - -class Log: - def __init__( - self, - address: str, - blockHash: str, - blockNumber: str, - blockchain: Blockchain, - data: str, - logIndex: str, - removed: bool, - topics: List[str], - transactionHash: str, - transactionIndex: str, - event: Event = None, - timestamp: str = None, - ): - self.address = address - self.blockHash = blockHash - self.blockNumber = blockNumber - self.blockchain = blockchain - self.data = data - self.logIndex = logIndex - self.removed = removed - self.topics = topics - self.transactionHash = transactionHash - self.transactionIndex = transactionIndex - self.event = event - self.timestamp = timestamp - - @classmethod - def from_dict(cls, **data): - return cls( - address=data.get("address"), - blockHash=data.get("blockHash"), - blockNumber=data.get("blockNumber"), - blockchain=Blockchain(data.get("blockchain")), - data=data.get("data"), - logIndex=data.get("logIndex"), - removed=data.get("removed"), - topics=data.get("topics"), - transactionHash=data.get("transactionHash"), - transactionIndex=data.get("transactionIndex"), - event=( - Event.from_dict(**data.get("event")) - if data.get("event") is not None - else None - ), - timestamp=data.get("timestamp"), - ) - - class GetLogsReply: def __init__( self, logs: List[Log], nextPageToken: str = None, syncStatus: SyncStatus = None @@ -354,11 +558,9 @@ def from_dict(cls, **data): return cls( logs=[Log.from_dict(**log_data) for log_data in data.get("logs", [])], nextPageToken=data.get("nextPageToken"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -366,18 +568,18 @@ class GetLogsRequest: def __init__( self, blockchain: Blockchain | List[Blockchain], - fromBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - fromTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, + fromBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + fromTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, address: List[str] = None, topics: List[str | List[str]] = None, pageToken: str = None, @@ -468,11 +670,9 @@ def from_dict(cls, **data): BlockchainStats.from_dict(**blockchainstats_data) for blockchainstats_data in data.get("stats", []) ], - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -510,11 +710,9 @@ def __init__(self, blockchains: List[str], syncStatus: SyncStatus = None): def from_dict(cls, **data): return cls( blockchains=data.get("blockchains"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -602,11 +800,9 @@ def from_dict(cls, **data): totalBalanceUsd=data.get("totalBalanceUsd"), totalCount=data.get("totalCount"), nextPageToken=data.get("nextPageToken"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -671,11 +867,9 @@ def from_dict(cls, **data): blockchain=Blockchain(data.get("blockchain")), usdPrice=data.get("usdPrice"), contractAddress=data.get("contractAddress"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -755,11 +949,9 @@ def from_dict(cls, **data): holdersCount=data.get("holdersCount"), nextPageToken=data.get("nextPageToken"), tokenDecimals=data.get("tokenDecimals"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -853,11 +1045,9 @@ def from_dict(cls, **data): latestHoldersCount=data.get("latestHoldersCount"), nextPageToken=data.get("nextPageToken"), tokenDecimals=data.get("tokenDecimals"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -940,11 +1130,9 @@ def from_dict(cls, **data): CurrencyDetailsExtended.from_dict(**currencydetailsextended_data) for currencydetailsextended_data in data.get("currencies", []) ], - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1043,11 +1231,9 @@ def from_dict(cls, **data): for tokentransfer_data in data.get("transfers", []) ], nextPageToken=data.get("nextPageToken"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1055,18 +1241,18 @@ class GetTransfersRequest: def __init__( self, blockchain: Blockchain | List[Blockchain], - fromBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toBlock: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - fromTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, + fromBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toBlock: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + fromTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, address: List[str] = None, pageToken: str = None, pageSize: float = None, @@ -1190,11 +1376,9 @@ def from_dict(cls, **data): assets=[Nft.from_dict(**nft_data) for nft_data in data.get("assets", [])], nextPageToken=data.get("nextPageToken"), owner=data.get("owner"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1315,21 +1499,15 @@ def __init__( @classmethod def from_dict(cls, **data): return cls( - metadata=( - NftMetadata.from_dict(**data.get("metadata")) - if data.get("metadata") is not None - else None - ), - attributes=( - NftAttributes.from_dict(**data.get("attributes")) - if data.get("attributes") is not None - else None - ), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + metadata=NftMetadata.from_dict(**data.get("metadata")) + if data.get("metadata") is not None + else None, + attributes=NftAttributes.from_dict(**data.get("attributes")) + if data.get("attributes") is not None + else None, + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1382,11 +1560,9 @@ def from_dict(cls, **data): return cls( holders=data.get("holders"), nextPageToken=data.get("nextPageToken"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1498,11 +1674,9 @@ def from_dict(cls, **data): for nfttransfer_data in data.get("transfers", []) ], nextPageToken=data.get("nextPageToken"), - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1585,11 +1759,9 @@ def from_dict(cls, **data): tokenName=data.get("tokenName"), tokenSymbol=data.get("tokenSymbol"), spenderAddress=data.get("spenderAddress"), - rawLog=( - Log.from_dict(**data.get("rawLog")) - if data.get("rawLog") is not None - else None - ), + rawLog=Log.from_dict(**data.get("rawLog")) + if data.get("rawLog") is not None + else None, ) @@ -1612,12 +1784,12 @@ def __init__( self, blockchain: Blockchain, contractAddress: str, - fromTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, - toTimestamp: ( - float | Literal[Literal["latest"]] | Literal[Literal["earliest"]] - ) = None, + fromTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + toTimestamp: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, interval: float = None, limit: float = None, syncCheck: bool = None, @@ -1679,11 +1851,9 @@ def from_dict(cls, **data): quotes=[ Quote.from_dict(**quote_data) for quote_data in data.get("quotes", []) ], - syncStatus=( - SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None - ), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, ) @@ -1803,16 +1973,12 @@ def from_dict(cls, **data): PriceEstimate.from_dict(**priceestimate_data) for priceestimate_data in data.get("priceEstimates", []) ], - token0=( - ExplainTokenPriceTokenDetails.from_dict(**data.get("token0")) - if data.get("token0") is not None - else None - ), - token1=( - ExplainTokenPriceTokenDetails.from_dict(**data.get("token1")) - if data.get("token1") is not None - else None - ), + token0=ExplainTokenPriceTokenDetails.from_dict(**data.get("token0")) + if data.get("token0") is not None + else None, + token1=ExplainTokenPriceTokenDetails.from_dict(**data.get("token1")) + if data.get("token1") is not None + else None, ) @@ -1847,6 +2013,238 @@ def from_dict(cls, **data): ) +class GetInternalTransactionsByParentHashRequest: + def __init__( + self, + blockchain: Blockchain, + onlyWithValue: bool, + parentTransactionHash: str, + syncCheck: bool = None, + ): + self.blockchain = blockchain + self.onlyWithValue = onlyWithValue + self.parentTransactionHash = parentTransactionHash + self.syncCheck = syncCheck + + def to_dict(self): + if isinstance(self.blockchain, str): + blockchain_value = self.blockchain + elif isinstance(self.blockchain, list): + blockchain_value = [ + block.value if isinstance(block, Blockchain) else block + for block in self.blockchain + ] + elif self.blockchain is not None: + blockchain_value = self.blockchain.value + else: + blockchain_value = None + return { + "blockchain": blockchain_value, + "onlyWithValue": self.onlyWithValue, + "parentTransactionHash": self.parentTransactionHash, + "syncCheck": self.syncCheck, + } + + +class GetInternalTransactionsByBlockNumberRequest: + def __init__( + self, + blockNumber: float, + blockchain: Blockchain, + onlyWithValue: bool, + syncCheck: bool = None, + ): + self.blockNumber = blockNumber + self.blockchain = blockchain + self.onlyWithValue = onlyWithValue + self.syncCheck = syncCheck + + def to_dict(self): + if isinstance(self.blockchain, str): + blockchain_value = self.blockchain + elif isinstance(self.blockchain, list): + blockchain_value = [ + block.value if isinstance(block, Blockchain) else block + for block in self.blockchain + ] + elif self.blockchain is not None: + blockchain_value = self.blockchain.value + else: + blockchain_value = None + return { + "blockNumber": self.blockNumber, + "blockchain": blockchain_value, + "onlyWithValue": self.onlyWithValue, + "syncCheck": self.syncCheck, + } + + +class InternalTransaction: + def __init__( + self, + blockHash: str, + blockHeight: float, + blockchain: Blockchain, + callType: str, + fromAddress: str, + gas: float, + gasUsed: float, + input: str, + output: str, + timestamp: str, + toAddress: str, + transactionHash: str, + transactionIndex: float, + value: str, + callPath: str = None, + callStack: List[float] = None, + error: str = None, + contractAddress: str = None, + ): + self.blockHash = blockHash + self.blockHeight = blockHeight + self.blockchain = blockchain + self.callType = callType + self.fromAddress = fromAddress + self.gas = gas + self.gasUsed = gasUsed + self.input = input + self.output = output + self.timestamp = timestamp + self.toAddress = toAddress + self.transactionHash = transactionHash + self.transactionIndex = transactionIndex + self.value = value + self.callPath = callPath + self.callStack = callStack + self.error = error + self.contractAddress = contractAddress + + @classmethod + def from_dict(cls, **data): + return cls( + blockHash=data.get("blockHash"), + blockHeight=data.get("blockHeight"), + blockchain=Blockchain(data.get("blockchain")), + callType=data.get("callType"), + fromAddress=data.get("fromAddress"), + gas=data.get("gas"), + gasUsed=data.get("gasUsed"), + input=data.get("input"), + output=data.get("output"), + timestamp=data.get("timestamp"), + toAddress=data.get("toAddress"), + transactionHash=data.get("transactionHash"), + transactionIndex=data.get("transactionIndex"), + value=data.get("value"), + callPath=data.get("callPath"), + callStack=data.get("callStack"), + error=data.get("error"), + contractAddress=data.get("contractAddress"), + ) + + +class GetInternalTransactionsReply: + def __init__( + self, internalTransactions: List[InternalTransaction], nextPageToken: str = None + ): + self.internalTransactions = internalTransactions + self.nextPageToken = nextPageToken + + @classmethod + def from_dict(cls, **data): + return cls( + internalTransactions=[ + InternalTransaction.from_dict(**internaltransaction_data) + for internaltransaction_data in data.get("internalTransactions", []) + ], + nextPageToken=data.get("nextPageToken"), + ) + + +class GetAccountBalanceHistoricalRequest: + def __init__( + self, + walletAddress: str, + blockchain: Blockchain | List[Blockchain] = None, + onlyWhitelisted: bool = None, + nativeFirst: bool = None, + pageToken: str = None, + pageSize: float = None, + blockHeight: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + syncCheck: bool = None, + ): + self.walletAddress = walletAddress + self.blockchain = blockchain + self.onlyWhitelisted = onlyWhitelisted + self.nativeFirst = nativeFirst + self.pageToken = pageToken + self.pageSize = pageSize + self.blockHeight = blockHeight + self.syncCheck = syncCheck + + def to_dict(self): + if isinstance(self.blockchain, str): + blockchain_value = self.blockchain + elif isinstance(self.blockchain, list): + blockchain_value = [ + block.value if isinstance(block, Blockchain) else block + for block in self.blockchain + ] + elif self.blockchain is not None: + blockchain_value = self.blockchain.value + else: + blockchain_value = None + return { + "walletAddress": self.walletAddress, + "blockchain": blockchain_value, + "onlyWhitelisted": self.onlyWhitelisted, + "nativeFirst": self.nativeFirst, + "pageToken": self.pageToken, + "pageSize": self.pageSize, + "blockHeight": self.blockHeight, + "syncCheck": self.syncCheck, + } + + +class GetAccountBalanceHistoricalReply: + def __init__( + self, + assets: List[Balance], + totalBalanceUsd: str, + totalCount: float, + nextPageToken: str = None, + syncStatus: SyncStatus = None, + blockHeight: float + | Literal[Literal["latest"]] + | Literal[Literal["earliest"]] = None, + ): + self.assets = assets + self.totalBalanceUsd = totalBalanceUsd + self.totalCount = totalCount + self.nextPageToken = nextPageToken + self.syncStatus = syncStatus + self.blockHeight = blockHeight + + @classmethod + def from_dict(cls, **data): + return cls( + assets=[ + Balance.from_dict(**balance_data) + for balance_data in data.get("assets", []) + ], + totalBalanceUsd=data.get("totalBalanceUsd"), + totalCount=data.get("totalCount"), + nextPageToken=data.get("nextPageToken"), + syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) + if data.get("syncStatus") is not None + else None, + blockHeight=data.get("blockHeight"), + ) + + class Blockchain(Enum): Arbitrum = "arbitrum" Avalanche = "avalanche" @@ -1860,19 +2258,17 @@ class Blockchain(Enum): Fantom = "fantom" Flare = "flare" Gnosis = "gnosis" - Incentiv_devnet_v3 = "incentiv_devnet_v3" - Incentiv_testnet = "incentiv_testnet" + Incentiv_devnet = "incentiv_devnet" Linea = "linea" Neura_devnet = "neura_devnet" Neura_testnet_v1 = "neura_testnet_v1" Optimism = "optimism" - Optimism_sepolia = "optimism_sepolia" + Optimism_testnet = "optimism_testnet" Polygon = "polygon" Polygon_amoy = "polygon_amoy" Polygon_zkevm = "polygon_zkevm" Rollux = "rollux" Scroll = "scroll" - Stellar = "stellar" Syscoin = "syscoin" Telos = "telos" Xai = "xai" From b85a847cc86ba61d0b11ff65b354f22df27f04b0 Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 11:19:27 -0400 Subject: [PATCH 07/10] Fix tests --- tests/test_client.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index cd10d19..bfd5bff 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -246,15 +246,3 @@ def test_get_token_price(client: AnkrAdvancedAPI) -> None: assert price assert float(price) > 0 - - -@pytest.mark.webtest -def test_get_token_price__no_price(client: AnkrAdvancedAPI) -> None: - price = client.get_token_price( - request=GetTokenPriceRequest( - contractAddress="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", - blockchain=Blockchain.Eth, - ) - ) - - assert price == "0" From dd844541160d134c72f25c7624a81aaab47c8783 Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 11:21:52 -0400 Subject: [PATCH 08/10] python version add back 3.8 --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5eac568..a14e997 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -35,7 +35,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: [ "3.9", "3.10", "3.11" ] + python-version: [ "3.8", "3.9", "3.10", "3.11" ] runs-on: "ubuntu-latest" steps: #---------------------------------------------- From fc24e7d77cf1b6704ba38e9c1317d71ddba11f6a Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 11:23:28 -0400 Subject: [PATCH 09/10] Revert "python version add back 3.8" This reverts commit dd844541160d134c72f25c7624a81aaab47c8783. --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a14e997..5eac568 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -35,7 +35,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: [ "3.8", "3.9", "3.10", "3.11" ] + python-version: [ "3.9", "3.10", "3.11" ] runs-on: "ubuntu-latest" steps: #---------------------------------------------- From b0499a35438e18a31a57f2ccb0dfe0524cd4ca9e Mon Sep 17 00:00:00 2001 From: Yurii Momotenko Date: Mon, 13 Oct 2025 11:25:54 -0400 Subject: [PATCH 10/10] Rm unsupported types --- ankr/types.py | 238 +------------------------------------------------- 1 file changed, 4 insertions(+), 234 deletions(-) diff --git a/ankr/types.py b/ankr/types.py index b20d0a2..b16028b 100644 --- a/ankr/types.py +++ b/ankr/types.py @@ -2013,238 +2013,6 @@ def from_dict(cls, **data): ) -class GetInternalTransactionsByParentHashRequest: - def __init__( - self, - blockchain: Blockchain, - onlyWithValue: bool, - parentTransactionHash: str, - syncCheck: bool = None, - ): - self.blockchain = blockchain - self.onlyWithValue = onlyWithValue - self.parentTransactionHash = parentTransactionHash - self.syncCheck = syncCheck - - def to_dict(self): - if isinstance(self.blockchain, str): - blockchain_value = self.blockchain - elif isinstance(self.blockchain, list): - blockchain_value = [ - block.value if isinstance(block, Blockchain) else block - for block in self.blockchain - ] - elif self.blockchain is not None: - blockchain_value = self.blockchain.value - else: - blockchain_value = None - return { - "blockchain": blockchain_value, - "onlyWithValue": self.onlyWithValue, - "parentTransactionHash": self.parentTransactionHash, - "syncCheck": self.syncCheck, - } - - -class GetInternalTransactionsByBlockNumberRequest: - def __init__( - self, - blockNumber: float, - blockchain: Blockchain, - onlyWithValue: bool, - syncCheck: bool = None, - ): - self.blockNumber = blockNumber - self.blockchain = blockchain - self.onlyWithValue = onlyWithValue - self.syncCheck = syncCheck - - def to_dict(self): - if isinstance(self.blockchain, str): - blockchain_value = self.blockchain - elif isinstance(self.blockchain, list): - blockchain_value = [ - block.value if isinstance(block, Blockchain) else block - for block in self.blockchain - ] - elif self.blockchain is not None: - blockchain_value = self.blockchain.value - else: - blockchain_value = None - return { - "blockNumber": self.blockNumber, - "blockchain": blockchain_value, - "onlyWithValue": self.onlyWithValue, - "syncCheck": self.syncCheck, - } - - -class InternalTransaction: - def __init__( - self, - blockHash: str, - blockHeight: float, - blockchain: Blockchain, - callType: str, - fromAddress: str, - gas: float, - gasUsed: float, - input: str, - output: str, - timestamp: str, - toAddress: str, - transactionHash: str, - transactionIndex: float, - value: str, - callPath: str = None, - callStack: List[float] = None, - error: str = None, - contractAddress: str = None, - ): - self.blockHash = blockHash - self.blockHeight = blockHeight - self.blockchain = blockchain - self.callType = callType - self.fromAddress = fromAddress - self.gas = gas - self.gasUsed = gasUsed - self.input = input - self.output = output - self.timestamp = timestamp - self.toAddress = toAddress - self.transactionHash = transactionHash - self.transactionIndex = transactionIndex - self.value = value - self.callPath = callPath - self.callStack = callStack - self.error = error - self.contractAddress = contractAddress - - @classmethod - def from_dict(cls, **data): - return cls( - blockHash=data.get("blockHash"), - blockHeight=data.get("blockHeight"), - blockchain=Blockchain(data.get("blockchain")), - callType=data.get("callType"), - fromAddress=data.get("fromAddress"), - gas=data.get("gas"), - gasUsed=data.get("gasUsed"), - input=data.get("input"), - output=data.get("output"), - timestamp=data.get("timestamp"), - toAddress=data.get("toAddress"), - transactionHash=data.get("transactionHash"), - transactionIndex=data.get("transactionIndex"), - value=data.get("value"), - callPath=data.get("callPath"), - callStack=data.get("callStack"), - error=data.get("error"), - contractAddress=data.get("contractAddress"), - ) - - -class GetInternalTransactionsReply: - def __init__( - self, internalTransactions: List[InternalTransaction], nextPageToken: str = None - ): - self.internalTransactions = internalTransactions - self.nextPageToken = nextPageToken - - @classmethod - def from_dict(cls, **data): - return cls( - internalTransactions=[ - InternalTransaction.from_dict(**internaltransaction_data) - for internaltransaction_data in data.get("internalTransactions", []) - ], - nextPageToken=data.get("nextPageToken"), - ) - - -class GetAccountBalanceHistoricalRequest: - def __init__( - self, - walletAddress: str, - blockchain: Blockchain | List[Blockchain] = None, - onlyWhitelisted: bool = None, - nativeFirst: bool = None, - pageToken: str = None, - pageSize: float = None, - blockHeight: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - syncCheck: bool = None, - ): - self.walletAddress = walletAddress - self.blockchain = blockchain - self.onlyWhitelisted = onlyWhitelisted - self.nativeFirst = nativeFirst - self.pageToken = pageToken - self.pageSize = pageSize - self.blockHeight = blockHeight - self.syncCheck = syncCheck - - def to_dict(self): - if isinstance(self.blockchain, str): - blockchain_value = self.blockchain - elif isinstance(self.blockchain, list): - blockchain_value = [ - block.value if isinstance(block, Blockchain) else block - for block in self.blockchain - ] - elif self.blockchain is not None: - blockchain_value = self.blockchain.value - else: - blockchain_value = None - return { - "walletAddress": self.walletAddress, - "blockchain": blockchain_value, - "onlyWhitelisted": self.onlyWhitelisted, - "nativeFirst": self.nativeFirst, - "pageToken": self.pageToken, - "pageSize": self.pageSize, - "blockHeight": self.blockHeight, - "syncCheck": self.syncCheck, - } - - -class GetAccountBalanceHistoricalReply: - def __init__( - self, - assets: List[Balance], - totalBalanceUsd: str, - totalCount: float, - nextPageToken: str = None, - syncStatus: SyncStatus = None, - blockHeight: float - | Literal[Literal["latest"]] - | Literal[Literal["earliest"]] = None, - ): - self.assets = assets - self.totalBalanceUsd = totalBalanceUsd - self.totalCount = totalCount - self.nextPageToken = nextPageToken - self.syncStatus = syncStatus - self.blockHeight = blockHeight - - @classmethod - def from_dict(cls, **data): - return cls( - assets=[ - Balance.from_dict(**balance_data) - for balance_data in data.get("assets", []) - ], - totalBalanceUsd=data.get("totalBalanceUsd"), - totalCount=data.get("totalCount"), - nextPageToken=data.get("nextPageToken"), - syncStatus=SyncStatus.from_dict(**data.get("syncStatus")) - if data.get("syncStatus") is not None - else None, - blockHeight=data.get("blockHeight"), - ) - - class Blockchain(Enum): Arbitrum = "arbitrum" Avalanche = "avalanche" @@ -2258,17 +2026,19 @@ class Blockchain(Enum): Fantom = "fantom" Flare = "flare" Gnosis = "gnosis" - Incentiv_devnet = "incentiv_devnet" + Incentiv_devnet_v3 = "incentiv_devnet_v3" + Incentiv_testnet = "incentiv_testnet" Linea = "linea" Neura_devnet = "neura_devnet" Neura_testnet_v1 = "neura_testnet_v1" Optimism = "optimism" - Optimism_testnet = "optimism_testnet" + Optimism_sepolia = "optimism_sepolia" Polygon = "polygon" Polygon_amoy = "polygon_amoy" Polygon_zkevm = "polygon_zkevm" Rollux = "rollux" Scroll = "scroll" + Stellar = "stellar" Syscoin = "syscoin" Telos = "telos" Xai = "xai"