-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add OracleSet and OracleDelete transactions (#983)
## High Level Overview of Change <!-- Please include a summary/list of the changes. If too broad, please consider splitting into multiple PRs. --> Title said it all. ### 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. --> PriceOracle amendment: XRPLF/XRPL-Standards#129 ### Type of Change <!-- Please check relevant options, delete irrelevant ones. --> - [x] New feature (non-breaking change which adds functionality) ## 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. --> OracleSet transaction page: <img width="843" alt="Screenshot 2024-05-23 at 9 20 35 PM" src="https://github.com/ripple/explorer/assets/71317875/f248328f-cc40-4d53-8f0e-b9796de5ff48"> OracleDelete transaction page: <img width="846" alt="Screenshot 2024-05-23 at 7 19 06 PM" src="https://github.com/ripple/explorer/assets/71317875/d95c7735-e355-4e54-9333-04919218a1ab"> Table Detail view: <img width="809" alt="Screenshot 2024-05-23 at 9 35 05 PM" src="https://github.com/ripple/explorer/assets/71317875/6244a478-a0fa-47e9-885d-ed938135bfd8">
- Loading branch information
Showing
29 changed files
with
624 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/containers/shared/components/Transaction/OracleDelete/Simple.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { TransactionSimpleComponent, TransactionSimpleProps } from '../types' | ||
import { SimpleRow } from '../SimpleRow' | ||
|
||
export const Simple: TransactionSimpleComponent = ({ | ||
data, | ||
}: TransactionSimpleProps) => { | ||
const { t } = useTranslation() | ||
const { OracleDocumentID } = data.instructions | ||
return ( | ||
<SimpleRow label={t('oracle_document_id')} data-test="oracle-document-id"> | ||
{OracleDocumentID} | ||
</SimpleRow> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/containers/shared/components/Transaction/OracleDelete/TableDetail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { TransactionTableDetailProps } from '../types' | ||
import { OracleDelete } from './types' | ||
|
||
export const TableDetail = ({ | ||
instructions: tx, | ||
}: TransactionTableDetailProps<OracleDelete>) => { | ||
const { t } = useTranslation() | ||
return ( | ||
<div className="oracle-document-id"> | ||
<span className="label">{t('oracle_document_id')}: </span> | ||
<span className="case-sensitive">{tx.OracleDocumentID}</span> | ||
</div> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/containers/shared/components/Transaction/OracleDelete/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
TransactionAction, | ||
TransactionCategory, | ||
TransactionMapping, | ||
} from '../types' | ||
|
||
import { Simple } from './Simple' | ||
import { TableDetail } from './TableDetail' | ||
|
||
export const OracleDeleteTransaction: TransactionMapping = { | ||
Simple, | ||
TableDetail, | ||
action: TransactionAction.CANCEL, | ||
category: TransactionCategory.DEX, | ||
} |
12 changes: 12 additions & 0 deletions
12
src/containers/shared/components/Transaction/OracleDelete/test/OracleDeleteSimple.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createSimpleWrapperFactory, expectSimpleRowText } from '../../test' | ||
import { Simple } from '../Simple' | ||
import OracleDelete from './mock_data/OracleDelete.json' | ||
|
||
const createWrapper = createSimpleWrapperFactory(Simple) | ||
describe('OracleDelete: Simple', () => { | ||
it('renders', () => { | ||
const wrapper = createWrapper(OracleDelete) | ||
expectSimpleRowText(wrapper, 'oracle-document-id', '1') | ||
wrapper.unmount() | ||
}) | ||
}) |
13 changes: 13 additions & 0 deletions
13
...ntainers/shared/components/Transaction/OracleDelete/test/OracleDeleteTableDetail.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createTableDetailWrapperFactory } from '../../test' | ||
import { TableDetail } from '../TableDetail' | ||
import OracleDelete from './mock_data/OracleDelete.json' | ||
|
||
const createWrapper = createTableDetailWrapperFactory(TableDetail) | ||
|
||
describe('OracleDelete: TableDetail', () => { | ||
it('renders', () => { | ||
const wrapper = createWrapper(OracleDelete) | ||
expect(wrapper).toHaveText('oracle_document_id: 1') | ||
wrapper.unmount() | ||
}) | ||
}) |
91 changes: 91 additions & 0 deletions
91
src/containers/shared/components/Transaction/OracleDelete/test/mock_data/OracleDelete.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"tx": { | ||
"Account": "rnuj2NkRxGbGpUK8u9hqEJA1zGRWyxHGvC", | ||
"Fee": "10", | ||
"Flags": 0, | ||
"LastLedgerSequence": 670056, | ||
"OracleDocumentID": 1, | ||
"Sequence": 670033, | ||
"SigningPubKey": "ED9376FE6E9063CB291C1031FC07A3B349D9FC45F2D71001B9CC7318F32C3A8F72", | ||
"TransactionType": "OracleDelete", | ||
"TxnSignature": "B1BD6A7AA9A0B3779D4EBE0652931D22792931B2F853C38E14BCFC2FD981FF3AFAA4921748B0321C8F0088180703425A8421606FCAFA028BF09F6E9A636DEC0D", | ||
"ctid": "C00A395600000002", | ||
"date": 768949530, | ||
"inLedger": 670038, | ||
"ledger_index": 670038 | ||
}, | ||
"meta": { | ||
"AffectedNodes": [ | ||
{ | ||
"ModifiedNode": { | ||
"FinalFields": { | ||
"Account": "rnuj2NkRxGbGpUK8u9hqEJA1zGRWyxHGvC", | ||
"Balance": "99999970", | ||
"Flags": 0, | ||
"OwnerCount": 0, | ||
"Sequence": 670034 | ||
}, | ||
"LedgerEntryType": "AccountRoot", | ||
"LedgerIndex": "05CC65869680974EF73B8C16A8D59DE7CE9C6B3B012328B11FCC28232B552EA6", | ||
"PreviousFields": { | ||
"Balance": "99999980", | ||
"OwnerCount": 1, | ||
"Sequence": 670033 | ||
}, | ||
"PreviousTxnID": "F5729FD72193989887718F13A28F2F8A33C03FD8299DC0C00F9952B28C8DA7EA", | ||
"PreviousTxnLgrSeq": 670036 | ||
} | ||
}, | ||
{ | ||
"DeletedNode": { | ||
"FinalFields": { | ||
"AssetClass": "63757272656E6379", | ||
"Flags": 0, | ||
"LastUpdateTime": 1715634318, | ||
"Owner": "rnuj2NkRxGbGpUK8u9hqEJA1zGRWyxHGvC", | ||
"OwnerNode": "0", | ||
"PreviousTxnID": "F5729FD72193989887718F13A28F2F8A33C03FD8299DC0C00F9952B28C8DA7EA", | ||
"PreviousTxnLgrSeq": 670036, | ||
"PriceDataSeries": [ | ||
{ | ||
"PriceData": { | ||
"AssetPrice": "67", | ||
"BaseAsset": "BTC", | ||
"QuoteAsset": "EUR", | ||
"Scale": 2 | ||
} | ||
}, | ||
{ | ||
"PriceData": { | ||
"AssetPrice": "2e6", | ||
"BaseAsset": "XRP", | ||
"QuoteAsset": "USD", | ||
"Scale": 1 | ||
} | ||
} | ||
], | ||
"Provider": "70726F7669646572" | ||
}, | ||
"LedgerEntryType": "Oracle", | ||
"LedgerIndex": "2E0AC1D6AFC11AD78E48BE575761F75C0326F0547EE178CBB5D67F61691E13E7" | ||
} | ||
}, | ||
{ | ||
"ModifiedNode": { | ||
"FinalFields": { | ||
"Flags": 0, | ||
"Owner": "rnuj2NkRxGbGpUK8u9hqEJA1zGRWyxHGvC", | ||
"RootIndex": "D745822C67049231E61684BF1F68DACFE522A3172FE4B635FE3966B218E90E2F" | ||
}, | ||
"LedgerEntryType": "DirectoryNode", | ||
"LedgerIndex": "D745822C67049231E61684BF1F68DACFE522A3172FE4B635FE3966B218E90E2F" | ||
} | ||
} | ||
], | ||
"TransactionIndex": 0, | ||
"TransactionResult": "tesSUCCESS" | ||
}, | ||
"hash": "DEBA9881129F2191619045FC07B294107342410BF4E447CEEB801BFC75CC2342", | ||
"ledger_index": 670038, | ||
"date": 768949530 | ||
} |
6 changes: 6 additions & 0 deletions
6
src/containers/shared/components/Transaction/OracleDelete/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { BaseTransaction } from 'xrpl' | ||
|
||
// TODO: get type from xrpl.js once it's been added there | ||
export interface OracleDelete extends BaseTransaction { | ||
OracleDocumentID: string | ||
} |
Oops, something went wrong.