@xlink-network/xlink-sdk
Version:
110 lines (109 loc) • 4.06 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);
// src/utils/errors.ts
var errors_exports = {};
__export(errors_exports, {
BridgeValidateFailedError: () => BridgeValidateFailedError,
InvalidMethodParametersError: () => InvalidMethodParametersError,
StacksAddressVersionNotSupportedError: () => StacksAddressVersionNotSupportedError,
TooFrequentlyError: () => TooFrequentlyError,
UnsupportedBridgeRouteError: () => UnsupportedBridgeRouteError,
UnsupportedChainError: () => UnsupportedChainError,
UnsupportedContractAssignedChainIdError: () => UnsupportedContractAssignedChainIdError,
XLinkSDKErrorBase: () => XLinkSDKErrorBase
});
module.exports = __toCommonJS(errors_exports);
var XLinkSDKErrorBase = class extends Error {
constructor(...args) {
super(...args);
this.name = "XLinkSDKErrorBase";
}
};
var BridgeValidateFailedError = class extends XLinkSDKErrorBase {
constructor(cause) {
super("Bridge order validation failed", { cause });
this.cause = cause;
this.name = "BridgeValidateFailedError";
}
};
var StacksAddressVersionNotSupportedError = class extends XLinkSDKErrorBase {
constructor(address, versionName) {
super(`Stacks address ${address} version not supported: ${versionName}`);
this.address = address;
this.versionName = versionName;
this.name = "StacksAddressVersionNotSupportedError";
}
};
var TooFrequentlyError = class extends XLinkSDKErrorBase {
constructor(methodPath, retryAfter, options) {
super(
`Call method ${methodPath.join(".")} too frequently` + retryAfter == null ? "" : `, retry after ${retryAfter} seconds`,
options
);
this.methodPath = methodPath;
this.retryAfter = retryAfter;
this.name = "TooFrequentlyError";
}
};
var InvalidMethodParametersError = class extends XLinkSDKErrorBase {
constructor(methodPath, params) {
super(`Invalid method parameters of method ${methodPath.join(".")}`);
this.methodPath = methodPath;
this.params = params;
this.name = "InvalidMethodParametersError";
}
};
var UnsupportedBridgeRouteError = class extends XLinkSDKErrorBase {
constructor(fromChain, toChain, fromToken, toToken) {
super(
`Unsupported chain combination: ${fromToken}(${fromChain}) -> ${toToken ?? "Unknown Token"}(${toChain})`
);
this.fromChain = fromChain;
this.toChain = toChain;
this.fromToken = fromToken;
this.toToken = toToken;
this.name = "UnsupportedBridgeRouteError";
}
};
var UnsupportedChainError = class extends XLinkSDKErrorBase {
constructor(chain) {
super(`Unsupported chain: ${chain}`);
this.chain = chain;
this.name = "UnsupportedChainError";
}
};
var UnsupportedContractAssignedChainIdError = class extends XLinkSDKErrorBase {
constructor(chainId) {
super(`Unsupported smart contract assigned chain id: ${chainId}`);
this.chainId = chainId;
this.name = "UnsupportedContractAssignedChainIdError";
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BridgeValidateFailedError,
InvalidMethodParametersError,
StacksAddressVersionNotSupportedError,
TooFrequentlyError,
UnsupportedBridgeRouteError,
UnsupportedChainError,
UnsupportedContractAssignedChainIdError,
XLinkSDKErrorBase
});
//# sourceMappingURL=errors.js.map