From 53aa6ef138853e05e1af360dcabf741e47be6e9a Mon Sep 17 00:00:00 2001 From: nerfZael Date: Tue, 2 Jul 2024 17:29:34 +0200 Subject: [PATCH 1/3] raising not implemented error in abstract methods --- autotx/intents.py | 2 +- autotx/smart_accounts/smart_account.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autotx/intents.py b/autotx/intents.py index 3c824c4..d2d1364 100644 --- a/autotx/intents.py +++ b/autotx/intents.py @@ -28,7 +28,7 @@ class IntentBase(BaseModel): @abstractmethod async def build_transactions(self, web3: Web3, network: NetworkInfo, smart_wallet_address: ETHAddress) -> list[Transaction]: - pass + raise NotImplementedError() class SendIntent(IntentBase): receiver: str diff --git a/autotx/smart_accounts/smart_account.py b/autotx/smart_accounts/smart_account.py index 646d0ac..c4ef3d2 100644 --- a/autotx/smart_accounts/smart_account.py +++ b/autotx/smart_accounts/smart_account.py @@ -21,15 +21,15 @@ def on_intents_prepared(self, intents: list[Intent]) -> None: @abstractmethod async def on_intents_ready(self, intents: list[Intent]) -> bool | str: # True if sent, False if declined, str if feedback - pass + raise NotImplementedError() @abstractmethod async def send_transaction(self, transaction: TransactionBase) -> None: - pass + raise NotImplementedError() @abstractmethod async def send_transactions(self, transactions: list[TransactionBase]) -> None: - pass + raise NotImplementedError() def wait(self, tx_hash: HexBytes) -> TxReceipt: return self.web3.eth.wait_for_transaction_receipt(tx_hash) \ No newline at end of file From 2d84bd2834b035f7a8cacf1ef85b518a1f8f4811 Mon Sep 17 00:00:00 2001 From: nerfZael Date: Tue, 2 Jul 2024 17:29:46 +0200 Subject: [PATCH 2/3] fixed async load tokens --- autotx/load_tokens.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autotx/load_tokens.py b/autotx/load_tokens.py index f020a53..089a633 100644 --- a/autotx/load_tokens.py +++ b/autotx/load_tokens.py @@ -1,3 +1,4 @@ +import asyncio import json from textwrap import dedent from typing import Union @@ -42,5 +43,5 @@ async def fetch_tokens_list() -> None: f.write(content) -async def run() -> None: - await fetch_tokens_list() +def run() -> None: + asyncio.run(fetch_tokens_list()) From 67543aed202b17254281869a3c5de13f5e2d8290 Mon Sep 17 00:00:00 2001 From: nerfZael Date: Tue, 2 Jul 2024 17:30:04 +0200 Subject: [PATCH 3/3] validating chain id --- smart_account_api/src/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smart_account_api/src/index.ts b/smart_account_api/src/index.ts index 423bb1d..3e070b5 100644 --- a/smart_account_api/src/index.ts +++ b/smart_account_api/src/index.ts @@ -40,6 +40,10 @@ app.use((req: Request, res: Response, next: NextFunction) => { app.get("/api/v1/account/address", handleError(async (req: Request, res: Response) => { const chainId = parseInt(req.query.chainId as string); + if (!chainId) { + res.status(400).json({ error: "chainId is required" }); + return; + } const { smartAccount } = await initClientWithAccount(SMART_ACCOUNT_OWNER_PK, chainId); @@ -52,6 +56,10 @@ app.get("/api/v1/account/address", handleError(async (req: Request, res: Respons app.post("/api/v1/account/deploy", handleError(async (req: Request, res: Response) => { const chainId = parseInt(req.query.chainId as string); + if (!chainId) { + res.status(400).json({ error: "chainId is required" }); + return; + } const { smartAccount } = await initClientWithAccount(SMART_ACCOUNT_OWNER_PK, chainId); @@ -64,6 +72,10 @@ app.post("/api/v1/account/deploy", handleError(async (req: Request, res: Respons app.post("/api/v1/account/transactions", handleError(async (req: Request, res: Response, next: NextFunction) => { const chainId = parseInt(req.query.chainId as string); + if (!chainId) { + res.status(400).json({ error: "chainId is required" }); + return; + } const transactions: TransactionDto[] = req.body;