Skip to content

Commit 1f8985d

Browse files
pdp2121intelliot
authored andcommitted
fix: handle non standard currency with decoded length of 3 (#1131)
## High Level Overview of Change <!-- Please include a summary/list of the changes. If too broad, please consider splitting into multiple PRs. --> Handle non standard currency that decoded to 3 characters, putting prefix `Fake` to such currency. Instead of being non-standard, 3 character currency codes should use the [standard format](https://xrpl.org/docs/references/protocol/data-types/currency-formats#standard-currency-codes) if they are not "fake". ### Context of Change <!-- Please include the context of a change. If a bug fix, when was the bug introduced? What was the behavior? If a new feature, why was this architecture chosen? What were the alternatives? If a refactor, how is this better than the previous implementation? If there is a design document for this feature, please link it here. --> Resolve #1130 ### Type of Change <!-- Please check relevant options, delete irrelevant ones. --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Refactor (non-breaking change that only restructures code) - [ ] Tests (You added tests for code that already exists, or your new feature included in this PR) - [ ] Documentation Updates - [ ] Translation Updates - [ ] Release ## Before / After <!-- If just refactoring / back-end changes, this can be just an in-English description of the change at a technical level. If a UI change, screenshots should be included. --> ### Before <img width="941" alt="Screenshot 2025-02-19 at 4 06 15 PM" src="https://github.com/user-attachments/assets/f7df4ce9-942e-4274-b7ea-39050b976456" /> ### After <img width="952" alt="Screenshot 2025-02-19 at 4 07 00 PM" src="https://github.com/user-attachments/assets/95e46ee3-01c7-425d-a0ca-d2e584eccb76" /> --------- Co-authored-by: Elliot Lee <github.public@intelliot.com>
1 parent 3de6037 commit 1f8985d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/containers/shared/components/Currency.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ const Currency = (props: Props) => {
4040
display
4141
)
4242
} else {
43-
const currencyCode =
43+
let currencyCode =
4444
currency?.length === NON_STANDARD_CODE_LENGTH &&
4545
currency?.substring(0, 2) !== LP_TOKEN_IDENTIFIER
4646
? hexToString(currency)
4747
: currency
4848

49+
if (
50+
currency?.length === NON_STANDARD_CODE_LENGTH &&
51+
currencyCode.length === 3
52+
) {
53+
currencyCode = `Fake${currencyCode}`
54+
}
55+
4956
let display = `${currencyCode}`
5057

5158
if (currencyCode === XRP && displaySymbol) {

src/containers/shared/components/test/Currency.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ describe('Currency', () => {
5858
wrapper.unmount()
5959
})
6060

61+
it('handle non-standard currency decoded to equal or fewer than 3 characters', () => {
62+
const wrapper = mount(
63+
<Currency currency="5852500000000000000000000000000000000000" />,
64+
)
65+
expect(wrapper.find('.currency').text()).toEqual('FakeXRP')
66+
})
67+
6168
it('displays the XRP symbol when rendering XRP', () => {
6269
const wrapper = mount(<Currency currency="XRP" />)
6370
expect(wrapper.find('.currency').text()).toEqual('\uE900 XRP')

0 commit comments

Comments
 (0)