nested Timepoint/Duration in struct args rejected by from_json
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
問題は cmd/crates/soroban-spec-tools/src/lib.rs にあります。328 行目あたりの from_json 関数と、937 行目あたりの from_json_primitives 関数を確認してください。修正では、primitives に振り分ける match アームに ScType::Timepoint と ScType::Duration を追加し、それらが ScVal::U64 ではなく正しい ScVal バリアント (ScVal::Timepoint と ScVal::Duration) を生成することを確認します。CLI をビルドし、提供された再現コマンドを実行してテストしてください。
索引モデルが issue の本文から書いたものです。
説明
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(...))`
- 主要言語
- Rust
- スター
- 123
- フォーク
- 147
- 平均マージ
- 3日 11時間
- マージ済み PR(30日)
- 39
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
stellar/stellar-cli のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
stellar/stellar-cli#2781 ·
メンテナーはふだん 2 日以内に返信
-
Display the full authorization tree before signing auth entries対応中かも @DeadZen が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
stellar/stellar-cli#2779 ·
メンテナーはふだん 2 日以内に返信
-
`tx update sequence-number next` fails when the transaction source is a muxed account対応中かも @neimasilk-arch が 3 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
stellar/stellar-cli#2774 ·
メンテナーはふだん 2 日以内に返信
-
`tx edit` fails on transaction XDR that is wrapped across multiple lines対応中かも @neimasilk-arch が 3 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
stellar/stellar-cli#2773 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
stellar/stellar-cli#2770 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
stellar/stellar-cli の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
wardian-app/Wardian#1603 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
peteonrails/voxtype#844 ·
メンテナーはふだん 1 日以内に返信
-
feature
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
uwuclxdy/clauth#107 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信