Skip to content

Commit 0859ff7

Browse files
committed
fix: linters
1 parent 1040929 commit 0859ff7

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

mech_client/marketplace_interact.py

+42-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@
5757
)
5858

5959

60-
PAYMENT_TYPE_NATIVE = "ba699a34be8fe0e7725e93dcbce1701b0211a8ca61330aaeb8a05bf2ec7abed1"
61-
PAYMENT_TYPE_TOKEN = "3679d66ef546e66ce9057c4a052f317b135bc8e8c509638f7966edfd4fcf45e9"
60+
# false positives for [B105:hardcoded_password_string] Possible hardcoded password
61+
PAYMENT_TYPE_NATIVE = (
62+
"ba699a34be8fe0e7725e93dcbce1701b0211a8ca61330aaeb8a05bf2ec7abed1" # nosec
63+
)
64+
PAYMENT_TYPE_TOKEN = (
65+
"3679d66ef546e66ce9057c4a052f317b135bc8e8c509638f7966edfd4fcf45e9" # nosec
66+
)
6267

6368
CHAIN_TO_OLAS = {
6469
1: "0x0001A500A6B18995B03f44bb040A5fFc28E45CB0",
@@ -98,6 +103,18 @@ def fetch_mech_info(
98103
mech_marketplace_contract: Web3Contract,
99104
priority_mech_service_id: int,
100105
) -> Tuple[str, str]:
106+
"""
107+
Fetchs the info of the requested mech.
108+
109+
:param ledger_api: The Ethereum API used for interacting with the ledger.
110+
:type ledger_api: EthereumApi
111+
:param mech_marketplace_contract: The mech marketplace contract instance.
112+
:type mech_marketplace_contract: Web3Contract
113+
:param priority_mech_service_id: Service id of the request mech
114+
:type priority_mech_service_id: int
115+
:return: The mech info containing payment_type and mech_payment_balance_tracker.
116+
:rtype: Tuple[str,str]
117+
"""
101118
priority_mech_address = mech_marketplace_contract.functions.mapServiceIdMech(
102119
priority_mech_service_id
103120
).call()
@@ -135,7 +152,23 @@ def approve_price_tokens(
135152
olas: str,
136153
mech_payment_balance_tracker: str,
137154
price: int,
138-
):
155+
) -> str:
156+
"""
157+
Sends the approve tx for olas token of the sender to the requested mech's balance payment tracker contract.
158+
159+
:param crypto: The Ethereum crypto object.
160+
:type crypto: EthereumCrypto
161+
:param ledger_api: The Ethereum API used for interacting with the ledger.
162+
:type ledger_api: EthereumApi
163+
:param olas: The olas token contract address.
164+
:type olas: str
165+
:param mech_payment_balance_tracker: Requested mech's balance tracker contract address
166+
:type mech_payment_balance_tracker: str
167+
:param price: Amount of olas to approve
168+
:type price: int
169+
:return: The transaction digest.
170+
:rtype: str
171+
"""
139172
sender = crypto.address
140173

141174
with open(Path(__file__).parent / "abis" / "IToken.json", encoding="utf-8") as f:
@@ -149,7 +182,7 @@ def approve_price_tokens(
149182
f" - Sender Token balance low. Needed: {price}, Actual: {user_token_balance}"
150183
)
151184
print(f" - Sender Address: {sender}")
152-
return None
185+
sys.exit(1)
153186

154187
tx_args = {"sender_address": sender, "value": 0, "gas": 60000}
155188
raw_transaction = ledger_api.build_transaction(
@@ -338,7 +371,7 @@ async def _wait_for_tasks() -> Any: # type: ignore
338371
return result
339372

340373

341-
def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals
374+
def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals, too-many-statements
342375
prompt: str,
343376
tool: Optional[str] = None,
344377
extra_attributes: Optional[Dict[str, Any]] = None,
@@ -430,10 +463,13 @@ def marketplace_interact( # pylint: disable=too-many-arguments, too-many-locals
430463
)
431464

432465
print("Fetching Mech Info...")
466+
priority_mech_service_id = cast(
467+
int, mech_marketplace_config.priority_mech_service_id
468+
)
433469
(payment_type, mech_payment_balance_tracker) = fetch_mech_info(
434470
ledger_api,
435471
mech_marketplace_contract,
436-
mech_marketplace_config.priority_mech_service_id,
472+
priority_mech_service_id,
437473
)
438474

439475
price = mech_config.price or 10_000_000_000_000_000

scripts/whitelist.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
directory # unused attribute (mech_client/acn.py:85)
22
directory # unused attribute (mech_client/acn.py:100)
3-
directory # unused attribute (mech_client/acn.py:116)
3+
directory # unused attribute (mech_client/acn.py:116)
4+
payment_data # unused variable (mech_client/interact.py:111)

0 commit comments

Comments
 (0)