Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected getBasicBytes(): Buffer {
const transactionType = cryptography.intToBuffer(this.type, constants.BYTESIZES.TYPE);
const transactionTimestamp = cryptography.intToBuffer(
this.timestamp,
constants.BYTESIZES.TIMESTAMP,
'little',
);
const transactionSenderPublicKey = cryptography.hexToBuffer(this.senderPublicKey);
const transactionRecipientID = cryptography.intToBuffer(
this.asset.recipientId.slice(0, -1),
constants.BYTESIZES.RECIPIENT_ID,
).slice(0, constants.BYTESIZES.RECIPIENT_ID);
const transactionAmount = cryptography.bigNumberToBuffer(
this.asset.amount.toString(),
constants.BYTESIZES.AMOUNT,
'little',
);
const { dappId, transactionId } = this.asset.outTransfer;
const outAppIdBuffer = Buffer.from(dappId, 'utf8');
const outTransactionIdBuffer = Buffer.from(transactionId, 'utf8');
return Buffer.concat([
transactionType,
transactionTimestamp,
transactionSenderPublicKey,
transactionRecipientID,
transactionAmount,
Buffer.concat([outAppIdBuffer, outTransactionIdBuffer]),
protected getBasicBytes(): Buffer {
const transactionType = cryptography.intToBuffer(this.type, constants.BYTESIZES.TYPE);
const transactionTimestamp = cryptography.intToBuffer(
this.timestamp,
constants.BYTESIZES.TIMESTAMP,
'little',
);
const transactionSenderPublicKey = cryptography.hexToBuffer(this.senderPublicKey);
const transactionRecipientID = Buffer.alloc(constants.BYTESIZES.RECIPIENT_ID);
const transactionAmount = cryptography.bigNumberToBuffer(
this.asset.amount.toString(),
constants.BYTESIZES.AMOUNT,
'little',
);
return Buffer.concat([
transactionType,
transactionTimestamp,
transactionSenderPublicKey,
transactionRecipientID,
transactionAmount,
Buffer.from(this.asset.inTransfer.dappId, 'utf8'),
]);
}