Skip to content

Commit

Permalink
feat: add OracleSet and OracleDelete transactions (#983)
Browse files Browse the repository at this point in the history
## 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
pdp2121 authored May 24, 2024
1 parent a71fa2f commit 33ca4f4
Show file tree
Hide file tree
Showing 29 changed files with 624 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"redux": "^5.0.1",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"ripple-address-codec": "^5.0.0-beta.1",
"ripple-address-codec": "^5.0.0",
"topojson-client": "^3.0.0",
"usehooks-ts": "^2.9.1",
"vite": "^4.2.3",
Expand Down
10 changes: 9 additions & 1 deletion public/locales/ca-CA/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
"transaction_type_name_NFTokenMint": "Encunyar NFT",
"transaction_type_name_OfferCancel": "Cancel·lar Oferta",
"transaction_type_name_OfferCreate": "Crear Ofertae",
"transaction_type_name_OracleDelete": null,
"transaction_type_name_OracleSet": null,
"transaction_type_name_Payment": "Pagament",
"transaction_type_name_PaymentChannelClaim": "Reclamar al Canal de Pagament",
"transaction_type_name_PaymentChannelCreate": "Crear Canal de Pagament",
Expand Down Expand Up @@ -522,5 +524,11 @@
"note": "Nota",
"indicate_unl": "indica un validador en una UNL",
"transaction_tokens_involved": "<Currency/> i <Currency2/>",
"transaction_tokens_swapped": "<Currency/> per <Currency2/>"
"transaction_tokens_swapped": "<Currency/> per <Currency2/>",
"oracle_document_id": null,
"provider": null,
"last_update_time": null,
"asset_class": null,
"trading_pairs": null,
"deleted": null
}
10 changes: 9 additions & 1 deletion public/locales/en-US/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
"transaction_type_name_NFTokenMint": "NFT Mint",
"transaction_type_name_OfferCancel": "Offer Cancel",
"transaction_type_name_OfferCreate": "Offer Create",
"transaction_type_name_OracleDelete": "Oracle Delete",
"transaction_type_name_OracleSet": "Oracle Set",
"transaction_type_name_Payment": "Payment",
"transaction_type_name_PaymentChannelClaim": "Payment Channel Claim",
"transaction_type_name_PaymentChannelCreate": "Payment Channel Create",
Expand Down Expand Up @@ -522,5 +524,11 @@
"note": "Note",
"indicate_unl": "indicates a validator on an UNL",
"transaction_tokens_involved": "<Currency/> and <Currency2/>",
"transaction_tokens_swapped": "<Currency/> for <Currency2/>"
"transaction_tokens_swapped": "<Currency/> for <Currency2/>",
"oracle_document_id": "Oracle Document ID",
"provider": "Provider",
"last_update_time": "Last Update Time",
"asset_class": "Asset Class",
"trading_pairs": "Trading Pairs",
"deleted": "Deleted"
}
10 changes: 9 additions & 1 deletion public/locales/es-ES/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
"transaction_type_name_NFTokenMint": "Acuñar NFT",
"transaction_type_name_OfferCancel": "Cancelar Oferta",
"transaction_type_name_OfferCreate": "Crear Oferta",
"transaction_type_name_OracleDelete": null,
"transaction_type_name_OracleSet": null,
"transaction_type_name_Payment": "Pago",
"transaction_type_name_PaymentChannelClaim": "Reclamar Canal de Pago",
"transaction_type_name_PaymentChannelCreate": "Crear Canal de Pago",
Expand Down Expand Up @@ -518,5 +520,11 @@
"note": "Nota",
"indicate_unl": "indica a un validador en una UNL",
"transaction_tokens_involved": "<Currency/> y <Currency2/>",
"transaction_tokens_swapped": "<Currency/> por <Currency2/>"
"transaction_tokens_swapped": "<Currency/> por <Currency2/>",
"oracle_document_id": null,
"provider": null,
"last_update_time": null,
"asset_class": null,
"trading_pairs": null,
"deleted": null
}
10 changes: 9 additions & 1 deletion public/locales/fr-FR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@
"transaction_type_name_NFTokenMint": "NFT forgé",
"transaction_type_name_OfferCancel": "Offre annulée",
"transaction_type_name_OfferCreate": "Offre créée",
"transaction_type_name_OracleDelete": null,
"transaction_type_name_OracleSet": null,
"transaction_type_name_Payment": "Paiement effectué",
"transaction_type_name_PaymentChannelClaim": "Canal de paiement réclamé",
"transaction_type_name_PaymentChannelCreate": "Canal de paiement créé",
Expand Down Expand Up @@ -519,5 +521,11 @@
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
"transaction_tokens_swapped": null,
"oracle_document_id": null,
"provider": null,
"last_update_time": null,
"asset_class": null,
"trading_pairs": null,
"deleted": null
}
10 changes: 9 additions & 1 deletion public/locales/ja-JP/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@
"transaction_type_name_NFTokenMint": "NFTのミント",
"transaction_type_name_OfferCancel": "オファーの取消",
"transaction_type_name_OfferCreate": "オファーの作成",
"transaction_type_name_OracleDelete": null,
"transaction_type_name_OracleSet": null,
"transaction_type_name_Payment": "支払い",
"transaction_type_name_PaymentChannelClaim": "ペイメントチャネル請求",
"transaction_type_name_PaymentChannelCreate": "ペイメントチャネル作成",
Expand Down Expand Up @@ -518,5 +520,11 @@
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
"transaction_tokens_swapped": null,
"oracle_document_id": null,
"provider": null,
"last_update_time": null,
"asset_class": null,
"trading_pairs": null,
"deleted": null
}
10 changes: 9 additions & 1 deletion public/locales/ko-KR/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
"transaction_type_name_NFTokenMint": "NFT 발행",
"transaction_type_name_OfferCancel": "제안 취소",
"transaction_type_name_OfferCreate": "제안 생성",
"transaction_type_name_OracleDelete": null,
"transaction_type_name_OracleSet": null,
"transaction_type_name_PaymentChannelClaim": "결제 채널 청구",
"transaction_type_name_PaymentChannelCreate": "결제 채널 생성",
"transaction_type_name_PaymentChannelFund": "결제 채널 펀딩",
Expand Down Expand Up @@ -516,5 +518,11 @@
"note": null,
"indicate_unl": null,
"transaction_tokens_involved": null,
"transaction_tokens_swapped": null
"transaction_tokens_swapped": null,
"oracle_document_id": null,
"provider": null,
"last_update_time": null,
"asset_class": null,
"trading_pairs": null,
"deleted": null
}
9 changes: 9 additions & 0 deletions src/containers/Transactions/simpleTab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ $subdued-color: $black-40;
vertical-align: bottom;
}
}

&.list {
margin-bottom: 12px;

.one-line{
justify-content: flex-end;
margin: -1px 0px 0px;
}
}
}

ul {
Expand Down
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>
)
}
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 src/containers/shared/components/Transaction/OracleDelete/index.ts
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,
}
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()
})
})
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()
})
})
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
}
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
}
Loading

0 comments on commit 33ca4f4

Please sign in to comment.