hedera-sdk-js
hedera-sdk-js copied to clipboard
FileAppendTransaction incorrect content after deserialization
Description
Serializing and then deserializing a FileAppendTransaction causes incorrect content to be set. After the deserialization, the content is sliced to the chunk size. Ex. If you have a content length of 100_000 after the deserialization, the content will consist only of the first {chunkSize} bytes.
Steps to reproduce
- Run this snippet
const { FileAppendTransaction } = require('@hashgraph/sdk');
async function run() {
const contentLength = 632421;
const content = generateUInt8Array(contentLength);
const transaction = new FileAppendTransaction()
.setTransactionValidDuration(180)
.setContents(content);
console.log(transaction.contents.length); //632421 (content length)
const transactionBytes = transaction.toBytes();
const transactionFromBytes =
FileAppendTransaction.fromBytes(transactionBytes);
console.log(transactionFromBytes.contents.length); //4096 (default chunk size)
}
run();
function generateUInt8Array(length) {
const uint8Array = new Uint8Array(length);
for (let i = 0; i < length; i++) {
uint8Array[i] = Math.floor(Math.random() * 256);
}
return uint8Array;
}
Additional context
No response
Hedera network
other
Version
v2.42.0-beta.4
Operating system
None