Skip to content

Commit 5ee3a7a

Browse files
Steven LiuSteven Liu
authored andcommitted
Fixes #41 added alias without renaming current LockFundsTransaction class
1 parent 4a22a20 commit 5ee3a7a

File tree

7 files changed

+90
-7
lines changed

7 files changed

+90
-7
lines changed

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {CosignatureSignedTransaction} from '../../src/model/transaction/Cosignat
3434
import {CosignatureTransaction} from '../../src/model/transaction/CosignatureTransaction';
3535
import {Deadline} from '../../src/model/transaction/Deadline';
3636
import {HashType} from '../../src/model/transaction/HashType';
37-
import {HashLockTransaction} from '../../src/model/transaction/LockFundsTransaction';
37+
import {LockFundsTransaction} from '../../src/model/transaction/LockFundsTransaction';
3838
import {ModifyMultisigAccountTransaction} from '../../src/model/transaction/ModifyMultisigAccountTransaction';
3939
import {MosaicDefinitionTransaction} from '../../src/model/transaction/MosaicDefinitionTransaction';
4040
import {MosaicSupplyChangeTransaction} from '../../src/model/transaction/MosaicSupplyChangeTransaction';

src/infrastructure/transaction/CreateTransactionFromDTO.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {AggregateTransaction} from '../../model/transaction/AggregateTransaction
2626
import {AggregateTransactionCosignature} from '../../model/transaction/AggregateTransactionCosignature';
2727
import {AggregateTransactionInfo} from '../../model/transaction/AggregateTransactionInfo';
2828
import {Deadline} from '../../model/transaction/Deadline';
29-
import {HashLockTransaction} from '../../model/transaction/LockFundsTransaction';
29+
import {LockFundsTransaction} from '../../model/transaction/LockFundsTransaction';
3030
import {ModifyMultisigAccountTransaction} from '../../model/transaction/ModifyMultisigAccountTransaction';
3131
import {MosaicAliasTransaction} from '../../model/transaction/MosaicAliasTransaction';
3232
import {MosaicDefinitionTransaction} from '../../model/transaction/MosaicDefinitionTransaction';
@@ -188,7 +188,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
188188
);
189189
} else if (transactionDTO.type === TransactionType.LOCK) {
190190
const networkType = extractNetworkType(transactionDTO.version);
191-
return new HashLockTransaction(
191+
return new LockFundsTransaction(
192192
networkType,
193193
extractTransactionVersion(transactionDTO.version),
194194
Deadline.createFromDTO(transactionDTO.deadline),

src/model/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export * from './transaction/AliasTransaction';
6464
export * from './transaction/CosignatureSignedTransaction';
6565
export * from './transaction/CosignatureTransaction';
6666
export * from './transaction/Deadline';
67+
export * from './transaction/HashLockTransaction';
6768
export * from './transaction/HashType';
6869
export * from './transaction/InnerTransaction';
6970
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
@@ -32,7 +32,7 @@ import { TransactionVersion } from './TransactionVersion';
3232
*
3333
* @since 1.0
3434
*/
35-
class LockFundsTransaction extends Transaction {
35+
export class LockFundsTransaction extends Transaction {
3636

3737
/**
3838
* Aggregate bonded hash.
@@ -116,5 +116,3 @@ class LockFundsTransaction extends Transaction {
116116
}
117117

118118
}
119-
120-
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {NetworkType} from '../../../src/model/blockchain/NetworkType';
1919
import {NetworkCurrencyMosaic} from '../../../src/model/mosaic/NetworkCurrencyMosaic';
2020
import {AggregateTransaction} from '../../../src/model/transaction/AggregateTransaction';
2121
import {Deadline} from '../../../src/model/transaction/Deadline';
22-
import {HashLockTransaction} from '../../../src/model/transaction/LockFundsTransaction';
22+
import {LockFundsTransaction} from '../../../src/model/transaction/LockFundsTransaction';
2323
import {UInt64} from '../../../src/model/UInt64';
2424
import {TestingAccount} from '../../conf/conf.spec';
2525

0 commit comments

Comments
 (0)