import * as yup from 'yup' ; import { MEMO_MAX_LENGTH_BYTES } from '@stacks/transactions' ; import { isString } from '@app/common/utils' ; const exceedsMaxLengthBytes = ( string , maxLengthBytes ) : boolean => string ? Buffer . from ( string ) . length > maxLengthBytes : false ; function isTxMemoValid ( memo ) { return ! exceedsMaxLengthBytes ( memo , MEMO_MAX_LENGTH_BYTES ) ; } export function transactionMemoSchema ( errorMsg ) { return yup . string ( ) . test ( { message : errorMsg , test ( value ) { if ( ! isString ( value ) ) return true ; return isTxMemoValid ( value ) ; } , } ) ; }