From 76b1fb93d0351b7a34dba3e49aff2cd3dda2da58 Mon Sep 17 00:00:00 2001 From: Lathan Britz Date: Sat, 25 May 2024 23:21:32 -0400 Subject: [PATCH 1/6] add fill price and remove price form sumary and overview pages --- package-lock.json | 102 +++++++++++++----- package.json | 3 +- public/locales/ca-CA/translations.json | 3 +- public/locales/en-US/translations.json | 3 +- .../Transaction/OfferCreate/Simple.tsx | 30 +++--- .../Transaction/OfferCreate/TableDetail.tsx | 6 +- .../Transaction/OfferCreate/parser.ts | 14 ++- src/rippled/lib/txSummary/index.js | 2 + 8 files changed, 114 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b1f75f3a..f7ecf1bda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,7 +59,8 @@ "vite-plugin-html": "^3.2.0", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.2.0", - "xrpl-client": "^2.1.0" + "xrpl-client": "^2.1.0", + "xrpl-tx-path-parser": "^1.0.5" }, "devDependencies": { "@babel/eslint-parser": "^7.22.6", @@ -5351,7 +5352,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", - "dev": true, "dependencies": { "@noble/hashes": "1.3.2" }, @@ -5521,7 +5521,6 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", "integrity": "sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==", - "dev": true, "dependencies": { "@noble/curves": "~1.2.0", "@noble/hashes": "~1.3.2", @@ -5535,7 +5534,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", - "dev": true, "dependencies": { "@noble/hashes": "~1.3.0", "@scure/base": "~1.1.0" @@ -6878,12 +6876,33 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/@xrplf/secret-numbers/-/secret-numbers-1.0.0.tgz", "integrity": "sha512-qsCLGyqe1zaq9j7PZJopK+iGTGRbk6akkg6iZXJJgxKwck0C5x5Gnwlb1HKYGOwPKyrXWpV6a2YmcpNpUFctGg==", - "dev": true, "dependencies": { "@xrplf/isomorphic": "^1.0.0", "ripple-keypairs": "^2.0.0" } }, + "node_modules/@xrplkit/amount": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@xrplkit/amount/-/amount-1.2.3.tgz", + "integrity": "sha512-poV7ym7EhjAlEGym9Kc3AHuy3uuhVW3qnl2KDr8D4zk7hANj7aG6l1XdtWIAGAgBpHnvPEaOG7+llPRRv1irZw==", + "dependencies": { + "@xrplkit/xfl": "2.0.2" + } + }, + "node_modules/@xrplkit/txmeta": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@xrplkit/txmeta/-/txmeta-1.3.1.tgz", + "integrity": "sha512-iJNtLgXTpbuYBI0VDsXJhi3MHxmsCdWsI3OumETk+21HjxDw1AmPGmVHWu8q8turFth1qzRIAtHjxLHDl307sg==", + "dependencies": { + "@xrplkit/amount": "1.2.3", + "@xrplkit/xfl": "2.0.2" + } + }, + "node_modules/@xrplkit/xfl": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@xrplkit/xfl/-/xfl-2.0.2.tgz", + "integrity": "sha512-OUZZzSoXSxYxuhBcz08Wb9Xme71PkFYejk3vq4jPzdXreVhF71ZrM6nSObHFgasC8/srWKoqiS37CnB2Ht3k/g==" + }, "node_modules/abab": { "version": "2.0.5", "dev": true, @@ -9825,10 +9844,9 @@ } }, "node_modules/decimal.js": { - "version": "10.3.1", - "dev": true, - "license": "MIT", - "peer": true + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" }, "node_modules/decimal.js-light": { "version": "2.5.1", @@ -23893,7 +23911,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-2.0.0.tgz", "integrity": "sha512-zakENc9A5dlW85uzrmQHrJehymhL59ftggboRNrjxFDJdlNJ6DSE210P3ys/9kL0oVtOzFnTrOPFfxHZeOsA/Q==", - "dev": true, "dependencies": { "@xrplf/isomorphic": "^1.0.0", "bignumber.js": "^9.0.0", @@ -23907,7 +23924,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-2.0.0.tgz", "integrity": "sha512-b5rfL2EZiffmklqZk1W+dvSy97v3V/C7936WxCCgDynaGPp7GE6R2XO7EU9O2LlM/z95rj870IylYnOQs+1Rag==", - "dev": true, "dependencies": { "@noble/curves": "^1.0.0", "@xrplf/isomorphic": "^1.0.0", @@ -27964,7 +27980,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-3.0.0.tgz", "integrity": "sha512-QC+dNx3tvMEn9IrxcXFFa0rWwvBwACkGFNKl+W2miMGYnlgSiIsnjdqwtG2WRs0Pyxs5dd9nBTQHyQ1BPxZ78A==", - "dev": true, "dependencies": { "@scure/bip32": "^1.3.1", "@scure/bip39": "^1.2.1", @@ -27990,11 +28005,20 @@ "websocket": "^1.0.34" } }, + "node_modules/xrpl-tx-path-parser": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/xrpl-tx-path-parser/-/xrpl-tx-path-parser-1.0.5.tgz", + "integrity": "sha512-eQTdv/OKe5MIjOuiYB6FseUtiD8WOqYTmAGfOkHn4DWn233ES/970Yr10QPTrQoWtoA5forroXSiXBse6xxvow==", + "dependencies": { + "@xrplkit/txmeta": "^1.3.1", + "decimal.js": "^10.4.3", + "xrpl": "^3.0.0" + } + }, "node_modules/xrpl/node_modules/cross-fetch": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", - "dev": true, "dependencies": { "node-fetch": "^2.6.12" } @@ -28002,8 +28026,7 @@ "node_modules/xrpl/node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", - "dev": true + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" }, "node_modules/y18n": { "version": "4.0.3", @@ -31558,7 +31581,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", - "dev": true, "requires": { "@noble/hashes": "1.3.2" } @@ -31665,7 +31687,6 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", "integrity": "sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==", - "dev": true, "requires": { "@noble/curves": "~1.2.0", "@noble/hashes": "~1.3.2", @@ -31676,7 +31697,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", - "dev": true, "requires": { "@noble/hashes": "~1.3.0", "@scure/base": "~1.1.0" @@ -32576,12 +32596,33 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/@xrplf/secret-numbers/-/secret-numbers-1.0.0.tgz", "integrity": "sha512-qsCLGyqe1zaq9j7PZJopK+iGTGRbk6akkg6iZXJJgxKwck0C5x5Gnwlb1HKYGOwPKyrXWpV6a2YmcpNpUFctGg==", - "dev": true, "requires": { "@xrplf/isomorphic": "^1.0.0", "ripple-keypairs": "^2.0.0" } }, + "@xrplkit/amount": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@xrplkit/amount/-/amount-1.2.3.tgz", + "integrity": "sha512-poV7ym7EhjAlEGym9Kc3AHuy3uuhVW3qnl2KDr8D4zk7hANj7aG6l1XdtWIAGAgBpHnvPEaOG7+llPRRv1irZw==", + "requires": { + "@xrplkit/xfl": "2.0.2" + } + }, + "@xrplkit/txmeta": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@xrplkit/txmeta/-/txmeta-1.3.1.tgz", + "integrity": "sha512-iJNtLgXTpbuYBI0VDsXJhi3MHxmsCdWsI3OumETk+21HjxDw1AmPGmVHWu8q8turFth1qzRIAtHjxLHDl307sg==", + "requires": { + "@xrplkit/amount": "1.2.3", + "@xrplkit/xfl": "2.0.2" + } + }, + "@xrplkit/xfl": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@xrplkit/xfl/-/xfl-2.0.2.tgz", + "integrity": "sha512-OUZZzSoXSxYxuhBcz08Wb9Xme71PkFYejk3vq4jPzdXreVhF71ZrM6nSObHFgasC8/srWKoqiS37CnB2Ht3k/g==" + }, "abab": { "version": "2.0.5", "dev": true @@ -34648,9 +34689,9 @@ } }, "decimal.js": { - "version": "10.3.1", - "dev": true, - "peer": true + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" }, "decimal.js-light": { "version": "2.5.1" @@ -44266,7 +44307,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-2.0.0.tgz", "integrity": "sha512-zakENc9A5dlW85uzrmQHrJehymhL59ftggboRNrjxFDJdlNJ6DSE210P3ys/9kL0oVtOzFnTrOPFfxHZeOsA/Q==", - "dev": true, "requires": { "@xrplf/isomorphic": "^1.0.0", "bignumber.js": "^9.0.0", @@ -44277,7 +44317,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-2.0.0.tgz", "integrity": "sha512-b5rfL2EZiffmklqZk1W+dvSy97v3V/C7936WxCCgDynaGPp7GE6R2XO7EU9O2LlM/z95rj870IylYnOQs+1Rag==", - "dev": true, "requires": { "@noble/curves": "^1.0.0", "@xrplf/isomorphic": "^1.0.0", @@ -46953,7 +46992,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/xrpl/-/xrpl-3.0.0.tgz", "integrity": "sha512-QC+dNx3tvMEn9IrxcXFFa0rWwvBwACkGFNKl+W2miMGYnlgSiIsnjdqwtG2WRs0Pyxs5dd9nBTQHyQ1BPxZ78A==", - "dev": true, "requires": { "@scure/bip32": "^1.3.1", "@scure/bip39": "^1.2.1", @@ -46971,7 +47009,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", - "dev": true, "requires": { "node-fetch": "^2.6.12" } @@ -46979,8 +47016,7 @@ "eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", - "dev": true + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" } } }, @@ -46993,6 +47029,16 @@ "websocket": "^1.0.34" } }, + "xrpl-tx-path-parser": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/xrpl-tx-path-parser/-/xrpl-tx-path-parser-1.0.5.tgz", + "integrity": "sha512-eQTdv/OKe5MIjOuiYB6FseUtiD8WOqYTmAGfOkHn4DWn233ES/970Yr10QPTrQoWtoA5forroXSiXBse6xxvow==", + "requires": { + "@xrplkit/txmeta": "^1.3.1", + "decimal.js": "^10.4.3", + "xrpl": "^3.0.0" + } + }, "y18n": { "version": "4.0.3", "dev": true, diff --git a/package.json b/package.json index 9a0de5711..2cc88639f 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,8 @@ "vite-plugin-html": "^3.2.0", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.2.0", - "xrpl-client": "^2.1.0" + "xrpl-client": "^2.1.0", + "xrpl-tx-path-parser": "^1.0.5" }, "devDependencies": { "@babel/eslint-parser": "^7.22.6", diff --git a/public/locales/ca-CA/translations.json b/public/locales/ca-CA/translations.json index 1e7efac16..71b3ced51 100644 --- a/public/locales/ca-CA/translations.json +++ b/public/locales/ca-CA/translations.json @@ -522,5 +522,6 @@ "note": "Nota", "indicate_unl": "indica un validador en una UNL", "transaction_tokens_involved": " i ", - "transaction_tokens_swapped": " per " + "transaction_tokens_swapped": " per ", + "filled_price": "filled price" } diff --git a/public/locales/en-US/translations.json b/public/locales/en-US/translations.json index 9d7630114..ae2451690 100644 --- a/public/locales/en-US/translations.json +++ b/public/locales/en-US/translations.json @@ -522,5 +522,6 @@ "note": "Note", "indicate_unl": "indicates a validator on an UNL", "transaction_tokens_involved": " and ", - "transaction_tokens_swapped": " for " + "transaction_tokens_swapped": " for ", + "filled_price": "filled price" } diff --git a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx index c220c9b95..e79347b44 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx @@ -7,14 +7,27 @@ import Currency from '../../Currency' const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => { const { t } = useTranslation() const { data } = props - const { price, firstCurrency, secondCurrency, pays, gets, cancel } = + const { deliveredPrice, firstCurrency, secondCurrency, pays, gets, cancel } = data.instructions return ( <> - + + + + + + + {cancel && ( + + #{cancel} + + )} +
+

Executed Information

+
- {`${Number(price)}`} + {`${Number(deliveredPrice)}`}
{
- - - - - - - {cancel && ( - - #{cancel} - - )} ) } diff --git a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx index c42719ab9..71cd5b4a7 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx @@ -5,16 +5,16 @@ import Currency from '../../Currency' export const TableDetail = (props: any) => { const { t } = useTranslation() const { instructions } = props - const { gets, pays, price, firstCurrency, secondCurrency, cancel } = + const { gets, pays, deliveredPrice, firstCurrency, secondCurrency, cancel } = instructions return pays && gets ? (
- {t('price')}: + {t('filled_price')}: - {`${Number(price)} `} + {`${Number(deliveredPrice)} `} CURRENCY_ORDER.indexOf(base.currency) + tx.meta = meta + const parsed = pathParser(tx) + const deliveredPrice = Math.abs( + parsed.destinationAmount.value / parsed.sourceAmount.value, + ) + + console.log('parsed', parsed) + return { gets, pays, price: (invert ? 1 / price : price).toPrecision(6), + deliveredPrice: (invert ? 1 / deliveredPrice : deliveredPrice).toPrecision( + 6, + ), firstCurrency: invert ? counter : base, secondCurrency: invert ? base : counter, cancel: tx.OfferSequence, diff --git a/src/rippled/lib/txSummary/index.js b/src/rippled/lib/txSummary/index.js index 0dece7f49..858825611 100644 --- a/src/rippled/lib/txSummary/index.js +++ b/src/rippled/lib/txSummary/index.js @@ -27,6 +27,8 @@ const summarizeTransaction = (d, details = false) => { details: details ? { instructions: getInstructions(d.tx, d.meta), + tx: d.tx, + meta: d.meta, } : undefined, } From 29149c50a39f3b9279b97cbb8071876fabd5cf67 Mon Sep 17 00:00:00 2001 From: Lathan Britz Date: Sat, 25 May 2024 23:48:16 -0400 Subject: [PATCH 2/6] hide value when the offer has not crossed --- .../Transaction/OfferCreate/Simple.tsx | 49 +++++++++++-------- .../Transaction/OfferCreate/parser.ts | 16 +++--- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx index e79347b44..296600218 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx @@ -10,6 +10,34 @@ const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => { const { deliveredPrice, firstCurrency, secondCurrency, pays, gets, cancel } = data.instructions + const getDeliveredAmount = () => { + let result: string = '' + + if (deliveredPrice !== undefined) { + result = ( + +
+ {`${Number(deliveredPrice)}`} +
+ + / + +
+
+
+ ) + } + return result + } + return ( <> @@ -23,26 +51,7 @@ const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => { #{cancel} )} -
-

Executed Information

- -
- {`${Number(deliveredPrice)}`} -
- - / - -
-
-
+ {getDeliveredAmount()} ) } diff --git a/src/containers/shared/components/Transaction/OfferCreate/parser.ts b/src/containers/shared/components/Transaction/OfferCreate/parser.ts index 77c6934c4..7e83bfec1 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/parser.ts +++ b/src/containers/shared/components/Transaction/OfferCreate/parser.ts @@ -14,19 +14,19 @@ export function parser(tx: any, meta: any) { tx.meta = meta const parsed = pathParser(tx) - const deliveredPrice = Math.abs( - parsed.destinationAmount.value / parsed.sourceAmount.value, - ) - - console.log('parsed', parsed) + const deliveredPrice = + parsed.destinationAmount.value > 0 + ? Math.abs(parsed.destinationAmount.value / parsed.sourceAmount.value) + : undefined return { gets, pays, price: (invert ? 1 / price : price).toPrecision(6), - deliveredPrice: (invert ? 1 / deliveredPrice : deliveredPrice).toPrecision( - 6, - ), + deliveredPrice: + deliveredPrice !== undefined + ? (invert ? 1 / deliveredPrice : deliveredPrice).toPrecision(6) + : undefined, firstCurrency: invert ? counter : base, secondCurrency: invert ? base : counter, cancel: tx.OfferSequence, From 819dca60d19ca4f381b92724e7be94b5368eb341 Mon Sep 17 00:00:00 2001 From: Lathan Britz Date: Sun, 26 May 2024 00:46:31 -0400 Subject: [PATCH 3/6] add tfSell flag to outputs --- .../components/Transaction/OfferCreate/Simple.tsx | 6 ++++++ .../Transaction/OfferCreate/TableDetail.tsx | 14 ++++++++++++-- .../components/Transaction/OfferCreate/parser.ts | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx index 296600218..7aa767d4d 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/Simple.tsx @@ -38,6 +38,11 @@ const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => { return result } + const rendetfSell = () => { + const { tfSell } = data.instructions + return tfSell ?
tfSell
: null + } + return ( <> @@ -45,6 +50,7 @@ const Simple: TransactionSimpleComponent = (props: TransactionSimpleProps) => { + {rendetfSell()} {cancel && ( diff --git a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx index 71cd5b4a7..8551be2e0 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx @@ -5,9 +5,18 @@ import Currency from '../../Currency' export const TableDetail = (props: any) => { const { t } = useTranslation() const { instructions } = props - const { gets, pays, deliveredPrice, firstCurrency, secondCurrency, cancel } = - instructions + const { + gets, + pays, + deliveredPrice, + firstCurrency, + secondCurrency, + cancel, + tfSell, + } = instructions + const rendetfSell = () => + tfSell ?
tfSell
: null return pays && gets ? (
@@ -35,6 +44,7 @@ export const TableDetail = (props: any) => {
{t('sell')} + {rendetfSell()}
{cancel && (
diff --git a/src/containers/shared/components/Transaction/OfferCreate/parser.ts b/src/containers/shared/components/Transaction/OfferCreate/parser.ts index 7e83bfec1..3123608e8 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/parser.ts +++ b/src/containers/shared/components/Transaction/OfferCreate/parser.ts @@ -2,6 +2,8 @@ import pathParser from 'xrpl-tx-path-parser' import { CURRENCY_ORDER } from '../../../transactionUtils' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' +export const istfSell = (flags: any) => 0x00080000 & flags + export function parser(tx: any, meta: any) { const gets = formatAmount(tx.TakerGets) const base = tx.TakerGets.currency ? tx.TakerGets : { currency: 'XRP' } @@ -19,6 +21,8 @@ export function parser(tx: any, meta: any) { ? Math.abs(parsed.destinationAmount.value / parsed.sourceAmount.value) : undefined + const tfSell = !!istfSell(tx.Flags) + return { gets, pays, @@ -30,5 +34,6 @@ export function parser(tx: any, meta: any) { firstCurrency: invert ? counter : base, secondCurrency: invert ? base : counter, cancel: tx.OfferSequence, + tfSell, } } From 48e31b707c4185819e3e1fc895177babc9316a80 Mon Sep 17 00:00:00 2001 From: Lathan Britz Date: Mon, 27 May 2024 09:26:48 -0400 Subject: [PATCH 4/6] add filled price to payments that cross AAM or DEX --- .../components/Transaction/Payment/Simple.tsx | 33 ++++++++++++++++++- .../Transaction/Payment/TableDetail.tsx | 22 ++++++++++++- .../components/Transaction/Payment/parser.ts | 10 ++++++ 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/containers/shared/components/Transaction/Payment/Simple.tsx b/src/containers/shared/components/Transaction/Payment/Simple.tsx index ff24b6391..792aa6fa2 100644 --- a/src/containers/shared/components/Transaction/Payment/Simple.tsx +++ b/src/containers/shared/components/Transaction/Payment/Simple.tsx @@ -4,11 +4,12 @@ import { Amount } from '../../Amount' import { PaymentInstructions } from './types' import { TransactionSimpleProps } from '../types' import { SimpleRow } from '../SimpleRow' +import Currency from '../../Currency' export const Simple = (props: TransactionSimpleProps) => { const { data } = props const { t } = useTranslation() - const { amount, convert } = data.instructions + const { amount, convert, deliveredPrice } = data.instructions const renderPartial = () => { const { partial } = data.instructions @@ -17,6 +18,34 @@ export const Simple = (props: TransactionSimpleProps) => { ) : null } + const getDeliveredAmount = () => { + let result: string = '' + + if (deliveredPrice !== undefined) { + result = ( + +
+ {`${Number(deliveredPrice)}`} +
+ + / + +
+
+
+ ) + } + return result + } + const renderPayment = () => { const { max, destination, sourceTag, partial } = data.instructions @@ -55,6 +84,8 @@ export const Simple = (props: TransactionSimpleProps) => { {renderPartial()} + + {getDeliveredAmount()} ) : ( renderPayment() diff --git a/src/containers/shared/components/Transaction/Payment/TableDetail.tsx b/src/containers/shared/components/Transaction/Payment/TableDetail.tsx index 867566e33..4168b2a93 100644 --- a/src/containers/shared/components/Transaction/Payment/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/Payment/TableDetail.tsx @@ -3,12 +3,14 @@ import { Amount } from '../../Amount' import { TransactionTableDetailProps } from '../types' import { PaymentInstructions } from './types' import { Account } from '../../Account' +import Currency from '../../Currency' export const TableDetail = ({ instructions, }: TransactionTableDetailProps) => { const { t } = useTranslation() - const { convert, amount, destination, partial, sourceTag } = instructions + const { convert, amount, destination, partial, sourceTag, deliveredPrice } = + instructions const renderPartial = () => (
{t('partial_payment_allowed')}
@@ -17,6 +19,24 @@ export const TableDetail = ({ if (convert) { return (
+
+ {t('filled_price')}: + + + {`${Number(deliveredPrice)} `} + + / + + +
{t('convert_maximum')} {t('to')} diff --git a/src/containers/shared/components/Transaction/Payment/parser.ts b/src/containers/shared/components/Transaction/Payment/parser.ts index 743c05367..a4058bf0b 100644 --- a/src/containers/shared/components/Transaction/Payment/parser.ts +++ b/src/containers/shared/components/Transaction/Payment/parser.ts @@ -1,3 +1,4 @@ +import pathParser from 'xrpl-tx-path-parser' import type { Payment } from 'xrpl' import { formatAmount } from '../../../../../rippled/lib/txSummary/formatAmount' import { PaymentInstructions } from './types' @@ -20,12 +21,20 @@ export const parser = (tx: Payment, meta: any): PaymentInstructions => { const dt = tx.DestinationTag !== undefined ? `:${tx.DestinationTag}` : '' const destination = `${tx.Destination}${dt}` + tx.meta = meta + const parsed = pathParser(tx) + const deliveredPrice = + parsed.destinationAmount.value > 0 + ? Math.abs(parsed.destinationAmount.value / parsed.sourceAmount.value) + : undefined + if (tx.Account === tx.Destination) { return { amount, convert: max, destination, partial, + deliveredPrice, } } @@ -35,5 +44,6 @@ export const parser = (tx: Payment, meta: any): PaymentInstructions => { destination: `${tx.Destination}${dt}`, sourceTag: tx.SourceTag, partial, + deliveredPrice, } } From 08a0a0a981f47820b36676696b42150ea71242ea Mon Sep 17 00:00:00 2001 From: Lathan Britz Date: Mon, 27 May 2024 10:00:59 -0400 Subject: [PATCH 5/6] remove filled price on cancelled offers results in NaN --- .../Transaction/OfferCreate/TableDetail.tsx | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx index 8551be2e0..5391560b1 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx @@ -19,24 +19,26 @@ export const TableDetail = (props: any) => { tfSell ?
tfSell
: null return pays && gets ? (
-
- {t('filled_price')}: + {!cancel && ( +
+ {t('filled_price')}: - - {`${Number(deliveredPrice)} `} - - / - - -
+ + {`${Number(deliveredPrice)} `} + + / + + +
+ )}
{t('buy')} From 1a34d2f8671017d9a5a989a58256d4c8367114d7 Mon Sep 17 00:00:00 2001 From: Lathan Britz Date: Mon, 27 May 2024 10:11:03 -0400 Subject: [PATCH 6/6] still missed an edge case --- .../shared/components/Transaction/OfferCreate/TableDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx index 5391560b1..0ed058ee3 100644 --- a/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx +++ b/src/containers/shared/components/Transaction/OfferCreate/TableDetail.tsx @@ -19,7 +19,7 @@ export const TableDetail = (props: any) => { tfSell ?
tfSell
: null return pays && gets ? (
- {!cancel && ( + {!cancel && deliveredPrice !== undefined && (
{t('filled_price')}: