Skip to content

Commit

Permalink
fix(llm): 🐛 fix long Memo Tag issue on Cardano (#8608)
Browse files Browse the repository at this point in the history
* fix(llm): fix long memo issue on Cardano

* chore: update change log
  • Loading branch information
thesan committed Dec 6, 2024
1 parent 26e91b7 commit 09ed29a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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
7 changes: 7 additions & 0 deletions apps/ledger-live-mobile/src/families/cardano/MemoTagInput.tsx
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}
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;

0 comments on commit 09ed29a

Please sign in to comment.