Skip to content

Commit f9fb9a4

Browse files
committed
Merge branch 'task/g50-account-properties' of https://github.com/rg911/nem2-sdk-typescript-javascript into task/g50-account-properties
2 parents 6ad7ba8 + b71d16f commit f9fb9a4

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nem2-sdk",
3-
"version": "0.10.3-1",
3+
"version": "0.10.3-2",
44
"description": "Reactive Nem2 sdk for typescript and javascript",
55
"scripts": {
66
"pretest": "npm run build",

src/infrastructure/transaction/CreateTransactionFromDTO.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const CreateTransactionFromDTO = (transactionDTO): Transaction => {
7474
transactionDTO.transaction.type,
7575
extractTransactionVersion(transactionDTO.transaction.version),
7676
Deadline.createFromDTO(transactionDTO.transaction.deadline),
77-
new UInt64(transactionDTO.transaction.fee),
77+
new UInt64(transactionDTO.transaction.fee || [0, 0]),
7878
innerTransactions,
7979
transactionDTO.transaction.cosignatures ? transactionDTO.transaction.cosignatures
8080
.map((aggregateCosignatureDTO) => {
@@ -118,7 +118,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
118118
extractNetworkType(transactionDTO.version),
119119
extractTransactionVersion(transactionDTO.version),
120120
Deadline.createFromDTO(transactionDTO.deadline),
121-
new UInt64(transactionDTO.fee),
121+
new UInt64(transactionDTO.fee || [0, 0]),
122122
Address.createFromEncoded(transactionDTO.recipient),
123123
transactionDTO.mosaics === undefined ? [] :
124124
transactionDTO.mosaics
@@ -134,7 +134,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
134134
extractNetworkType(transactionDTO.version),
135135
extractTransactionVersion(transactionDTO.version),
136136
Deadline.createFromDTO(transactionDTO.deadline),
137-
new UInt64(transactionDTO.fee),
137+
new UInt64(transactionDTO.fee || [0, 0]),
138138
transactionDTO.namespaceType,
139139
transactionDTO.name,
140140
new NamespaceId(transactionDTO.namespaceId),
@@ -149,7 +149,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
149149
extractNetworkType(transactionDTO.version),
150150
extractTransactionVersion(transactionDTO.version),
151151
Deadline.createFromDTO(transactionDTO.deadline),
152-
new UInt64(transactionDTO.fee),
152+
new UInt64(transactionDTO.fee || [0, 0]),
153153
transactionDTO.nonce,
154154
new MosaicId(transactionDTO.mosaicId),
155155
new MosaicProperties(
@@ -166,7 +166,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
166166
extractNetworkType(transactionDTO.version),
167167
extractTransactionVersion(transactionDTO.version),
168168
Deadline.createFromDTO(transactionDTO.deadline),
169-
new UInt64(transactionDTO.fee),
169+
new UInt64(transactionDTO.fee || [0, 0]),
170170
new MosaicId(transactionDTO.mosaicId),
171171
transactionDTO.direction,
172172
new UInt64(transactionDTO.delta),
@@ -179,7 +179,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
179179
extractNetworkType(transactionDTO.version),
180180
extractTransactionVersion(transactionDTO.version),
181181
Deadline.createFromDTO(transactionDTO.deadline),
182-
new UInt64(transactionDTO.fee),
182+
new UInt64(transactionDTO.fee || [0, 0]),
183183
transactionDTO.minApprovalDelta,
184184
transactionDTO.minRemovalDelta,
185185
transactionDTO.modifications ? transactionDTO.modifications.map((modificationDTO) => new MultisigCosignatoryModification(
@@ -196,7 +196,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
196196
networkType,
197197
extractTransactionVersion(transactionDTO.version),
198198
Deadline.createFromDTO(transactionDTO.deadline),
199-
new UInt64(transactionDTO.fee),
199+
new UInt64(transactionDTO.fee || [0, 0]),
200200
new Mosaic(new MosaicId(transactionDTO.mosaicId), new UInt64(transactionDTO.amount)),
201201
new UInt64(transactionDTO.duration),
202202
new SignedTransaction('', transactionDTO.hash, '', TransactionType.AGGREGATE_BONDED, networkType),
@@ -209,7 +209,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
209209
extractNetworkType(transactionDTO.version),
210210
extractTransactionVersion(transactionDTO.version),
211211
Deadline.createFromDTO(transactionDTO.deadline),
212-
new UInt64(transactionDTO.fee),
212+
new UInt64(transactionDTO.fee || [0, 0]),
213213
new Mosaic(new MosaicId(transactionDTO.mosaicId), new UInt64(transactionDTO.amount)),
214214
new UInt64(transactionDTO.duration),
215215
transactionDTO.hashAlgorithm,
@@ -224,7 +224,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
224224
extractNetworkType(transactionDTO.version),
225225
extractTransactionVersion(transactionDTO.version),
226226
Deadline.createFromDTO(transactionDTO.deadline),
227-
new UInt64(transactionDTO.fee),
227+
new UInt64(transactionDTO.fee || [0, 0]),
228228
transactionDTO.hashAlgorithm,
229229
transactionDTO.secret,
230230
transactionDTO.proof,
@@ -237,7 +237,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
237237
extractNetworkType(transactionDTO.version),
238238
extractTransactionVersion(transactionDTO.version),
239239
Deadline.createFromDTO(transactionDTO.deadline),
240-
new UInt64(transactionDTO.fee),
240+
new UInt64(transactionDTO.fee || [0, 0]),
241241
transactionDTO.actionType,
242242
transactionDTO.namespaceId,
243243
transactionDTO.mosaicId,
@@ -250,7 +250,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
250250
extractNetworkType(transactionDTO.version),
251251
extractTransactionVersion(transactionDTO.version),
252252
Deadline.createFromDTO(transactionDTO.deadline),
253-
new UInt64(transactionDTO.fee),
253+
new UInt64(transactionDTO.fee || [0, 0]),
254254
transactionDTO.actionType,
255255
transactionDTO.namespaceId,
256256
transactionDTO.address,

test/model/transaction/Deadline.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@
1515
*/
1616

1717
import {expect} from 'chai';
18-
import {ChronoUnit} from 'js-joda';
18+
import {ChronoUnit, Instant, LocalDateTime, ZoneId} from 'js-joda';
1919
import {Deadline} from '../../../src/model/transaction/Deadline';
2020

2121
describe('Deadline', () => {
2222
it('should createComplete timestamp today', () => {
2323
const deadline = Deadline.create();
24-
const date = new Date();
25-
expect(deadline.value.dayOfMonth()).to.be.equal(date.getDate());
26-
expect(deadline.value.monthValue()).to.be.equal(date.getMonth() + 1);
27-
expect(deadline.value.year()).to.be.equal(date.getFullYear());
24+
25+
// avoid SYSTEM and UTC differences
26+
const networkTimeStamp = (new Date()).getTime();
27+
const timestampLocal = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM);
28+
const reproducedDate = timestampLocal.plus(2, ChronoUnit.HOURS);
29+
30+
expect(deadline.value.dayOfMonth()).to.be.equal(reproducedDate.dayOfMonth());
31+
expect(deadline.value.monthValue()).to.be.equal(reproducedDate.monthValue());
32+
expect(deadline.value.year()).to.be.equal(reproducedDate.year());
2833
});
2934

3035
it('should throw error deadline smaller than timeStamp', () => {

0 commit comments

Comments
 (0)