Skip to content

Commit 58c9eab

Browse files
Merge pull request #855 from symbol/dev
Release v2.0.5
2 parents 894a017 + 1162c1c commit 58c9eab

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

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

7+
## 2.0.5 - 15-Mar-2024
8+
9+
Package | Version | Link
10+
---|---|---
11+
SDK Core| v2.0.5 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk)
12+
Catbuffer | v1.0.2 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript)
13+
Client Library | v1.0.3 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)
14+
15+
- [Bug] [853](https://github.com/symbol/symbol-sdk-typescript-javascript/pull/853): Fixed encoding of raw messages in TransferTransaction.
16+
717
## 2.0.4 - 7-Mar-2023
818

919
Package | Version | Link

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "symbol-sdk",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"description": "Reactive symbol sdk for typescript and javascript",
55
"scripts": {
66
"pretest": "npm run build",

src/model/transaction/TransferTransaction.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,15 @@ export class TransferTransaction extends Transaction {
202202
if (!this.message || !this.message.payload) {
203203
return Uint8Array.of();
204204
}
205-
const messgeHex =
206-
this.message.type === MessageType.PersistentHarvestingDelegationMessage
207-
? this.message.payload
208-
: Convert.utf8ToHex(this.message.payload);
209-
const payloadBuffer = Convert.hexToUint8(messgeHex);
205+
const isPersistentHarvestingDelegationMessage = this.message.type === MessageType.PersistentHarvestingDelegationMessage;
206+
const isRawMessage = this.message.type === MessageType.RawMessage;
207+
208+
const messageHex =
209+
isPersistentHarvestingDelegationMessage || isRawMessage ? this.message.payload : Convert.utf8ToHex(this.message.payload);
210+
const payloadBuffer = Convert.hexToUint8(messageHex);
210211
const typeBuffer = GeneratorUtils.uintToBuffer(this.message.type, 1);
211-
return this.message.type === MessageType.PersistentHarvestingDelegationMessage || !this.message.payload
212+
213+
return isPersistentHarvestingDelegationMessage || isRawMessage || !this.message.payload
212214
? payloadBuffer
213215
: GeneratorUtils.concatTypedArrays(typeBuffer, payloadBuffer);
214216
}

test/model/transaction/TransferTransaction.spec.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { TransactionMapping } from '../../../src/core/utils';
2121
import { CreateTransactionFromPayload } from '../../../src/infrastructure/transaction';
2222
import { PersistentHarvestingDelegationMessage, UInt64 } from '../../../src/model';
2323
import { Account, Address } from '../../../src/model/account';
24-
import { EmptyMessage, MessageMarker, MessageType, PlainMessage } from '../../../src/model/message';
24+
import { EmptyMessage, MessageMarker, MessageType, PlainMessage, RawMessage } from '../../../src/model/message';
2525
import { Mosaic, MosaicId } from '../../../src/model/mosaic';
2626
import { NamespaceId } from '../../../src/model/namespace';
2727
import { NetworkType } from '../../../src/model/network';
@@ -133,6 +133,29 @@ describe('TransferTransaction', () => {
133133
);
134134
});
135135

136+
it('should createComplete an TransferTransaction object with raw message', () => {
137+
// Arrange:
138+
const messageBytes = new Uint8Array([3, 2, 1, 123, 0, 255]);
139+
const messageHex = '0302017B00FF';
140+
141+
// Act:
142+
const transferTransaction = TransferTransaction.create(
143+
Deadline.create(epochAdjustment),
144+
testAddress,
145+
[],
146+
RawMessage.create(messageBytes),
147+
TestNetworkType,
148+
);
149+
const transactionPayload = transferTransaction.signWith(account, generationHash).payload;
150+
const recreatedTransferTransaction = TransferTransaction.createFromPayload(transactionPayload) as TransferTransaction;
151+
152+
// Assert:
153+
expect(transferTransaction.message.type).to.be.equal(MessageType.RawMessage);
154+
expect(transferTransaction.message.payload).to.be.equal(messageHex);
155+
expect(recreatedTransferTransaction.message.type).to.be.equal(MessageType.RawMessage);
156+
expect(recreatedTransferTransaction.message.payload).to.be.equal(messageHex);
157+
});
158+
136159
it('should createComplete an TransferTransaction object and sign it with mosaics', () => {
137160
const transferTransaction = TransferTransaction.create(
138161
Deadline.create(epochAdjustment),

0 commit comments

Comments
 (0)