{"name":"eth-json-rpc-errors","version":"0.3.1","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"},"gitHead":"ea8a2c0b1416901234678e9e3afdea7e1dfda685","_id":"eth-json-rpc-errors@0.3.1","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-TUBUzAzl0ccQ94ygajkUUctw6Gql0PbgK5J7tD6v9hGk2yKiML+U6HjG9up2AMe15dlMQW33zDjwAerNjDRsYQ==","shasum":"fd8a3b21a14ed0a3dceb257a61c3ced28cd8b0b0","tarball":"http://registry-npm.ywwl.com/eth-json-rpc-errors/download/eth-json-rpc-errors-0.3.1.tgz","fileCount":15,"unpackedSize":26098,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdTfJwCRA9TVsSAnZWagAAyMsP/Rh6Gg9uzaRzljRCBq1I\nqy5ZbdNMyDi+e9XDvzJpZM9LArkwV6drRpdsuga5ajI+dRxikTq0IttDRe9q\nE+C1JMuQqtOo9SdT4o2jMgEM88gNFsG/PK7wROj7QFUk7Cwtd1D2Agy5pNsH\nzpHydqB8w8fRlQ3giobW52k9WYZpgH1FJRpt4LBGV3wMj8AW4B/d/YjD/pZq\nZrMac9DDpU3hnjLfq9Kv8/2Z3hLGLZFH5qLH5Y1LmMo/jC4T6/831AXfp/VJ\nd4zhtfAVfKFuNraF0frCOj8gagU1a5bYmc8kYuwE6EtPWEHhjcnwwtwJ/jNz\n4IPpkO5f6abilfEB1PXVCrPTsfRP90s1mDnhsAL93xr4OMuHnFguc7Uyv8bR\nY1hKc3LAljNYr8AN2ApACHLFfpy6fOKrfYtYuI8Tg2uaoBP8nxy73rqVbKQN\no8+YLtGlv32VMpgYmZNu4BJUwyNMy5bYrBM1p7VSewpiDRaHkReOLuloJhZX\nnPAO/2Zf2mARPz2jORLCa8Mw3S3s42x6jpG8K64zGm7MvfGVvctq3mZqruYf\noWO0Jv2C8xCxIeajlsLMXfrX1NJpcRxCTaoDTYlYm2pRsM2KFCoCLe/fQl7Q\noUTMzi1KjW1Ods50unetcDwC59x1/uwmAJicbtVZU35PE34jhCiD1j2Fsgbl\n0C0W\r\n=rOdM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFnhupP6z4T3ne2A/2cDbp+59Oew26bipVb78b+rL5/EAiEA0ItsG+cy+aLzhmEKKl/0INb/zSipWRieD8/Xiv8s7v0="}],"size":7499,"noattachment":false,"key":"/eth-json-rpc-errors/-/eth-json-rpc-errors-0.3.1.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_0.3.1_1565389423778_0.18653400281832888"},"_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":1565389423949,"_cnpm_publish_time":1565389423949,"dist-tags":{"latest":"2.0.2"}}