@thirdweb-dev/wallets
Version:
<p align="center"> <br /> <a href="https://thirdweb.com"><img src="https://github.com/thirdweb-dev/js/blob/main/legacy_packages/sdk/logo.svg?raw=true" width="200" alt=""/></a> <br /> </p> <h1 align="center">thirdweb Wallet SDK</h1> <p align="center"> <a h
136 lines (128 loc) • 3.48 kB
JavaScript
;
var defineProperty = require('./defineProperty-9051a5d3.cjs.dev.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;
}
}
/**
* @internal
* 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
});
}
}
/**
* @internal
*/
class AddChainError extends Error {
constructor() {
super(...arguments);
defineProperty._defineProperty(this, "name", "AddChainError");
defineProperty._defineProperty(this, "message", "Error adding chain");
}
}
/**
* @internal
*/
class ChainNotConfiguredError extends Error {
constructor(_ref) {
let {
chainId,
connectorId
} = _ref;
super(`Chain "${chainId}" not configured for connector "${connectorId}".`);
defineProperty._defineProperty(this, "name", "ChainNotConfigured");
}
}
class ConnectorNotFoundError extends Error {
constructor() {
super(...arguments);
defineProperty._defineProperty(this, "name", "ConnectorNotFoundError");
defineProperty._defineProperty(this, "message", "Connector not found");
}
}
class ResourceUnavailableError extends RpcError {
constructor(cause) {
super("Resource unavailable", {
cause,
code: -32002
});
defineProperty._defineProperty(this, "name", "ResourceUnavailable");
}
}
/**
* @internal
*/
class SwitchChainError extends ProviderRpcError {
constructor(cause) {
super("Error switching chain", {
cause,
code: 4902
});
defineProperty._defineProperty(this, "name", "SwitchChainError");
}
}
/**
* @internal
*/
class UserRejectedRequestError extends ProviderRpcError {
constructor(cause) {
super("User rejected request", {
cause,
code: 4001
});
defineProperty._defineProperty(this, "name", "UserRejectedRequestError");
}
}
/**
* @internal
*/
// 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
exports.AddChainError = AddChainError;
exports.ChainNotConfiguredError = ChainNotConfiguredError;
exports.ConnectorNotFoundError = ConnectorNotFoundError;
exports.ProviderRpcError = ProviderRpcError;
exports.ResourceUnavailableError = ResourceUnavailableError;
exports.SwitchChainError = SwitchChainError;
exports.UserRejectedRequestError = UserRejectedRequestError;