0xMiden / 0xMiden/compiler

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

未關閉
#814 9 則留言 0 個 reaction 已指派 1 人 已被 @greenhat 認領 在 GitHub 檢視
rust
主要語言
Rust
星號
115
分支
84
平均合併
1 天 8 小時
30 天內合併 PR
15

描述

### 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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。