{"name":"eth-json-rpc-errors","version":"2.0.2","description":"Ethereum JSON RPC and Provider errors.","main":"index.js","scripts":{"test":"node test","test:coverage":"nyc tape test","lint":"eslint index.js","lint:fix":"eslint index.js --fix","prepare":"yarn lint:fix && yarn 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","nyc":"^14.1.1","tape":"^4.11.0"},"dependencies":{"fast-safe-stringify":"^2.0.6"},"gitHead":"352e65b8d85a5845696224faebfb80409179c287","_id":"eth-json-rpc-errors@2.0.2","_nodeVersion":"13.7.0","_npmVersion":"6.13.6","dist":{"integrity":"sha512-uBCRM2w2ewusRHGxN8JhcuOb2RN3ueAOYH/0BhqdFmQkZx5lj5+fLKTz0mIVOzd4FG5/kUksCzCD7eTEim6gaA==","shasum":"c1965de0301fe941c058e928bebaba2e1285e3c4","tarball":"http://registry-npm.ywwl.com/eth-json-rpc-errors/download/eth-json-rpc-errors-2.0.2.tgz","fileCount":16,"unpackedSize":42302,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2qTSCRA9TVsSAnZWagAAIIUP/1Sj1lCIDOLxh8mIGhdz\nDjNgui7v0Bq5EcMYb0vaUOo/OEGwNHzEBLUFfHqYbmVeZsX8j1r+xmkgHqTl\nO7oFyaSuI426fC8eUNISf2dDENqr/0Uz5BvLLXyywmzIhqm0ShtneJxFEYUN\nRoCR0EHGpIfowTiLTbgURbi7+HRefUPhGPJG4gdITSA5MgzaB9NCeNs/jEZm\noOANAYbUftYeB7qnd2VYMXuSqvseoJUab2+nT28PbX5lBz/tl2v1ypYWRp8D\nHYAfanNPLvGy+JsrahrMyX5JPDw+G9dNP44I/IJPycAyF28KB5js1INrWZhm\n86gMaLdotXwBV+XQrYdPleZ1V2N5O/KdF7pkEsXtMf6HCMPYpZCyD84J+aXs\nwVfC8t38L/bf0+eJ9GsfT3kculI2ygQ/qczsqYPavEouRVT+q9QdnNlTUtkH\n3+QeXlbWCcMUc/NP2y1/ZN/Io5/vzSy/V2TOdEuIdL1octeUmnDpGAHUn2oN\n8NVkamI4H+qI/MKQcTDgcsZGX6jfsl9vuLGLE/9h+utIYu9s9rZaAmIQuXKl\nY1z8HcFIzZ6GD1UR1TjDQaI6u7kU7NeOkCbemiJdDABgJRxU30e7hxr+al1l\nYQU/ID8YIfH+xcbmgkC9jigEqxroWKRKkNBH7va6Run0kdJoQ0h2AsiGZHcC\n/+fJ\r\n=FHlc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE3uKkF39X/abNfy+5JH5C2++X9NaQ1mXw3xGrWiv67GAiBR5OlnOzOovb4v17VjgQ2MhJjKFf11TnOs866W+JmdEQ=="}],"size":10059,"noattachment":false,"key":"/eth-json-rpc-errors/-/eth-json-rpc-errors-2.0.2.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_2.0.2_1581531464370_0.5726574181701685"},"_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":1581531464505,"_cnpm_publish_time":1581531464505,"dist-tags":{"latest":"2.0.2"}}