Package Exports
- eth-abi-sort
- eth-abi-sort/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eth-abi-sort) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
eth-abi-sort
Sort an Ethereum ABI definition for easier comparison
Installation
npm install --global eth-abi-sortUsage
Sort ABI files in place:
abi-sort abi.jsonOr pipe an ABI into the command and redirect the output to a new file:
abi-sort < abi.json > sorted.jsonIt can also be used programatically:
const sortAbi = require("eth-sort-abi");
const abi = [
// the ABI of a contract
];
const sortedAbi = sortAbi(abi);How it works
The tool will place the events first, then the functions. Each group is sorted by signature, ascending. The signature is computed as "name(type,...)".
Motivation
When EVM contracts are compiled, the ABIs can be obtained. But the order of the descriptors inside the ABI and the order of the properties cannot be guaranteed. Depending on the contract code, compiler and versions used, the ABIs can be created with a different order.
To make comparisons easier, this tool can be used to deterministically sort ABIs.
License
MIT