nested Timepoint/Duration in struct args rejected by from_json
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 75/100
Línea de trabajo
El problema está en cmd/crates/soroban-spec-tools/src/lib.rs. Consulta la función from_json alrededor de la línea 328 y la función from_json_primitives alrededor de la línea 937. La corrección consiste en añadir ScType::Timepoint y ScType::Duration a la rama match que dirige a primitives y, luego, asegurarse de que produzcan la variante ScVal correcta (ScVal::Timepoint y ScVal::Duration) en lugar de ScVal::U64. Para probarlo, compila la CLI y ejecuta el comando de reproducción proporcionado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
When a contract function takes a struct with a `Timepoint` or `Duration` field, `stellar contract invoke` fails to parse the JSON argument. Top-level Timepoint/Duration args work fine.
Root cause
Two bugs in `cmd/crates/soroban-spec-tools/src/lib.rs`:
1. `from_json` does not route Timepoint/Duration to primitive parsing
The match arm at line ~328 that dispatches to `from_json_primitives` lists:
`Bool, U128, I128, U256, I256, I32, I64, U32, U64, String, Symbol, Address, MuxedAddress, Bytes, BytesN`
`Timepoint` and `Duration` are missing. When a struct field has type `Timepoint`, `parse_strukt` calls `from_json(Value::Number(1234), ScType::Timepoint)`. Since Timepoint is not in the list, it falls through to the serde catch-all which tries to deserialize a bare JSON number as `ScVal` -- this fails because `ScVal` expects tagged format (`{"timepoint": 1234}`).
Top-level args work because `from_string` pre-wraps the value as `{"timepoint": "value"}` before calling `from_json`.
2. `from_json_primitives` constructs `ScVal::U64` instead of `ScVal::Timepoint`
Line ~937:
```rust
(ScType::U64 | ScType::Timepoint | ScType::Duration, Value::Number(n)) => ScVal::U64(...)
```
This produces `ScVal::U64` for all three types. The Soroban VM distinguishes `SCV_U64` from `SCV_TIMEPOINT` and `SCV_DURATION` -- passing the wrong discriminant causes a host argument type mismatch at runtime.
Reproduce
Contract:
```rust
#[contracttype]
pub struct TimedAction {
pub deadline: Timepoint,
pub name: Symbol,
}
pub fn schedule(env: Env, action: TimedAction) -> TimedAction { action }
```
Invoke:
```
stellar contract invoke --id -- schedule --action '{"deadline": 1760501234, "name": "test"}'
```
Fails with a serde deserialization error on the `deadline` field.
Fix
- Add `| ScType::Timepoint | ScType::Duration` to the `from_json` primitives routing arm
- Split the `from_json_primitives` match so Timepoint produces `ScVal::Timepoint(TimePoint(...))` and Duration produces `ScVal::Duration(Duration(...))`
- Lenguaje dominante
- Rust
- Estrellas
- 123
- Forks
- 147
- Merge medio
- 3 d 11 h
- PR fusionados (30 d)
- 39
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stellar/stellar-cli
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
stellar/stellar-cli#2781 ·
Los mantenedores suelen responder en 2 días
-
Display the full authorization tree before signing auth entriesPosiblemente ocupada @DeadZen la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
stellar/stellar-cli#2779 ·
Los mantenedores suelen responder en 2 días
-
`tx update sequence-number next` fails when the transaction source is a muxed accountPosiblemente ocupada @neimasilk-arch la tomó hace 2 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
stellar/stellar-cli#2774 ·
Los mantenedores suelen responder en 2 días
-
`tx edit` fails on transaction XDR that is wrapped across multiple linesPosiblemente ocupada @neimasilk-arch la tomó hace 2 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
stellar/stellar-cli#2773 ·
Los mantenedores suelen responder en 2 días
-
`tx new liquidity-pool-deposit`/`-withdraw` reject the hex pool ID supported on other commandsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
stellar/stellar-cli#2770 · 1 comentario ·
Los mantenedores suelen responder en 2 días
Todos los issues de stellar/stellar-cli
Issues similares
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
zcashlabs/thus-spoke-zakura#153 ·
Los mantenedores suelen responder en 1 día
-
claude_code: step fails on session-scoped (`@inline`) plugins with `Invalid scope "session"`Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
topgrade-rs/topgrade#2395 ·
Los mantenedores suelen responder en 1 día
-
app bug windows-os
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
Improve sublime text syntaxAbiertoeditor good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
funnyboy-roks/inq#54 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
pnpm/pnpm#16635 · 1 comentario ·
Los mantenedores suelen responder en 1 día