{"_id":"@1hive/radspec","_rev":"4-cb0ba161803b8edc14559d8ff5c83b67","name":"@1hive/radspec","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"@1hive/radspec","version":"2.0.0","description":"Radspec is a safe alternative to Ethereum's natspec","main":"dist/index.js","scripts":{"docs":"documentation build src/index.js -f md -o docs/API.md --shallow","lint":"standard \"src/**/*.js\" && documentation lint \"src/**/*.js\"","test":"nyc ava","test:coverage":"nyc --all --reporter=lcov --reporter=text-summary --reporter=html npm test","build":"babel src -d dist -s","prepublishOnly":"env NODE_ENV=production npm run build"},"repository":{"type":"git","url":"git+https://github.com/aragon/radspec.git"},"keywords":["language","compiler","ethereum"],"author":{"name":"Aragon Association","email":"legal@aragon.org"},"license":"MIT","bugs":{"url":"https://github.com/aragon/radspec/issues"},"homepage":"https://github.com/aragon/radspec#readme","devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/plugin-transform-runtime":"^7.1.0","@babel/preset-env":"^7.1.0","@babel/register":"^7.10.1","ava":"^3.8.2","babel-eslint":"^10.0.1","babel-preset-minify":"^0.5.0","codecov":"^3.6.5","documentation":"^13.0.1","nyc":"^14.1.1","standard":"^12.0.1"},"dependencies":{"@babel/runtime":"^7.1.2","date-fns":"^2.26.0","ethers":"^5.0.0"},"ava":{"require":["@babel/register"]},"standard":{"parser":"babel-eslint"},"gitHead":"eb0404eec1bb60d3c18cd481b17c40a113087203","_id":"@1hive/radspec@2.0.0","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"integrity":"sha512-OwYb0K7MNgda1310D6vRG9XyuupoAKrKHApBktT2N4c5VYnEBBhSQLYeGzwBXqHJ/WrTXvWJAkLPwrQHbqbxOg==","shasum":"add8e83aaf4e0de0ff2ffbd2428dfeb024a98762","tarball":"https://registry.npmjs.org/@1hive/radspec/-/radspec-2.0.0.tgz","fileCount":71,"unpackedSize":174534,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpDmnCRA9TVsSAnZWagAAdAMP/39B0Ny+ydkwwa0PxGSB\ncXqX3xJlq63kzpwEgeLbm7QnZ8wmibMlYsOCbe1M4NN/vu24Qq+slC2M0j7W\nNzI+OJ66GB3dU9GK0or1XxCb+sMH5yDdEzKNb/D7ZlbynkWlclLviJ9FiDsK\nOXODa2AkucFizUuPiUXWrjO+hmDEUoWzzfI//hXZX+g7wLr/4YtPQf1pWCI3\nunvGPyc8FOiJ83oc6NjHv9Nh2DV7z20oWtQFqgdCV7sjAi4O9npqXhUr6gqz\nmRIrH325Iiemo4d8its6afkQiFdXAeuvRDDeEnB2x6RmYkjXkDeLoXwsqn9n\nlwxikHoMEXNo9pCtqWu0Vk5zmAW6znTg6JfeH4tzNz2dCCUi3sHVvFJV2ImA\nCopkfnI5ruW/anAXl6XUOaDK9MdDRoS2DrgdGYnmyve83bNUtyfEm1FWnKHI\ngpO2d6A+7bXG8fO+h/e4Al6m51v3lpFY5UlpGkhh7xgbsB6h8lhKv81PhB3q\ndX2DWX8xxCGxvTaWolmnYJjD9scbSIWZ+24iUrIj9kEGK2vG4JclP2TwUbAm\nZOIO+NFwo9LvcqT4UhiL0r3PyhRKUx09haycnbhKmspVBm+OAtFfFhKwSAJC\nUF1whvruh3v1+KrRae4LdiYUGniKKh5bSGdFTThqymwCWXMENtIaWRtujNyJ\nuvEn\r\n=7fwR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAwllWwGz51F9/ZIVMV3kyJO2QZAnIWhPWxCAFEdo4BfAiEApVhH6iZfWdS2QUS2YOXSq1LvpDj4y+z8lm/vLNle/4s="}]},"_npmUser":{"name":"gabrielg","email":"gabrielpk.18@gmail.com"},"directories":{},"maintainers":[{"name":"pcolombo","email":"paulo.colombo@pm.me"},{"name":"gabrielg","email":"gabrielpk.18@gmail.com"},{"name":"fabriv","email":"fabriziovigevani@gmail.com"},{"name":"starsower","email":"sembrestels@gmail.com"},{"name":"willjgriff","email":"willjgriff@gmail.com"},{"name":"rperez89","email":"rodrigopi1989@gmail.com"},{"name":"crisog","email":"ortega.cpp@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/radspec_2.0.0_1638152615082_0.9457784533545686"},"_hasShrinkwrap":false},"2.0.1":{"name":"@1hive/radspec","version":"2.0.1","description":"Radspec is a safe alternative to Ethereum's natspec","main":"dist/index.js","scripts":{"docs":"documentation build src/index.js -f md -o docs/API.md --shallow","lint":"standard \"src/**/*.js\" && documentation lint \"src/**/*.js\"","test":"nyc ava","test:coverage":"nyc --all --reporter=lcov --reporter=text-summary --reporter=html npm test","build":"babel src -d dist -s","prepublishOnly":"env NODE_ENV=production npm run build"},"repository":{"type":"git","url":"git+https://github.com/aragon/radspec.git"},"keywords":["language","compiler","ethereum"],"author":{"name":"Aragon Association","email":"legal@aragon.org"},"license":"MIT","bugs":{"url":"https://github.com/aragon/radspec/issues"},"homepage":"https://github.com/aragon/radspec#readme","devDependencies":{"@babel/cli":"^7.1.2","@babel/core":"^7.1.2","@babel/plugin-proposal-object-rest-spread":"^7.0.0","@babel/plugin-transform-runtime":"^7.1.0","@babel/preset-env":"^7.1.0","@babel/register":"^7.10.1","ava":"^3.8.2","babel-eslint":"^10.0.1","babel-preset-minify":"^0.5.0","codecov":"^3.6.5","documentation":"^13.0.1","nyc":"^14.1.1","standard":"^12.0.1"},"dependencies":{"@babel/runtime":"^7.1.2","date-fns":"^2.26.0","ethers":"^5.0.0"},"ava":{"require":["@babel/register"]},"standard":{"parser":"babel-eslint"},"gitHead":"74a36cd839a9af19cb2737f3c7459e95409fcb30","_id":"@1hive/radspec@2.0.1","_nodeVersion":"16.16.0","_npmVersion":"8.16.0","dist":{"integrity":"sha512-XyYUU3y9IUdyzM8QB1u9VC/+AOMlvb7SvzFCn7P/KzJCLFLKKe737hm2UMvhl4sWPFYaLweyEpdyZ5VVsNtSVQ==","shasum":"2a20980ca442038a6a2570a7d51ff167c31ebd14","tarball":"https://registry.npmjs.org/@1hive/radspec/-/radspec-2.0.1.tgz","fileCount":71,"unpackedSize":174480,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBva86WGmljHr70XycIdftzHiZaP8n0guNcvKcROC1isAiBsk0eCGGSzhPj/lMO6440mlTMKOxnJ2A4LmGIIk0e0DA=="}]},"_npmUser":{"name":"gabrielg","email":"gabrielpk.18@gmail.com"},"directories":{},"maintainers":[{"name":"kamikazebr","email":"windholyghost@gmail.com"},{"name":"pcolombo","email":"paulo.colombo@pm.me"},{"name":"gabrielg","email":"gabrielpk.18@gmail.com"},{"name":"fabriv","email":"fabriziovigevani@gmail.com"},{"name":"starsower","email":"sembrestels@gmail.com"},{"name":"willjgriff","email":"willjgriff@gmail.com"},{"name":"rperez89","email":"rodrigopi1989@gmail.com"},{"name":"crisog","email":"ortega.cpp@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/radspec_2.0.1_1698458846153_0.5630341807419259"},"_hasShrinkwrap":false}},"time":{"created":"2021-11-29T02:23:35.039Z","2.0.0":"2021-11-29T02:23:35.275Z","modified":"2024-05-01T23:03:50.656Z","2.0.1":"2023-10-28T02:07:26.408Z"},"maintainers":[{"email":"windholyghost@gmail.com","name":"kamikazebr"},{"email":"gabrielpk.18@gmail.com","name":"gabrielg"},{"email":"fabriziovigevani@gmail.com","name":"fabriv"},{"email":"sembrestels@gmail.com","name":"starsower"},{"email":"willjgriff@gmail.com","name":"willjgriff"},{"email":"rodrigopi1989@gmail.com","name":"rperez89"}],"description":"Radspec is a safe alternative to Ethereum's natspec","homepage":"https://github.com/aragon/radspec#readme","keywords":["language","compiler","ethereum"],"repository":{"type":"git","url":"git+https://github.com/aragon/radspec.git"},"author":{"name":"Aragon Association","email":"legal@aragon.org"},"bugs":{"url":"https://github.com/aragon/radspec/issues"},"license":"MIT","readme":"# radspec 🤘\n\n[![Travis branch](https://img.shields.io/travis/aragon/radspec/master.svg?style=flat-square)](https://travis-ci.org/aragon/radspec)\n[![Coveralls github branch](https://img.shields.io/coveralls/github/aragon/radspec/master.svg?style=flat-square)](https://coveralls.io/github/aragon/radspec)\n\nRadspec is a safe interpreter for dynamic expressions in Ethereum's [NatSpec](https://github.com/ethereum/wiki/wiki/Ethereum-Natural-Specification-Format).\n\nThis allows smart contact developers to show improved function documentation to end users, without the [security pitfalls of natspec.js](#aside-why-is-natspecjs-unsafe). Radspec defines its own syntax structure and parses its own AST rather than directly evaluating untrusted JavaScript.\n\n<img height=\"250\" src=\".github/assets/metamask_example.png\" />\n\n## Features\n\n- **Expressive**: Show relevant details to smart contract end-users at the time they make transactions.\n- **External calls**: Radspec can query other contracts.\n- **Safe**: Radspec requires no DOM access or untrusted JavaScript evaluation.\n- **Compatible**: Most existing NatSpec dynamic expressions are compatible with Radspec.\n\n## Introduction & quick start\n\nRadspec supports any contract programming language, such as Solidity or Vyper because radspec works on the compiled JSON ABI. Here is an example using Solidity.\n\n```solidity\npragma solidity ^0.5.0;\n\ncontract Tree {\n    /// @notice Set the tree age to `numYears` years\n    function setAge(uint256 numYears) external {\n        // set the age into storage\n    }\n}\n```\n\nNotice the *dynamic expression* documentation for the `setAge` function. When presented to the end user, this will render based on the inputs provided by the user. For example, if the end user is calling the contract with an input of 10 years, this will be rendered by radspec as:\n\n> Set the tree age to 10 years\n\nUse the Solidity compiler to generate user documentation and ABI with:\n\n```sh\nsolc --userdoc --abi tree.sol\n```\n\nThis produces the outputs:\n\n```json\n{\n  \"methods\" :\n  {\n    \"setAge(uint256)\" :\n    {\n      \"notice\" : \"Set the tree age to `numYears` years\"\n    }\n  }\n}\n\n```\n\nand\n\n```json\n[{\n  \"constant\":false,\n  \"inputs\":[{\"name\":\"numYears\",\"type\":\"uint256\"}],\n  \"name\":\"setAge\",\n  \"outputs\":[],\n  \"payable\":false,\n  \"stateMutability\":\"nonpayable\",\n  \"type\":\"function\"\n}]\n```\n\nNote you can also use [Human-Redable abis](https://blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917). For the above example that would be:\n\n```json\n[\"function setAge(uint256 numYears) public view\"]\n```\n---\n\nWrite a simple tool using radspec to interpret this:\n\n```js\nimport radspec from 'radspec'\n\n// Set userDoc and ABI from above\nconst expression = userDoc.methods[\"setAge(uint256)\"].notice\nconst call = {\n  abi: abi,\n  transaction: {\n    to: '0x8521742d3f456bd237e312d6e30724960f72517a',\n    data: '0xd5dcf127000000000000000000000000000000000000000000000000000000000000000a'\n  }\n}\nradspec.evaluate(expression, call)\n  .then(console.log) // => \"Set the tree age to 10 years\"\n```\n\nOr see more examples [here](examples) and in the [tests](test/examples/examples.js).\n\nPlease let us know if there's anything else you'd like Radspec to be able to evaluate by filing an [issue](https://github.com/aragon/radspec/issues/new)!\n\n## Installation\n\nSimply use your favorite Node.js package manager:\n\n```sh\nnpm i radspec\n```\n\n## Documentation\n\nDocumentation about radspec and the internals of radspec can be found [here](docs).\n\n## Contributing\n\nTBD\n\n## Aside: Why is natspec.js unsafe?\n\n[natspec.js](https://github.com/ethereum/natspec.js) accepts any valid JavaScript. There are multiple reasons this is a bad idea:\n\n1. You either need to write your own JavaScript VM or use `eval` (unsafe!) from inside JavaScript\n2. A fully-featured language with classes, functions and much more is absolutely overkill for something that could be solved with a simple DSL.\n\nAs dapps become increasingly complex, it is paramount that tools are written in a way that makes phishing near impossible. Evaluating JavaScript directly makes opens your dapp up to cross-site scripting attacks by users merely submitting a transaction(!).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}