@ defuse-protocol/ 合同类型
这个包提供了Defuse协议合同的TypeScript类型定义. 它包含由Defuse协议合同ABI所衍生的自动生成的TypeScript接口.
安装
npm install @defuse-protocol/contract-types
标准Schema
验证器是 标准Schema 符合,并与任何接受光谱的库(TanStack Form,Hono,tRPC等)合作. 见 标准-schema.test.ts 用于使用示例.
与 Schema 图书馆使用
类验证器( NestJS)
见 等级验证员. test.ts 联 合 国 ValidateWithSchema 与NestJS验证管相通的装饰.
佐德语Name
现有两个备选方案: zod.test.ts (中文(简体) )数字 :
z.fromJSONSchema()- 只验证原始结构, 没有 JSON 字符串解析toZodSchema()包装 - 校验和剖析内部 JSON 字符串
维利博特
见 valibot.test.ts (英语). 互联网档案馆的存檔,存档日期2013-12-02 用于包装功能.
ArkType 密码
见 方舟类型. test.ts 用于包装功能.
使用量
import { Intent } from '@defuse-protocol/contract-types';
// Use the generated types in your application
const transferIntent: Intent = {
intent: "transfer",
receiver_id: "receiver.near",
tokens: {
"token.near": "1000000000000000000000000"
}
};
可用类型
此套件会导出以下类型 :
Intent- 各种意图行动的类型(转让、添加 public key、去除 public key等)- 与合同有关的其他类型来源于《防御议定书》
发展
先决条件
- 菲律宾 (v10.14.0) (中文(简体) )
构建
pnpm run build
生成类型
这些类型由Defuse协议合同ABI自动生成,使用脚本 scripts/gen-defuse-types.ts。此脚本从合同ABI中提取类型定义,并将其转换为TypeScript接口.
重新生成这些类型:
# Run the type generation script
cd packages/contract-types
pnpm run gen-defuse-types
发展模式
pnpm run dev
林特
pnpm run lint
许可证
MIT许可证 2025 NEAR基金会