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.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toAptosTransactionHashSafe = exports.toAptosTransactionHash = exports.aptosTransactionHashValidator = exports.isAptosTransactionHash = exports.aptosTransactionHashRegexp = void 0; const common_js_1 = require("../../common/common.js"); const hash_js_1 = require("../../common/hash.js"); const domain_js_1 = require("../../union/enum/domain.js"); // Aptos transaction hashes are hex encoded strings, typically 66 characters long. exports.aptosTransactionHashRegexp = new RegExp(/^0[xX][0-9a-fA-F]{64}$/); function isAptosTransactionHash(raw) { return exports.aptosTransactionHashRegexp.test(raw); } exports.isAptosTransactionHash = isAptosTransactionHash; exports.aptosTransactionHashValidator = (0, common_js_1.createLayer1fulValidator)(domain_js_1.BlockchainLayer1Enum.APTOS, isAptosTransactionHash); function toAptosTransactionHash(raw) { const safe = toAptosTransactionHashSafe(raw); if (!safe) throw new hash_js_1.InvalidTransactionHashError(domain_js_1.BlockchainLayer1Enum.APTOS, raw); return safe; } exports.toAptosTransactionHash = toAptosTransactionHash; function toAptosTransactionHashSafe(raw) { if (isAptosTransactionHash(raw)) return raw; return undefined; } exports.toAptosTransactionHashSafe = toAptosTransactionHashSafe;