{"bugs":{"url":"https://github.com/trufflesuite/truffle/issues"},"dist":{"shasum":"76c49b3274d27c8ccabc0cf1fd649826b26a64ff","tarball":"https://registry.npmjs.org/@truffle/abi-utils/-/abi-utils-0.3.1-hardhat-error.0.tgz","fileCount":39,"integrity":"sha512-H6Dq+35MSdArNlC40m3yDmAqA7QunFHdGhBXaQx6HawtSkVPqufS3m8WqzaTbcYvmRRDCT1JBW0nV4BQDaY3ig==","signatures":[{"sig":"MEUCIQC97f5nd1PSuJ+cRJdzk+vEnF0vxiMu90auNiO8NeTnCQIgAzqInUpcB8AYa9MAOgVzMyp53z9eEWFxQkRlj2O++aI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":67737,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjBx8yACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrqLw//ZasDfjiTpzBrgWIhCuEmpqgu7Sw9pavayVTU0btkwLWrkWmS\r\n6bkt5mdjtfbDKQ5brVZ6nDwGInZf71lu53GmzEifSUiDz4B0M8zA0XAe4a4c\r\nLPoEGw/E2gPZ4/wt0CJJhSw7sJXqVW6zWH5pyDWd4BhIES1F/f884fRljyVd\r\nKmfUBtBM5ruGhaLOzVYGO1umqXBBnAq3WZAI1PSIECfMTpMMNRqsKVzszmZm\r\nsE+pQdzXWPg4UHjlKQDSlZpMpevdWPBdGfEZtFllgVq6gBqLt5DnIdvOB0E2\r\nEpr5WX6wJQbAySHTKt1Nuq4l0KlUEbiceOkdeBTkuF80p4QCXcw8MJj0721M\r\nNKSaKnAA9kaygg4Et1DuUX5P2LzwOmGXXBYjjkQqu3AQt2oOytRWNyVEMsc6\r\nhR3rjUNkDfoZ/FkBnCSdD32OFxhK7zXyH1oXdYQVdsq8M5wW4HL0F+RXmtwe\r\nJNcirP2PDWjtlEw0JTP6VaqNx7ky7iShZjs/YCkQq9S5M+8iA+n87fRT4Hwz\r\nfgxcnI76nfx2VKtNT8+FlQu8Tci+hEvItTPq1O00pxdWwX9XhXYCRkq08DZM\r\nT5Mym5Iuy5Rzm7sjJa7Xq7uTNSwKTdijlz6HRR9olSDOQmWbY3IiQsxSoq+C\r\n3rH8Wlt7W2Lb/CsG4O8BbYrqFg1Kfq3fHRQ=\r\n=nzST\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/lib/index.js","name":"@truffle/abi-utils","types":"dist/lib/index.d.ts","author":{"name":"g. nicholas d'andrea","email":"gnidan@trufflesuite.com"},"readme":"# `@truffle/abi-utils`\n\nContains a few utilities for dealing with ABIs.\n\n## Contents\n\nThis package contains a few different components:\n\n- [Normalize ABIs](#normalize-abis)\n- [TypeScript types](#typescript-types)\n- [Selector and signature computation](#selector-and-signature-computation)\n- [Arbitrary random ABIs](#arbitrary-random-abis)\n\n## Normalize ABIs\n\n> ```typescript\n> // handle function entries omitting \"type\" from JSON\n> const isFunctionEntry = entry.type === \"function\" || !(\"type\" in entry);\n>\n> // handle:        v--- new way                           v--- old way     v--- default\n> const isPayable =\n>   entry.stateMutability === \"payable\" || entry.payable || false;\n>\n> // handle \"outputs\" possibly being undefined\n> const outputs = entry.outputs || [];\n> ```\n>\n> _^ Have you ever had to do this sort of thing?_ :scream:\n\nSolidity's official [JSON ABI specification](https://solidity.readthedocs.io/en/v0.7.3/abi-spec.html)\nis rather permissive, since it remains backwards compatible with older\nversions of the language and because it permits omitting fields with default\nvalues. This can get annoying if you're programmatically processing ABIs.\n\n:information_source: This package provides a `normalize` function to purge\nthese kinds of inconsistencies.\n\n```javascript\nconst { normalize } = require(\"@truffle/abi-utils\");\n```\n\n```typescript\nimport { normalize } from \"@truffle/abi-utils\";\n```\n\nSpecifically, this normalizes by:\n\n- Ensuring every ABI entry has a `type` field, since it's optional for\n  `type: \"function\"`\n- Populating default value `[]` for function `outputs` field\n- Removing all instances of the legacy `payable` and `constant` fields\n- Replacing those two fields with the newer `stateMutability` field\n\nTo use, provide the ABI as a JavaScript array, as the sole argument to the\nfunction:\n\n```typescript\n// accepts ABIs from Solidity versions back to 0.4.12 or earlier!\nconst abi = normalize([{\"type\": \"constructor\"/*, ...*/}/*, ...*/);\n\n// don't even worry about it\nconst isFunctionEntry = entry.type === \"function\";\nconst isPayable = entry.stateMutability === \"payable\";\n```\n\n## TypeScript types\n\nThis package exports the following types for **normalized** ABIs.\n\n- `Abi`, to represent the full ABI array\n- `Entry`, to represent items in ABI arrays\n- `FunctionEntry`, to represent named functions\n- `ConstructorEntry`, to represent constructors\n- `FallbackEntry`, to represent old or new fallback functions\n- `ReceiveEntry`, to represent receive functions\n- `Parameter`, to represent parameters defined in entry inputs or outputs\n- `EventParameter`, to represent event parameters\n\nTo use these, you should first call [`normalize`](#normalize-abis), described\nabove.\n\n```typescript\nimport * as Abi from \"@truffle/abi-utils\";\n\nconst abi: Abi.Abi = [{ type: \"constructor\" /*, ...*/ } /*, ...*/];\nconst parameter: Abi.Parameter = {\n  type: \"tuple[]\",\n  components: [\n    /*...*/\n  ]\n};\n// etc.\n```\n\n## Selector and signature computation\n\nThis package exports the following functions for computing signatures and selectors:\n\n- `abiSelector`: This function takes a `FunctionEntry`, `EventEntry`, or\n  `ErrorEntry` and computes its selector, returned as a hex string. This will\n  be 4 bytes for a function or error, and 32 bytes for an event.\n- `abiSignature`: This function takes a `FunctionEntry`, `EventEntry`, or\n  `ErrorEntry` and computes its written-out signature (e.g., `\"setStoredValue(uint256)\"`).\n- `abiTupleSignature`: This function takes a `Parameter[]` and computes the signature\n  of that tuple on its own; e.g., `\"(uint256,string)\"` for a `uint` and a `string`.\n- `abiTypeSignature`: This function takes an individual `Parameter` and computes\n  the signature of that type on its own; e.g., `uint256` for a `uint`.\n\nIn addition, the package also exports the constant `ShortSelectorSize`, which\nis equal to 4 (the number of bytes in a function or event selector).\n\n## Arbitrary random ABIs\n\n_Do you need to test all the different kinds of ABIs, including testing your\nsupport for the various quirks across different Solidity versions?_ :flushed:\n\nYou can use this package for generating all sorts of random ABIs, random ABI\nevents, random ABI parameter values, etc.\n\nThis package provides [fast-check](https://github.com/dubzzz/fast-check)\narbitraries for property-based testing methodologies. If you're not familiar\nwith fast-check or property-based testing, please see the link above for more\ninformation.\n\n```typescript\nimport * as fc from \"fast-check\";\nimport { Arbitrary } from \"@truffle/abi-utils\";\n\n// generate 10 random ABIs\nconst randomAbis = fc.sample(Arbitrary.Abi(), 10);\n```\n\nSee this package's [internal tests for `normalize`](./lib/normalize.test.ts)\nfor example usage in automated tests.\n","gitHead":"f1970ca2361849a1a7d7569d7ddc4db9657c8558","license":"MIT","scripts":{"test":"jest lib/**","build":"tsc","prepare":"yarn build"},"_npmUser":{"name":"gnidan","email":"nick@gnidan.org"},"homepage":"https://github.com/trufflesuite/truffle/tree/master/packages/abi-utils#readme","keywords":["abi","ethereum","solidity"],"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/trufflesuite/truffle.git","type":"git","directory":"packages/abi-utils"},"_npmVersion":"lerna/4.0.0/node@v14.20.0+arm64 (darwin)","description":"Utilities for working with ABIs","directories":{},"maintainers":[{"name":"sukanyaparashar","email":"sukanyaparashar111@gmail.com"},{"name":"cliffoo","email":"cliffzhang08@gmail.com"},{"name":"benjamincburns","email":"benjamin.c.burns@gmail.com"},{"name":"kevinbluer","email":"kevin@bluer.com"},{"name":"tenthirtyone","email":"ASherbuck@gmail.com"},{"name":"lsqproduction","email":"ll@trufflesuite.com"},{"name":"kevinweaver","email":"kevinweaver2@gmail.com"},{"name":"leeftk","email":"leandro.faria@consensys.net"},{"name":"gnidan","email":"nick@gnidan.org"},{"name":"haltman","email":"harry.j.altman@gmail.com"},{"name":"eggplantzzz","email":"pobol234@gmail.com"},{"name":"fainashalts","email":"fainashalts@gmail.com"},{"name":"rkalis","email":"roscokalis@gmail.com"},{"name":"cds-amal","email":"cds.sudama@gmail.com"}],"_nodeVersion":"14.20.0","dependencies":{"faker":"5.5.3","fast-check":"3.1.1","web3-utils":"1.7.4","change-case":"3.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"28.1.3","ts-jest":"28.0.7","ts-node":"10.7.0","typescript":"^4.7.4","@types/jest":"27.4.1","@types/node":"~12.12.0","@types/faker":"^5.1.2","jest-extended":"^0.11.5","@fast-check/jest":"^1.0.1","jest-json-schema":"^2.1.0","@types/jest-json-schema":"^2.1.2","@truffle/contract-schema":"^3.4.9"},"_npmOperationalInternal":{"tmp":"tmp/abi-utils_0.3.1-hardhat-error.0_1661411122371_0.7990807536016227","host":"s3://npm-registry-packages"},"_id":"@truffle/abi-utils@0.3.1-hardhat-error.0","version":"0.3.1-hardhat-error.0"}