@nucypher/shared
Version:
## [`nucypher/taco-web`](../../README.md)
26 lines • 896 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockIdentifierSchema = exports.EthAddressSchema = void 0;
const ethers_1 = require("ethers");
const zod_1 = require("zod");
const isAddress = (address) => {
try {
return ethers_1.ethers.utils.getAddress(address);
}
catch {
return false;
}
};
exports.EthAddressSchema = zod_1.z
.string()
.refine(isAddress, { message: 'Invalid Ethereum address' });
const BLOCK_HASH_REGEXP = new RegExp('^0x[a-fA-F0-9]{64}$');
const BlockNumber = zod_1.z.number().int().nonnegative();
const BlockHash = zod_1.z.string().regex(BLOCK_HASH_REGEXP, 'Invalid block hash');
const BlockTag = zod_1.z.enum(['earliest', 'finalized', 'safe', 'latest', 'pending']);
exports.BlockIdentifierSchema = zod_1.z.union([
BlockNumber,
BlockHash,
BlockTag,
]);
//# sourceMappingURL=schemas.js.map