{"name":"eth-json-rpc-errors","version":"1.1.0","description":"Ethereum JSON RPC errors and standard JSON RPC 2.0 errors.","main":"index.js","scripts":{"test":"node test","lint":"eslint index.js","lint:fix":"eslint index.js --fix","prepare":"npm run lint:fix && npm run test"},"repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-json-rpc-errors.git"},"keywords":["json","rpc","ethereum","errors","utility"],"author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"license":"MIT","bugs":{"url":"https://github.com/MetaMask/eth-json-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-json-rpc-errors#readme","devDependencies":{"eslint":"^6.1.0","fast-deep-equal":"^2.0.1","tape":"^4.11.0"},"dependencies":{"fast-safe-stringify":"^2.0.6"},"gitHead":"399807e9d210380e277ea0d905b042b2f6469093","_id":"eth-json-rpc-errors@1.1.0","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-AAA76BmwwSR5Mws+ivZUYxoDwMygDuMWxSTEmqDXhRPTExSWe5wuJLT/rSfvPSy9+owSudy67JmyRQ02RAOOYQ==","shasum":"2a4291fb20c0483c99b53286a814ed14ca4efb2e","tarball":"http://registry-npm.ywwl.com/eth-json-rpc-errors/download/eth-json-rpc-errors-1.1.0.tgz","fileCount":15,"unpackedSize":31962,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdgBUVCRA9TVsSAnZWagAAH0YP/jqCUyijnl9BFbZb6EDa\n55CEQYDFbTicazhqxq3MgurfdKzoFlGOMq66mBEZFYN5amYJbgA0sqKL2QeI\ni0i8VDgS/9EJasluJ8+IgM+UjO6cCKmMYGwDYOCGReS5d3BoPf9z4GqF79Pv\nA7xyY7w65hWDVS6OqUdEPnet1oWfjLx4jxTLV2wJztedZZb2SGJHrJgBt8UC\nlAW2JtZvD+pIzvjCyYzq6KDawsLjRFMbYWapEp2XExT4/6IMRiS8u6bXjFmx\nuE/S6yyeWnu5fb9+wsRTtT6zatcJoEEm/30MA5AxLEqYkDxVIEQ4w/iS5CKy\nq6v+uKqd8iFtkEFwGAxZ+aM1NjzCMyNFSZQGFj0AWbSOOSzkXupE3XY7A1/0\nnQ406ac9jAk/lxYHO8+VZ1mUCxqsFKUiZRA24g38r8GxcBm+5Ngf1DVIqaWt\nnmdYmNV0jX86XrwqzOAFkGa80R/NYuk/Cne/x1yYtdbK8UiiTfF/qQfRMVry\nmM3kC74ltsmIxe5orkNh7KmWIqhH1TqH3wj89Sf9oxQzYwsAN0JjslANDvrB\nnK5VDj/R5sIjP+AoeMbIOUS0oO3KezfMpKh4HMuktOVGmIaA32WyYUbtsgE/\nOELniij7nP7QqTyYEId27YlNP8uzQbYpEdgEl0uF0MkWDLGat7y8bWYf0dhv\n3PMv\r\n=ZnAv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9EGImwLdVZLsiVSPFWWkmhVGPwxs5ZCWyaJ67ATKgBgIgQ01n4LSwmwjQz2slukhbdbvTNwv/RtBczEj5beCk5OE="}],"size":8270,"noattachment":false,"key":"/eth-json-rpc-errors/-/eth-json-rpc-errors-1.1.0.tgz"},"maintainers":[{"name":"rekmarks","email":"rekmarks@protonmail.com"}],"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-json-rpc-errors_1.1.0_1568675093330_0.9305676661993039"},"_hasShrinkwrap":false,"deprecated":"Package renamed: https://www.npmjs.com/package/eth-rpc-errors","readme":"# eth-json-rpc-errors\n\nErrors for the\n[Ethereum JSON RPC](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md)\nand\n[Ethereum Provider](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md),\nand [making unknown errors compliant with either spec](#parsing-unknown-errors).\n\n## Basic Usage\n\n```js\nimport { ethErrors } from 'eth-json-rpc-errors'\n\nthrow ethErrors.provider.unauthorized()\n// or\nthrow ethErrors.provider.unauthorized('my custom message')\n```\n\n## Supported Errors\n\n- Ethereum JSON RPC\n  - Per [EIP 1474](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md#error-codes)\n    - This includes all\n    [JSON RPC 2.0 errors](https://www.jsonrpc.org/specification#error_object)\n- Ethereum Provider errors\n  - Per [EIP 1193](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#error-object-and-codes)\n    - Does **not** yet support [`CloseEvent` errors or status codes](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes).\n\n## Usage\n\nInstallation: `npm install eth-json-rpc-errors` or `yarn add eth-json-rpc-errors`\n\nImport using ES6 syntax (no default export) or Node `require`.\n\n### Errors API\n\n```js\nimport { ethErrors } from 'eth-json-rpc-errors'\n\n// Ethereum RPC errors are namespaced under \"ethErrors.rpc\"\nresponse.error = ethErrors.rpc.methodNotFound({\n  message: optionalCustomMessage, data: optionalData\n})\n\n// ETH JSON RPC errors namespaced under ethErrors.provider\nresponse.error = ethErrors.provider.unauthorized({\n  message: optionalCustomMessage, data: optionalData\n})\n\n// each error getter takes a single \"opts\" argument\n// for most errors, this can be replaced with a single string, which becomes\n// the error message\nresponse.error = ethErrors.provider.unauthorized(customMessage)\n\n// if an error getter accepts a single string, all arguments can be omitted\nresponse.error = ethErrors.provider.unauthorized()\nresponse.error = ethErrors.provider.unauthorized({})\n\n// omitting the message will produce an error with a default message per\n// the relevant spec\n\n// omitting the data argument will produce an error without a\n// \"data\" property\n\n// the JSON RPC 2.0 server error requires a valid code\nresponse.error = ethErrors.rpc.server({\n  code: -32031\n})\n\n// custom Ethereum Provider errors require a valid code and message\n// valid codes are integers i such that: 1000 <= i <= 4999\nresponse.error = ethErrors.provider.custom({\n  code: 1001, message: 'foo'\n})\n```\n\n### Parsing Unknown Errors\n\n```js\n// this is useful for ensuring your errors are standardized\nimport { serializeError } from 'eth-json-rpc-errors'\n\n// if the argument is not a valid error per any supported spec,\n// it will be added as error.data.originalError\nresponse.error = serializeError(maybeAnError)\n\n// you can add a custom fallback error code and message if desired\nconst fallbackError = { code: 4999, message: 'My custom error.' }\nresponse.error = serializeError(maybeAnError, fallbackError)\n\n// Note: if the original error has a \"message\" property, it will take\n// precedence over the fallback error's message\n\n// the default fallback is:\n{\n  code: -32603,\n  message: 'Internal JSON-RPC error.'\n}\n```\n\n### Other Exports\n\n```js\n/**\n * TypeScript interfaces\n */\nimport {\n  // these describe to the corresponding exports from index.js\n  IEthErrors, IEthereumRpcError, IEthereumProviderError, ISerializeError,\n  // these describe the options argument to error getters in ethErrors\n  IErrorOptions, IRpcServerErrorOptions, IProviderCustomErrorOptions\n} from 'eth-json-rpc-errors/@types'\n\n/**\n * Classes\n */\nimport { EthereumRpcError, EthereumProviderError } from 'eth-json-rpc-errors'\n\n/**\n * getMessageFromCode & ERROR_CODES\n */\nimport { getMessageFromCode, ERROR_CODES } from 'eth-json-rpc-errors'\n\n// get the default message string for the given code, or a fallback message if\n// no message exists for the given code\nconst message1 = getMessageFromCode(someCode)\n\n// you can specify your own fallback message\nconst message2 = getMessageFromCode(someCode, myFallback)\n// it can be anything, use at your own peril\nconst message3 = getMessageFromCode(someCode, null)\n\n// {\n//   jsonRpc: { [errorName]: code, ... },\n//   eth: { [errorName]: code, ... },\n// }\nconst code1 = ERROR_CODES.rpc.parse\nconst code2 = ERROR_CODES.provider.userRejectedRequest\n\n// all codes in ERROR_CODES have default messages\nconst message4 = getMessageFromCode(code1)\nconst message5 = getMessageFromCode(code2)\n```\n\n## License\n\nMIT\n","publish_time":1568675093425,"_cnpm_publish_time":1568675093425,"dist-tags":{"latest":"2.0.2"}}