Skip to content

Add support for GHS and NGN currencies#494

Merged
gcomte merged 1 commit intomasterfrom
feature/add-ghs-ngn-currencies
Mar 30, 2026
Merged

Add support for GHS and NGN currencies#494
gcomte merged 1 commit intomasterfrom
feature/add-ghs-ngn-currencies

Conversation

@gcomte
Copy link
Copy Markdown
Owner

@gcomte gcomte commented Mar 30, 2026

Add Ghanaian cedi (GHS) and Nigerian naira (NGN) to supported fiat currencies, matching what the blockchain.info ticker API already provides.

Summary by CodeRabbit

  • New Features

    • Added support for two new fiat currencies: Ghanaian cedi (GHS) and Nigerian naira (NGN).
  • Documentation

    • Updated supported currencies list.

The blockchain.info ticker API returns these currencies but they were
missing from the supported fiat list.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

This pull request adds support for two new fiat currencies: GHS (Ghanaian cedi) and NGN (Nigerian naira). The changes extend the currency enum, update the decimal places configuration to assign both currencies 2 decimal places, update the blockchain.info API consumer to parse and map these currencies, and document the additions in the README.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added GHS and NGN entries to the supported fiat currencies table.
Currency Definitions
src/currency/fiat.rs
Added GHS and NGN enum variants to Fiat; updated Currency::decimal_places match logic to return 2 decimal places for both new variants.
API Integration
src/fiat_rates/blockchain_info_consumer.rs
Extended Currencies struct deserialization to include ghs and ngn fields; added corresponding Fiat::GHS and Fiat::NGN entries to the returned HashMap in fetch_api.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #355: Modifies the Currency::decimal_places implementation in src/currency/fiat.rs that this PR extends with the new currency variants.
  • PR #354: Contains related currency mapping changes to src/currency/fiat.rs and src/fiat_rates/blockchain_info_consumer.rs, demonstrating a pattern of currency support modifications.

Poem

🐰 Two new coins hop into the fold,
From Ghana's heart and Nigeria's gold,
GHS and NGN now find their place,
In decimals two, with crypto's grace!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add support for GHS and NGN currencies' directly and clearly summarizes the main change: adding support for two new fiat currencies (Ghanaian cedi and Nigerian naira) across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-ghs-ngn-currencies

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/currency/fiat.rs (1)

62-88: Consider adding explicit precision regression tests for GHS and NGN.

This will guard against accidental remapping in future enum edits.

Proposed test addition
 #[cfg(test)]
 mod tests {
     use super::*;
     use std::time::Instant;

+    #[test]
+    fn decimal_places_for_new_fiats_are_two() {
+        assert_eq!(Fiat::GHS.decimal_places(), 2);
+        assert_eq!(Fiat::NGN.decimal_places(), 2);
+    }
+
     #[test]
     fn test_exchange_rate_caching() {
         let start = Instant::now();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/currency/fiat.rs` around lines 62 - 88, Add regression unit tests to
assert that Fiat::GHS.decimal_places() and Fiat::NGN.decimal_places() return 2
to prevent accidental remapping of those variants; create tests in the fiat.rs
test module (or existing currency tests) that call the decimal_places() method
on the Fiat enum for GHS and NGN and assert_eq!(..., 2) so future edits to the
Fiat variants or match in fn decimal_places() will fail the build if these
precisions change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/currency/fiat.rs`:
- Around line 62-88: Add regression unit tests to assert that
Fiat::GHS.decimal_places() and Fiat::NGN.decimal_places() return 2 to prevent
accidental remapping of those variants; create tests in the fiat.rs test module
(or existing currency tests) that call the decimal_places() method on the Fiat
enum for GHS and NGN and assert_eq!(..., 2) so future edits to the Fiat variants
or match in fn decimal_places() will fail the build if these precisions change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fbb08664-8f03-4128-bf2b-bdc19296c11a

📥 Commits

Reviewing files that changed from the base of the PR and between c3901cc and 7926c68.

📒 Files selected for processing (3)
  • README.md
  • src/currency/fiat.rs
  • src/fiat_rates/blockchain_info_consumer.rs

@gcomte gcomte merged commit 0ea5341 into master Mar 30, 2026
7 of 8 checks passed
@gcomte gcomte deleted the feature/add-ghs-ngn-currencies branch March 30, 2026 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant