Skip to content

Commit

Permalink
Merge pull request #8514 from LedgerHQ/feat/acre-remove-withdrawal-modal
Browse files Browse the repository at this point in the history
feat(ACRE): Remove fields from the sign-message modal type withdraw
  • Loading branch information
ComradeAERGO authored Nov 28, 2024
2 parents d4058aa + b8b9f76 commit 1df9b64
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 79 deletions.
6 changes: 6 additions & 0 deletions .changeset/lovely-glasses-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": minor
"live-mobile": minor
---

Removed message fields for sign message modal for ACRE Withdrawals
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,12 @@ const SignMessageConfirm = ({ device, account, parentAccount, signMessageRequest
const { currency } = mainAccount;
const [messageFields, setMessageFields] = useState<MessageProperties | null>(null);

const isACREWithdraw = "type" in signMessageRequested && signMessageRequested.type === "Withdraw";

useEffect(() => {
if (signMessageRequested.standard === "EIP712") {
const specific = getLLDCoinFamily(currency.family);
specific?.message?.getMessageProperties(signMessageRequested).then(setMessageFields);
} else if (isACREWithdraw) {
setMessageFields(
Object.entries(signMessageRequested.message).map(([label, value]) => ({
label,
value,
})),
);
}
}, [currency, isACREWithdraw, mainAccount, signMessageRequested]);
}, [currency, mainAccount, signMessageRequested]);

if (!device) return null;

Expand All @@ -97,12 +88,6 @@ const SignMessageConfirm = ({ device, account, parentAccount, signMessageRequest
label: t("SignMessageConfirm.messageHash"),
value: signMessageRequested.hashStruct,
});
} else if (!isACREWithdraw) {
fields.push({
type: "text",
label: t("SignMessageConfirm.message"),
value: signMessageRequested.message,
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,8 @@ export default function StepSummary({ account, message: messageData }: StepProps
if (messageData.standard === "EIP712") {
const specific = getLLDCoinFamily(mainAccount.currency.family);
specific?.message?.getMessageProperties(messageData).then(setMessageFields);
} else if (isACREWithdraw) {
setMessageFields(
Object.entries(messageData.message).map(([label, value]) => ({
label,
value,
})),
);
}
}, [account.currency.family, isACREWithdraw, mainAccount, messageData, setMessageFields]);
}, [account.currency.family, mainAccount, messageData, setMessageFields]);

return (
<Box flow={1}>
Expand All @@ -145,11 +138,13 @@ export default function StepSummary({ account, message: messageData }: StepProps
</Box>
<Separator />

{messageData.standard === "EIP712" || isACREWithdraw ? (
<MessagePropertiesComp properties={messageFields} />
) : (
<MessageProperty label={"message"} value={messageData.message} />
)}
{!isACREWithdraw ? (
messageData.standard === "EIP712" ? (
<MessagePropertiesComp properties={messageFields} />
) : (
<MessageProperty label={"message"} value={messageData.message} />
)
) : null}

<MessageContainer flex="1">
{messageFields ? (
Expand Down
63 changes: 29 additions & 34 deletions apps/ledger-live-mobile/src/components/ValidateMessageOnDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,8 @@ export default function ValidateOnDevice({ device, message: messageData, account
useEffect(() => {
if (messageData.standard === "EIP712") {
getMessageProperties(messageData).then(setMessageFields);
} else if (isACREWithdraw) {
setMessageFields(
Object.entries(messageData.message).map(([label, value]) => ({
label,
value,
})),
);
}
}, [isACREWithdraw, mainAccount, mainAccount.currency, messageData, setMessageFields]);
}, [mainAccount, mainAccount.currency, messageData, setMessageFields]);

return (
<View style={styles.root}>
Expand All @@ -81,33 +74,35 @@ export default function ValidateOnDevice({ device, message: messageData, account
<LText style={messageTextStyle}>{t("walletconnect.stepVerification.accountName")}</LText>
<LText semiBold>{mainAccountName}</LText>
</View>
{messageData.standard === "EIP712" || isACREWithdraw ? (
<>
{messageFields
? messageFields.map(({ label, value }) => (
<View key={label} style={messageContainerStyle}>
<LText style={messageTextStyle}>{label}</LText>
{Array.isArray(value) ? (
value.map((v, i) => (
<LText key={i} style={[styles.value, styles.subValue]} semiBold>
{v}
{!isACREWithdraw ? (
messageData.standard === "EIP712" ? (
<>
{messageFields
? messageFields.map(({ label, value }) => (
<View key={label} style={messageContainerStyle}>
<LText style={messageTextStyle}>{label}</LText>
{Array.isArray(value) ? (
value.map((v, i) => (
<LText key={i} style={[styles.value, styles.subValue]} semiBold>
{v}
</LText>
))
) : (
<LText style={styles.value} semiBold>
{value}
</LText>
))
) : (
<LText style={styles.value} semiBold>
{value}
</LText>
)}
</View>
))
: null}
</>
) : (
<View style={messageContainerStyle}>
<LText style={messageTextStyle}>{t("walletconnect.message")}</LText>
<LText semiBold>{messageData.message}</LText>
</View>
)}
)}
</View>
))
: null}
</>
) : (
<View style={messageContainerStyle}>
<LText style={messageTextStyle}>{t("walletconnect.message")}</LText>
<LText semiBold>{messageData.message}</LText>
</View>
)
) : null}
</ScrollView>
</View>
);
Expand Down
27 changes: 11 additions & 16 deletions apps/ledger-live-mobile/src/screens/SignMessage/01-Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,8 @@ function SignSummary({
useEffect(() => {
if (messageData.standard === "EIP712") {
getMessageProperties(messageData).then(setMessageFields);
} else if (isACREWithdraw) {
setMessageFields(
Object.entries(messageData.message).map(([label, value]) => ({
label,
value,
})),
);
}
}, [isACREWithdraw, mainAccount, mainAccount.currency, messageData, setMessageFields]);
}, [mainAccount, mainAccount.currency, messageData, setMessageFields]);

return (
<SafeAreaView
Expand Down Expand Up @@ -160,15 +153,17 @@ function SignSummary({
]}
/>
<ScrollView style={styles.scrollContainer}>
{messageData.standard === "EIP712" || isACREWithdraw ? (
<MessagePropertiesComp properties={messageFields} />
) : (
<View style={styles.messageContainer}>
<MessageProperty label={"message"} value={messageData.message || ""} />
</View>
)}
{!isACREWithdraw ? (
messageData.standard === "EIP712" ? (
<MessagePropertiesComp properties={messageFields} />
) : (
<View style={styles.messageContainer}>
<MessageProperty label={"message"} value={messageData.message || ""} />
</View>
)
) : null}

{messageData.standard === "EIP712" || isACREWithdraw ? (
{messageData.standard === "EIP712" ? (
<>
{messageFields ? (
<View>
Expand Down

0 comments on commit 1df9b64

Please sign in to comment.