Skip to content

Commit a473e16

Browse files
authored
fix: convert CredentialCreate Expiration to readable date format (#1247)
## High Level Overview of Change Fix the incorrect date display of the `Expiration` field in `CredentialCreate` transactions in Simple view. ### Context of Change The `Expiration` field in `CredentialCreate` transactions was displaying an incorrect date in the Simple view. The timestamp was being converted twice - once by `convertRippleDate()` and then multiplied by `MILLIS_PER_SECOND` again, resulting in an incorrect date far in the future (e.g., `February 19, 58731 at 7:40:00 PM`). This change removes the unnecessary multiplication to display the correct expiration date (e.g., `October 5, 2026 at 1:53:30 PM`). ### Type of Change - [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) - [x] Tests (You added tests for code that already exists, or your new feature included in this PR) - [ ] Documentation Updates - [ ] Translation Updates - [ ] Release ## Before / After #### Before - CredentialCreate Expiration Display Expiration: February 19, 58731 at 7:40:00 PM <img width="1049" height="669" alt="before" src="https://github.com/user-attachments/assets/b2a69d5c-db7f-425e-a38a-6ee0a15cd916" /> #### After - CredentialCreate Expiration Display Expiration: October 5, 2026 at 1:53:30 PM <img width="1025" height="668" alt="after" src="https://github.com/user-attachments/assets/8102d73d-34bf-4789-9089-818a282b5bfc" /> ## Test Plan - [x] **Unit Tests** - [x] **Manual Tests** 1. `npm run build && npm start` 2. Visit transaction detail page for CredentialCreate transactions with Expiration field and confirm that the date displays correctly in Simple view
1 parent 8f5d4ea commit a473e16

File tree

4 files changed

+57
-57
lines changed

4 files changed

+57
-57
lines changed

src/containers/shared/components/Transaction/CredentialCreate/Simple.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { SimpleRow } from '../SimpleRow'
55
import { convertHexToString } from '../../../../../rippled/lib/utils'
66
import { localizeDate } from '../../../utils'
77
import { useLanguage } from '../../../hooks'
8-
import {
9-
convertRippleDate,
10-
MILLIS_PER_SECOND,
11-
} from '../../../../../rippled/lib/convertRippleDate'
8+
import { convertRippleDate } from '../../../../../rippled/lib/convertRippleDate'
129
import { DATE_OPTIONS } from '../../../transactionUtils'
1310

1411
const Simple: TransactionSimpleComponent = (
@@ -37,7 +34,7 @@ const Simple: TransactionSimpleComponent = (
3734
{expiration && (
3835
<SimpleRow label={t('expiration')} data-testid="expiration">
3936
{localizeDate(
40-
new Date(convertRippleDate(expiration) * MILLIS_PER_SECOND),
37+
new Date(convertRippleDate(expiration)),
4138
language,
4239
DATE_OPTIONS,
4340
)}

src/containers/shared/components/Transaction/CredentialCreate/test/CredentialCreateSimple.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ describe('CredentialCreate: Simple', () => {
1010
expectSimpleRowText(
1111
wrapper,
1212
'subject',
13-
'rwXChshgJHh6KwwXY8hN1iNAiuyzJkz7p6',
13+
'rDeEwcsbGz4GXyGpyRuQo9vRGGT269Jmjk',
1414
)
15-
expectSimpleRowText(wrapper, 'credential-type', 'My test credential')
15+
expectSimpleRowText(wrapper, 'credential-type', 'VerifiedAccount')
16+
expectSimpleRowText(wrapper, 'expiration', 'October 5, 2026 at 1:53:30 PM')
1617

1718
wrapper.unmount()
1819
})

src/containers/shared/components/Transaction/CredentialCreate/test/CredentialCreateTableDetail.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ describe('CredentialAcceptTableDetail ', () => {
99
const wrapper = createWrapper(mockCredentialCreate)
1010

1111
expect(wrapper.find('[data-testid="subject"]')).toHaveText(
12-
'subject: rwXChshgJHh6KwwXY8hN1iNAiuyzJkz7p6',
12+
'subject: rDeEwcsbGz4GXyGpyRuQo9vRGGT269Jmjk',
1313
)
1414
expect(wrapper.find('[data-testid="credential-type"]')).toHaveText(
15-
'credential_type: My test credential',
15+
'credential_type: VerifiedAccount',
16+
)
17+
expect(wrapper.find('[data-testid="expiration"]')).toHaveText(
18+
'expiration: 844523610',
1619
)
17-
expect(wrapper.find('[data-testid="uri"]')).toHaveText('uri: testURI')
1820

1921
wrapper.unmount()
2022
})
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,81 @@
11
{
2-
"close_time_iso": "2025-02-18T15:06:22Z",
3-
"ctid": "C006630C00000002",
4-
"hash": "FADDC5925ACC5A5C567E3C70730E090767A9B22330CFB272005169A7CABA82DB",
5-
"ledger_hash": "9C59CCF5A001D6A922A22E59A390D1526E0DF93667C4C13F14C4C23277ACEAD3",
6-
"ledger_index": 418572,
2+
"close_time_iso": "2025-10-05T13:53:31Z",
3+
"ctid": "C000DAA700000002",
4+
"hash": "38668D75129E7949649D001907709D1F8DB0FD88232B03CD510707E679AD1E0B",
5+
"ledger_hash": "B7DE3742299BE553CC1DE08EFDA3EDE88F94C65B073A623F0C72484F6A9C78C7",
6+
"ledger_index": 55975,
77
"meta": {
88
"AffectedNodes": [
9+
{
10+
"ModifiedNode": {
11+
"FinalFields": {
12+
"Account": "rfEd8iC2g1LVUj75bMkui3yTPcPj6W5Mgr",
13+
"Balance": "99999996",
14+
"Flags": 0,
15+
"OwnerCount": 1,
16+
"Sequence": 51131
17+
},
18+
"LedgerEntryType": "AccountRoot",
19+
"LedgerIndex": "3AFBED20615BECB3DE06CB98E2DD0C905E572E4D279C4B5FD77EB48E110991A4",
20+
"PreviousFields": {
21+
"Balance": "99999997",
22+
"OwnerCount": 0,
23+
"Sequence": 51130
24+
},
25+
"PreviousTxnID": "76E2BEEC3AE4DF755F821BA301CED0DCC56D20BC6ABAB5C4F3717057D9F82D1A",
26+
"PreviousTxnLgrSeq": 51555
27+
}
28+
},
929
{
1030
"CreatedNode": {
1131
"LedgerEntryType": "DirectoryNode",
12-
"LedgerIndex": "675537AB5EB6416AED24E856E20E5A203FB5A73F0C5D2D92359B5A45184BC594",
32+
"LedgerIndex": "A0102CBC99F6B6114ACD2AD065DC41A5517CB5BEA7958FACA106FF2066B8041D",
1333
"NewFields": {
14-
"Owner": "rwXChshgJHh6KwwXY8hN1iNAiuyzJkz7p6",
15-
"RootIndex": "675537AB5EB6416AED24E856E20E5A203FB5A73F0C5D2D92359B5A45184BC594"
34+
"Owner": "rDeEwcsbGz4GXyGpyRuQo9vRGGT269Jmjk",
35+
"RootIndex": "A0102CBC99F6B6114ACD2AD065DC41A5517CB5BEA7958FACA106FF2066B8041D"
1636
}
1737
}
1838
},
1939
{
2040
"CreatedNode": {
2141
"LedgerEntryType": "Credential",
22-
"LedgerIndex": "7B685088D546B9E8905D26206F452BB2F44D9A33C9BD9BCF280F7BA39015A955",
42+
"LedgerIndex": "C9B22CD799166C336E5F4EE0B85986EC354F1279F2A80C77B4A8B2EEF6EB9517",
2343
"NewFields": {
24-
"CredentialType": "4D7920746573742063726564656E7469616C",
25-
"Issuer": "rL6bethyyyphLye6A8WHhw1KxDZrwiqCmi",
26-
"Subject": "rwXChshgJHh6KwwXY8hN1iNAiuyzJkz7p6",
27-
"URI": "74657374555249"
44+
"CredentialType": "56657269666965644163636F756E74",
45+
"Expiration": 844523610,
46+
"Issuer": "rfEd8iC2g1LVUj75bMkui3yTPcPj6W5Mgr",
47+
"Subject": "rDeEwcsbGz4GXyGpyRuQo9vRGGT269Jmjk"
2848
}
2949
}
3050
},
3151
{
3252
"CreatedNode": {
3353
"LedgerEntryType": "DirectoryNode",
34-
"LedgerIndex": "7D29B654F46648EA1787141BEC0CB3BAA6B42290955C335F9A7B2F34F9D4ACA0",
54+
"LedgerIndex": "D79FCA4F80ABD89F9D0BEBB4B44986D0E5D552DECF4A12947FD2C2493CF55C4A",
3555
"NewFields": {
36-
"Owner": "rL6bethyyyphLye6A8WHhw1KxDZrwiqCmi",
37-
"RootIndex": "7D29B654F46648EA1787141BEC0CB3BAA6B42290955C335F9A7B2F34F9D4ACA0"
56+
"Owner": "rfEd8iC2g1LVUj75bMkui3yTPcPj6W5Mgr",
57+
"RootIndex": "D79FCA4F80ABD89F9D0BEBB4B44986D0E5D552DECF4A12947FD2C2493CF55C4A"
3858
}
3959
}
40-
},
41-
{
42-
"ModifiedNode": {
43-
"FinalFields": {
44-
"Account": "rL6bethyyyphLye6A8WHhw1KxDZrwiqCmi",
45-
"Balance": "99999988",
46-
"Flags": 0,
47-
"OwnerCount": 1,
48-
"Sequence": 418570
49-
},
50-
"LedgerEntryType": "AccountRoot",
51-
"LedgerIndex": "CF3D9A16400DAE31DA3F0FEF511D753C5F7560ECDB8EC9B7F9E92DC837A01F52",
52-
"PreviousFields": {
53-
"Balance": "100000000",
54-
"OwnerCount": 0,
55-
"Sequence": 418569
56-
},
57-
"PreviousTxnID": "B5B9A081FB2113EA2985B819F3014D666D9D4A563A3F7695D7DBB3EC310F92CE",
58-
"PreviousTxnLgrSeq": 418569
59-
}
6060
}
6161
],
6262
"TransactionIndex": 0,
6363
"TransactionResult": "tesSUCCESS"
6464
},
6565
"tx": {
66-
"Account": "rL6bethyyyphLye6A8WHhw1KxDZrwiqCmi",
67-
"CredentialType": "4D7920746573742063726564656E7469616C",
68-
"Fee": "12",
66+
"Account": "rfEd8iC2g1LVUj75bMkui3yTPcPj6W5Mgr",
67+
"CredentialType": "56657269666965644163636F756E74",
68+
"Expiration": 844523610,
69+
"Fee": "1",
6970
"Flags": 0,
70-
"LastLedgerSequence": 418590,
71-
"Sequence": 418569,
72-
"SigningPubKey": "ED8627CFD25412BDC67E6B1F1C219669FFEEF7F8D3D46EA572FBE394FAD3A8F46E",
73-
"Subject": "rwXChshgJHh6KwwXY8hN1iNAiuyzJkz7p6",
71+
"LastLedgerSequence": 55993,
72+
"Sequence": 51130,
73+
"SigningPubKey": "ED607EE5D1864691EAF2AB8E20873ECAC397EEFAD7E9D714EFC19F44DBC858BDDE",
74+
"Subject": "rDeEwcsbGz4GXyGpyRuQo9vRGGT269Jmjk",
7475
"TransactionType": "CredentialCreate",
75-
"TxnSignature": "D59616E53C8EE14A1584983A7D2661BCE9F30B16C8F4D10B561AB4DA5EC4989F29B344FE182A0F73B2EFCBD0D65E9B4575E1313A48707F08E8445A8BBB4CA50D",
76-
"URI": "74657374555249",
77-
"date": 793206382,
78-
"ledger_index": 418572
76+
"TxnSignature": "EDE43649F01BDAC931E5C2477AE77E7C04B82EF3DEA575F3C8C2E553221747F59E6E57A625FA858C019D9709D829ED33B6C2ABBF42C55952B1F5FCE0309F3608",
77+
"date": 812987611,
78+
"ledger_index": 55975
7979
},
8080
"validated": true
8181
}

0 commit comments

Comments
 (0)