Skip to content

Commit

Permalink
Update version and fix symbol retrieval in TicTonAsyncClient
Browse files Browse the repository at this point in the history
  • Loading branch information
alan890104 committed Mar 8, 2024
1 parent 72f0a07 commit c67e32d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ticton"
version = "0.1.30"
version = "0.1.31"
description = ""
authors = ["alan890104 <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion ticton/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .arithmetic import FixedFloat, to_token, token_to_float
from .client import DryRunResult, TicTonAsyncClient

__version__ = "0.1.30"
__version__ = "0.1.31"

__all__ = [
"FixedFloat",
Expand Down
17 changes: 7 additions & 10 deletions ticton/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
AlarmMetadataDecoder,
EstimateDataDecoder,
JettonWalletAddressDecoder,
OracleMetadata,
OracleMetadataDecoder,
OracleMetadataWithSymbols,
)
Expand Down Expand Up @@ -76,12 +75,12 @@ async def get_symbol_from_address(toncenter: AsyncTonCenterClientV3, base_asset_
base_symbol = "UNKNOWN"
quote_symbol = "UNKNOWN"
if result[0] is not None:
if result[0].jetton_content.symbol is not None:
if result[0].jetton_content is not None and result[0].jetton_content.symbol is not None:
base_symbol = result[0].jetton_content.symbol
else:
base_symbol = "TON"
if result[1] is not None:
if result[1].jetton_content.symbol is not None:
if result[1].jetton_content is not None and result[1].jetton_content.symbol is not None:
quote_symbol = result[1].jetton_content.symbol
else:
quote_symbol = "TON"
Expand Down Expand Up @@ -171,12 +170,8 @@ async def init(

metadata = await cls.get_oracle_metadata(toncenter, oracle_addr_str)

base_symbol, quote_symbol = await get_symbol_from_address(toncenter, metadata.base_asset_address, metadata.quote_asset_address)

new_metadata = OracleMetadataWithSymbols(**metadata.model_dump(), base_asset_symbol=base_symbol, quote_asset_symbol=quote_symbol)

return cls(
metadata=new_metadata,
metadata=metadata,
toncenter=toncenter,
mnemonics=phrase,
oracle_addr=oracle_addr_str,
Expand All @@ -190,9 +185,11 @@ async def get_oracle_metadata(
cls: Type[TicTonAsyncClient],
toncenter: AsyncTonCenterClientV3,
oracle_addr: str,
) -> OracleMetadata:
) -> OracleMetadataWithSymbols:
result = await toncenter.run_get_method(RunGetMethodRequest(address=oracle_addr, method="getOracleData", stack=[]))
return OracleMetadataDecoder().decode(result)
md = OracleMetadataDecoder().decode(result)
base_symbol, quote_symbol = await get_symbol_from_address(toncenter, md.base_asset_address, md.quote_asset_address)
return OracleMetadataWithSymbols(**md.model_dump(), base_asset_symbol=base_symbol, quote_asset_symbol=quote_symbol)

async def sync_oracle_metadata(self):
self.metadata = await self.get_oracle_metadata(self.toncenter, self.oracle.to_string())
Expand Down

0 comments on commit c67e32d

Please sign in to comment.