@opendatalabs/vana-sdk
Version:
A TypeScript library for interacting with Vana Network smart contracts.
158 lines • 4.09 kB
JavaScript
class VanaError extends Error {
constructor(message, code) {
super(message);
this.code = code;
this.name = this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
code;
}
class RelayerError extends VanaError {
constructor(message, statusCode, response) {
super(message, "RELAYER_ERROR");
this.statusCode = statusCode;
this.response = response;
}
statusCode;
response;
}
class UserRejectedRequestError extends VanaError {
constructor(message = "User rejected the signature request") {
super(message, "USER_REJECTED_REQUEST");
}
}
class InvalidConfigurationError extends VanaError {
constructor(message) {
super(message, "INVALID_CONFIGURATION");
}
}
class ContractNotFoundError extends VanaError {
constructor(contractName, chainId) {
super(
`Contract ${contractName} not found on chain ${chainId}`,
"CONTRACT_NOT_FOUND"
);
}
}
class BlockchainError extends VanaError {
constructor(message, originalError) {
super(message, "BLOCKCHAIN_ERROR");
this.originalError = originalError;
}
originalError;
}
class SerializationError extends VanaError {
constructor(message) {
super(message, "SERIALIZATION_ERROR");
}
}
class SignatureError extends VanaError {
constructor(message, originalError) {
super(message, "SIGNATURE_ERROR");
this.originalError = originalError;
}
originalError;
}
class NetworkError extends VanaError {
constructor(message, originalError) {
super(message, "NETWORK_ERROR");
this.originalError = originalError;
}
originalError;
}
class NonceError extends VanaError {
constructor(message) {
super(message, "NONCE_ERROR");
}
}
class PersonalServerError extends VanaError {
constructor(message, originalError) {
super(message, "PERSONAL_SERVER_ERROR");
this.originalError = originalError;
}
originalError;
}
class ServerUrlMismatchError extends VanaError {
constructor(existingUrl, providedUrl, serverId) {
super(
`Server ${serverId} is already registered with URL "${existingUrl}". Cannot change to "${providedUrl}".`,
"SERVER_URL_MISMATCH"
);
this.existingUrl = existingUrl;
this.providedUrl = providedUrl;
this.serverId = serverId;
}
existingUrl;
providedUrl;
serverId;
}
class PermissionError extends VanaError {
constructor(message, originalError) {
super(message, "PERMISSION_ERROR");
this.originalError = originalError;
}
originalError;
}
class ReadOnlyError extends VanaError {
constructor(operation, suggestion = "Initialize the SDK with a walletClient to perform this operation") {
super(
`Operation '${operation}' requires a wallet client. ${suggestion}`,
"READ_ONLY_ERROR"
);
this.operation = operation;
this.suggestion = suggestion;
}
/** The operation that was attempted */
operation;
/** Suggested solution for fixing the error */
suggestion;
}
class TransactionPendingError extends VanaError {
constructor(operationId, message, lastKnownStatus) {
super(
`Transaction operation pending: ${message} (operationId: ${operationId})`,
"TRANSACTION_PENDING"
);
this.operationId = operationId;
this.lastKnownStatus = lastKnownStatus;
}
operationId;
lastKnownStatus;
/**
* Converts the error to a JSON-serializable format.
*
* @remarks
* Useful for logging, storage, or transmission of error details.
*
* @returns JSON representation of the error
*/
toJSON() {
return {
name: this.name,
code: this.code,
message: this.message,
operationId: this.operationId,
lastKnownStatus: this.lastKnownStatus
};
}
}
export {
BlockchainError,
ContractNotFoundError,
InvalidConfigurationError,
NetworkError,
NonceError,
PermissionError,
PersonalServerError,
ReadOnlyError,
RelayerError,
SerializationError,
ServerUrlMismatchError,
SignatureError,
TransactionPendingError,
UserRejectedRequestError,
VanaError
};
//# sourceMappingURL=errors.js.map