@agentek/tools
Version:
Blockchain tools for AI agents
32 lines • 878 B
JavaScript
;
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()
.refine((val) => (0, utils_1.isAddress)(val), {
message: "Invalid Ethereum address",
})
.transform((val) => val);
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