-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(LLD, LLM): token summary and device screens
- Loading branch information
Showing
8 changed files
with
128 additions
and
40 deletions.
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
apps/ledger-live-desktop/src/renderer/families/solana/TransactionConfirmFields.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,67 @@ | ||
import React, { useMemo } from "react"; | ||
import { getDeviceTransactionConfig } from "@ledgerhq/live-common/transaction/index"; | ||
import { SolanaFamily } from "./types"; | ||
import Alert from "~/renderer/components/Alert"; | ||
import { Trans } from "react-i18next"; | ||
import ConfirmTitle from "~/renderer/components/TransactionConfirm/ConfirmTitle"; | ||
import LinkWithExternalIcon from "~/renderer/components/LinkWithExternalIcon"; | ||
import Box from "~/renderer/components/Box"; | ||
import { openURL } from "~/renderer/linking"; | ||
import { useLocalizedUrl } from "~/renderer/hooks/useLocalizedUrls"; | ||
import { urls } from "~/config/urls"; | ||
|
||
const Title: TitleComponent = props => { | ||
const { transaction, account, parentAccount, status } = props; | ||
const transferTokenHelpUrl = useLocalizedUrl(urls.solana.splTokenInfo); | ||
|
||
const fields = getDeviceTransactionConfig({ | ||
account, | ||
parentAccount, | ||
transaction, | ||
status, | ||
}); | ||
|
||
const typeTransaction: string | undefined = useMemo(() => { | ||
const typeField = fields.find(field => field.label && field.label === "Type"); | ||
|
||
if (typeField && typeField.type === "text" && typeField.value) { | ||
return typeField.value; | ||
} | ||
}, [fields]); | ||
|
||
if (transaction.model.commandDescriptor?.command.kind === "token.transfer") { | ||
return ( | ||
<Box | ||
flexDirection="column" | ||
alignItems="center" | ||
gap={4} | ||
mb={4} | ||
justifyContent="center" | ||
className="title-test-transfer" | ||
> | ||
<ConfirmTitle title={undefined} typeTransaction={typeTransaction} {...props} /> | ||
<Alert type="warning"> | ||
<Trans i18nKey="solana.token.transferWarning"> | ||
<LinkWithExternalIcon | ||
color="palette.warning.c60" | ||
onClick={() => openURL(transferTokenHelpUrl)} | ||
/> | ||
</Trans> | ||
</Alert> | ||
</Box> | ||
); | ||
} | ||
|
||
return <ConfirmTitle title={undefined} typeTransaction={typeTransaction} {...props} />; | ||
}; | ||
|
||
type TransactionConfirmFields = SolanaFamily["transactionConfirmFields"]; | ||
type TitleComponent = NonNullable<NonNullable<TransactionConfirmFields>["title"]>; | ||
|
||
const transactionConfirmFields: TransactionConfirmFields = { | ||
// footer: Footer, // is not shown without manifestId | ||
// fieldComponents, | ||
title: Title, | ||
}; | ||
|
||
export default transactionConfirmFields; |
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
46 changes: 46 additions & 0 deletions
46
apps/ledger-live-mobile/src/families/solana/TransactionConfirmFields.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,46 @@ | ||
import invariant from "invariant"; | ||
import React from "react"; | ||
import { Linking, View } from "react-native"; | ||
import { Trans } from "react-i18next"; | ||
import { Link } from "@ledgerhq/native-ui"; | ||
import { DeviceTransactionField } from "@ledgerhq/live-common/transaction/index"; | ||
import { | ||
SolanaAccount, | ||
SolanaTokenAccount, | ||
Transaction, | ||
TransactionStatus, | ||
} from "@ledgerhq/live-common/families/solana/types"; | ||
import Alert from "~/components/Alert"; | ||
import { urls } from "~/utils/urls"; | ||
import LText from "~/components/LText"; | ||
|
||
type SolanaFieldComponentProps = { | ||
account: SolanaAccount | SolanaTokenAccount; | ||
parentAccount: SolanaAccount | undefined | null; | ||
transaction: Transaction; | ||
status: TransactionStatus; | ||
field: DeviceTransactionField; | ||
}; | ||
|
||
const Warning = ({ transaction }: SolanaFieldComponentProps) => { | ||
invariant(transaction.family === "solana", "solana transaction"); | ||
if (transaction.model.commandDescriptor?.command.kind === "token.transfer") { | ||
return ( | ||
<View> | ||
<Alert type="hint"> | ||
<LText> | ||
<Trans i18nKey="solana.token.transferWarning"> | ||
<Link onPress={() => Linking.openURL(urls.solana.splTokenInfo)} type="color" /> | ||
</Trans> | ||
</LText> | ||
</Alert> | ||
</View> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
export default { | ||
warning: Warning, | ||
fieldComponents: {}, | ||
}; |
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