UNPKG

wowok_agent

Version:

Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.

72 lines (71 loc) 4.58 kB
import { z } from "zod"; import { TypedPermissionObjectSchema, CoinParamSchema, NamedObjectSchema, SubmissionCallSchema, CallEnvSchema } from "./base.js"; import { AmountFromDepositGuardSchema, AmountFromWithdrawGuardSchema, PaymentInfoSchema } from "../query/index.js"; import { AccountOrMark_AddressSchema, DescriptionSchema, ReceivedBalanceOrRecentlySchema, ReceivedObjectsOrRecentlySchema, NameOrAddressSchema } from "../common/index.js"; import { BalanceTypeSchema } from "../common/index.js"; export const DepositSchema = z.object({ coin: CoinParamSchema.describe("Asset to deposit"), by_external_deposit_guard: z.string().optional().describe("Deposit by verifying the specified Guard object ID or name; if not specified, deposit through Permission"), payment_info: PaymentInfoSchema, namedNewPayment: NamedObjectSchema.optional().describe("After deposit, create a new Payment object. You can specify a name for this object"), }).strict(); export const WithdrawSchema = z.object({ amount: z.union([ z.object({ fixed: BalanceTypeSchema }).strict().describe("Fixed withdrawal amount, this method can only withdraw through Permission"), z.object({ by_external_withdraw_guard: z.string().describe("Withdraw by verifying the specified Guard object ID or name (the amount is the value of the index number corresponding to the Guard object); if not specified, withdraw through Permission") }).strict(), ]).describe("Withdrawal amount"), recipient: AccountOrMark_AddressSchema.describe("ID or account to receive assets"), payment_info: PaymentInfoSchema, namedNewPayment: NamedObjectSchema.optional().describe("After withdrawal, create a new Payment object. You can specify a name for this object"), }).strict(); export const ExternalDepositGuardSchema = z.discriminatedUnion("op", [ z.object({ op: z.literal("add"), guards: z.array(AmountFromDepositGuardSchema), }).strict(), z.object({ op: z.literal("set"), guards: z.array(AmountFromDepositGuardSchema), }).strict(), z.object({ op: z.literal("remove"), guards: z.array(NameOrAddressSchema).describe("List of Guard object IDs or names to remove"), }).strict(), z.object({ op: z.literal("clear"), }).strict(), ]); export const ExternalWithdrawGuardSchema = z.discriminatedUnion("op", [ z.object({ op: z.literal("add"), guards: z.array(AmountFromWithdrawGuardSchema), }).strict(), z.object({ op: z.literal("set"), guards: z.array(AmountFromWithdrawGuardSchema), }).strict(), z.object({ op: z.literal("remove"), guards: z.array(NameOrAddressSchema).describe("List of Guard object IDs or names to remove"), }).strict(), z.object({ op: z.literal("clear"), }).strict(), ]); export const CallTreasury_DataSchema = z.object({ object: TypedPermissionObjectSchema, description: DescriptionSchema.optional(), receive: ReceivedBalanceOrRecentlySchema.optional().describe("Receive CoinWrapper objects received by the object and deposit them into its balance."), deposit: DepositSchema.optional().describe("Deposit to Treasury object"), withdraw: WithdrawSchema.optional().describe("Withdraw from Treasury object"), external_deposit_guard: ExternalDepositGuardSchema.optional().describe("Set external deposit Guard for Treasury object"), external_withdraw_guard: ExternalWithdrawGuardSchema.optional().describe("Set external withdrawal Guard for Treasury object"), owner_receive: ReceivedObjectsOrRecentlySchema.optional().describe("Unwrap CoinWrapper objects and other objects received by this object and send them to the owner of its Permission object."), um: z.union([NamedObjectSchema, z.null()]).optional().describe("Contact object."), }).strict().describe("On-chain Treasury operations. USAGE: (1) CREATE NEW: Set 'object' field with OBJECT format {name, type_parameter, permission, ...} to create a Treasury. NOTE: 'name' goes INSIDE 'object', NOT at the data root level. 'permission' can be a new Permission object or reference an existing one - check 'object' field description for details. (2) OPERATE EXISTING: Set 'object' field with STRING format (object ID or name). The 'object' field is CRITICAL and REQUIRED in both cases. STRING for existing, OBJECT for new creation."); export const CallTreasury_InputSchema = z.object({ data: CallTreasury_DataSchema, env: CallEnvSchema.optional(), submission: SubmissionCallSchema.optional(), }).strict();