-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: casper support on memo tag send flow (#8419)
- Loading branch information
1 parent
a9edfa0
commit 24e2ef9
Showing
10 changed files
with
108 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"ledger-live-desktop": minor | ||
--- | ||
|
||
Fix casper issues with new memo tag flow (using an intermediary screen) - feature flagged |
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
1 change: 0 additions & 1 deletion
1
apps/ledger-live-desktop/src/newArch/features/MemoTag/constants.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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
export const MEMO_TAG_COINS: string[] = [ | ||
"algorand", | ||
"cardano", | ||
"casper", | ||
"cosmos", | ||
|
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
39 changes: 39 additions & 0 deletions
39
apps/ledger-live-desktop/src/renderer/families/casper/MemoField.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,39 @@ | ||
import React, { useCallback } from "react"; | ||
import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; | ||
import invariant from "invariant"; | ||
import { useTranslation } from "react-i18next"; | ||
import MemoTagField from "~/newArch/features/MemoTag/components/MemoTagField"; | ||
import { MemoTagFieldProps } from "./types"; | ||
|
||
const MemoField = ({ onChange, account, transaction, status, autoFocus }: MemoTagFieldProps) => { | ||
invariant(transaction.family === "casper", "TransferIdField: casper family expected"); | ||
|
||
const { t } = useTranslation(); | ||
|
||
const bridge = getAccountBridge(account); | ||
|
||
const onTransferIdFieldChange = useCallback( | ||
(value: string) => { | ||
value = value.replace(/\D/g, ""); | ||
if (value !== "") onChange(bridge.updateTransaction(transaction, { transferId: value })); | ||
else onChange(bridge.updateTransaction(transaction, { transferId: undefined })); | ||
}, | ||
[onChange, transaction, bridge], | ||
); | ||
|
||
return ( | ||
<MemoTagField | ||
warning={status.warnings.transaction} | ||
error={status.errors.transaction} | ||
value={transaction.transferId ?? ""} | ||
placeholder={t("families.casper.transferIdPlaceholder")} | ||
label={t("families.casper.transferId")} | ||
tooltipText={t("families.casper.transferIdWarningText")} | ||
onChange={onTransferIdFieldChange} | ||
spellCheck="false" | ||
autoFocus={autoFocus} | ||
/> | ||
); | ||
}; | ||
|
||
export default MemoField; |
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
21 changes: 21 additions & 0 deletions
21
apps/ledger-live-desktop/src/renderer/families/casper/SendRecipientFields.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 React from "react"; | ||
import Box from "~/renderer/components/Box"; | ||
import MemoField from "./MemoField"; | ||
import { TransferIdProps } from "./types"; | ||
import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; | ||
|
||
const Root = (props: TransferIdProps) => { | ||
const lldMemoTag = useFeature("lldMemoTag"); | ||
|
||
if (!lldMemoTag?.enabled) return null; | ||
|
||
return ( | ||
<Box flow={1}> | ||
<MemoField {...props} /> | ||
</Box> | ||
); | ||
}; | ||
export default { | ||
component: Root, | ||
fields: ["memo"], | ||
}; |
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