@opendatalabs/vana-sdk
Version:
A TypeScript library for interacting with Vana Network smart contracts.
196 lines • 5.75 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var errors_exports = {};
__export(errors_exports, {
BlockchainError: () => BlockchainError,
ContractNotFoundError: () => ContractNotFoundError,
InvalidConfigurationError: () => InvalidConfigurationError,
NetworkError: () => NetworkError,
NonceError: () => NonceError,
PermissionError: () => PermissionError,
PersonalServerError: () => PersonalServerError,
ReadOnlyError: () => ReadOnlyError,
RelayerError: () => RelayerError,
SerializationError: () => SerializationError,
ServerUrlMismatchError: () => ServerUrlMismatchError,
SignatureError: () => SignatureError,
TransactionPendingError: () => TransactionPendingError,
UserRejectedRequestError: () => UserRejectedRequestError,
VanaError: () => VanaError
});
module.exports = __toCommonJS(errors_exports);
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
};
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BlockchainError,
ContractNotFoundError,
InvalidConfigurationError,
NetworkError,
NonceError,
PermissionError,
PersonalServerError,
ReadOnlyError,
RelayerError,
SerializationError,
ServerUrlMismatchError,
SignatureError,
TransactionPendingError,
UserRejectedRequestError,
VanaError
});
//# sourceMappingURL=errors.cjs.map