Skip to content

Commit 08c3059

Browse files
committed
Fixed #405 use enum type on transaction status
1 parent 3386693 commit 08c3059

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/infrastructure/TransactionHttp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ export class TransactionHttp extends Http implements TransactionRepository {
126126
*/
127127
private toTransactionStatus(dto: TransactionStatusDTO): TransactionStatus {
128128
return new TransactionStatus(
129-
dto.group.toString(),
129+
dto.group,
130130
dto.hash,
131131
Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO()),
132-
dto.code ? dto.code.toString() : '',
132+
dto.code,
133133
dto.height ? UInt64.fromNumericString(dto.height) : undefined);
134134
}
135135

src/model/transaction/TransactionStatus.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { TransactionStateTypeEnum, TransactionStatusTypeEnum } from 'nem2-sdk-openapi-typescript-node-client';
1718
import {UInt64} from '../UInt64';
1819
import {Deadline} from './Deadline';
1920

@@ -33,7 +34,7 @@ export class TransactionStatus {
3334
/**
3435
* The transaction status group "failed", "unconfirmed", "confirmed", etc...
3536
*/
36-
public readonly group: string,
37+
public readonly group: TransactionStateTypeEnum,
3738
/**
3839
* The transaction hash.
3940
*/
@@ -45,7 +46,7 @@ export class TransactionStatus {
4546
/**
4647
* The transaction status code being the error name in case of failure and success otherwise.
4748
*/
48-
public readonly code?: string,
49+
public readonly code?: TransactionStatusTypeEnum,
4950
/**
5051
* The height of the block at which it was confirmed or rejected.
5152
*/

test/model/transaction/TransactionStatus.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { deepEqual } from 'assert';
1818
import { expect } from 'chai';
1919
import { TransactionStatusTypeEnum } from 'nem2-sdk-openapi-typescript-node-client';
20+
import { TransactionStateTypeEnum } from 'nem2-sdk-openapi-typescript-node-client';
2021
import { Deadline } from '../../../src/model/transaction/Deadline';
2122
import { TransactionStatus } from '../../../src/model/transaction/TransactionStatus';
2223
import { UInt64 } from '../../../src/model/UInt64';
@@ -25,7 +26,7 @@ describe('TransactionStatus', () => {
2526
it('should createComplete TransactionStatus object', () => {
2627
const transactionStatusDTO = {
2728
deadline: Deadline.createFromDTO('1'),
28-
group: 'confirmed',
29+
group: TransactionStateTypeEnum.Confirmed,
2930
hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219',
3031
height: new UInt64([1, 0]),
3132
code: TransactionStatusTypeEnum.Success,
@@ -35,7 +36,7 @@ describe('TransactionStatus', () => {
3536
transactionStatusDTO.group,
3637
transactionStatusDTO.hash,
3738
transactionStatusDTO.deadline,
38-
transactionStatusDTO.code.toString(),
39+
transactionStatusDTO.code,
3940
transactionStatusDTO.height,
4041
);
4142

0 commit comments

Comments
 (0)