@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.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toEVMTransactionHashSafe = exports.toEVMTransactionHash = exports.evmTransactionHashValidator = exports.isEVMTransactionHash = exports.evmTransactionHashRegexp = 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.evmTransactionHashRegexp = /^0x([A-Fa-f0-9]{64})$/;
function isEVMTransactionHash(raw) {
return exports.evmTransactionHashRegexp.test(raw);
}
exports.isEVMTransactionHash = isEVMTransactionHash;
exports.evmTransactionHashValidator = (0, common_js_1.createLayer1fulValidator)(domain_js_1.BlockchainLayer1Enum.ETHEREUM, isEVMTransactionHash);
function toEVMTransactionHash(raw) {
const safe = toEVMTransactionHashSafe(raw);
if (!safe)
throw new hash_js_1.InvalidTransactionHashError(domain_js_1.BlockchainLayer1Enum.ETHEREUM, raw);
return safe;
}
exports.toEVMTransactionHash = toEVMTransactionHash;
function toEVMTransactionHashSafe(raw) {
if (isEVMTransactionHash(raw))
return raw;
return undefined;
}
exports.toEVMTransactionHashSafe = toEVMTransactionHashSafe;