@rarible/types
Version:
`@rarible/types` is a TypeScript library that provides type definitions and interfaces for the Rarible ecosystem. This package is designed to facilitate seamless integration with Rarible's APIs and services, ensuring type safety and improved developer exp
26 lines (25 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toFlowTransactionHashSafe = exports.toFlowTransactionHash = exports.flowTransactionHashValidator = exports.isFlowTransactionHash = exports.flowTransactionHashRegExp = void 0;
const hash_js_1 = require("../../common/hash.js");
const domain_js_1 = require("../../union/enum/domain.js");
const common_js_1 = require("../../common/common.js");
exports.flowTransactionHashRegExp = /^[a-f0-9]{64}$/;
function isFlowTransactionHash(raw) {
return exports.flowTransactionHashRegExp.test(raw);
}
exports.isFlowTransactionHash = isFlowTransactionHash;
exports.flowTransactionHashValidator = (0, common_js_1.createLayer1fulValidator)(domain_js_1.BlockchainLayer1Enum.FLOW, isFlowTransactionHash);
function toFlowTransactionHash(raw) {
const safe = toFlowTransactionHashSafe(raw);
if (!safe)
throw new hash_js_1.InvalidTransactionHashError(domain_js_1.BlockchainLayer1Enum.FLOW, raw);
return safe;
}
exports.toFlowTransactionHash = toFlowTransactionHash;
function toFlowTransactionHashSafe(raw) {
if (isFlowTransactionHash(raw))
return raw;
return undefined;
}
exports.toFlowTransactionHashSafe = toFlowTransactionHashSafe;