@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
146 lines • 6.14 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserRejectedRequestError = exports.UnsupportedMethodError = exports.UnauthorizedError = exports.DisconnectedError = exports.ChainDisconnectedError = exports.TransactionRejected = exports.ResourceUnavailableError = exports.ResourceNotFoundError = exports.ParseError = exports.MethodNotSupportedError = exports.MethodNotFoundError = exports.LimitExceededError = exports.InvalidRequestError = exports.InvalidParamsError = exports.InvalidInputError = exports.InternalError = void 0;
const rpc_errors_1 = require("@metamask/rpc-errors");
const internals_1 = require("./internals/index.cjs");
/**
* A JSON-RPC 2.0 Internal (-32603) error.
*
* This can be thrown by a Snap to indicate that an internal error occurred,
* without crashing the Snap.
*
* @see https://www.jsonrpc.org/specification#error_object
*/
exports.InternalError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.internal);
/**
* An Ethereum JSON-RPC Invalid Input (-32000) error.
*
* This can be thrown by a Snap to indicate that the input to a method is
* invalid, without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
*/
exports.InvalidInputError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.invalidInput);
/**
* A JSON-RPC 2.0 Invalid Params (-32602) error.
*
* This can be thrown by a Snap to indicate that the parameters to a method are
* invalid, without crashing the Snap.
*
* @see https://www.jsonrpc.org/specification#error_object
*/
exports.InvalidParamsError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.invalidParams);
/**
* A JSON-RPC 2.0 Invalid Request (-32600) error.
*
* This can be thrown by a Snap to indicate that the request is invalid, without
* crashing the Snap.
*
* @see https://www.jsonrpc.org/specification#error_object
*/
exports.InvalidRequestError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.invalidRequest);
/**
* An Ethereum JSON-RPC Limit Exceeded (-32005) error.
*
* This can be thrown by a Snap to indicate that a limit has been exceeded,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
*/
exports.LimitExceededError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.limitExceeded);
/**
* An Ethereum JSON-RPC Method Not Found (-32601) error.
*
* This can be thrown by a Snap to indicate that a method does not exist,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
*/
exports.MethodNotFoundError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.methodNotFound);
/**
* An Ethereum JSON-RPC Method Not Supported (-32004) error.
*
* This can be thrown by a Snap to indicate that a method is not supported,
* without crashing the Snap.
*/
exports.MethodNotSupportedError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.methodNotSupported);
/**
* A JSON-RPC 2.0 Parse (-32700) error.
*
* This can be thrown by a Snap to indicate that a request is not valid JSON,
* without crashing the Snap.
*
* @see https://www.jsonrpc.org/specification#error_object
*/
exports.ParseError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.parse);
/**
* An Ethereum JSON-RPC Resource Not Found (-32001) error.
*
* This can be thrown by a Snap to indicate that a resource does not exist,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
*/
exports.ResourceNotFoundError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.resourceNotFound);
/**
* An Ethereum JSON-RPC Resource Unavailable (-32002) error.
*
* This can be thrown by a Snap to indicate that a resource is unavailable,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
*/
exports.ResourceUnavailableError = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.resourceUnavailable);
/**
* An Ethereum JSON-RPC Transaction Rejected (-32003) error.
*
* This can be thrown by a Snap to indicate that a transaction was rejected,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1474#error-codes
*/
exports.TransactionRejected = (0, internals_1.createSnapError)(rpc_errors_1.rpcErrors.transactionRejected);
/**
* An Ethereum Provider Chain Disconnected (4901) error.
*
* This can be thrown by a Snap to indicate that the provider is disconnected
* from the requested chain, without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
*/
exports.ChainDisconnectedError = (0, internals_1.createSnapError)(rpc_errors_1.providerErrors.chainDisconnected);
/**
* An Ethereum Provider Disconnected (4900) error.
*
* This can be thrown by a Snap to indicate that the provider is disconnected,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
*/
exports.DisconnectedError = (0, internals_1.createSnapError)(rpc_errors_1.providerErrors.disconnected);
/**
* An Ethereum Provider Unauthorized (4100) error.
*
* This can be thrown by a Snap to indicate that the requested method / account
* is not authorized by the user, without crashing the Snap.
*/
exports.UnauthorizedError = (0, internals_1.createSnapError)(rpc_errors_1.providerErrors.unauthorized);
/**
* An Ethereum Provider Unsupported Method (4200) error.
*
* This can be thrown by a Snap to indicate that the requested method is not
* supported by the provider, without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
*/
exports.UnsupportedMethodError = (0, internals_1.createSnapError)(rpc_errors_1.providerErrors.unsupportedMethod);
/**
* An Ethereum Provider User Rejected Request (4001) error.
*
* This can be thrown by a Snap to indicate that the user rejected the request,
* without crashing the Snap.
*
* @see https://eips.ethereum.org/EIPS/eip-1193#provider-errors
*/
exports.UserRejectedRequestError = (0, internals_1.createSnapError)(rpc_errors_1.providerErrors.userRejectedRequest);
//# sourceMappingURL=error-wrappers.cjs.map