Skip to content

Commit 7761b89

Browse files
author
Grégory Saive
authored
Merge pull request #59 from rg911/issue#24
Fix getTransactionStatus for failed transaction (#24)
2 parents a2baae4 + 64f088e commit 7761b89

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

src/infrastructure/TransactionHttp.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {PublicAccount} from '../model/account/PublicAccount';
2222
import {CosignatureSignedTransaction} from '../model/transaction/CosignatureSignedTransaction';
2323
import {Deadline} from '../model/transaction/Deadline';
2424
import {SignedTransaction} from '../model/transaction/SignedTransaction';
25+
import { SyncAnnounce } from '../model/transaction/SyncAnnounce';
2526
import {Transaction} from '../model/transaction/Transaction';
2627
import {TransactionAnnounceResponse} from '../model/transaction/TransactionAnnounceResponse';
2728
import {TransactionStatus} from '../model/transaction/TransactionStatus';
@@ -93,7 +94,7 @@ export class TransactionHttp extends Http implements TransactionRepository {
9394
transactionStatusDTO.status,
9495
transactionStatusDTO.hash,
9596
Deadline.createFromDTO(transactionStatusDTO.deadline),
96-
new UInt64(transactionStatusDTO.height));
97+
transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : UInt64.fromUint(0));
9798
}));
9899
}
99100

@@ -115,7 +116,7 @@ export class TransactionHttp extends Http implements TransactionRepository {
115116
transactionStatusDTO.status,
116117
transactionStatusDTO.hash,
117118
Deadline.createFromDTO(transactionStatusDTO.deadline),
118-
new UInt64(transactionStatusDTO.height));
119+
transactionStatusDTO.height ? new UInt64(transactionStatusDTO.height) : UInt64.fromUint(0));
119120
});
120121
}));
121122
}
@@ -182,27 +183,11 @@ export class TransactionHttp extends Http implements TransactionRepository {
182183
} else {
183184
return CreateTransactionFromDTO(response);
184185
}
185-
}),catchError((err) => {
186+
}), catchError((err) => {
186187
if (err.statusCode === 405) {
187188
return observableThrowError('non sync server');
188189
}
189190
return observableThrowError(err);
190-
}),);
191-
}
192-
}
193-
194-
class SyncAnnounce {
195-
constructor(/**
196-
* Transaction serialized data
197-
*/
198-
public readonly payload: string,
199-
/**
200-
* Transaction hash
201-
*/
202-
public readonly hash: string,
203-
/**
204-
* Transaction address
205-
*/
206-
public readonly address: string) {
191+
}));
207192
}
208193
}

src/model/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export * from './transaction/RegisterNamespaceTransaction';
8080
export * from './transaction/SecretLockTransaction';
8181
export * from './transaction/SecretProofTransaction';
8282
export * from './transaction/SignedTransaction';
83+
export * from './transaction/SyncAnnounce';
8384
export * from './transaction/Transaction';
8485
export * from './transaction/TransactionAnnounceResponse';
8586
export * from './transaction/TransactionInfo';
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2019 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+
export class SyncAnnounce {
18+
/**
19+
* @internal
20+
* @param payload
21+
* @param hash
22+
* @param address
23+
*/
24+
constructor(
25+
/**
26+
* Transaction serialized data
27+
*/
28+
public readonly payload: string,
29+
/**
30+
* Transaction hash
31+
*/
32+
public readonly hash: string,
33+
/**
34+
* Transaction address
35+
*/
36+
public readonly address: string) {
37+
}
38+
}

test/model/UInt64.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('Uint64', () => {
7373
expect(uint64Compact).to.be.equal(51110867862);
7474
});
7575

76-
it('should fromUnit throw exception with negative unit value', () => {
76+
it('should fromUint throw exception with negative uint value', () => {
7777
expect(() => {
7878
UInt64.fromUint(-1);
7979
}).to.throw(Error, 'Unsigned integer cannot be negative');

0 commit comments

Comments
 (0)