Skip to content

Commit b0617d5

Browse files
Steven LiuSteven Liu
authored andcommitted
Fixes #41 added alias without renaming current LockFundsTransaction class
1 parent de91e71 commit b0617d5

File tree

7 files changed

+96
-13
lines changed

7 files changed

+96
-13
lines changed

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {CosignatureSignedTransaction} from '../../src/model/transaction/Cosignat
3333
import {CosignatureTransaction} from '../../src/model/transaction/CosignatureTransaction';
3434
import {Deadline} from '../../src/model/transaction/Deadline';
3535
import {HashType} from '../../src/model/transaction/HashType';
36-
import {HashLockTransaction} from '../../src/model/transaction/LockFundsTransaction';
36+
import {LockFundsTransaction} from '../../src/model/transaction/LockFundsTransaction';
3737
import {ModifyMultisigAccountTransaction} from '../../src/model/transaction/ModifyMultisigAccountTransaction';
3838
import {MosaicDefinitionTransaction} from '../../src/model/transaction/MosaicDefinitionTransaction';
3939
import {MosaicSupplyChangeTransaction} from '../../src/model/transaction/MosaicSupplyChangeTransaction';
@@ -242,7 +242,7 @@ describe('TransactionHttp', () => {
242242
[Cosignatory2Account],
243243
);
244244

245-
const lockFundsTransaction = HashLockTransaction.create(Deadline.create(),
245+
const lockFundsTransaction = LockFundsTransaction.create(Deadline.create(),
246246
XEM.createRelative(10),
247247
UInt64.fromUint(10000),
248248
signedTransaction,
@@ -277,7 +277,7 @@ describe('TransactionHttp', () => {
277277
CosignatoryAccount,
278278
);
279279

280-
const lockFundsTransaction = HashLockTransaction.create(Deadline.create(),
280+
const lockFundsTransaction = LockFundsTransaction.create(Deadline.create(),
281281
XEM.createRelative(10),
282282
UInt64.fromUint(10000),
283283
signedTransaction,
@@ -314,7 +314,7 @@ describe('TransactionHttp', () => {
314314
);
315315
const signedTransaction = account.sign(aggregateTransaction);
316316

317-
const lockFundsTransaction = HashLockTransaction.create(Deadline.create(),
317+
const lockFundsTransaction = LockFundsTransaction.create(Deadline.create(),
318318
XEM.createRelative(10),
319319
UInt64.fromUint(10000),
320320
signedTransaction,
@@ -331,7 +331,7 @@ describe('TransactionHttp', () => {
331331
[],
332332
);
333333
const signedTransaction = account.sign(aggregateTransaction);
334-
const lockFundsTransaction = HashLockTransaction.create(Deadline.create(),
334+
const lockFundsTransaction = LockFundsTransaction.create(Deadline.create(),
335335
XEM.createRelative(10),
336336
UInt64.fromUint(10),
337337
signedTransaction,

src/infrastructure/transaction/CreateTransactionFromDTO.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {AggregateTransaction} from '../../model/transaction/AggregateTransaction
2525
import {AggregateTransactionCosignature} from '../../model/transaction/AggregateTransactionCosignature';
2626
import {AggregateTransactionInfo} from '../../model/transaction/AggregateTransactionInfo';
2727
import {Deadline} from '../../model/transaction/Deadline';
28-
import {HashLockTransaction} from '../../model/transaction/LockFundsTransaction';
28+
import {LockFundsTransaction} from '../../model/transaction/LockFundsTransaction';
2929
import {ModifyMultisigAccountTransaction} from '../../model/transaction/ModifyMultisigAccountTransaction';
3030
import {MosaicDefinitionTransaction} from '../../model/transaction/MosaicDefinitionTransaction';
3131
import {MosaicSupplyChangeTransaction} from '../../model/transaction/MosaicSupplyChangeTransaction';
@@ -187,7 +187,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
187187
);
188188
} else if (transactionDTO.type === TransactionType.LOCK) {
189189
const networkType = extractNetworkType(transactionDTO.version);
190-
return new HashLockTransaction(
190+
return new LockFundsTransaction(
191191
networkType,
192192
extractTransactionVersion(transactionDTO.version),
193193
Deadline.createFromDTO(transactionDTO.deadline),

src/model/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export * from './transaction/AggregateTransactionInfo';
5656
export * from './transaction/CosignatureSignedTransaction';
5757
export * from './transaction/CosignatureTransaction';
5858
export * from './transaction/Deadline';
59+
export * from './transaction/HashLockTransaction';
5960
export * from './transaction/HashType';
6061
export * from './transaction/InnerTransaction';
6162
export * from './transaction/LockFundsTransaction';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2018 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { LockFundsTransaction } from './LockFundsTransaction';
18+
19+
/*
20+
* An alias for LockFundsTransaction class
21+
*/
22+
export class HashLockTransaction extends LockFundsTransaction {
23+
}

src/model/transaction/LockFundsTransaction.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { TransactionType } from './TransactionType';
3131
*
3232
* @since 1.0
3333
*/
34-
class LockFundsTransaction extends Transaction {
34+
export class LockFundsTransaction extends Transaction {
3535

3636
/**
3737
* Aggregate bonded hash.
@@ -115,5 +115,3 @@ class LockFundsTransaction extends Transaction {
115115
}
116116

117117
}
118-
119-
export { LockFundsTransaction as HashLockTransaction };
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2018 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import {expect} from 'chai';
17+
import {NetworkType} from '../../../src/model/blockchain/NetworkType';
18+
import {XEM} from '../../../src/model/mosaic/XEM';
19+
import {AggregateTransaction} from '../../../src/model/transaction/AggregateTransaction';
20+
import {Deadline} from '../../../src/model/transaction/Deadline';
21+
import {HashLockTransaction} from '../../../src/model/transaction/HashLockTransaction';
22+
import {UInt64} from '../../../src/model/UInt64';
23+
import {TestingAccount} from '../../conf/conf.spec';
24+
25+
describe('HashLockTransaction', () => {
26+
const account = TestingAccount;
27+
it('creation with an aggregate bonded tx', () => {
28+
const aggregateTransaction = AggregateTransaction.createBonded(
29+
Deadline.create(),
30+
[],
31+
NetworkType.MIJIN_TEST,
32+
[],
33+
);
34+
const signedTransaction = account.sign(aggregateTransaction);
35+
const transaction = HashLockTransaction.create(Deadline.create(),
36+
XEM.createRelative(10),
37+
UInt64.fromUint(10),
38+
signedTransaction,
39+
NetworkType.MIJIN_TEST);
40+
expect(transaction.mosaic.id).to.be.equal(XEM.MOSAIC_ID);
41+
expect(transaction.mosaic.amount.compact()).to.be.equal(10000000);
42+
expect(transaction.hash).to.be.equal(signedTransaction.hash);
43+
});
44+
45+
it('should throw exception if it is not a aggregate bonded tx', () => {
46+
const aggregateTransaction = AggregateTransaction.createComplete(
47+
Deadline.create(),
48+
[],
49+
NetworkType.MIJIN_TEST,
50+
[],
51+
);
52+
const signedTransaction = account.sign(aggregateTransaction);
53+
expect(() => {
54+
HashLockTransaction.create(Deadline.create(),
55+
XEM.createRelative(10),
56+
UInt64.fromUint(10),
57+
signedTransaction,
58+
NetworkType.MIJIN_TEST);
59+
}).to.throw(Error);
60+
});
61+
});

test/model/transaction/LockFundsTransaction.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {NetworkType} from '../../../src/model/blockchain/NetworkType';
1818
import {XEM} from '../../../src/model/mosaic/XEM';
1919
import {AggregateTransaction} from '../../../src/model/transaction/AggregateTransaction';
2020
import {Deadline} from '../../../src/model/transaction/Deadline';
21-
import {HashLockTransaction} from '../../../src/model/transaction/LockFundsTransaction';
21+
import {LockFundsTransaction} from '../../../src/model/transaction/LockFundsTransaction';
2222
import {UInt64} from '../../../src/model/UInt64';
2323
import {TestingAccount} from '../../conf/conf.spec';
2424

@@ -32,7 +32,7 @@ describe('LockFundsTransaction', () => {
3232
[],
3333
);
3434
const signedTransaction = account.sign(aggregateTransaction);
35-
const transaction = HashLockTransaction.create(Deadline.create(),
35+
const transaction = LockFundsTransaction.create(Deadline.create(),
3636
XEM.createRelative(10),
3737
UInt64.fromUint(10),
3838
signedTransaction,
@@ -51,7 +51,7 @@ describe('LockFundsTransaction', () => {
5151
);
5252
const signedTransaction = account.sign(aggregateTransaction);
5353
expect(() => {
54-
HashLockTransaction.create(Deadline.create(),
54+
LockFundsTransaction.create(Deadline.create(),
5555
XEM.createRelative(10),
5656
UInt64.fromUint(10),
5757
signedTransaction,

0 commit comments

Comments
 (0)