0xMiden / 0xMiden/protocol

Prefer using `AssetAmount` instead of `u64` for asset amounts

オープン
#2,781 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る
rust standards
主要言語
Rust
スター
132
フォーク
167
平均マージ
1日 23時間
マージ済み PR(30日)
110

説明

We have recently introduced `AssetAmount`, but we're not using it to its full extent yet. A couple of improvements we can make:

- `impl From for Felt` so users can infallibly do this conversion without having to `expect`.
- We can simplify logic like this then:
https://github.com/0xMiden/protocol/blob/c46871a4e2c4028c52fa1a7a5f4eea36514e4374/crates/miden-protocol/src/asset/fungible.rs#L153-L156
- The `FungibleAsset::amount` API should return `AssetAmount` instead of u64 so users can take advantage of the guarantees of `AssetAmount`. This should have a lot of ripple effects to also convert other APIs that deal with asset amounts to use `AssetAmount`.
- After https://github.com/0xMiden/protocol/pull/2636:
- `PswapNote::create_args(account_fill: u64, note_fill: u64)` which deals with asset amounts.
- `PswapNote::calculate_output_amount(offered_total: u64, requested_total: u64, fill_amount: u64) -> u64` can use `AssetAmount`.

These are just examples. We should explore the codebase to see where similar patterns can be improved / simplified.

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

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

評価

この issue はまだ評価されていません。

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

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