Skip to content

Commit

Permalink
update new pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
olivmath committed Sep 22, 2024
1 parent 141449e commit 14fe310
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions smartcontracts/deploy.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 14fe310

Please sign in to comment.