From f241989709cc90439d615dd7c7e7ec0ce9fb3250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rard=20Dethier?= Date: Wed, 8 May 2024 15:26:45 +0200 Subject: [PATCH] feat: completely remove fake multicoin support. logion-network/logion-internal#1231 --- package.json | 4 +- public/assets/dot.png | Bin 2130 -> 0 bytes src/__mocks__/@logion/node-api/index.ts | 3 +- src/common/AccountAddress.test.tsx | 13 +- src/common/AccountAddress.tsx | 10 +- src/common/AddressSwitcher.tsx | 8 +- src/common/Amount.ts | 20 + src/common/AssetNameCell.tsx | 7 +- src/common/BalanceDetails.tsx | 10 +- src/common/BalanceGauge.tsx | 21 + src/common/BalanceReading.tsx | 22 + src/common/TestData.ts | 19 +- src/common/Transactions.test.tsx | 23 +- src/common/Transactions.tsx | 19 +- src/common/WalletGauge.test.tsx | 12 +- src/common/WalletGauge.tsx | 13 +- .../AccountAddress.test.tsx.snap | 22 +- .../__snapshots__/Transactions.test.tsx.snap | 95 +++-- .../__snapshots__/WalletGauge.test.tsx.snap | 72 +--- src/components/coin/CoinIcon.test.tsx | 7 +- src/components/coin/CoinIcon.tsx | 16 +- src/components/coin/CoinName.test.tsx | 13 - src/components/coin/CoinName.tsx | 12 - .../coin/__snapshots__/CoinIcon.test.tsx.snap | 9 - .../coin/__snapshots__/CoinName.test.tsx.snap | 13 - src/components/inlineamount/InlineAmount.tsx | 16 +- src/legal-officer/LegalOfficerRouter.tsx | 2 +- .../LegalOfficerRouter.test.tsx.snap | 2 +- src/legal-officer/home/Home.test.tsx | 2 +- src/legal-officer/home/Home.tsx | 9 +- .../home/__snapshots__/Home.test.tsx.snap | 19 +- src/wallet-user/UserDashboard.tsx | 8 +- src/wallet-user/UserPaths.tsx | 14 +- src/wallet-user/UserRouter.tsx | 4 +- .../__snapshots__/UserDashboard.test.tsx.snap | 8 +- .../__snapshots__/UserRouter.test.tsx.snap | 8 +- src/wallet-user/home/Home.test.tsx | 2 +- src/wallet-user/home/Home.tsx | 14 +- src/wallet-user/recovery/RecoveryProcess.tsx | 5 +- .../recovery/VaultRecoveryProcessTab.tsx | 22 +- .../WalletRecoveryProcessTab.test.tsx | 17 +- .../recovery/WalletRecoveryProcessTab.tsx | 18 +- yarn.lock | 396 +++++++++--------- 43 files changed, 490 insertions(+), 539 deletions(-) delete mode 100644 public/assets/dot.png create mode 100644 src/common/Amount.ts create mode 100644 src/common/BalanceGauge.tsx create mode 100644 src/common/BalanceReading.tsx delete mode 100644 src/components/coin/CoinName.test.tsx delete mode 100644 src/components/coin/CoinName.tsx delete mode 100644 src/components/coin/__snapshots__/CoinName.test.tsx.snap diff --git a/package.json b/package.json index 104af0bb..f49c2d67 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "license": "Apache-2.0", "dependencies": { "@creativecommons/cc-assets": "^0.1.0", - "@logion/client": "^0.43.1-5", + "@logion/client": "^0.44.0-1", "@logion/client-browser": "^0.3.5", "@logion/crossmint": "^0.1.32", - "@logion/extension": "^0.8.0", + "@logion/extension": "^0.8.1-1", "@logion/multiversx": "^0.1.13", "@multiversx/sdk-extension-provider": "^2.0.7", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3", diff --git a/public/assets/dot.png b/public/assets/dot.png deleted file mode 100644 index 9b5ed2742001b59d2dbc42d6a95ceca6f90b971f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2130 zcmZuxc|6o>7yr$mk=?71okm1qB;2dAyu?_BY$1}RD3V>1TuVbni|Weqs;=p_Sl;Y) zZ^(@7k|oI+W`<#evCd%T_xs&npZDMQd_K=}KF@icvwhDw57~`iFDa%Z1^|F0-oe%# z;Z{GFs1UM0{VRP5VZve7F4h20lPfL=5<$+WICpy+pt4Ve4FG7+&Dqn=`Em>l!`s{2 z$o_u`1VIjmv$?s6s54nC>QCyVGiK-J=c&}Mn_TV+hqJV_#N+YkbjIrHI+x3((`PLM z1DQ-FVir+PO--eCbZl;I%`h0fy}gJKc{VaKva_>;+?udc04(`VP#*4EcI5J!l7 zcXyY+%kSvvSy@?GSX}(@;q%lK9dWU|%$b^*;c|KJ-?#Mk_pfl)uvmw#uJP^d9mFiw z!J%t>9LWL+6@nmvK!DgsqtPf73W8xipTE4q5fT#GvuBU6u&}78r~rnirl#n5s;DTRoSfX)*ccibLXyqO$^s#{udfe_#j2{R8X6dA zXlVHQ`kp*_GBGi+w5+V7qXWUVrly8Qqph#6*VfiXL`3N8>wo+9&DGTvDN0F6$=uvr zQBhG_TN|6rR#sLflgTYDEn{P2ckbND$;l}wC~$Oi)Y8&&b8|!L6%rDH0KR|!{^aE3 z`uh6iQ+}*M@B}{>2y0gyREIQ(9qDNq(n0_vt5AzhM>&MOa#uuhYzc(tJ~Vz z>gnl4MMZggdxwRE!5|2OkN|>*zYPocg69;<_RJd6fuKOZn_P;Ij~^TyMoJ?2jW05G6uhmqr%&sfvm)^m z4l)6+^R=}JMa9N(9?l-83VqX6brhN|DC@>m-R(pM;(z2^)#%Q^j(a^h5%%m4?V|$K zQSg{kwuWCC++TG3=n0|?!O^jg)J?x!$69@tcKTm;>A=3n+_T{5;vnezW8>nz&x z%23gg?0P1_%j+N@%N_8VGQKQ8hgpdmn?IIN$0=FuWjn@6?mOA$cRE**;Ewt0Z$UK$ z*j0Scqo{gep;|sq^pWO4)R#T!RT7RuiodjB(uq|=R?%;^6ufSyKYh{s)#OWojS@D` zq$Fi0oO9Eds$Z&CZ!=n2xk1KQ|CppIlXUAH!$ljmIFk~TkhINosevnOAjP31L@o_r z59jZwP!#r>+?xhgSDxhC4F*|-n0UN3_;7BX`s&%zcRQzh`U7(DW4c4pZFyVlfja9< zjqbDuq1m$1V#l%HHM^o^P2MC++nJ=*CKMbAd>=X1Gv`!j5KQuVX`d8kDT22oqats_ z1R4DL=$y}ziRkG~re64XX^O3gvrnViU@U4h1oV@&_Ts9xdx}1&d5%8heFT5%iIs3RK_lrg8h;)PTLv?bQhv&6i zy#82TMCE+d&F>Q*Ct|vKYUu1j7ScIFo1nt z!R<=qyEn<#uBu$4-5c@aUTTdXNwG=2g?n?(rXNj|Fspqn`%=$^voAoWD?mVFBzE3-#R=uu97V^|Qbr98sWeNjw@>?&x zh!ApaNB0aWDr3Pm%9yW8Ji^cmIg@v6BGD9nax9a%V2<-Z)3$p_tvND=NzDcZp(MBX za#G%P#a0dNcp)jf#?tNlimLxM+bV^R~SwbTeOYcqs;rXD1V>h6&7BlPyCVE zbldb3PK)B8`#Gk??nvwe3aTu-Ka_+0CC2gh2YS*UC9@}bU7O23=WZ(~NtN}4Kb?q{ zW`wQwS5XC!$BPaO?PbE{U`jOIB_E_qzomlP%e+(;l_@lHNZ$9#F}lC}2Oebw=KKcz zxFfhiB+tAuCC0w2=x^R6Zrp0HY=(Fhu4RD|Pi7Yjrh;&{h=wrL(6T&b&^~>4bH(F= z+x+UtS5#AMy{p7AC8vG9Wac6mwdM4i+T8;4ZUtX_0kK=*Kivflc!i0p20Y$DzvMvk zN7Qv}D*MXqh`@D)e$v@#P%a>4g1-Kp^#eYy)bzL{%@@6Ze18Dmj$m79b0Om&78z~O diff --git a/src/__mocks__/@logion/node-api/index.ts b/src/__mocks__/@logion/node-api/index.ts index 800c1566..d6765074 100644 --- a/src/__mocks__/@logion/node-api/index.ts +++ b/src/__mocks__/@logion/node-api/index.ts @@ -14,8 +14,7 @@ export { } from "@logion/node-api"; export type { - Coin, - CoinBalance, + TypesAccountData, } from "@logion/node-api"; import { api } from "src/__mocks__/LogionMock"; diff --git a/src/common/AccountAddress.test.tsx b/src/common/AccountAddress.test.tsx index d2881b94..f51bc32a 100644 --- a/src/common/AccountAddress.test.tsx +++ b/src/common/AccountAddress.test.tsx @@ -1,4 +1,4 @@ -import { Numbers } from "@logion/node-api"; +import { Lgnt, Numbers } from "@logion/node-api"; import { shallowRender } from '../tests'; import AccountAddress from './AccountAddress'; @@ -10,14 +10,9 @@ describe("AccountAddress", () => { const result = shallowRender( void; @@ -101,12 +101,12 @@ export default function AccountAddress(props: Props) { { props.balance !== null && <> - {" "} + {" "} { - !props.balance.reserved.coefficient.isZero() && + props.balance.reserved.compareTo(Lgnt.zero()) !== 0 && +{" "} - + } diff --git a/src/common/AddressSwitcher.tsx b/src/common/AddressSwitcher.tsx index b947f4e2..d15f09eb 100644 --- a/src/common/AddressSwitcher.tsx +++ b/src/common/AddressSwitcher.tsx @@ -25,13 +25,7 @@ export default function AddressSwitcher() { selectAddressCallback(address); }, [ authenticate, selectAddressCallback ]); - const balance = useMemo(() => { - if(balanceState && balanceState.balances.length > 0) { - return balanceState.balances[0]; - } else { - return null; - } - }, [ balanceState ]); + const balance = useMemo(() => balanceState?.balance || null, [ balanceState ]); if(accounts === null || selectAddress === null || accounts.current === undefined) { return null; diff --git a/src/common/Amount.ts b/src/common/Amount.ts new file mode 100644 index 00000000..1091df0b --- /dev/null +++ b/src/common/Amount.ts @@ -0,0 +1,20 @@ +import { Lgnt, Numbers, TypesAccountData } from "@logion/node-api"; +import { useMemo } from "react"; + +export function useAvailableMemo(balance: TypesAccountData | undefined) { + return useMemo(() => { + if(balance) { + return toOptimizedNumber(balance.available); + } else { + return Numbers.PrefixedNumber.ZERO; + } + }, [ balance ]); +} + +export function toOptimizedNumber(amount: Lgnt) { + return amount.toPrefixedNumber().optimizeScale(3); +} + +export function balanceLevel(amount: Numbers.PrefixedNumber) { + return amount.toNumber() === 0 ? 0 : 1; +} diff --git a/src/common/AssetNameCell.tsx b/src/common/AssetNameCell.tsx index 7c327c8d..b19d1d9c 100644 --- a/src/common/AssetNameCell.tsx +++ b/src/common/AssetNameCell.tsx @@ -1,15 +1,14 @@ -import { CoinBalance } from "@logion/node-api"; -import CoinName from "src/components/coin/CoinName"; +import { Lgnt, Numbers } from "@logion/node-api"; export interface Props { - balance: CoinBalance; + unit: Numbers.UnitPrefix; } export default function AssetNameCell(props: Props) { return (
- ({ props.balance.available.prefix.symbol }{ props.balance.coin.symbol }) + Logion Token ({ props.unit.symbol }{ Lgnt.CODE })
); } diff --git a/src/common/BalanceDetails.tsx b/src/common/BalanceDetails.tsx index f155c939..4d5e61e0 100644 --- a/src/common/BalanceDetails.tsx +++ b/src/common/BalanceDetails.tsx @@ -1,9 +1,9 @@ -import { CoinBalance } from "@logion/node-api"; +import { TypesAccountData } from "@logion/node-api"; import InlineAmount from "src/components/inlineamount/InlineAmount"; import "./BalanceDetails.css"; export interface Props { - balance: CoinBalance; + balance: TypesAccountData; } export default function BalanceDetails(props: Props) { @@ -12,19 +12,19 @@ export default function BalanceDetails(props: Props) {
Available:
- +
Reserved:
- +
Total:
- +
diff --git a/src/common/BalanceGauge.tsx b/src/common/BalanceGauge.tsx new file mode 100644 index 00000000..8fb8ad47 --- /dev/null +++ b/src/common/BalanceGauge.tsx @@ -0,0 +1,21 @@ +import { Lgnt, TypesAccountData } from "@logion/node-api"; +import Gauge from "./Gauge"; +import { balanceLevel, useAvailableMemo } from "./Amount"; + +export interface Props { + balance?: TypesAccountData; +} + +export default function BalanceGauge(props: Props) { + + const balance = useAvailableMemo(props.balance); + + return ( + + ); +} diff --git a/src/common/BalanceReading.tsx b/src/common/BalanceReading.tsx new file mode 100644 index 00000000..b42b8d95 --- /dev/null +++ b/src/common/BalanceReading.tsx @@ -0,0 +1,22 @@ +import { Lgnt, TypesAccountData } from '@logion/node-api'; +import './Reading.css'; +import Reading from './Reading'; +import { balanceLevel, useAvailableMemo } from './Amount'; + +export interface Props { + balance?: TypesAccountData; +} + +export default function BalanceReading(props: Props) { + + const balance = useAvailableMemo(props.balance); + + return ( + + ); +} diff --git a/src/common/TestData.ts b/src/common/TestData.ts index 6628b5d9..0ef01da5 100644 --- a/src/common/TestData.ts +++ b/src/common/TestData.ts @@ -1,7 +1,7 @@ import { LegalOfficer, PostalAddress, UserIdentity } from '@logion/client'; import { LegalOfficerClass } from "@logion/client/dist/Types.js"; import { Transaction } from '@logion/client'; -import { Coin, CoinBalance, Numbers, Lgnt } from '@logion/node-api'; +import { TypesAccountData, Numbers, Lgnt } from '@logion/node-api'; import { ColorTheme, rgbaToHex } from './ColorTheme'; @@ -121,17 +121,16 @@ export const COLOR_THEME: ColorTheme = { }, }; -export const DEFAULT_COIN: Coin = { - id: 'lgnt', - symbol: Lgnt.CODE, +export const DEFAULT_COIN_BALANCE: TypesAccountData = { + total: Lgnt.fromCanonical(42n), + available: Lgnt.fromCanonical(42n), + reserved: Lgnt.zero(), }; -export const DEFAULT_COIN_BALANCE: CoinBalance = { - coin: DEFAULT_COIN, - total: new Numbers.PrefixedNumber("42", Numbers.ATTO), - available: new Numbers.PrefixedNumber("42", Numbers.ATTO), - reserved: new Numbers.PrefixedNumber("0", Numbers.ATTO), - level: 0.1, +export const ZERO_BALANCE: TypesAccountData = { + total: Lgnt.zero(), + available: Lgnt.zero(), + reserved: Lgnt.zero(), }; export const DEFAULT_TRANSACTION: Transaction = { diff --git a/src/common/Transactions.test.tsx b/src/common/Transactions.test.tsx index 9eb8d1ef..ab666c02 100644 --- a/src/common/Transactions.test.tsx +++ b/src/common/Transactions.test.tsx @@ -4,16 +4,13 @@ jest.mock("./CommonContext"); import { shallowRender } from '../tests'; import Transactions from './Transactions'; -import { setBalanceState } from './__mocks__/CommonContextMock'; -import { setParams } from '../__mocks__/ReactRouterMock'; -import { DEFAULT_COIN_BALANCE, DEFAULT_TRANSACTION, DEFAULT_FAILED_TRANSACTION } from './TestData'; -import { BalanceState } from '@logion/client/dist/Balance.js'; +import { DEFAULT_COIN_BALANCE, DEFAULT_FAILED_TRANSACTION, ZERO_BALANCE } from './TestData'; import { TEST_WALLET_USER } from 'src/wallet-user/TestData'; test('renders null with missing data', () => { const result = shallowRender(); @@ -21,14 +18,9 @@ test('renders null with missing data', () => { }); test('renders with all data', () => { - setParams({coinId: 'lgnt'}); - setBalanceState({ - balances: [ DEFAULT_COIN_BALANCE ], - transactions: [ DEFAULT_TRANSACTION ], - } as BalanceState); const result = shallowRender(); @@ -36,15 +28,10 @@ test('renders with all data', () => { }); test('renders failed transaction', () => { - setParams({coinId: 'lgnt'}); - setBalanceState({ - balances: [ DEFAULT_COIN_BALANCE ], - transactions: [ DEFAULT_FAILED_TRANSACTION ], - } as BalanceState); const result = shallowRender(); expect(result).toMatchSnapshot(); diff --git a/src/common/Transactions.tsx b/src/common/Transactions.tsx index 81b1e5b2..6b43ef84 100644 --- a/src/common/Transactions.tsx +++ b/src/common/Transactions.tsx @@ -1,10 +1,9 @@ -import { useParams } from 'react-router'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; import OverlayTrigger from 'react-bootstrap/OverlayTrigger'; import Tooltip from 'react-bootstrap/Tooltip'; import { Transaction } from '@logion/client'; -import { CoinBalance, ValidAccountId } from '@logion/node-api'; +import { TypesAccountData, ValidAccountId } from '@logion/node-api'; import { FullWidthPane } from './Dashboard'; import Frame from './Frame'; @@ -31,7 +30,7 @@ export type WalletType = "Wallet" | "Vault"; export interface Props { account?: ValidAccountId, - balances: CoinBalance[] | null, + balance: TypesAccountData | null, transactions: Transaction[] | null, type: WalletType, vaultAddress?: ValidAccountId, @@ -39,9 +38,9 @@ export interface Props { export default function Transactions(props: Props) { const { colorTheme } = useCommonContext(); - const { account, balances, transactions, type, vaultAddress } = props; + const { account, balance, transactions, type, vaultAddress } = props; - if (balances === null || transactions === null) { + if (balance === null || transactions === null) { return null; } @@ -56,22 +55,21 @@ export default function Transactions(props: Props) { background: colorTheme.topMenuItems.iconGradient, } } > - + ); } interface ContentProps { account?: ValidAccountId, - balances: CoinBalance[], + balance: TypesAccountData, transactions: Transaction[], type: WalletType, vaultAccount?: ValidAccountId, } function Content(props: ContentProps) { - const { account, balances, transactions, type, vaultAccount } = props; - const { coinId } = useParams<"coinId">(); + const { account, balance, transactions, type, vaultAccount } = props; const { width } = useResponsiveContext(); const addressTitle = useMemo(() => { @@ -82,11 +80,10 @@ function Content(props: ContentProps) { } }, [ props.type ]); - if (balances === null || transactions === null) { + if (balance === null || transactions === null) { return ; } - const balance = balances.filter(balance => balance.coin.id === coinId)[0]; const columns: Column[] = [ { header: "Status", diff --git a/src/common/WalletGauge.test.tsx b/src/common/WalletGauge.test.tsx index 918d06b1..b32b1983 100644 --- a/src/common/WalletGauge.test.tsx +++ b/src/common/WalletGauge.test.tsx @@ -1,19 +1,17 @@ jest.mock("../logion-chain"); import { shallowRender } from '../tests'; -import { CoinBalance, Queries, Numbers } from '@logion/node-api'; +import { TypesAccountData, Lgnt } from '@logion/node-api'; import WalletGauge from './WalletGauge'; describe("WalletGauge", () => { it("renders", () => { - const balance: CoinBalance = { - coin: Queries.getCoin('lgnt'), - available: new Numbers.PrefixedNumber("20.00", Numbers.MILLI), - reserved: new Numbers.PrefixedNumber("0", Numbers.NONE), - total: new Numbers.PrefixedNumber("20.00", Numbers.MILLI), - level: 0.5, + const balance: TypesAccountData = { + available: Lgnt.from(0.02), + reserved: Lgnt.zero(), + total: Lgnt.from(0.02), }; const result = shallowRender( - diff --git a/src/common/__snapshots__/Transactions.test.tsx.snap b/src/common/__snapshots__/Transactions.test.tsx.snap index 2393d783..ce091a6c 100644 --- a/src/common/__snapshots__/Transactions.test.tsx.snap +++ b/src/common/__snapshots__/Transactions.test.tsx.snap @@ -25,45 +25,64 @@ exports[`renders failed transaction 1`] = ` }, } } - balances={Array []} - transactions={Array []} - type="Wallet" - /> - -`; - -exports[`renders null with missing data 1`] = ` - - `; +exports[`renders null with missing data 1`] = `null`; + exports[`renders with all data 1`] = ` diff --git a/src/common/__snapshots__/WalletGauge.test.tsx.snap b/src/common/__snapshots__/WalletGauge.test.tsx.snap index 75ea7db9..a0a802a7 100644 --- a/src/common/__snapshots__/WalletGauge.test.tsx.snap +++ b/src/common/__snapshots__/WalletGauge.test.tsx.snap @@ -4,64 +4,32 @@ exports[`WalletGauge renders 1`] = `
- { - it("renders DOT", () => expectMatchSnapshot("dot")); - it("renders LGNT", () => expectMatchSnapshot("lgnt")); + it("renders LGNT", () => expectMatchSnapshot()); }); -function expectMatchSnapshot(coindId: string) { - const element = render(); +function expectMatchSnapshot() { + const element = render(); expect(element).toMatchSnapshot(); } diff --git a/src/components/coin/CoinIcon.tsx b/src/components/coin/CoinIcon.tsx index 21f890cb..fff439bc 100644 --- a/src/components/coin/CoinIcon.tsx +++ b/src/components/coin/CoinIcon.tsx @@ -1,25 +1,13 @@ -import Icon, { IconFileType } from "src/common/Icon"; +import Icon from "src/common/Icon"; export interface Props { - coinId: string; height: string; } -const iconIds: Record = { - "lgnt": "lgnt", - "dot": "dot" -}; - -const iconTypes: Record = { - "lgnt": "svg", - "dot": "png" -}; - export default function CoinIcon(props: Props) { return ( diff --git a/src/components/coin/CoinName.test.tsx b/src/components/coin/CoinName.test.tsx deleted file mode 100644 index 917182ae..00000000 --- a/src/components/coin/CoinName.test.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { render } from "src/tests"; -import CoinName from "./CoinName"; - -describe("CoinName", () => { - - it("renders DOT", () => expectMatchSnapshot("dot")); - it("renders LGNT", () => expectMatchSnapshot("lgnt")); -}); - -function expectMatchSnapshot(coindId: string) { - const element = render(); - expect(element).toMatchSnapshot(); -} diff --git a/src/components/coin/CoinName.tsx b/src/components/coin/CoinName.tsx deleted file mode 100644 index 9e0d131e..00000000 --- a/src/components/coin/CoinName.tsx +++ /dev/null @@ -1,12 +0,0 @@ -export interface Props { - coinId: string; -} - -const coinNames: Record = { - "lgnt": "Logion Token", - "dot": "Polkadot" -}; - -export default function CoinName(props: Props) { - return { coinNames[props.coinId] }; -} diff --git a/src/components/coin/__snapshots__/CoinIcon.test.tsx.snap b/src/components/coin/__snapshots__/CoinIcon.test.tsx.snap index 74357d44..af9c718f 100644 --- a/src/components/coin/__snapshots__/CoinIcon.test.tsx.snap +++ b/src/components/coin/__snapshots__/CoinIcon.test.tsx.snap @@ -1,14 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`CoinIcon renders DOT 1`] = ` -dot -`; - exports[`CoinIcon renders LGNT 1`] = ` lgnt - Polkadot - -`; - -exports[`CoinName renders LGNT 1`] = ` - - Logion Token - -`; diff --git a/src/components/inlineamount/InlineAmount.tsx b/src/components/inlineamount/InlineAmount.tsx index 5bc75ea2..1941b11a 100644 --- a/src/components/inlineamount/InlineAmount.tsx +++ b/src/components/inlineamount/InlineAmount.tsx @@ -1,17 +1,23 @@ -import { Coin, Numbers } from "@logion/node-api"; +import { Lgnt } from "@logion/node-api"; import "./InlineAmount.css"; +import { useMemo } from "react"; +import { toOptimizedNumber } from "src/common/Amount"; export interface Props { - coin: Coin; - amount: Numbers.PrefixedNumber; + amount: Lgnt; } export default function InlineAmount(props: Props) { + + const amount = useMemo(() => { + return toOptimizedNumber(props.amount); + }, [ props.amount ]); + return ( - { props.amount.coefficient.toFixedPrecision(2) }{" "} - { props.amount.prefix.symbol + props.coin.symbol } + { amount.coefficient.toFixedPrecision(2) }{" "} + { amount.prefix.symbol + Lgnt.CODE } ); } diff --git a/src/legal-officer/LegalOfficerRouter.tsx b/src/legal-officer/LegalOfficerRouter.tsx index 86470c28..ea637341 100644 --- a/src/legal-officer/LegalOfficerRouter.tsx +++ b/src/legal-officer/LegalOfficerRouter.tsx @@ -88,7 +88,7 @@ export default function LegalOfficerRouter() { } /> } /> diff --git a/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap b/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap index 31744533..f7f69b0c 100644 --- a/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap +++ b/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap @@ -34,7 +34,7 @@ exports[`renders 1`] = ` }, } } - balances={Array []} + balance={null} transactions={Array []} type="Wallet" /> diff --git a/src/legal-officer/home/Home.test.tsx b/src/legal-officer/home/Home.test.tsx index 4cd414e1..9ec66e31 100644 --- a/src/legal-officer/home/Home.test.tsx +++ b/src/legal-officer/home/Home.test.tsx @@ -13,7 +13,7 @@ describe("Home", () => { it("renders", () => { setBalanceState({ - balances: [ DEFAULT_COIN_BALANCE ], + balance: DEFAULT_COIN_BALANCE, transactions: [ DEFAULT_TRANSACTION ], } as BalanceState); const tree = shallowRender() diff --git a/src/legal-officer/home/Home.tsx b/src/legal-officer/home/Home.tsx index b20eaeb2..0faef71a 100644 --- a/src/legal-officer/home/Home.tsx +++ b/src/legal-officer/home/Home.tsx @@ -10,7 +10,6 @@ import Loader from '../../common/Loader'; import Table, { ActionCell, Cell, DateCell, DateTimeCell, EmptyTableMessage } from '../../common/Table'; import TransferAmountCell, { transferBalance } from '../../common/TransferAmountCell'; import AmountCell from '../../common/AmountCell'; -import Reading from '../../common/Reading'; import Button from '../../common/Button'; import LocStatusCell from '../../common/LocStatusCell'; import ButtonGroup from '../../common/ButtonGroup'; @@ -27,6 +26,7 @@ import { toFeesClass } from "@logion/client/dist/Fees.js"; import VaultTransferRequestDetails from '../vault/VaultTransferDetails'; import VaultTransferRequestStatusCell from '../../common/VaultTransferRequestStatusCell'; import { useResponsiveContext } from '../../common/Responsive'; +import BalanceReading from 'src/common/BalanceReading'; const MAX_WAITING_SHOWN = 3; @@ -100,11 +100,8 @@ export default function Home() {
-