-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(llm): 🐛 release fix long Memo Tag issue on Stacks (#8624)
fix(llm): fix long Memo Tag issue in Stacks chore: update change log chore: update unimported fix(llm): use `truncateUtf8` instead of `Array.slice` chore(llm): use `maxLength` instead of `Array.slice` on Algorand fix(llm): validate the memo bytes length instead of the js string length
- Loading branch information
Showing
7 changed files
with
25 additions
and
2 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,7 @@ | ||
--- | ||
"@ledgerhq/coin-stacks": minor | ||
"live-mobile": minor | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
Truncate Stacks memos in the input to prevent the transaction validation from failing |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
import React from "react"; | ||
|
||
import { STACKS_MAX_MEMO_SIZE } from "@ledgerhq/live-common/families/stacks/constants"; | ||
import type { Transaction as StacksTransaction } from "@ledgerhq/live-common/families/stacks/types"; | ||
import type { MemoTagInputProps } from "LLM/features/MemoTag/types"; | ||
import { GenericMemoTagInput } from "LLM/features/MemoTag/components/GenericMemoTagInput"; | ||
import { truncateUtf8 } from "LLM/utils/truncateUtf8"; | ||
|
||
// `TextInputProps.maxLength` can not be used here because it counts the length of the string instead of the byte size. | ||
// E.g. | ||
// Javascript will evaluate a 16👍 emojis string as 34 characters. | ||
// While this string is in fact encoded in 68B in UTF8 which is well above STX limit. | ||
// `truncateUtf8` will truncate the string correctly, which is 8👍 with 2 characters to spare. | ||
|
||
export default (props: MemoTagInputProps<StacksTransaction>) => ( | ||
<GenericMemoTagInput | ||
{...props} | ||
textToValue={text => truncateUtf8(text, STACKS_MAX_MEMO_SIZE)} | ||
valueToTxPatch={value => tx => ({ ...tx, memo: value || undefined })} | ||
/> | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const STACKS_MAX_MEMO_SIZE = 34; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Encapsulate for LLD & LLM | ||
export * from "@ledgerhq/coin-stacks/contants"; |