UNPKG

@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

27 lines (26 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toTezosTransactionHashSafe = exports.toTezosTransactionHash = exports.tezosTransactionHashValidator = exports.isTezosTransactionHash = exports.tezosTransactionHashRegexp = 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"); // Tezos transaction hashes are Base58 encoded strings, typically 51 characters long, starting with 'o'. exports.tezosTransactionHashRegexp = /^o[1-9A-HJ-NP-Za-km-z]{50}$/; function isTezosTransactionHash(raw) { return exports.tezosTransactionHashRegexp.test(raw); } exports.isTezosTransactionHash = isTezosTransactionHash; exports.tezosTransactionHashValidator = (0, common_js_1.createLayer1fulValidator)(domain_js_1.BlockchainLayer1Enum.TEZOS, isTezosTransactionHash); function toTezosTransactionHash(raw) { const safe = toTezosTransactionHashSafe(raw); if (!safe) throw new hash_js_1.InvalidTransactionHashError(domain_js_1.BlockchainLayer1Enum.TEZOS, raw); return safe; } exports.toTezosTransactionHash = toTezosTransactionHash; function toTezosTransactionHashSafe(raw) { if (isTezosTransactionHash(raw)) return raw; return undefined; } exports.toTezosTransactionHashSafe = toTezosTransactionHashSafe;