import type { Transaction } from "@solana/web3.js" ; function shortvecEncodeLength ( bytes , len ) { let rem_len = len ; for ( ; ; ) { let elem = rem_len & 0x7f ; rem_len >>= 7 ; if ( rem_len === 0 ) { bytes . push ( elem ) ; break ; } else { elem |= 0x80 ; bytes . push ( elem ) ; } } } param tx returns export const calculateTxSizeUnsafe = ( tx ) : number => { const { feePayer } = tx ; const hasFeePayerSigned = feePayer && tx . signatures . find ( ( s ) => s . publicKey . equals ( feePayer ) ) ; const signData = tx . serializeMessage ( ) ; const numSigners = tx . signatures . length + ( hasFeePayerSigned ? 1 : 0 ) ; const signatureCount = [ ] ; shortvecEncodeLength ( signatureCount , numSigners ) ; return signatureCount . length + numSigners * 64 + signData . length ; } ;