Skip to content

Commit 9ae8129

Browse files
Steven LiuSteven Liu
authored andcommitted
Error handling on Uint64.fromUnit with negative value.
Couple of tslint issues fixed on MosaicProperty.
1 parent 200b48d commit 9ae8129

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

src/model/UInt64.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export class UInt64 {
3737
* @returns {UInt64}
3838
*/
3939
public static fromUint(value: number): UInt64 {
40+
if (value < 0) {
41+
throw new Error('Unit value cannot be negative');
42+
}
4043
return new UInt64(uint64.fromUint(value));
4144
}
4245

src/model/mosaic/Mosaic.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class Mosaic {
4141

4242
}
4343

44-
4544
/**
4645
* @internal
4746
* @returns {{amount: number[], id: number[]}}

src/model/mosaic/MosaicProperties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class MosaicProperties {
6060
* The duration in blocks a mosaic will be available.
6161
* After the duration finishes mosaic is inactive and can be renewed.
6262
*/
63-
public readonly duration: UInt64,) {
63+
public readonly duration: UInt64) {
6464
let binaryFlags = '00' + (flags.lower >>> 0).toString(2);
6565
binaryFlags = binaryFlags.substr(binaryFlags.length - 3, 3);
6666
this.supplyMutable = binaryFlags[2] === '1';

test/model/UInt64.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ describe('Uint64', () => {
6464
expect(uint64Compact).to.be.equal(51110867862);
6565
});
6666

67+
it('should fromUnit throw exception with negative unit value', () => {
68+
expect(() => {
69+
UInt64.fromUint(-1);
70+
}).to.throw(Error, 'Unit value cannot be negative');
71+
});
72+
6773
describe('equal', () => {
6874
it('should return true if the inside values are the same', () => {
6975
const value = new UInt64([12, 12]);

tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
}
4646
],
4747
"no-arg": true,
48-
"no-bitwise": true,
48+
"no-bitwise": false,
4949
"no-console": [
5050
true,
5151
"debug",

0 commit comments

Comments
 (0)