@agentek/tools
Version:
Blockchain tools for AI agents
28 lines • 698 B
JavaScript
import { z } from "zod";
import { isAddress } from "viem/utils";
export const addressSchema = z
.string()
.refine((val) => isAddress(val), {
message: "Invalid Ethereum address",
})
.transform((val) => val);
export const clean = (obj) => {
if (typeof obj === "bigint") {
return obj.toString();
}
if (Array.isArray(obj)) {
return obj.map(clean);
}
if (typeof obj === "string") {
return obj.trim();
}
if (obj && typeof obj === "object") {
const newObj = {};
for (const key in obj) {
newObj[key] = clean(obj[key]);
}
return newObj;
}
return obj;
};
//# sourceMappingURL=utils.js.map