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

20 lines (19 loc) 812 B
import { InvalidTransactionHashError } from "../../common/hash.js"; import { BlockchainLayer1Enum } from "../../union/enum/domain.js"; import { createLayer1fulValidator } from "../../common/common.js"; export const flowTransactionHashRegExp = /^[a-f0-9]{64}$/; export function isFlowTransactionHash(raw) { return flowTransactionHashRegExp.test(raw); } export const flowTransactionHashValidator = createLayer1fulValidator(BlockchainLayer1Enum.FLOW, isFlowTransactionHash); export function toFlowTransactionHash(raw) { const safe = toFlowTransactionHashSafe(raw); if (!safe) throw new InvalidTransactionHashError(BlockchainLayer1Enum.FLOW, raw); return safe; } export function toFlowTransactionHashSafe(raw) { if (isFlowTransactionHash(raw)) return raw; return undefined; }