0xMiden / 0xMiden/compiler

Schema for user-defined types in the contracts (note inputs, etc.)

Đang mở
#814 9 bình luận 0 reaction 1 người được giao Được @greenhat nhận Xem trên GitHub
rust
Ngôn ngữ chính
Rust
Star
115
Fork
84
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
15

Mô tả

### Why

When a user defines a custom type as part of the note inputs, they have to define it both in the on-chain code (note script) for deserialization and in the off-chain code for serialization when passing note inputs using `miden-client` API.
We would like to avoid the duplicate type definition and define the type only once. With the on-chain definition being the source of truth.

### How

We could generate the WIT representation for the type defined in Rust (note script) by the user with a macro. Given our previous experience of generating a WIT interface for the account (in the `#[component]` macro), I would say it is easy and should not take more than a day. We could store it in the Miden package as a custom section.
Then, in the off-chain code we would generate the Rust type from the WIT from the note script's Miden package using `wit-bindgen` machinery. This task seems like it could be done in a couple of days tops.

EDIT: #870 is the prerequisite for this task

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.