0.2.4 • Published 1 month ago

@lagunagames/abi-compiler v0.2.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

LG ABI Compiler

This tool combines the ABI data from a project's build directory into one combined ABI, for use with projects that use the EIP-2535 "Diamond" pattern, or other proxy architectures.

One or more project folders can be analyzed and processed at a time.

The abi_tool will only include files named *Facet.sol or files starting with Lib*. This will ensure only internal LG methods and events are exposed.


Installation:

npm install @lagunagames/abi-compiler --location=global

Note for Foundry:

Create a script for this plugin in package.json:

    "scripts": {
        "abi-compile": "abi-compiler --path ./ -v"
    },

Basic configuration

Your project structure should look like this:

j:~/best_dapp_ever/ $ tree
├── abiConfig.json
└── src
    ├── contracts
        ├── FacetA.sol
        └── FacetB.sol

Note for Foundry:

Project folders should contain a configuration file named abiConfig.json, use the --config flag to see additional information.

Example abiConfig.json schema:

    {
        "projectName": "projectName",
        "buildDirectory": "build",
        "abiOutputDirectory": "abis",
        "abiConfigurations": [
            {
                "configuration": "name_of_config",
                "minified": false,
                "functionsPrecedence": {
                    "functionName1":"contractName1",
                    "functionName2":"contractName2"
                },
                "eventsPrecedence": {
                    "eventName1":"contractName1",
                    "eventName2":"contractName2"
                },
                "selectorsPrecedence": {
                    "selector1":"contractName1",
                    "selector2":"contractName1",
                    "selector3":"contractName2",
                },
                "contractsToIgnore": [
                    "contractName1",
                    "contractName2"
                ],
                "eventsToIgnore": [
                    "eventName1",
                    "eventName2"
                ],
                "functionsToIgnore": [
                    "functionName1",
                    "functionName2"
                ],
                "selectorsToIgnore": [
                    "selector1"
                    "selector2"
                ],
                "eventsOnly": true,
                "selectorLookup": true
            }
        ]
    }

Usage:

abi-compiler --path PROJECT_DIRECTORY

abi-compiler --path PROJECT_DIRECTORY [--help] [--config]

abi-compiler --path PROJECT_DIRECTORY [--path ADDITIONAL_DIRECTORY] [--report] [--verbose]

NOTE: path defaults to current path, when no path is specified in CLI

abi-compiler --verbose

Arguments:

 -h, --help: Print this message
 -c, --config: Instructions for project configuration
 --path PATH: Path to a project directory to scan.
 -r, --report: Analyze and print the ABI data found in a project
 -d, --dry-run: Preview the ABI structure for the target project(s)
 -v, --verbose: Show maximum logging output
 -q, --quiet: Show minimal logging output
 --ignore-collisions: Do not remove duplicates from collisions
 --quiet-collisions: Do not show collision logging
 -o, --ordered: Order JSON files for easier diffing (slow)

Example

abi-compiler --config

abi-compiler --path ../example/path --verbose

abi-compiler --report

abi-compiler --dry-run

abi-compiler --ignore-collisions

abi-compiler --quiet-collisions

abi-compiler --ordered