-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add AMMDelete Transaction (#810)
Adds the `AMMDelete` transaction and corresponding pages / views ### Context of Change Added as part of the AMM changes for the explorer. ### Type of Change <!-- Please check relevant options, delete irrelevant ones. --> - [X] New feature (non-breaking change which adds functionality) ## Before / After Simple: ![image](https://github.com/ripple/explorer/assets/19694186/dc324022-52df-488b-aee6-2d4174f54ccf) Detailed: ![image](https://github.com/ripple/explorer/assets/19694186/d9ae6eab-73b0-4e7e-9e92-dbc8948b2e3f) TableView: (You can get here by clicking the account for the `AMMDelete` transaction) ![image](https://github.com/ripple/explorer/assets/19694186/4fc482bc-8203-4a49-97f3-281924c6818e) ## Test Plan Added SimplePage CI You can also inspect the changes in the preview by going to this extension on the AMM Devnet to see an AMMDelete transaction in action: accounts/rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9
- Loading branch information
Showing
15 changed files
with
274 additions
and
19 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
31 changes: 31 additions & 0 deletions
31
src/containers/shared/components/Transaction/AMMDelete/Description.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,31 @@ | ||
import { Trans } from 'react-i18next' | ||
import { type AMMDelete } from 'xrpl' | ||
import { TransactionDescriptionProps } from '../types' | ||
import Currency from '../../Currency' | ||
|
||
export const Description = ({ | ||
data, | ||
}: TransactionDescriptionProps<AMMDelete>) => { | ||
const { Asset, Asset2 } = data.tx | ||
|
||
return ( | ||
<div data-test="amm-delete-description"> | ||
<Trans | ||
i18nKey="amm_delete_description" | ||
components={{ | ||
// @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451 | ||
Asset: <Currency currency={Asset.currency} issuer={Asset.issuer} />, | ||
Asset2: ( | ||
<Currency | ||
currency={Asset2.currency} | ||
// @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451 | ||
issuer={Asset2.issuer} | ||
/> | ||
), | ||
}} | ||
/> | ||
<br /> | ||
<Trans i18nKey="amm_delete_description_caveat" /> | ||
</div> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/containers/shared/components/Transaction/AMMDelete/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,24 @@ | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { type AMMDelete } from 'xrpl' | ||
import { SimpleRow } from '../SimpleRow' | ||
import { TransactionSimpleProps } from '../types' | ||
import Currency from '../../Currency' | ||
|
||
export const Simple = ({ data }: TransactionSimpleProps<AMMDelete>) => { | ||
const { t } = useTranslation() | ||
const { Asset, Asset2 } = data.instructions | ||
|
||
return ( | ||
<> | ||
<SimpleRow label={t('asset1')} data-test="asset1"> | ||
{/* @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451 */} | ||
<Currency currency={Asset.currency} issuer={Asset.issuer} /> | ||
</SimpleRow> | ||
<SimpleRow label={t('asset2')} data-test="asset2"> | ||
{/* @ts-expect-error -- Fixed by https://github.com/XRPLF/xrpl.js/pull/2451 */} | ||
<Currency currency={Asset2.currency} issuer={Asset2.issuer} /> | ||
</SimpleRow> | ||
</> | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/containers/shared/components/Transaction/AMMDelete/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,24 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { type AMMDelete } from 'xrpl' | ||
import { TransactionTableDetailProps } from '../types' | ||
import Currency from '../../Currency' | ||
|
||
export const TableDetail = ({ | ||
instructions, | ||
}: TransactionTableDetailProps<AMMDelete>) => { | ||
const { t } = useTranslation() | ||
const { Asset, Asset2 } = instructions | ||
|
||
return ( | ||
<div className="ammDelete"> | ||
<div data-test="asset"> | ||
<span className="label">{t('asset')}</span> | ||
<Currency currency={Asset.currency} issuer={(Asset as any).issuer} /> | ||
</div> | ||
<div data-test="asset2"> | ||
<span className="label">{t('asset2')}</span> | ||
<Currency currency={Asset2.currency} issuer={(Asset2 as any).issuer} /> | ||
</div> | ||
</div> | ||
) | ||
} |
19 changes: 19 additions & 0 deletions
19
src/containers/shared/components/Transaction/AMMDelete/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,19 @@ | ||
import { type AMMDelete } from 'xrpl' | ||
import { | ||
TransactionAction, | ||
TransactionCategory, | ||
TransactionMapping, | ||
} from '../types' | ||
import { Description } from './Description' | ||
|
||
import { Simple } from './Simple' | ||
import { TableDetail } from './TableDetail' | ||
|
||
export const AMMDeleteTransaction: TransactionMapping = { | ||
Description, | ||
TableDetail, | ||
Simple, | ||
action: TransactionAction.CANCEL, | ||
category: TransactionCategory.DEX, | ||
parser: (tx: AMMDelete): AMMDelete => tx, | ||
} |
22 changes: 22 additions & 0 deletions
22
src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteDescription.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,22 @@ | ||
import i18n from '../../../../../../i18n/testConfigEnglish' | ||
import mockAMMDelete from './mock_data/AMMDelete.json' | ||
import { Description } from '../Description' | ||
import { createDescriptionWrapperFactory } from '../../test' | ||
|
||
const createWrapper = createDescriptionWrapperFactory(Description, i18n) | ||
|
||
describe('AMMDelete: Description', () => { | ||
it('renders description for AMMDelete transaction', () => { | ||
const wrapper = createWrapper(mockAMMDelete) | ||
|
||
expect(wrapper.find('[data-test="amm-delete-description"]')).toHaveText( | ||
'Attempted to delete the AMM for \uE900 XRP and FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9.If there were more than 512 trustlines, this only removes 512 trustlines instead.', | ||
) | ||
expect(wrapper.find('a')).toHaveProp( | ||
'href', | ||
'/token/FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9', | ||
) | ||
|
||
wrapper.unmount() | ||
}) | ||
}) |
21 changes: 21 additions & 0 deletions
21
src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteSimple.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,21 @@ | ||
import i18n from '../../../../../../i18n/testConfigEnglish' | ||
import { expectSimpleRowText } from '../../test' | ||
|
||
import { createSimpleWrapperFactory } from '../../test/createWrapperFactory' | ||
import { Simple } from '../Simple' | ||
import mockAMMDelete from './mock_data/AMMDelete.json' | ||
|
||
const createWrapper = createSimpleWrapperFactory(Simple, i18n) | ||
|
||
describe('AMMDelete: Simple', () => { | ||
it('renders', () => { | ||
const wrapper = createWrapper(mockAMMDelete) // TOOD: - Make this look up asset 1 / asset 2 currency codes | ||
expectSimpleRowText(wrapper, 'asset1', '\uE900 XRP') | ||
expectSimpleRowText( | ||
wrapper, | ||
'asset2', | ||
'FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9', | ||
) | ||
wrapper.unmount() | ||
}) | ||
}) |
18 changes: 18 additions & 0 deletions
18
src/containers/shared/components/Transaction/AMMDelete/test/AMMDeleteTableDetail.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,18 @@ | ||
import { TableDetail } from '../TableDetail' | ||
import mockAMMDelete from './mock_data/AMMDelete.json' | ||
import { createTableDetailWrapperFactory } from '../../test' | ||
import i18n from '../../../../../../i18n/testConfigEnglish' | ||
|
||
const createWrapper = createTableDetailWrapperFactory(TableDetail, i18n) | ||
|
||
describe('AMMDelete: TableDetail', () => { | ||
it('renders with an expiration and offer', () => { | ||
const wrapper = createWrapper(mockAMMDelete) | ||
|
||
expect(wrapper.find('[data-test="asset"]')).toHaveText('asset\uE900 XRP') | ||
expect(wrapper.find('[data-test="asset2"]')).toHaveText( | ||
'Asset 2FOO.rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9', | ||
) | ||
wrapper.unmount() | ||
}) | ||
}) |
48 changes: 48 additions & 0 deletions
48
src/containers/shared/components/Transaction/AMMDelete/test/mock_data/AMMDelete.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,48 @@ | ||
{ | ||
"tx": { | ||
"Account": "rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9", | ||
"Asset": { | ||
"currency": "XRP" | ||
}, | ||
"Asset2": { | ||
"currency": "FOO", | ||
"issuer": "rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9" | ||
}, | ||
"Fee": "12", | ||
"Flags": 0, | ||
"LastLedgerSequence": 372572, | ||
"Sequence": 372548, | ||
"SigningPubKey": "ED6784394D134E202BCCD957A1A3C5A66647092F3929D388A878A16D1910875435", | ||
"TransactionType": "AMMDelete", | ||
"TxnSignature": "F9AA459D8CE593E6E2E69BB6A6F723A4822FD5F40314F642FA9EC5187F7FD937FBD3E8A214119D04C74358A3478DCB6EAABE02EFAC1E6E125E15310E18A36D0D", | ||
"date": 1693268101000 | ||
}, | ||
"meta": { | ||
"AffectedNodes": [ | ||
{ | ||
"ModifiedNode": { | ||
"FinalFields": { | ||
"Account": "rm5c42Crqpdch5fbuCdHmSMV1wrL9arV9", | ||
"Balance": "9997998976", | ||
"Flags": 8388608, | ||
"OwnerCount": 1, | ||
"Sequence": 372549 | ||
}, | ||
"LedgerEntryType": "AccountRoot", | ||
"LedgerIndex": "84CA74ECFDB34F014142013B4CD2FBE3942C7BA9BA7E1FC5A1CB1EF719173812", | ||
"PreviousFields": { | ||
"Balance": "9997998988", | ||
"Sequence": 372548 | ||
}, | ||
"PreviousTxnID": "E5051DA09F143A719521D6ABBB3856EA3E2CA38EF1CFF0E7DF9FE1C31DD73B6D", | ||
"PreviousTxnLgrSeq": 372552 | ||
} | ||
} | ||
], | ||
"TransactionIndex": 0, | ||
"TransactionResult": "tecAMM_NOT_EMPTY" | ||
}, | ||
"hash": "D159883D456646562F51F3E5A2754F7D880D39A6372EDF679A43A7DDB77F735C", | ||
"ledger_index": 372554, | ||
"date": 1693268101000 | ||
} |
Oops, something went wrong.