UNPKG

@agentek/tools

Version:

Blockchain tools for AI agents

37 lines 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clean = exports.addressSchema = void 0; const zod_1 = require("zod"); const utils_1 = require("viem/utils"); exports.addressSchema = zod_1.z.string().transform((val, ctx) => { if (!(0, utils_1.isAddress)(val)) { ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message: "Invalid Ethereum address", }); // stop here return zod_1.z.NEVER; } return val; // output is Address }); const clean = (obj) => { if (typeof obj === "bigint") { return obj.toString(); } if (Array.isArray(obj)) { return obj.map(exports.clean); } if (typeof obj === "string") { return obj.trim(); } if (obj && typeof obj === "object") { const newObj = {}; for (const key in obj) { newObj[key] = (0, exports.clean)(obj[key]); } return newObj; } return obj; }; exports.clean = clean; //# sourceMappingURL=utils.js.map