`invoice_count()` returns the next invoice id, not the number of invoices

オープン
#55 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust

調査の方向性

Start in contracts/invoice/src/lib.rs at invoice_count, which returns the stored NextId, and at the test invoice_count_returns_next_id in contracts/invoice/src/test.rs, which currently asserts that behaviour. Confirm the intended semantics with a maintainer first, since the issue asks for either NextId - 1 or a rename to a next-id function. Done means the count matches the chosen semantics, the doc comment and contracts/invoice/README.md agree, and cargo test, cargo fmt --check and clippy pass.

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

説明

bug contract difficulty: beginner needs-discussion

Difficulty: Beginner

Problem

invoice_count returns the stored NextId, which is 1 when no invoice exists. The unit test invoice_count_returns_next_id codifies this, and the doc comment says "total number of invoices ever created (the next invoice id)", which contradicts itself. A client that loops 1..=count would be off by one.

Why it matters

The function exists to replace the id-by-id scan. An off-by-one in a newly merged public function is cheapest to fix before the contract is redeployed (the live testnet contract does not have it yet).

Scope of work

Make the function return the real count (NextId - 1, saturating) or rename it to match its behaviour, update its doc comment, test and the contract README, and state the choice in the PR.

Acceptance criteria

  • No invoices gives 0; after N creations it gives N (or the function is renamed and documented as "next id").
  • Test and README updated.
  • cargo fmt --check, clippy and tests pass.

Relevant files

  • contracts/invoice/src/lib.rs
  • contracts/invoice/src/test.rs
  • contracts/invoice/README.md

Dependencies

Related to #27, #28 and #29, which also touch lib.rs; coordinate to avoid conflicts.

Maintainer discussion needed?

Yes, briefly: confirm the intended semantics. The function is not deployed yet, so there is no compatibility concern.

主要言語
TypeScript
スター
0
フォーク
4
平均マージ
54分
マージ済み PR(30日)
6

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Yormee-103/PayLoop のほかの issue

Yormee-103/PayLoop の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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