Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 45 additions & 3 deletions TonTools/Providers/TonCenterClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ..Contracts.Contract import Transaction
from ..Contracts.Wallet import Wallet
from ..Contracts.Jetton import Jetton, JettonWallet
from .utils import markets_adresses, get, process_jetton_data
from .utils import markets_adresses, get, process_jetton_data, from_nanotons
from ._orbs_ton_access import get_http_endpoint


Expand Down Expand Up @@ -303,15 +303,57 @@ async def get_wallet_seqno(self, address: str):
data = await self.run_get_method(address=address, method='seqno', stack=[])
return int(data[0][1], 16)

async def get_balance(self, address: str):
async def get_balance(self, address: str,convert_nanotons=False):
async with aiohttp.ClientSession() as session:
url = self.base_url + 'getAddressBalance'
params = {
'address': address
}
response = await session.get(url=url, params=params, headers=self.headers)
response = await process_response(response)
return int(response['result'])
balance = int(response['result'])

return balance if not convert_nanotons else from_nanotons(balance)

async def get_address_information(self, address: str):
async with aiohttp.ClientSession() as session:
url = self.base_url + 'getAddressInformation'
params = {
'address': address
}
response = await session.get(url=url, params=params, headers=self.headers)
response = await process_response(response)
return response['result']

async def get_wallet_information(self, address: str):
async with aiohttp.ClientSession() as session:
url = self.base_url + 'getWalletInformation'
params = {
'address': address
}
response = await session.get(url=url, params=params, headers=self.headers)
response = await process_response(response)
return response['result']

async def get_extended_address_information(self, address: str):
async with aiohttp.ClientSession() as session:
url = self.base_url + 'getExtendedAddressInformation'
params = {
'address': address
}
response = await session.get(url=url, params=params, headers=self.headers)
response = await process_response(response)
return response['result']

async def get_extended_address_information(self, address: str):
async with aiohttp.ClientSession() as session:
url = self.base_url + 'getExtendedAddressInformation'
params = {
'address': address
}
response = await session.get(url=url, params=params, headers=self.headers)
response = await process_response(response)
return response['result']

async def get_state(self, address: str):
async with aiohttp.ClientSession() as session:
Expand Down
6 changes: 6 additions & 0 deletions TonTools/Providers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def process_jetton_data(data):
'decimals': int(decimals)
}

def from_nanotons(amount):
return amount / 1000000000

def to_nanotons(amount):
return amount * 1000000000


async def get(url: str):
if 'ipfs' in url:
Expand Down