UNPKG

@nervosnetwork/ckb-sdk-utils

Version:

Utils module of @nervosnetwork/ckb-sdk-core

59 lines 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AddressFormatTypeAndEncodeMethodNotMatchException = exports.AddressFormatTypeException = exports.HashTypeException = exports.CodeHashException = exports.AddressException = exports.AddressPayloadException = void 0; const tslib_1 = require("tslib"); const ErrorCode_js_1 = (0, tslib_1.__importDefault)(require("./ErrorCode.js")); class AddressPayloadException extends Error { constructor(payload, type) { super(`'${payload}' is not a valid ${type ? `${type} version ` : ''}address payload`); this.code = ErrorCode_js_1.default.AddressInvalid; this.type = type; } } exports.AddressPayloadException = AddressPayloadException; class AddressException extends Error { constructor(addr, stack, type) { super(`'${addr}' is not a valid ${type ? `${type} version ` : ''}address`); this.code = ErrorCode_js_1.default.AddressInvalid; this.type = type; this.stack = stack; } } exports.AddressException = AddressException; class CodeHashException extends Error { constructor(codeHash) { super(`'${codeHash}' is not a valid code hash`); this.code = ErrorCode_js_1.default.AddressInvalid; } } exports.CodeHashException = CodeHashException; class HashTypeException extends Error { constructor(hashType) { super(`'${hashType}' is not a valid hash type`); this.code = ErrorCode_js_1.default.AddressInvalid; } } exports.HashTypeException = HashTypeException; class AddressFormatTypeException extends Error { constructor(type) { super(`0x${type.toString(16).padStart(2, '0')} is not a valid address format type`); this.code = ErrorCode_js_1.default.AddressInvalid; } } exports.AddressFormatTypeException = AddressFormatTypeException; class AddressFormatTypeAndEncodeMethodNotMatchException extends Error { constructor(type, bech32Type = 'unknown') { super(`Address format type 0x${type.toString(16).padStart(2, '0')} doesn't match encode method ${bech32Type}`); this.code = ErrorCode_js_1.default.AddressInvalid; } } exports.AddressFormatTypeAndEncodeMethodNotMatchException = AddressFormatTypeAndEncodeMethodNotMatchException; exports.default = { AddressPayloadException, AddressException, CodeHashException, HashTypeException, AddressFormatTypeException, AddressFormatTypeAndEncodeMethodNotMatchException, }; //# sourceMappingURL=address.js.map