From 14fe310b0c2c37a61afa3b0ff1f9f346322e3b23 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sun, 22 Sep 2024 18:36:07 -0300 Subject: [PATCH] update new pattern --- smartcontracts/deploy.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/smartcontracts/deploy.py b/smartcontracts/deploy.py index ab30281..e1bf932 100644 --- a/smartcontracts/deploy.py +++ b/smartcontracts/deploy.py @@ -1,6 +1,7 @@ """ Automation for update debug section in front-end """ + from dataclasses import dataclass, field from json import dumps, load from typing import List @@ -23,8 +24,7 @@ class Contract: CHAIN_ID = 31337 CONTRACT_SCRIPT_NAME = "deploy.local.s.sol" TRANSACTIONS_PATH = f"broadcast/{CONTRACT_SCRIPT_NAME}/{CHAIN_ID}/run-latest.json" -TARGET_DIR = "../ui/generated/deployedContracts.ts" - +TARGET_DIR = "../ui/contracts/deployedContracts.ts" def abi_path(name) -> str: @@ -44,19 +44,21 @@ def abi_path(name) -> str: contracts.append(Contract(name, address, abi)) -json_config = { - CHAIN_ID: [{"name": "localhost", "chainId": str(CHAIN_ID), "contracts": {}}] -} - +typescript_content = f""" +import {{ GenericContractsDeclaration }} from "~~/utils/scaffold-eth/contract"; -for contract in contracts: - json_config[CHAIN_ID][0]["contracts"][contract.name] = { - "address": contract.address, - "abi": contract.abi, - } +const deployedContracts = {{ + {CHAIN_ID}: {dumps({ + contract.name: { + "address": contract.address, + "abi": contract.abi, + } + for contract in contracts + })} +}} as const; - -typescript_content = f"const deployedContracts = {dumps(json_config)} as const; \n\n export default deployedContracts" +export default deployedContracts satisfies GenericContractsDeclaration; +""" with open(TARGET_DIR, "w") as ts_file: