From 6531b87bdfe8b3af7fc4996395ad9b51418b6793 Mon Sep 17 00:00:00 2001 From: "andrey.torsunov" Date: Wed, 24 Apr 2024 19:24:09 +0300 Subject: [PATCH] fix: linter fixes --- .../contract/wallet/_highload_query_id.py | 20 +++++++++---------- .../wallet/_highload_wallet_contract_v3.py | 12 ++++++----- tonsdk_ng/provider/_toncenter/_client.py | 18 ++++++++++++----- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tonsdk_ng/contract/wallet/_highload_query_id.py b/tonsdk_ng/contract/wallet/_highload_query_id.py index 31543c5..76bda6d 100644 --- a/tonsdk_ng/contract/wallet/_highload_query_id.py +++ b/tonsdk_ng/contract/wallet/_highload_query_id.py @@ -7,7 +7,7 @@ class HighloadQueryId: def __init__(self): """ - Initializes a HighloadQueryId instance with default values. + Initializes a HighloadQueryId instance with default values :ivar _shift: Internal state for shift (bigint) [0 .. 8191] :ivar _bit_number: Internal state for bit number (bigint) [0 .. 1022] @@ -18,7 +18,7 @@ def __init__(self): @staticmethod def from_shift_and_bit_number(shift, bit_number): """ - Creates a new HighloadQueryId object with specified shift and bit number. + Creates a new HighloadQueryId object with specified shift and bit number :param shift: The shift value (int) :param bit_number: The bit number value (int) @@ -37,7 +37,7 @@ def from_shift_and_bit_number(shift, bit_number): def get_next(self): """ - Calculates the next HighloadQueryId based on the current state. + Calculates the next HighloadQueryId based on the current state :return: HighloadQueryId representing the next ID :raises ValueError: If the current ID is at the maximum capacity @@ -61,7 +61,7 @@ def get_next(self): def has_next(self): """ - Checks if there is a next HighloadQueryId available. + Checks if there is a next HighloadQueryId available :return: True if there is a next ID available, False otherwise """ @@ -75,7 +75,7 @@ def has_next(self): @property def shift(self): """ - Gets the current shift value. + Gets the current shift value :return: The current shift value (int) """ @@ -84,7 +84,7 @@ def shift(self): @property def bit_number(self): """ - Gets the current bit number value. + Gets the current bit number value :return: The current bit number value (int) """ @@ -93,7 +93,7 @@ def bit_number(self): @property def query_id(self): """ - Computes the query ID based on the current shift and bit number. + Computes the query ID based on the current shift and bit number :return: The computed query ID (int) """ @@ -102,7 +102,7 @@ def query_id(self): @staticmethod def from_query_id(query_id: int): """ - Creates a new HighloadQueryId object from a given query ID. + Creates a new HighloadQueryId object from a given query ID :param query_id: The query ID to parse (int) :return: A new instance of HighloadQueryId @@ -114,7 +114,7 @@ def from_query_id(query_id: int): @staticmethod def from_seqno(i: int): """ - Creates a HighloadQueryId from a sequence number. + Creates a HighloadQueryId from a sequence number :param i: The sequence number (int) :return: A new HighloadQueryId @@ -125,7 +125,7 @@ def from_seqno(i: int): def to_seqno(self) -> int: """ - Converts the current HighloadQueryId to a sequence number. + Converts the current HighloadQueryId to a sequence number :return: The sequence number (int) """ diff --git a/tonsdk_ng/contract/wallet/_highload_wallet_contract_v3.py b/tonsdk_ng/contract/wallet/_highload_wallet_contract_v3.py index c71f8a8..4333ed6 100644 --- a/tonsdk_ng/contract/wallet/_highload_wallet_contract_v3.py +++ b/tonsdk_ng/contract/wallet/_highload_wallet_contract_v3.py @@ -1,6 +1,6 @@ -from ...boc import Cell, begin_cell, begin_dict +from ...boc import Cell from ...crypto import private_key_to_public_key -from ...utils import Address, sign_message +from ...utils import sign_message from .. import Contract from ._highload_query_id import HighloadQueryId from ._wallet_contract import WalletContract @@ -18,7 +18,7 @@ def check_timeout(seconds): class HighloadWalletV3Contract(WalletContract): def __init__(self, **kwargs): # https://github.com/ton-blockchain/highload-wallet-contract-v3 - self.code = "b5ee9c7241021001000228000114ff00f4a413f4bcf2c80b01020120020d02014803040078d020d74bc00101c060b0915be101d0d3030171b0915be0fa4030f828c705b39130e0d31f018210ae42e5a4ba9d8040d721d74cf82a01ed55fb04e030020120050a02027306070011adce76a2686b85ffc00201200809001aabb6ed44d0810122d721d70b3f0018aa3bed44d08307d721d70b1f0201200b0c001bb9a6eed44d0810162d721d70b15800e5b8bf2eda2edfb21ab09028409b0ed44d0810120d721f404f404d33fd315d1058e1bf82325a15210b99f326df82305aa0015a112b992306dde923033e2923033e25230800df40f6fa19ed021d721d70a00955f037fdb31e09130e259800df40f6fa19cd001d721d70a00937fdb31e0915be270801f6f2d48308d718d121f900ed44d0d3ffd31ff404f404d33fd315d1f82321a15220b98e12336df82324aa00a112b9926d32de58f82301de541675f910f2a106d0d31fd4d307d30cd309d33fd315d15168baf2a2515abaf2a6f8232aa15250bcf2a304f823bbf2a35304800df40f6fa199d024d721d70a00f2649130e20e01fe5309800df40f6fa18e13d05004d718d20001f264c858cf16cf8301cf168e1030c824cf40cf8384095005a1a514cf40e2f800c94039800df41704c8cbff13cb1ff40012f40012cb3f12cb15c9ed54f80f21d0d30001f265d3020171b0925f03e0fa4001d70b01c000f2a5fa4031fa0031f401fa0031fa00318060d721d300010f0020f265d2000193d431d19130e272b1fb00b585bf03" + self.code = "b5ee9c7241021001000228000114ff00f4a413f4bcf2c80b01020120020d02014803040078d020d74bc00101c060b0915be101d0d3030171b0915be0fa4030f828c705b39130e0d31f018210ae42e5a4ba9d8040d721d74cf82a01ed55fb04e030020120050a02027306070011adce76a2686b85ffc00201200809001aabb6ed44d0810122d721d70b3f0018aa3bed44d08307d721d70b1f0201200b0c001bb9a6eed44d0810162d721d70b15800e5b8bf2eda2edfb21ab09028409b0ed44d0810120d721f404f404d33fd315d1058e1bf82325a15210b99f326df82305aa0015a112b992306dde923033e2923033e25230800df40f6fa19ed021d721d70a00955f037fdb31e09130e259800df40f6fa19cd001d721d70a00937fdb31e0915be270801f6f2d48308d718d121f900ed44d0d3ffd31ff404f404d33fd315d1f82321a15220b98e12336df82324aa00a112b9926d32de58f82301de541675f910f2a106d0d31fd4d307d30cd309d33fd315d15168baf2a2515abaf2a6f8232aa15250bcf2a304f823bbf2a35304800df40f6fa199d024d721d70a00f2649130e20e01fe5309800df40f6fa18e13d05004d718d20001f264c858cf16cf8301cf168e1030c824cf40cf8384095005a1a514cf40e2f800c94039800df41704c8cbff13cb1ff40012f40012cb3f12cb15c9ed54f80f21d0d30001f265d3020171b0925f03e0fa4001d70b01c000f2a5fa4031fa0031f401fa0031fa00318060d721d300010f0020f265d2000193d431d19130e272b1fb00b585bf03" # noqa:E501 kwargs["code"] = Cell.one_from_boc(self.code) super().__init__(**kwargs) @@ -133,7 +133,8 @@ def create_external_message( # return id.to_number() # # async def get_public_key(self): - # return self.provider.call2(self.address.to_string(), "get_public_key") + # return self.provider.call2( + # self.address.to_string(), "get_public_key") # # async def get_last_clean_time(self): # id = await self.provider.call2( @@ -142,7 +143,8 @@ def create_external_message( # return id.to_number() # # async def get_timeout(self): - # id = await self.provider.call2(self.address.to_string(), "get_timeout") + # id = await self.provider.call2( + # self.address.to_string(), "get_timeout") # return id.to_number() # # async def is_processed(self, query_id, need_clean): diff --git a/tonsdk_ng/provider/_toncenter/_client.py b/tonsdk_ng/provider/_toncenter/_client.py index e445404..e606eb5 100644 --- a/tonsdk_ng/provider/_toncenter/_client.py +++ b/tonsdk_ng/provider/_toncenter/_client.py @@ -1,4 +1,7 @@ -import httpx +import httpj + +from tonsdk_ng.boc import Cell +from tonsdk_ng.utils import b64str_to_bytes class ToncenterClient: @@ -10,7 +13,9 @@ def __init__( headers = {"Content-Type": "application/json"} if api_key: headers["X-API-Key"] = api_key - self.client = httpx.Client(base_url=base_url, headers=headers) + self.client = httpj.Client( + base_url=base_url.rstrip("/"), headers=headers + ) def send(self, method, params): params = {k: v for k, v in params.items() if v is not None} @@ -66,10 +71,13 @@ def send_query(self, query): def get_estimate_fee(self, query): return self.send("estimateFee", query) - def call(self, address, method, params=[]): + def run_get_method( + self, address: str, method: str, stack: list | None = None + ): + stack = stack or [] return self.send( "runGetMethod", - {"address": address, "method": method, "stack": params}, + {"address": address, "method": method, "stack": stack}, ) def get_config_param(self, config_param_id): @@ -82,7 +90,7 @@ def get_config_param(self, config_param_id): raise Exception("getConfigParam expected type tvm.cell") if "bytes" not in raw_result["config"]: raise Exception("getConfigParam expected bytes") - return Cell.one_from_boc(base64_to_bytes(raw_result["config"]["bytes"])) + return Cell.one_from_boc(b64str_to_bytes(raw_result["config"]["bytes"])) def get_masterchain_info(self): return self.send("getMasterchainInfo", {})