Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(llm): πŸ› fix long Memo Tag issue on Cardano #8608

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rare-schools-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Truncate Cardano memos in the input to prevent the transaction validation errors
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import React from "react";
import type { Transaction as CardanoTransaction } from "@ledgerhq/live-common/families/cardano/types";
import type { MemoTagInputProps } from "LLM/features/MemoTag/types";
import { GenericMemoTagInput } from "LLM/features/MemoTag/components/GenericMemoTagInput";
import { truncateUtf8 } from "LLM/utils/truncateUtf8";

export default (props: MemoTagInputProps<CardanoTransaction>) => (
<GenericMemoTagInput
{...props}
themooneer marked this conversation as resolved.
Show resolved Hide resolved
textToValue={text => truncateUtf8(text, MAX_MEMO_LENGTH)}
valueToTxPatch={value => tx => ({ ...tx, memo: value || undefined })}
/>
);

// From the Cardano metadata documentation:
// > Strings must be at most 64 bytes when UTF-8 encoded.
// https://developers.cardano.org/docs/get-started/cardano-serialization-lib/transaction-metadata/#metadata-limitations
const MAX_MEMO_LENGTH = 64;