Skip to content

Instantly share code, notes, and snippets.

@cds-amal
Created July 9, 2021 14:19
Show Gist options
  • Save cds-amal/3d8a80af39daac07f9147b614f7f819f to your computer and use it in GitHub Desktop.
Save cds-amal/3d8a80af39daac07f9147b614f7f819f to your computer and use it in GitHub Desktop.
const sig_type = (o) =>
o.name.trim() === "" ? `${o.type}` : `${o.name}: ${o.type}`;
// converts inputs object into (name : type, ... )
// skips internal type
//
const expand_io = (o) => o.map((param) => sig_type(param)).join(", ");
const abi = (contract) => {
const funcs = contract.abi.filter((x) => x.type === "function");
order = ["name", "inputs", "outputs", "payable", "signature", "constant"];
console.table(
funcs.map((f) => ({
...f,
inputs: expand_io(f.inputs),
outputs: expand_io(f.outputs),
})),
order,
);
};
module.exports = {
abi,
log: (msg) => console.log("config:", msg),
accounts: ["PWNED"],
checkcheck: () => console.log("loaded from snippets folder"),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment