diff --git a/src/infrastructure/TransactionHttp.ts b/src/infrastructure/TransactionHttp.ts index 33f4b76d03..9351063fbc 100644 --- a/src/infrastructure/TransactionHttp.ts +++ b/src/infrastructure/TransactionHttp.ts @@ -22,6 +22,7 @@ import {PublicAccount} from '../model/account/PublicAccount'; import {CosignatureSignedTransaction} from '../model/transaction/CosignatureSignedTransaction'; import {Deadline} from '../model/transaction/Deadline'; import {SignedTransaction} from '../model/transaction/SignedTransaction'; +import { SyncAnnounce } from '../model/transaction/SyncAnnounce'; import {Transaction} from '../model/transaction/Transaction'; import {TransactionAnnounceResponse} from '../model/transaction/TransactionAnnounceResponse'; import {TransactionStatus} from '../model/transaction/TransactionStatus'; @@ -93,7 +94,7 @@ export class TransactionHttp extends Http implements TransactionRepository { transactionStatusDTO.status, transactionStatusDTO.hash, Deadline.createFromDTO(transactionStatusDTO.deadline), - new UInt64(transactionStatusDTO.height)); + transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : UInt64.fromUint(0)); })); } @@ -115,7 +116,7 @@ export class TransactionHttp extends Http implements TransactionRepository { transactionStatusDTO.status, transactionStatusDTO.hash, Deadline.createFromDTO(transactionStatusDTO.deadline), - new UInt64(transactionStatusDTO.height)); + transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : UInt64.fromUint(0)); }); })); } @@ -182,27 +183,11 @@ export class TransactionHttp extends Http implements TransactionRepository { } else { return CreateTransactionFromDTO(response); } - }),catchError((err) => { + }), catchError((err) => { if (err.statusCode === 405) { return observableThrowError('non sync server'); } return observableThrowError(err); - }),); - } -} - -class SyncAnnounce { - constructor(/** - * Transaction serialized data - */ - public readonly payload: string, - /** - * Transaction hash - */ - public readonly hash: string, - /** - * Transaction address - */ - public readonly address: string) { + })); } } diff --git a/src/model/model.ts b/src/model/model.ts index e5c49129e3..dfb6b3e733 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -80,6 +80,7 @@ export * from './transaction/RegisterNamespaceTransaction'; export * from './transaction/SecretLockTransaction'; export * from './transaction/SecretProofTransaction'; export * from './transaction/SignedTransaction'; +export * from './transaction/SyncAnnounce'; export * from './transaction/Transaction'; export * from './transaction/TransactionAnnounceResponse'; export * from './transaction/TransactionInfo'; diff --git a/src/model/transaction/SyncAnnounce.ts b/src/model/transaction/SyncAnnounce.ts new file mode 100644 index 0000000000..5efe2fcfda --- /dev/null +++ b/src/model/transaction/SyncAnnounce.ts @@ -0,0 +1,38 @@ +/* + * Copyright 2019 NEM + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class SyncAnnounce { + /** + * @internal + * @param payload + * @param hash + * @param address + */ + constructor( + /** + * Transaction serialized data + */ + public readonly payload: string, + /** + * Transaction hash + */ + public readonly hash: string, + /** + * Transaction address + */ + public readonly address: string) { + } +} diff --git a/test/model/UInt64.spec.ts b/test/model/UInt64.spec.ts index 035d0d43b2..d1c9aed3d0 100644 --- a/test/model/UInt64.spec.ts +++ b/test/model/UInt64.spec.ts @@ -73,7 +73,7 @@ describe('Uint64', () => { expect(uint64Compact).to.be.equal(51110867862); }); - it('should fromUnit throw exception with negative unit value', () => { + it('should fromUint throw exception with negative uint value', () => { expect(() => { UInt64.fromUint(-1); }).to.throw(Error, 'Unsigned integer cannot be negative');