@thirdweb-dev/wallets
Version:
<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a href="ht
110 lines (105 loc) • 3.07 kB
JavaScript
import { _ as _defineProperty } from './defineProperty-c8ecdc07.browser.esm.js';
/**
* Error subclass implementing JSON RPC 2.0 errors and Ethereum RPC errors per EIP-1474.
* @see https://eips.ethereum.org/EIPS/eip-1474
*/
class RpcError extends Error {
constructor( /** Human-readable string */
message, options) {
const {
cause,
code,
data
} = options;
if (!Number.isInteger(code)) {
throw new Error('"code" must be an integer.');
}
if (!message || typeof message !== "string") {
throw new Error('"message" must be a nonempty string.');
}
super(`${message}. Cause: ${JSON.stringify(cause)}`);
this.cause = cause;
this.code = code;
this.data = data;
}
}
/**
* Error subclass implementing Ethereum Provider errors per EIP-1193.
* @see https://eips.ethereum.org/EIPS/eip-1193
*/
class ProviderRpcError extends RpcError {
/**
* Create an Ethereum Provider JSON-RPC error.
* `code` must be an integer in the 1000 <= 4999 range.
*/
constructor( /** Human-readable string */
message, options) {
const {
cause,
code,
data
} = options;
if (!(Number.isInteger(code) && code >= 1000 && code <= 4999)) {
throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');
}
super(message, {
cause,
code,
data
});
}
}
class AddChainError extends Error {
constructor() {
super(...arguments);
_defineProperty(this, "name", "AddChainError");
_defineProperty(this, "message", "Error adding chain");
}
}
class ChainNotConfiguredError extends Error {
constructor(_ref) {
let {
chainId,
connectorId
} = _ref;
super(`Chain "${chainId}" not configured for connector "${connectorId}".`);
_defineProperty(this, "name", "ChainNotConfigured");
}
}
class ConnectorNotFoundError extends Error {
constructor() {
super(...arguments);
_defineProperty(this, "name", "ConnectorNotFoundError");
_defineProperty(this, "message", "Connector not found");
}
}
class ResourceUnavailableError extends RpcError {
constructor(cause) {
super("Resource unavailable", {
cause,
code: -32002
});
_defineProperty(this, "name", "ResourceUnavailable");
}
}
class SwitchChainError extends ProviderRpcError {
constructor(cause) {
super("Error switching chain", {
cause,
code: 4902
});
_defineProperty(this, "name", "SwitchChainError");
}
}
class UserRejectedRequestError extends ProviderRpcError {
constructor(cause) {
super("User rejected request", {
cause,
code: 4001
});
_defineProperty(this, "name", "UserRejectedRequestError");
}
}
// Ethers does not have an error type so we can use this for casting
// https://github.com/ethers-io/ethers.js/blob/main/packages/logger/src.ts/index.ts#L268
export { AddChainError as A, ChainNotConfiguredError as C, ProviderRpcError as P, ResourceUnavailableError as R, SwitchChainError as S, UserRejectedRequestError as U, ConnectorNotFoundError as a };