Commit e98204f
feat: add struct/enum transaction argument support with dual sync/async API
Implements support for passing public copy structs and enums as transaction
arguments in JSON format, matching the Rust CLI implementation.
Key Features:
- Struct arguments: Pass structs with field names as JSON objects
- Enum arguments: Pass enum variants with variant name and fields
- Option<T> support: Both legacy vector format and new variant format
- Dual API design: Synchronous (offline) and asynchronous (with struct/enum)
Architecture:
- checkOrConvertArgument() - synchronous, offline, no struct/enum (original)
- checkOrConvertArgumentWithABI() - async, with struct/enum support (new)
- StructEnumArgumentParser - handles struct/enum encoding via REST API
- Module ABI caching (5 min TTL) to minimize network calls
Backward Compatibility:
- No breaking changes - all existing synchronous APIs preserved
- digitalAsset.ts remains synchronous (no modifications)
- generateTransactionPayloadWithABI() maintains offline design
- Struct/enum support is opt-in via async functions
Implementation Details:
- Fetches module ABIs from REST API for struct/enum type information
- BCS encoding based on struct field definitions and enum variant layouts
- Clear error messages guide users to async API when struct/enum detected
- Comprehensive test coverage for all supported formats
Related: Rust CLI PR #18591
Addresses review comments: backward compatibility, offline design, no breaking changes
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent d10017e commit e98204f
File tree
13 files changed
+8138
-4693
lines changed- plans
- src
- internal
- transactions
- transactionBuilder
- tests
- e2e/transaction
- unit
13 files changed
+8138
-4693
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
13 | 26 | | |
14 | 27 | | |
15 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
225 | 311 | | |
226 | 312 | | |
227 | 313 | | |
| |||
0 commit comments