Skip to content

Commit

Permalink
Merge pull request #855 from symbol/dev
Browse files Browse the repository at this point in the history
Release v2.0.5
  • Loading branch information
OlegMakarenko authored Mar 15, 2024
2 parents 894a017 + 1162c1c commit 58c9eab
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 2.0.5 - 15-Mar-2024

Package | Version | Link
---|---|---
SDK Core| v2.0.5 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk)
Catbuffer | v1.0.2 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript)
Client Library | v1.0.3 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)

- [Bug] [853](https://github.com/symbol/symbol-sdk-typescript-javascript/pull/853): Fixed encoding of raw messages in TransferTransaction.

## 2.0.4 - 7-Mar-2023

Package | Version | Link
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "symbol-sdk",
"version": "2.0.4",
"version": "2.0.5",
"description": "Reactive symbol sdk for typescript and javascript",
"scripts": {
"pretest": "npm run build",
Expand Down
14 changes: 8 additions & 6 deletions src/model/transaction/TransferTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ export class TransferTransaction extends Transaction {
if (!this.message || !this.message.payload) {
return Uint8Array.of();
}
const messgeHex =
this.message.type === MessageType.PersistentHarvestingDelegationMessage
? this.message.payload
: Convert.utf8ToHex(this.message.payload);
const payloadBuffer = Convert.hexToUint8(messgeHex);
const isPersistentHarvestingDelegationMessage = this.message.type === MessageType.PersistentHarvestingDelegationMessage;
const isRawMessage = this.message.type === MessageType.RawMessage;

const messageHex =
isPersistentHarvestingDelegationMessage || isRawMessage ? this.message.payload : Convert.utf8ToHex(this.message.payload);
const payloadBuffer = Convert.hexToUint8(messageHex);
const typeBuffer = GeneratorUtils.uintToBuffer(this.message.type, 1);
return this.message.type === MessageType.PersistentHarvestingDelegationMessage || !this.message.payload

return isPersistentHarvestingDelegationMessage || isRawMessage || !this.message.payload
? payloadBuffer
: GeneratorUtils.concatTypedArrays(typeBuffer, payloadBuffer);
}
Expand Down
25 changes: 24 additions & 1 deletion test/model/transaction/TransferTransaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TransactionMapping } from '../../../src/core/utils';
import { CreateTransactionFromPayload } from '../../../src/infrastructure/transaction';
import { PersistentHarvestingDelegationMessage, UInt64 } from '../../../src/model';
import { Account, Address } from '../../../src/model/account';
import { EmptyMessage, MessageMarker, MessageType, PlainMessage } from '../../../src/model/message';
import { EmptyMessage, MessageMarker, MessageType, PlainMessage, RawMessage } from '../../../src/model/message';
import { Mosaic, MosaicId } from '../../../src/model/mosaic';
import { NamespaceId } from '../../../src/model/namespace';
import { NetworkType } from '../../../src/model/network';
Expand Down Expand Up @@ -133,6 +133,29 @@ describe('TransferTransaction', () => {
);
});

it('should createComplete an TransferTransaction object with raw message', () => {
// Arrange:
const messageBytes = new Uint8Array([3, 2, 1, 123, 0, 255]);
const messageHex = '0302017B00FF';

// Act:
const transferTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
testAddress,
[],
RawMessage.create(messageBytes),
TestNetworkType,
);
const transactionPayload = transferTransaction.signWith(account, generationHash).payload;
const recreatedTransferTransaction = TransferTransaction.createFromPayload(transactionPayload) as TransferTransaction;

// Assert:
expect(transferTransaction.message.type).to.be.equal(MessageType.RawMessage);
expect(transferTransaction.message.payload).to.be.equal(messageHex);
expect(recreatedTransferTransaction.message.type).to.be.equal(MessageType.RawMessage);
expect(recreatedTransferTransaction.message.payload).to.be.equal(messageHex);
});

it('should createComplete an TransferTransaction object and sign it with mosaics', () => {
const transferTransaction = TransferTransaction.create(
Deadline.create(epochAdjustment),
Expand Down

0 comments on commit 58c9eab

Please sign in to comment.