Skip to content

Commit 9ea880c

Browse files
dguidoclaude
andauthored
feat: remove truffle export format (#645)
* feat: remove truffle export format Remove the deprecated truffle export format. The truffle export was limited to single compilation units and the Truffle ecosystem has declined. Users needing artifact exports should use the standard or solc formats instead. Fixes #383 Co-Authored-By: Claude Opus 4.5 <[email protected]> * fix: update CI tests to use solc format after truffle export removal Update CI test scripts to use solc export format instead of the removed truffle format. The solc format output is processed by process_combined_solc.js to normalize paths, then compared against expected output. - ci_test_solc.sh: Use solc format with processing - ci_test_solc_multi_file.sh: Use solc format only - ci_test_hardhat_multi_file.sh: Use solc format only - Remove truffle format expected files (A.json, B.json, etc.) - Update solc-demo.json to use normalized solc format output Co-Authored-By: Claude Opus 4.5 <[email protected]> --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent be6bef5 commit 9ea880c

File tree

24 files changed

+7
-76
lines changed

24 files changed

+7
-76
lines changed

crytic_compile/platform/all_export.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
from crytic_compile.platform.archive import export_to_archive
66
from crytic_compile.platform.solc import export_to_solc
77
from crytic_compile.platform.standard import export_to_standard
8-
from crytic_compile.platform.truffle import export_to_truffle
98

109
PLATFORMS_EXPORT = {
1110
"standard": export_to_standard,
1211
"crytic-compile": export_to_standard,
1312
"solc": export_to_solc,
14-
"truffle": export_to_truffle,
1513
"archive": export_to_archive,
1614
}

crytic_compile/platform/truffle.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,57 +30,6 @@
3030
LOGGER = logging.getLogger("CryticCompile")
3131

3232

33-
def export_to_truffle(crytic_compile: "CryticCompile", **kwargs: str) -> list[str]:
34-
"""Export to the truffle format
35-
36-
Args:
37-
crytic_compile (CryticCompile): CryticCompile object to export
38-
**kwargs: optional arguments. Used: "export_dir"
39-
40-
Raises:
41-
InvalidCompilation: If there are more than 1 compilation unit
42-
43-
Returns:
44-
List[str]: Singleton with the generated directory
45-
"""
46-
# Get our export directory, if it's set, we create the path.
47-
export_dir = kwargs.get("export_dir", "crytic-export")
48-
if export_dir and not os.path.exists(export_dir):
49-
os.makedirs(export_dir)
50-
51-
compilation_units = list(crytic_compile.compilation_units.values())
52-
if len(compilation_units) != 1:
53-
raise InvalidCompilation("Truffle export require 1 compilation unit")
54-
compilation_unit = compilation_units[0]
55-
56-
# Loop for each contract filename.
57-
58-
libraries = compilation_unit.crytic_compile.libraries
59-
60-
results: list[dict] = []
61-
for source_unit in compilation_unit.source_units.values():
62-
for contract_name in source_unit.contracts_names:
63-
# Create the informational object to output for this contract
64-
output = {
65-
"contractName": contract_name,
66-
"abi": source_unit.abi(contract_name),
67-
"bytecode": "0x" + source_unit.bytecode_init(contract_name, libraries),
68-
"deployedBytecode": "0x" + source_unit.bytecode_runtime(contract_name, libraries),
69-
"ast": source_unit.ast,
70-
"userdoc": source_unit.natspec[contract_name].userdoc.export(),
71-
"devdoc": source_unit.natspec[contract_name].devdoc.export(),
72-
}
73-
results.append(output)
74-
75-
# If we have an export directory, export it.
76-
77-
path = os.path.join(export_dir, contract_name + ".json")
78-
with open(path, "w", encoding="utf8") as file_desc:
79-
json.dump(output, file_desc)
80-
81-
return [export_dir]
82-
83-
8433
class Truffle(AbstractPlatform):
8534
"""
8635
Truffle platform

scripts/ci_test_hardhat_multi_file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DIR=$(mktemp -d)
66
cp -r tests/hardhat-multi-file "$DIR"
77
cd "$DIR/hardhat-multi-file" || exit 255
88
npm install
9-
crytic-compile --compile-remove-metadata --export-formats solc,truffle .
9+
crytic-compile --compile-remove-metadata --export-format solc .
1010

1111
cd - || exit 255
1212
node tests/process_combined_solc.js "$DIR/hardhat-multi-file/crytic-export/combined_solc.json" "$DIR"

scripts/ci_test_solc.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ DIR=$(mktemp -d)
55

66
cp tests/contract.sol "$DIR"
77
cd "$DIR" || exit 255
8-
crytic-compile contract.sol --compile-remove-metadata --export-format truffle
8+
crytic-compile contract.sol --compile-remove-metadata --export-format solc
99

1010
cd - || exit 255
11-
DIFF=$(diff "$DIR/crytic-export/C.json" tests/expected/solc-demo.json)
11+
node tests/process_combined_solc.js "$DIR/crytic-export/combined_solc.json" "$DIR"
12+
13+
DIFF=$(diff "$DIR/crytic-export/combined_solc.json" tests/expected/solc-demo.json)
1214
if [ "$?" != "0" ] || [ "$DIFF" != "" ]
1315
then
1416
echo "solc test failed"

scripts/ci_test_solc_multi_file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ EOF
3232

3333
cp -r tests/solc-multi-file "$DIR"
3434
cd "$DIR/solc-multi-file" || exit 255
35-
crytic-compile --compile-remove-metadata --export-formats solc,truffle A.sol
35+
crytic-compile --compile-remove-metadata --export-format solc A.sol
3636

3737
cd - || exit 255
3838
node tests/process_combined_solc.js "$DIR/solc-multi-file/crytic-export/combined_solc.json" "$DIR"

tests/expected/hardhat-multi-file/A.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/expected/hardhat-multi-file/B.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/expected/hardhat-multi-file/C.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/expected/hardhat-multi-file/D.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/expected/hardhat-multi-file/E.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)