@haneullabs/codegen 0.1.0 → 0.8.3
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/CHANGELOG.md +138 -33
- package/README.md +40 -38
- package/dist/bin/bash-complete.d.mts +6 -0
- package/dist/bin/bash-complete.d.mts.map +1 -0
- package/dist/bin/bash-complete.mjs +29 -0
- package/dist/bin/bash-complete.mjs.map +1 -0
- package/dist/bin/cli.d.mts +1 -0
- package/dist/bin/cli.mjs +24 -0
- package/dist/bin/cli.mjs.map +1 -0
- package/dist/cli/cli.mjs +28 -0
- package/dist/cli/cli.mjs.map +1 -0
- package/dist/cli/commands/generate/command.mjs +90 -0
- package/dist/cli/commands/generate/command.mjs.map +1 -0
- package/dist/cli/commands/generate/impl.mjs +72 -0
- package/dist/cli/commands/generate/impl.mjs.map +1 -0
- package/dist/cli/context.mjs +17 -0
- package/dist/cli/context.mjs.map +1 -0
- package/dist/config.d.mts +105 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +70 -0
- package/dist/config.mjs.map +1 -0
- package/dist/file-builder.mjs +66 -0
- package/dist/file-builder.mjs.map +1 -0
- package/dist/{esm/generate-utils.js → generate-utils.mjs} +95 -27
- package/dist/generate-utils.mjs.map +1 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +80 -0
- package/dist/index.mjs.map +1 -0
- package/dist/move-module-builder.mjs +350 -0
- package/dist/move-module-builder.mjs.map +1 -0
- package/dist/render-types.mjs +207 -0
- package/dist/render-types.mjs.map +1 -0
- package/dist/utils.mjs +89 -0
- package/dist/utils.mjs.map +1 -0
- package/docs/index.md +436 -0
- package/docs/llms-index.md +6 -0
- package/package.json +29 -28
- package/src/bin/bash-complete.ts +18 -7
- package/src/bin/cli.ts +3 -9
- package/src/cli/commands/generate/command.ts +32 -0
- package/src/cli/commands/generate/impl.ts +93 -5
- package/src/config.ts +53 -5
- package/src/file-builder.ts +15 -1
- package/src/generate-utils.ts +88 -18
- package/src/index.ts +89 -29
- package/src/move-module-builder.ts +181 -76
- package/src/render-types.ts +82 -29
- package/dist/cjs/bin/bash-complete.d.ts +0 -2
- package/dist/cjs/bin/bash-complete.js +0 -51
- package/dist/cjs/bin/bash-complete.js.map +0 -7
- package/dist/cjs/bin/cli.d.ts +0 -2
- package/dist/cjs/bin/cli.js +0 -34
- package/dist/cjs/bin/cli.js.map +0 -7
- package/dist/cjs/cli/cli.d.ts +0 -1
- package/dist/cjs/cli/cli.js +0 -49
- package/dist/cjs/cli/cli.js.map +0 -7
- package/dist/cjs/cli/commands/generate/command.d.ts +0 -1
- package/dist/cjs/cli/commands/generate/command.js +0 -80
- package/dist/cjs/cli/commands/generate/command.js.map +0 -7
- package/dist/cjs/cli/commands/generate/impl.d.ts +0 -8
- package/dist/cjs/cli/commands/generate/impl.js +0 -66
- package/dist/cjs/cli/commands/generate/impl.js.map +0 -7
- package/dist/cjs/cli/context.d.ts +0 -6
- package/dist/cjs/cli/context.js +0 -45
- package/dist/cjs/cli/context.js.map +0 -7
- package/dist/cjs/config.d.ts +0 -51
- package/dist/cjs/config.js +0 -75
- package/dist/cjs/config.js.map +0 -7
- package/dist/cjs/file-builder.d.ts +0 -13
- package/dist/cjs/file-builder.js +0 -83
- package/dist/cjs/file-builder.js.map +0 -7
- package/dist/cjs/generate-utils.d.ts +0 -1
- package/dist/cjs/generate-utils.js +0 -187
- package/dist/cjs/generate-utils.js.map +0 -7
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.js +0 -124
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/move-module-builder.d.ts +0 -26
- package/dist/cjs/move-module-builder.js +0 -464
- package/dist/cjs/move-module-builder.js.map +0 -7
- package/dist/cjs/package.json +0 -5
- package/dist/cjs/render-types.d.ts +0 -19
- package/dist/cjs/render-types.js +0 -313
- package/dist/cjs/render-types.js.map +0 -7
- package/dist/cjs/summary.d.ts +0 -3
- package/dist/cjs/summary.js +0 -218
- package/dist/cjs/summary.js.map +0 -7
- package/dist/cjs/types/deserialized.d.ts +0 -89
- package/dist/cjs/types/deserialized.js +0 -17
- package/dist/cjs/types/deserialized.js.map +0 -7
- package/dist/cjs/types/summary.d.ts +0 -105
- package/dist/cjs/types/summary.js +0 -17
- package/dist/cjs/types/summary.js.map +0 -7
- package/dist/cjs/utils.d.ts +0 -22
- package/dist/cjs/utils.js +0 -164
- package/dist/cjs/utils.js.map +0 -7
- package/dist/esm/bin/bash-complete.d.ts +0 -2
- package/dist/esm/bin/bash-complete.js +0 -31
- package/dist/esm/bin/bash-complete.js.map +0 -7
- package/dist/esm/bin/cli.d.ts +0 -2
- package/dist/esm/bin/cli.js +0 -32
- package/dist/esm/bin/cli.js.map +0 -7
- package/dist/esm/cli/cli.d.ts +0 -1
- package/dist/esm/cli/cli.js +0 -29
- package/dist/esm/cli/cli.js.map +0 -7
- package/dist/esm/cli/commands/generate/command.d.ts +0 -1
- package/dist/esm/cli/commands/generate/command.js +0 -50
- package/dist/esm/cli/commands/generate/command.js.map +0 -7
- package/dist/esm/cli/commands/generate/impl.d.ts +0 -8
- package/dist/esm/cli/commands/generate/impl.js +0 -46
- package/dist/esm/cli/commands/generate/impl.js.map +0 -7
- package/dist/esm/cli/context.d.ts +0 -6
- package/dist/esm/cli/context.js +0 -15
- package/dist/esm/cli/context.js.map +0 -7
- package/dist/esm/config.d.ts +0 -51
- package/dist/esm/config.js +0 -45
- package/dist/esm/config.js.map +0 -7
- package/dist/esm/file-builder.d.ts +0 -13
- package/dist/esm/file-builder.js +0 -63
- package/dist/esm/file-builder.js.map +0 -7
- package/dist/esm/generate-utils.d.ts +0 -1
- package/dist/esm/generate-utils.js.map +0 -7
- package/dist/esm/index.d.ts +0 -8
- package/dist/esm/index.js +0 -104
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/move-module-builder.d.ts +0 -26
- package/dist/esm/move-module-builder.js +0 -457
- package/dist/esm/move-module-builder.js.map +0 -7
- package/dist/esm/package.json +0 -5
- package/dist/esm/render-types.d.ts +0 -19
- package/dist/esm/render-types.js +0 -293
- package/dist/esm/render-types.js.map +0 -7
- package/dist/esm/summary.d.ts +0 -3
- package/dist/esm/summary.js +0 -198
- package/dist/esm/summary.js.map +0 -7
- package/dist/esm/types/deserialized.d.ts +0 -89
- package/dist/esm/types/deserialized.js +0 -1
- package/dist/esm/types/deserialized.js.map +0 -7
- package/dist/esm/types/summary.d.ts +0 -105
- package/dist/esm/types/summary.js +0 -1
- package/dist/esm/types/summary.js.map +0 -7
- package/dist/esm/utils.d.ts +0 -22
- package/dist/esm/utils.js +0 -134
- package/dist/esm/utils.js.map +0 -7
- package/dist/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,109 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @mysten/codegen
|
|
2
|
+
|
|
3
|
+
## 0.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 43e69f8: Add embedded LLM-friendly docs to published packages
|
|
8
|
+
- Updated dependencies [43e69f8]
|
|
9
|
+
- Updated dependencies [e51dc5d]
|
|
10
|
+
- @mysten/bcs@2.0.3
|
|
11
|
+
- @mysten/sui@2.8.0
|
|
12
|
+
|
|
13
|
+
## 0.8.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 3d53583: Improve typing of generated bcs tuples
|
|
18
|
+
|
|
19
|
+
## 0.8.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 99d1e00: Add default export condition
|
|
24
|
+
- Updated dependencies [99d1e00]
|
|
25
|
+
- @mysten/bcs@2.0.2
|
|
26
|
+
- @mysten/sui@2.3.2
|
|
27
|
+
|
|
28
|
+
## 0.8.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- fcbf952: - Fix phantom type parameter index mismatch when generating BCS types for structs with
|
|
33
|
+
phantom types followed by non-phantom types
|
|
34
|
+
- Include phantom type parameters in generated MoveStruct names (e.g., `Pair<T, phantom U>`
|
|
35
|
+
instead of just `Pair<T>`)
|
|
36
|
+
- Add `includePhantomTypeParameters` config option to generate BCS types that include phantom type
|
|
37
|
+
parameters as function arguments
|
|
38
|
+
- Remove invalid `--yes` flag from `sui move summary` CLI calls
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [724a13a]
|
|
43
|
+
- Updated dependencies [fcbf952]
|
|
44
|
+
- @mysten/sui@2.3.0
|
|
45
|
+
|
|
46
|
+
## 0.7.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- 03d43fa: Add `generate` option to package config for controlling type and function generation.
|
|
51
|
+
Replaces the old `modules` and `include` package-level properties with a unified
|
|
52
|
+
`generate: { types, functions, modules }` structure. Add CLI flags `--modules`, `--noTypes`,
|
|
53
|
+
`--noFunctions`, and `--private` to override generation options from the command line.
|
|
54
|
+
- 6000f4e: Add flag --yes to sui move summary to not block CI pipelines
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [6125fbd]
|
|
59
|
+
- @mysten/sui@2.2.0
|
|
60
|
+
|
|
61
|
+
## 0.6.0
|
|
62
|
+
|
|
63
|
+
### Minor Changes
|
|
64
|
+
|
|
65
|
+
- e00788c: Add automatic import aliasing to resolve naming conflicts and configurable import
|
|
66
|
+
extensions.
|
|
67
|
+
|
|
68
|
+
**Import Conflict Resolution:** When Move contracts define structs, enums, or functions with names
|
|
69
|
+
that conflict with SDK imports (e.g., `Transaction`, `BcsType`, `bcs`, `MoveStruct`,
|
|
70
|
+
`normalizeMoveArguments`), the codegen now automatically aliases the SDK imports to avoid
|
|
71
|
+
TypeScript compilation errors while preserving the user's original type names.
|
|
72
|
+
|
|
73
|
+
**Import Extension Configuration:** Added `importExtension` option to control file extensions in
|
|
74
|
+
generated import statements:
|
|
75
|
+
- Config file: `importExtension: '.js' | '.ts' | ''`
|
|
76
|
+
- CLI: `--import-extension .js|.ts|none`
|
|
77
|
+
|
|
78
|
+
This allows compatibility with different bundler/runtime configurations:
|
|
79
|
+
- `.js` (default): ESM compatible for Node.js
|
|
80
|
+
- `.ts`: For Bun, Deno, or bundlers that handle .ts imports directly
|
|
81
|
+
- `''` (none): For bundlers that don't require extensions
|
|
82
|
+
|
|
83
|
+
- e00788c: Update to use SuiJsonRpcClient instead of SuiClient
|
|
84
|
+
|
|
85
|
+
Updated all type signatures, internal usages, examples, and documentation to use
|
|
86
|
+
`SuiJsonRpcClient` from `@mysten/sui/jsonRpc` instead of the deprecated `SuiClient` from
|
|
87
|
+
`@mysten/sui/client`.
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [e00788c]
|
|
92
|
+
- Updated dependencies [e00788c]
|
|
93
|
+
- Updated dependencies [e00788c]
|
|
94
|
+
- Updated dependencies [e00788c]
|
|
95
|
+
- Updated dependencies [e00788c]
|
|
96
|
+
- Updated dependencies [e00788c]
|
|
97
|
+
- Updated dependencies [e00788c]
|
|
98
|
+
- Updated dependencies [e00788c]
|
|
99
|
+
- Updated dependencies [e00788c]
|
|
100
|
+
- Updated dependencies [e00788c]
|
|
101
|
+
- Updated dependencies [e00788c]
|
|
102
|
+
- Updated dependencies [e00788c]
|
|
103
|
+
- Updated dependencies [e00788c]
|
|
104
|
+
- Updated dependencies [e00788c]
|
|
105
|
+
- @mysten/sui@2.0.0
|
|
106
|
+
- @mysten/bcs@2.0.0
|
|
2
107
|
|
|
3
108
|
## 0.5.13
|
|
4
109
|
|
|
@@ -16,14 +121,14 @@
|
|
|
16
121
|
### Patch Changes
|
|
17
122
|
|
|
18
123
|
- Updated dependencies [29e8b92]
|
|
19
|
-
- @
|
|
124
|
+
- @mysten/sui@1.45.2
|
|
20
125
|
|
|
21
126
|
## 0.5.11
|
|
22
127
|
|
|
23
128
|
### Patch Changes
|
|
24
129
|
|
|
25
130
|
- Updated dependencies [e3811f1]
|
|
26
|
-
- @
|
|
131
|
+
- @mysten/sui@1.45.1
|
|
27
132
|
|
|
28
133
|
## 0.5.10
|
|
29
134
|
|
|
@@ -37,30 +142,30 @@
|
|
|
37
142
|
consistency with the privateMethods option added in version 0.5.0.
|
|
38
143
|
|
|
39
144
|
- Updated dependencies [88bdbac]
|
|
40
|
-
- @
|
|
145
|
+
- @mysten/sui@1.45.0
|
|
41
146
|
|
|
42
147
|
## 0.5.9
|
|
43
148
|
|
|
44
149
|
### Patch Changes
|
|
45
150
|
|
|
46
151
|
- Updated dependencies [44d9b4f]
|
|
47
|
-
- @
|
|
152
|
+
- @mysten/sui@1.44.0
|
|
48
153
|
|
|
49
154
|
## 0.5.8
|
|
50
155
|
|
|
51
156
|
### Patch Changes
|
|
52
157
|
|
|
53
158
|
- Updated dependencies [89fa2dc]
|
|
54
|
-
- @
|
|
55
|
-
- @
|
|
159
|
+
- @mysten/bcs@1.9.2
|
|
160
|
+
- @mysten/sui@1.43.2
|
|
56
161
|
|
|
57
162
|
## 0.5.7
|
|
58
163
|
|
|
59
164
|
### Patch Changes
|
|
60
165
|
|
|
61
166
|
- Updated dependencies [a37829f]
|
|
62
|
-
- @
|
|
63
|
-
- @
|
|
167
|
+
- @mysten/bcs@1.9.1
|
|
168
|
+
- @mysten/sui@1.43.1
|
|
64
169
|
|
|
65
170
|
## 0.5.6
|
|
66
171
|
|
|
@@ -69,15 +174,15 @@
|
|
|
69
174
|
- Updated dependencies [f3b19a7]
|
|
70
175
|
- Updated dependencies [f3b19a7]
|
|
71
176
|
- Updated dependencies [bf9f85c]
|
|
72
|
-
- @
|
|
73
|
-
- @
|
|
177
|
+
- @mysten/sui@1.43.0
|
|
178
|
+
- @mysten/bcs@1.9.0
|
|
74
179
|
|
|
75
180
|
## 0.5.5
|
|
76
181
|
|
|
77
182
|
### Patch Changes
|
|
78
183
|
|
|
79
184
|
- Updated dependencies [98c8a27]
|
|
80
|
-
- @
|
|
185
|
+
- @mysten/sui@1.42.0
|
|
81
186
|
|
|
82
187
|
## 0.5.4
|
|
83
188
|
|
|
@@ -86,22 +191,22 @@
|
|
|
86
191
|
- Updated dependencies [a17c337]
|
|
87
192
|
- Updated dependencies [d554cd2]
|
|
88
193
|
- Updated dependencies [04fcfbc]
|
|
89
|
-
- @
|
|
90
|
-
- @
|
|
194
|
+
- @mysten/bcs@1.8.1
|
|
195
|
+
- @mysten/sui@1.41.0
|
|
91
196
|
|
|
92
197
|
## 0.5.3
|
|
93
198
|
|
|
94
199
|
### Patch Changes
|
|
95
200
|
|
|
96
201
|
- Updated dependencies [f5fc0c0]
|
|
97
|
-
- @
|
|
202
|
+
- @mysten/sui@1.40.0
|
|
98
203
|
|
|
99
204
|
## 0.5.2
|
|
100
205
|
|
|
101
206
|
### Patch Changes
|
|
102
207
|
|
|
103
208
|
- Updated dependencies [a9f9035]
|
|
104
|
-
- @
|
|
209
|
+
- @mysten/sui@1.39.1
|
|
105
210
|
|
|
106
211
|
## 0.5.1
|
|
107
212
|
|
|
@@ -110,7 +215,7 @@
|
|
|
110
215
|
- 24e6b36: Optional struct generation should be bcs.option instead of bcs.vector
|
|
111
216
|
- Updated dependencies [ca92487]
|
|
112
217
|
- Updated dependencies [5ab3c0a]
|
|
113
|
-
- @
|
|
218
|
+
- @mysten/sui@1.39.0
|
|
114
219
|
|
|
115
220
|
## 0.5.0
|
|
116
221
|
|
|
@@ -124,8 +229,8 @@
|
|
|
124
229
|
|
|
125
230
|
- Updated dependencies [3c1741f]
|
|
126
231
|
- Updated dependencies [ea1ac70]
|
|
127
|
-
- @
|
|
128
|
-
- @
|
|
232
|
+
- @mysten/sui@1.38.0
|
|
233
|
+
- @mysten/bcs@1.8.0
|
|
129
234
|
|
|
130
235
|
## 0.4.5
|
|
131
236
|
|
|
@@ -134,35 +239,35 @@
|
|
|
134
239
|
- 78bd0e9: Update codegen arg normalization for object args
|
|
135
240
|
- Updated dependencies [c689b98]
|
|
136
241
|
- Updated dependencies [5b9ff1a]
|
|
137
|
-
- @
|
|
242
|
+
- @mysten/sui@1.37.6
|
|
138
243
|
|
|
139
244
|
## 0.4.4
|
|
140
245
|
|
|
141
246
|
### Patch Changes
|
|
142
247
|
|
|
143
248
|
- Updated dependencies [3980d04]
|
|
144
|
-
- @
|
|
249
|
+
- @mysten/sui@1.37.5
|
|
145
250
|
|
|
146
251
|
## 0.4.3
|
|
147
252
|
|
|
148
253
|
### Patch Changes
|
|
149
254
|
|
|
150
255
|
- Updated dependencies [6b03e57]
|
|
151
|
-
- @
|
|
256
|
+
- @mysten/sui@1.37.4
|
|
152
257
|
|
|
153
258
|
## 0.4.2
|
|
154
259
|
|
|
155
260
|
### Patch Changes
|
|
156
261
|
|
|
157
262
|
- Updated dependencies [8ff1471]
|
|
158
|
-
- @
|
|
263
|
+
- @mysten/sui@1.37.3
|
|
159
264
|
|
|
160
265
|
## 0.4.1
|
|
161
266
|
|
|
162
267
|
### Patch Changes
|
|
163
268
|
|
|
164
269
|
- Updated dependencies [660377c]
|
|
165
|
-
- @
|
|
270
|
+
- @mysten/sui@1.37.2
|
|
166
271
|
|
|
167
272
|
## 0.4.0
|
|
168
273
|
|
|
@@ -183,29 +288,29 @@
|
|
|
183
288
|
- Updated dependencies [33230ed]
|
|
184
289
|
- Updated dependencies [33230ed]
|
|
185
290
|
- Updated dependencies [33230ed]
|
|
186
|
-
- @
|
|
187
|
-
- @
|
|
291
|
+
- @mysten/bcs@1.7.0
|
|
292
|
+
- @mysten/sui@1.37.1
|
|
188
293
|
|
|
189
294
|
## 0.2.5
|
|
190
295
|
|
|
191
296
|
### Patch Changes
|
|
192
297
|
|
|
193
298
|
- Updated dependencies [72168f0]
|
|
194
|
-
- @
|
|
299
|
+
- @mysten/sui@1.37.0
|
|
195
300
|
|
|
196
301
|
## 0.2.4
|
|
197
302
|
|
|
198
303
|
### Patch Changes
|
|
199
304
|
|
|
200
305
|
- Updated dependencies [44354ab]
|
|
201
|
-
- @
|
|
306
|
+
- @mysten/sui@1.36.2
|
|
202
307
|
|
|
203
308
|
## 0.2.3
|
|
204
309
|
|
|
205
310
|
### Patch Changes
|
|
206
311
|
|
|
207
312
|
- Updated dependencies [c76ddc5]
|
|
208
|
-
- @
|
|
313
|
+
- @mysten/sui@1.36.1
|
|
209
314
|
|
|
210
315
|
## 0.2.2
|
|
211
316
|
|
|
@@ -223,8 +328,8 @@
|
|
|
223
328
|
- Updated dependencies [783bb9e]
|
|
224
329
|
- Updated dependencies [783bb9e]
|
|
225
330
|
- Updated dependencies [5cbbb21]
|
|
226
|
-
- @
|
|
227
|
-
- @
|
|
331
|
+
- @mysten/bcs@1.6.4
|
|
332
|
+
- @mysten/sui@1.36.0
|
|
228
333
|
|
|
229
334
|
## 0.2.0
|
|
230
335
|
|
|
@@ -240,7 +345,7 @@
|
|
|
240
345
|
- 888afe6: Fix falsy args
|
|
241
346
|
- 4ee5185: Add argument interfaces for move calls
|
|
242
347
|
- Updated dependencies [888afe6]
|
|
243
|
-
- @
|
|
348
|
+
- @mysten/sui@1.35.0
|
|
244
349
|
|
|
245
350
|
## 0.1.0
|
|
246
351
|
|
|
@@ -256,4 +361,4 @@
|
|
|
256
361
|
- c0560fe: Fix check for context arg
|
|
257
362
|
- c0560fe: remove support for generating from bytecode
|
|
258
363
|
- Updated dependencies [3fb7a83]
|
|
259
|
-
- @
|
|
364
|
+
- @mysten/sui@1.34.0
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Haneul typescript codegen
|
|
2
2
|
|
|
3
3
|
⚠️ **Warning**: This package is currently in development and may have breaking changes.
|
|
4
4
|
|
|
@@ -10,12 +10,12 @@ To use this package you will need to install it from npm:
|
|
|
10
10
|
pnpm install @haneullabs/codegen
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Then create a `
|
|
13
|
+
Then create a `haneul-codegen.config.ts` to define what packages you want to generate code for:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import type {
|
|
16
|
+
import type { HaneulCodegenConfig } from './src/config.js';
|
|
17
17
|
|
|
18
|
-
const config:
|
|
18
|
+
const config: HaneulCodegenConfig = {
|
|
19
19
|
output: './src/generated',
|
|
20
20
|
generateSummaries: true,
|
|
21
21
|
prune: true,
|
|
@@ -31,8 +31,8 @@ export default config;
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
The `package` field should be the MVR name for your move package. If you have not registered your
|
|
34
|
-
package on MVR yet, you can use the `@local-pkg` scope, and set up an override in your
|
|
35
|
-
to resolve it to the correct address.
|
|
34
|
+
package on MVR yet, you can use the `@local-pkg` scope, and set up an override in your
|
|
35
|
+
`HaneulGrpcClient` to resolve it to the correct address.
|
|
36
36
|
|
|
37
37
|
## Generating code
|
|
38
38
|
|
|
@@ -40,19 +40,19 @@ To generate code, you will first need to create `package_summaries` for your pac
|
|
|
40
40
|
this by running the following command in the root of you move package:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
|
|
43
|
+
haneul move summary
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
this will create a new `package_summaries` directory (which can be added to `.gitignore`) for the
|
|
47
47
|
codegen tool to analyze when generating code for your package.
|
|
48
48
|
|
|
49
|
-
If you are having trouble with this command, ensure you are using the latest version of the
|
|
49
|
+
If you are having trouble with this command, ensure you are using the latest version of the haneul cli
|
|
50
50
|
(version `1.51.1` or later).
|
|
51
51
|
|
|
52
52
|
Now that you have the `package_summaries` you can generate you typescript code, by running
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
pnpm
|
|
55
|
+
pnpm haneul-ts-codegen generate
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
or by adding something the following script to your package.json and running `pnpm codegen`
|
|
@@ -60,21 +60,23 @@ or by adding something the following script to your package.json and running `pn
|
|
|
60
60
|
```json
|
|
61
61
|
{
|
|
62
62
|
"scripts": {
|
|
63
|
-
"codegen": "
|
|
63
|
+
"codegen": "haneul-ts-codegen generate"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
## Setting up
|
|
68
|
+
## Setting up Haneul Client with MVR
|
|
69
69
|
|
|
70
70
|
If your package is registered on MVR, the generated code should work without additional
|
|
71
|
-
configuration. If you are using a `@local-pkg` name, you will need to configure your `
|
|
72
|
-
|
|
71
|
+
configuration. If you are using a `@local-pkg` name, you will need to configure your `HaneulGrpcClient`
|
|
72
|
+
to resolve the package name correctly:
|
|
73
73
|
|
|
74
74
|
```ts
|
|
75
|
-
|
|
75
|
+
import { HaneulGrpcClient } from '@haneullabs/haneul/grpc';
|
|
76
|
+
|
|
77
|
+
const client = new HaneulGrpcClient({
|
|
76
78
|
network: 'testnet',
|
|
77
|
-
|
|
79
|
+
baseUrl: 'https://fullnode.testnet.haneul.io:443',
|
|
78
80
|
mvr: {
|
|
79
81
|
overrides: {
|
|
80
82
|
packages: {
|
|
@@ -85,39 +87,39 @@ const client = new HaneulClient({
|
|
|
85
87
|
});
|
|
86
88
|
```
|
|
87
89
|
|
|
88
|
-
If you are using `dapp-kit`, you
|
|
90
|
+
If you are using `dapp-kit-core`, you can configure package overrides when creating your dApp Kit
|
|
91
|
+
instance:
|
|
89
92
|
|
|
90
93
|
```ts
|
|
91
|
-
|
|
94
|
+
import { createDAppKit } from '@haneullabs/dapp-kit-core';
|
|
95
|
+
import { HaneulGrpcClient } from '@haneullabs/haneul/grpc';
|
|
96
|
+
|
|
97
|
+
const GRPC_URLS = {
|
|
98
|
+
testnet: 'https://fullnode.testnet.haneul.io:443',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const PACKAGE_IDS = {
|
|
92
102
|
testnet: {
|
|
93
|
-
|
|
94
|
-
variables: {
|
|
95
|
-
yourPackageId: YOUR_TESTNET_PACKAGE_ID,
|
|
96
|
-
},
|
|
103
|
+
yourPackage: YOUR_TESTNET_PACKAGE_ID,
|
|
97
104
|
},
|
|
98
|
-
}
|
|
99
|
-
```
|
|
105
|
+
};
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
createClient={(network, config) => {
|
|
106
|
-
return new HaneulClient({
|
|
107
|
+
const dAppKit = createDAppKit({
|
|
108
|
+
networks: ['testnet'],
|
|
109
|
+
createClient: (network) => {
|
|
110
|
+
return new HaneulGrpcClient({
|
|
107
111
|
network,
|
|
108
|
-
|
|
112
|
+
baseUrl: GRPC_URLS[network],
|
|
109
113
|
mvr: {
|
|
110
114
|
overrides: {
|
|
111
115
|
packages: {
|
|
112
|
-
'@local-pkg/your-package':
|
|
116
|
+
'@local-pkg/your-package': PACKAGE_IDS[network].yourPackage,
|
|
113
117
|
},
|
|
114
118
|
},
|
|
115
119
|
},
|
|
116
120
|
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
<App />
|
|
120
|
-
</HaneulClientProvider>
|
|
121
|
+
},
|
|
122
|
+
});
|
|
121
123
|
```
|
|
122
124
|
|
|
123
125
|
## Calling Move Functions
|
|
@@ -140,7 +142,7 @@ async function createCounter() {
|
|
|
140
142
|
// Add a create call
|
|
141
143
|
tx.add(counter.create());
|
|
142
144
|
|
|
143
|
-
const { digest } =
|
|
145
|
+
const { digest } = haneulClient.signAndExecuteTransaction({
|
|
144
146
|
transaction: tx,
|
|
145
147
|
signer: keypair,
|
|
146
148
|
});
|
|
@@ -159,7 +161,7 @@ async function incrementCount(id: string) {
|
|
|
159
161
|
}),
|
|
160
162
|
);
|
|
161
163
|
|
|
162
|
-
const { digest } =
|
|
164
|
+
const { digest } = haneulClient.signAndExecuteTransaction({
|
|
163
165
|
transaction: tx,
|
|
164
166
|
signer: keypair,
|
|
165
167
|
});
|
|
@@ -178,7 +180,7 @@ First, you will need to load the bcs data for your object, then parse it with yo
|
|
|
178
180
|
import * as counter from './generated/counter/counter';
|
|
179
181
|
|
|
180
182
|
async await function readCounter(id: string) {
|
|
181
|
-
const data =
|
|
183
|
+
const data = haneulClient.getObject({
|
|
182
184
|
id,
|
|
183
185
|
options: {
|
|
184
186
|
// request the bcs data when loading your object
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-complete.d.mts","names":[],"sources":["../../src/bin/bash-complete.ts"],"mappings":";;iBAqBsB,IAAA,CAAA,GAAI,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { buildContext } from "../cli/context.mjs";
|
|
3
|
+
import { buildCli } from "../cli/cli.mjs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { proposeCompletions } from "@stricli/core";
|
|
7
|
+
|
|
8
|
+
//#region src/bin/bash-complete.ts
|
|
9
|
+
async function getVersion() {
|
|
10
|
+
const dirname = import.meta.dirname;
|
|
11
|
+
const packageJsonPath = resolve(dirname, dirname.endsWith("src/bin") ? "../../package.json" : "../../package.json");
|
|
12
|
+
return JSON.parse(await readFile(packageJsonPath, "utf-8")).version;
|
|
13
|
+
}
|
|
14
|
+
async function main() {
|
|
15
|
+
const cli = buildCli(await getVersion());
|
|
16
|
+
const inputs = process.argv.slice(3);
|
|
17
|
+
if (process.env["COMP_LINE"]?.endsWith(" ")) inputs.push("");
|
|
18
|
+
try {
|
|
19
|
+
for (const { completion } of await proposeCompletions(cli, inputs, buildContext(process))) process.stdout.write(`${completion}\n`);
|
|
20
|
+
} catch {}
|
|
21
|
+
}
|
|
22
|
+
main().then(() => process.exit(0), (error) => {
|
|
23
|
+
console.error(error);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { main };
|
|
29
|
+
//# sourceMappingURL=bash-complete.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-complete.mjs","names":[],"sources":["../../src/bin/bash-complete.ts"],"sourcesContent":["#!/usr/bin/env node\n// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { proposeCompletions } from '@stricli/core';\nimport { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport { buildContext } from '../cli/context.js';\nimport { buildCli } from '../cli/cli.js';\n\nasync function getVersion() {\n\t// @ts-ignore\n\tconst dirname = import.meta.dirname;\n\tconst packageJsonPath = resolve(\n\t\tdirname,\n\t\tdirname.endsWith('src/bin') ? '../../package.json' : '../../package.json',\n\t);\n\tconst packageJson: { version: string } = JSON.parse(await readFile(packageJsonPath, 'utf-8'));\n\treturn packageJson.version;\n}\n\nexport async function main() {\n\tconst version = await getVersion();\n\tconst cli = buildCli(version);\n\n\tconst inputs = process.argv.slice(3);\n\tif (process.env['COMP_LINE']?.endsWith(' ')) {\n\t\tinputs.push('');\n\t}\n\n\ttry {\n\t\tfor (const { completion } of await proposeCompletions(cli, inputs, buildContext(process))) {\n\t\t\tprocess.stdout.write(`${completion}\\n`);\n\t\t}\n\t} catch {\n\t\t// ignore\n\t}\n}\n\nmain().then(\n\t() => process.exit(0),\n\t(error) => {\n\t\tconsole.error(error);\n\t\tprocess.exit(1);\n\t},\n);\n"],"mappings":";;;;;;;;AAUA,eAAe,aAAa;CAE3B,MAAM,UAAU,OAAO,KAAK;CAC5B,MAAM,kBAAkB,QACvB,SACA,QAAQ,SAAS,UAAU,GAAG,uBAAuB,qBACrD;AAED,QADyC,KAAK,MAAM,MAAM,SAAS,iBAAiB,QAAQ,CAAC,CAC1E;;AAGpB,eAAsB,OAAO;CAE5B,MAAM,MAAM,SADI,MAAM,YAAY,CACL;CAE7B,MAAM,SAAS,QAAQ,KAAK,MAAM,EAAE;AACpC,KAAI,QAAQ,IAAI,cAAc,SAAS,IAAI,CAC1C,QAAO,KAAK,GAAG;AAGhB,KAAI;AACH,OAAK,MAAM,EAAE,gBAAgB,MAAM,mBAAmB,KAAK,QAAQ,aAAa,QAAQ,CAAC,CACxF,SAAQ,OAAO,MAAM,GAAG,WAAW,IAAI;SAEjC;;AAKT,MAAM,CAAC,WACA,QAAQ,KAAK,EAAE,GACpB,UAAU;AACV,SAAQ,MAAM,MAAM;AACpB,SAAQ,KAAK,EAAE;EAEhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/bin/cli.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { buildContext } from "../cli/context.mjs";
|
|
3
|
+
import { buildCli } from "../cli/cli.mjs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { run } from "@stricli/core";
|
|
7
|
+
|
|
8
|
+
//#region src/bin/cli.ts
|
|
9
|
+
async function getVersion() {
|
|
10
|
+
const dirname = import.meta.dirname;
|
|
11
|
+
const packageJsonPath = resolve(dirname, dirname.endsWith("src/bin") ? "../../package.json" : "../../package.json");
|
|
12
|
+
return JSON.parse(await readFile(packageJsonPath, "utf-8")).version;
|
|
13
|
+
}
|
|
14
|
+
async function main() {
|
|
15
|
+
await run(buildCli(await getVersion()), process.argv.slice(2), buildContext(process));
|
|
16
|
+
}
|
|
17
|
+
main().then(() => process.exit(0), (error) => {
|
|
18
|
+
console.error(error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { };
|
|
24
|
+
//# sourceMappingURL=cli.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../../src/bin/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { run } from '@stricli/core';\nimport { buildContext } from '../cli/context.js';\nimport { buildCli } from '../cli/cli.js';\nimport { readFile } from 'node:fs/promises';\nimport { resolve } from 'node:path';\n\nasync function getVersion() {\n\t// @ts-ignore\n\tconst dirname = import.meta.dirname;\n\n\tconst packageJsonPath = resolve(\n\t\tdirname,\n\t\tdirname.endsWith('src/bin') ? '../../package.json' : '../../package.json',\n\t);\n\tconst packageJson: { version: string } = JSON.parse(await readFile(packageJsonPath, 'utf-8'));\n\treturn packageJson.version;\n}\n\nasync function main() {\n\tconst version = await getVersion();\n\tawait run(buildCli(version), process.argv.slice(2), buildContext(process));\n}\n\nmain().then(\n\t() => process.exit(0),\n\t(error) => {\n\t\tconsole.error(error);\n\t\tprocess.exit(1);\n\t},\n);\n"],"mappings":";;;;;;;;AAUA,eAAe,aAAa;CAE3B,MAAM,UAAU,OAAO,KAAK;CAE5B,MAAM,kBAAkB,QACvB,SACA,QAAQ,SAAS,UAAU,GAAG,uBAAuB,qBACrD;AAED,QADyC,KAAK,MAAM,MAAM,SAAS,iBAAiB,QAAQ,CAAC,CAC1E;;AAGpB,eAAe,OAAO;AAErB,OAAM,IAAI,SADM,MAAM,YAAY,CACP,EAAE,QAAQ,KAAK,MAAM,EAAE,EAAE,aAAa,QAAQ,CAAC;;AAG3E,MAAM,CAAC,WACA,QAAQ,KAAK,EAAE,GACpB,UAAU;AACV,SAAQ,MAAM,MAAM;AACpB,SAAQ,KAAK,EAAE;EAEhB"}
|
package/dist/cli/cli.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { generateCommand } from "./commands/generate/command.mjs";
|
|
2
|
+
import { buildApplication, buildRouteMap } from "@stricli/core";
|
|
3
|
+
import { buildInstallCommand, buildUninstallCommand } from "@stricli/auto-complete";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/cli.ts
|
|
6
|
+
function buildCli(version) {
|
|
7
|
+
return buildApplication(buildRouteMap({
|
|
8
|
+
routes: {
|
|
9
|
+
generate: generateCommand,
|
|
10
|
+
install: buildInstallCommand("haneul-ts-codegen", { bash: "__haneul-ts-codegen_bash_complete" }),
|
|
11
|
+
uninstall: buildUninstallCommand("haneul-ts-codegen", { bash: true })
|
|
12
|
+
},
|
|
13
|
+
docs: {
|
|
14
|
+
brief: "Generate TypeScript bindings for your Move code",
|
|
15
|
+
hideRoute: {
|
|
16
|
+
install: true,
|
|
17
|
+
uninstall: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}), {
|
|
21
|
+
name: "haneul-ts-codegen",
|
|
22
|
+
versionInfo: { currentVersion: version }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { buildCli };
|
|
28
|
+
//# sourceMappingURL=cli.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../../src/cli/cli.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { buildApplication, buildRouteMap } from '@stricli/core';\nimport { buildInstallCommand, buildUninstallCommand } from '@stricli/auto-complete';\nimport { generateCommand } from './commands/generate/command.js';\n\nexport function buildCli(version: string) {\n\tconst routes = buildRouteMap({\n\t\troutes: {\n\t\t\tgenerate: generateCommand,\n\t\t\tinstall: buildInstallCommand('haneul-ts-codegen', { bash: '__haneul-ts-codegen_bash_complete' }),\n\t\t\tuninstall: buildUninstallCommand('haneul-ts-codegen', { bash: true }),\n\t\t},\n\t\tdocs: {\n\t\t\tbrief: 'Generate TypeScript bindings for your Move code',\n\t\t\thideRoute: {\n\t\t\t\tinstall: true,\n\t\t\t\tuninstall: true,\n\t\t\t},\n\t\t},\n\t});\n\n\treturn buildApplication(routes, {\n\t\tname: 'haneul-ts-codegen',\n\t\tversionInfo: {\n\t\t\tcurrentVersion: version,\n\t\t},\n\t});\n}\n"],"mappings":";;;;;AAMA,SAAgB,SAAS,SAAiB;AAgBzC,QAAO,iBAfQ,cAAc;EAC5B,QAAQ;GACP,UAAU;GACV,SAAS,oBAAoB,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;GAChG,WAAW,sBAAsB,qBAAqB,EAAE,MAAM,MAAM,CAAC;GACrE;EACD,MAAM;GACL,OAAO;GACP,WAAW;IACV,SAAS;IACT,WAAW;IACX;GACD;EACD,CAAC,EAE8B;EAC/B,MAAM;EACN,aAAa,EACZ,gBAAgB,SAChB;EACD,CAAC"}
|