0xMiden / 0xMiden/docs

[Docs] Code example bugs in Notes & Transactions quickstart (notes.md)

オープン 初心者向け
#161 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
10
フォーク
50
平均マージ
22日 23時間
マージ済み PR(30日)
1

説明

## Summary

The Notes & Transactions quickstart page (`docs/builder/quick-start/notes.md`) has three code example correctness issues that will confuse developers following the guide.

## Bug 1: Expected output contradicts TypeScript code in consume section

**Location:** Consume Notes section — TypeScript example + expected output

The TypeScript code wraps the balance in `Number()`:

```typescript
console.log(
"Alice's TEST token balance:",
Number(alice.vault().getBalance(faucet.id()))
);
```

But the expected output shows a `Result`-like wrapper:

```text
Alice's TEST token balance: Ok(1000)
```

These are contradictory:
- If `getBalance()` returns something like `Ok(1000)`, then `Number(Ok(1000))` would produce `NaN`, not `Ok(1000)`
- If `getBalance()` returns a number, the output should be `1000`, not `Ok(1000)`

Additionally, the **send section** on the same page shows the same code pattern producing `Alice's TEST token balance: 100` — no `Ok()` wrapper. So the same code path shows two different output formats within the same document.

**Suggested fix:** Determine the actual return type of `getBalance()` and correct the expected output to match what the TypeScript code actually produces. Align both the consume and send sections to use the same format.

## Bug 2: Expected output uses wrong log message for send transaction

**Location:** Send Tokens section — TypeScript example + expected output

The TypeScript send code logs:

```typescript
console.log("Send transaction submitted successfully, ID:", sendTxId.toHex());
```

But the expected output shows:

```text
Send 100 tokens to Bob note transaction ID: "0x51ac27474ade3a54..."
```

The log message in the code says `"Send transaction submitted successfully, ID:"` but the expected output says `"Send 100 tokens to Bob note transaction ID:"`. The expected output appears to be copied from the Rust example's `println!` rather than the TypeScript `console.log`.

**Suggested fix:** Update the expected output to match the actual TypeScript log message, or update the TypeScript code to match the expected output.

## Bug 3: Unused `ConsumableNoteRecord` import in send.ts example

**Location:** Send Tokens section — TypeScript example

```typescript
import {
WebClient,
AccountStorageMode,
NoteType,
ConsumableNoteRecord, // <-- imported but never used
AccountId,
AuthScheme,
} from "@miden-sdk/miden-sdk";
```

`ConsumableNoteRecord` is imported but never used in the send example. This suggests the code was copy-pasted from the consume example without cleanup, which undermines confidence in the example's correctness.

**Suggested fix:** Remove the unused `ConsumableNoteRecord` import from the send.ts example.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Issueは`docs/builder/quick-start/notes.md`ファイルにあります。まず、リポジトリ内でファイルを特定します。「Consume Notes」と「Send Tokens」セクションのTypeScriptコードブロックを調べて、報告された不整合を確認します。SDKのソースコードまたは既存のテストを参照して、`getBalance()`の実際の戻り値の型を確認します。期待される出力文字列を修正し、未使用のインポートを削除します。変更をローカルでドキュメントをビルドして検証し、フォーマットが保持されていることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
documentation
issue の種類
ドキュメント
難易度
1/5
見積もり時間
1時間未満
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
90/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。