lampamazaza-new-contract-types 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 NEAR Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @defuse-protocol/contract-types
2
+
3
+ This package provides TypeScript type definitions for Defuse Protocol contracts. It contains automatically generated TypeScript interfaces derived from the Defuse Protocol contract ABI.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @defuse-protocol/contract-types
9
+ ```
10
+
11
+ ## Standard Schema
12
+
13
+ Validators are [Standard Schema](https://standardschema.dev/) compliant and work with any library that accepts the spec (TanStack Form, Hono, tRPC, etc.). See [standard-schema.test.ts](./src/standard-schema.test.ts) for usage examples.
14
+
15
+ ## Using with Schema Libraries
16
+
17
+ ### class-validator (NestJS)
18
+
19
+ See [class-validator.test.ts](./src/class-validator.test.ts) for the `ValidateWithSchema` decorator that works with NestJS validation pipes.
20
+
21
+ ### Zod
22
+
23
+ Two options available in [zod.test.ts](./src/zod.test.ts):
24
+ - `z.fromJSONSchema()` - validates raw structure only, no JSON string parsing
25
+ - `toZodSchema()` wrapper - validates and parses inner JSON strings
26
+
27
+ ### Valibot
28
+
29
+ See [valibot.test.ts](./src/valibot.test.ts) for the wrapper function.
30
+
31
+ ### ArkType
32
+
33
+ See [arktype.test.ts](./src/arktype.test.ts) for the wrapper function.
34
+
35
+ ## Usage
36
+
37
+ ```typescript
38
+ import { Intent } from '@defuse-protocol/contract-types';
39
+
40
+ // Use the generated types in your application
41
+ const transferIntent: Intent = {
42
+ intent: "transfer",
43
+ receiver_id: "receiver.near",
44
+ tokens: {
45
+ "token.near": "1000000000000000000000000"
46
+ }
47
+ };
48
+ ```
49
+
50
+ ## Available Types
51
+
52
+ This package exports the following TypeScript types:
53
+
54
+ - `Intent` - Types for various intent actions (transfer, add_public_key, remove_public_key, etc.)
55
+ - And other contract-related types derived from the Defuse Protocol ABI
56
+
57
+ ## Development
58
+
59
+ ### Prerequisites
60
+
61
+ - [PNPM](https://pnpm.io) (v10.14.0)
62
+
63
+ ### Build
64
+
65
+ ```bash
66
+ pnpm run build
67
+ ```
68
+
69
+ ### Generating Types
70
+
71
+ The types are automatically generated from the Defuse Protocol contract ABI using the script at `scripts/gen-defuse-types.ts`. This script extracts the type definitions from the contract ABI and converts them to TypeScript interfaces.
72
+
73
+ To regenerate the types:
74
+
75
+ ```bash
76
+ # Run the type generation script
77
+ cd packages/contract-types
78
+ pnpm run gen-defuse-types
79
+ ```
80
+
81
+ ### Development Mode
82
+
83
+ ```bash
84
+ pnpm run dev
85
+ ```
86
+
87
+ ### Lint
88
+
89
+ ```bash
90
+ pnpm run lint
91
+ ```
92
+
93
+ ## License
94
+
95
+ MIT License © 2025 NEAR Foundation
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+
2
+ //#region src/index.ts
3
+ /**
4
+ * Enum of supported intent standards.
5
+ * Generated from the MultiPayload schema variants.
6
+ */
7
+ let IntentStandardEnum = /* @__PURE__ */ function(IntentStandardEnum$1) {
8
+ IntentStandardEnum$1["NEP413"] = "nep413";
9
+ IntentStandardEnum$1["ERC191"] = "erc191";
10
+ IntentStandardEnum$1["TIP191"] = "tip191";
11
+ IntentStandardEnum$1["RAW_ED25519"] = "raw_ed25519";
12
+ IntentStandardEnum$1["WEBAUTHN"] = "webauthn";
13
+ IntentStandardEnum$1["TON_CONNECT"] = "ton_connect";
14
+ IntentStandardEnum$1["SEP53"] = "sep53";
15
+ return IntentStandardEnum$1;
16
+ }({});
17
+
18
+ //#endregion
19
+ exports.IntentStandardEnum = IntentStandardEnum;