0xMiden / 0xMiden/compiler

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

Aberta
#814 9 comentários 0 reações 1 responsável Reivindicada por @greenhat Ver no GitHub
rust
Linguagem predominante
Rust
Estrelas
115
Forks
84
Merge médio
1d 8h
PRs com merge (30d)
15

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

The issue involves generating a WIT representation from a Rust type defined in a note script using a macro, storing it in the Miden package, and then generating a Rust type off-chain from that WIT using wit-bindgen. Start by examining the existing #[component] macro for WIT generation. Look at the note script deserialization code and the miden-client API serialization. The prerequisite is issue #870, so review that first. 'Done' means a user can define a custom type once in the on-chain code and have it automatically available off-chain.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
rust
Domínio
compilers
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
45/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.