Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"ripemd160": "^2.0.2",
"rxjs": "^6.5.3",
"rxjs-compat": "^6.5.3",
"symbol-openapi-typescript-fetch-client": "0.9.6",
"symbol-openapi-typescript-fetch-client": "0.9.7-SNAPSHOT.202009041234",
"tweetnacl": "^1.0.3",
"utf8": "^3.0.0",
"ws": "^7.2.3"
Expand Down
2 changes: 0 additions & 2 deletions src/infrastructure/Http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ export abstract class Http {
data.map((d) => mapper(d, networkType)),
pagination?.pageNumber,
pagination?.pageSize,
pagination?.totalEntries,
pagination?.totalPages,
);
}
}
12 changes: 2 additions & 10 deletions src/infrastructure/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,8 @@ export class Page<T> {
* @param data the page data
* @param pageNumber the current page number starting from 1.
* @param pageSize the page size.
* @param totalEntries the total entries.
* @param totalPages the total pages for the given criteria.
*/
constructor(
public readonly data: T[],
public readonly pageNumber: number,
public readonly pageSize: number,
public readonly totalEntries: number,
public readonly totalPages: number,
) {
this.isLastPage = this.pageNumber >= this.totalPages;
constructor(public readonly data: T[], public readonly pageNumber: number, public readonly pageSize: number) {
this.isLastPage = !this.data.length || this.pageSize > this.data.length;
}
}
2 changes: 0 additions & 2 deletions test/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ describe('AccountHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 1;
pagination.totalEntries = 1;
pagination.totalPages = 1;

const body = {} as AccountPage;
body.data = [accountInfoDto];
Expand Down
2 changes: 0 additions & 2 deletions test/infrastructure/BlockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ describe('BlockHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 1;
pagination.totalEntries = 1;
pagination.totalPages = 1;

const body = {} as BlockPage;
body.data = [blockInfoDto];
Expand Down
2 changes: 0 additions & 2 deletions test/infrastructure/MetadataHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ describe('MetadataHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 1;
pagination.totalEntries = 1;
pagination.totalPages = 1;

const metadataDTOMosaic = {} as MetadataInfoDTO;
metadataDTOMosaic.id = 'aaa';
Expand Down
2 changes: 0 additions & 2 deletions test/infrastructure/MosaicHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ describe('MosaicHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 1;
pagination.totalEntries = 1;
pagination.totalPages = 1;

const body = {} as MosaicPage;
body.data = [mosaicInfoDto];
Expand Down
2 changes: 0 additions & 2 deletions test/infrastructure/NamespaceHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ describe('NamespaceHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 1;
pagination.totalEntries = 1;
pagination.totalPages = 1;

const body = {} as NamespacePage;
body.data = [namespaceInfoDto];
Expand Down
16 changes: 7 additions & 9 deletions test/infrastructure/Page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ describe('Page', () => {
[TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)],
1,
1,
1,
1,
);
expect(page.data.length).to.be.equal(1);
expect(page.pageNumber).to.be.equal(1);
expect(page.pageSize).to.be.equal(1);
expect(page.totalEntries).to.be.equal(1);
expect(page.isLastPage).to.be.true;
expect(page.isLastPage).to.be.false;

page = new Page<Transaction>(
[TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)],
1,
1,
1,
3,
2,
2,
);
expect(page.isLastPage).to.be.false;
expect(page.isLastPage).to.be.true;

page = new Page<Transaction>([], 2, 2);
expect(page.isLastPage).to.be.true;
});
});
6 changes: 0 additions & 6 deletions test/infrastructure/ReceiptHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ describe('ReceiptHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 20;
pagination.totalEntries = 1;
pagination.totalPages = 1;
resolutionPage.pagination = pagination;

when(receiptRoutesApi.searchMosaicResolutionStatements('1', undefined, undefined, undefined, undefined)).thenReturn(
Expand Down Expand Up @@ -118,8 +116,6 @@ describe('ReceiptHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 20;
pagination.totalEntries = 1;
pagination.totalPages = 1;
resolutionPage.pagination = pagination;

when(receiptRoutesApi.searchAddressResolutionStatements('1', undefined, undefined, undefined, undefined)).thenReturn(
Expand Down Expand Up @@ -161,8 +157,6 @@ describe('ReceiptHttp', () => {
const pagination = {} as Pagination;
pagination.pageNumber = 1;
pagination.pageSize = 20;
pagination.totalEntries = 1;
pagination.totalPages = 1;
resolutionPage.pagination = pagination;

when(
Expand Down
8 changes: 0 additions & 8 deletions test/infrastructure/TransactionHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ describe('TransactionHttp', () => {
const paginationDto = {} as Pagination;
paginationDto.pageNumber = 1;
paginationDto.pageSize = 1;
paginationDto.totalEntries = 1;
paginationDto.totalPages = 1;

const transactionInfoDto = {} as TransactionInfoDTO;
const metaDto = {} as TransactionMetaDTO;
Expand Down Expand Up @@ -177,8 +175,6 @@ describe('TransactionHttp', () => {

expect(transactions.pageNumber).to.be.equal(1);
expect(transactions.pageSize).to.be.equal(1);
expect(transactions.totalEntries).to.be.equal(1);
expect(transactions.totalPages).to.be.equal(1);

transactions = await transactionHttp.search({ group: TransactionGroup.Unconfirmed, address: account.address }).toPromise();

Expand All @@ -192,8 +188,6 @@ describe('TransactionHttp', () => {

expect(transactions.pageNumber).to.be.equal(1);
expect(transactions.pageSize).to.be.equal(1);
expect(transactions.totalEntries).to.be.equal(1);
expect(transactions.totalPages).to.be.equal(1);

transactions = await transactionHttp.search({ group: TransactionGroup.Partial, address: account.address }).toPromise();

Expand All @@ -207,8 +201,6 @@ describe('TransactionHttp', () => {

expect(transactions.pageNumber).to.be.equal(1);
expect(transactions.pageSize).to.be.equal(1);
expect(transactions.totalEntries).to.be.equal(1);
expect(transactions.totalPages).to.be.equal(1);
});

it('Test getTransaction method', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ export class PaginationStreamerTestHelper<E, C extends SearchCriteria> {
partitions.push(infos.slice(i, i + pageSize));
}
let pageNumber = 0;
return partitions.map((pageData) => of(new Page<T>(pageData, ++pageNumber, pageSize, infos.length, partitions.length)));
return partitions.map((pageData) => of(new Page<T>(pageData, ++pageNumber, pageSize)));
}
}
4 changes: 2 additions & 2 deletions test/service/AccountService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ describe('AccountService', () => {
pageNumber: 1,
}),
),
).thenReturn(observableOf(new Page<NamespaceInfo>(mockNamespaceInfo(), 1, 20, 3, 1)));
).thenReturn(observableOf(new Page<NamespaceInfo>(mockNamespaceInfo(), 1, 20)));

when(mockNamespaceRepository.search(deepEqual({ ownerAddress: account.address, pageNumber: 1 }))).thenReturn(
observableOf(new Page<NamespaceInfo>(mockNamespaceInfo(), 1, 20, 3, 1)),
observableOf(new Page<NamespaceInfo>(mockNamespaceInfo(), 1, 20)),
);

when(mockNamespaceRepository.getNamespacesNames(deepEqual([NetworkCurrencyLocal.NAMESPACE_ID]))).thenReturn(
Expand Down
6 changes: 3 additions & 3 deletions test/service/MetadataTransactionservice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('MetadataTransactionService', () => {
metadataType: MetadataType.Account,
}),
),
).thenReturn(observableOf(new Page<Metadata>([mockMetadata(MetadataType.Account)], 1, 20, 1, 1)));
).thenReturn(observableOf(new Page<Metadata>([mockMetadata(MetadataType.Account)], 1, 20)));

when(
mockMetadataRepository.search(
Expand All @@ -91,7 +91,7 @@ describe('MetadataTransactionService', () => {
metadataType: MetadataType.Mosaic,
}),
),
).thenReturn(observableOf(new Page<Metadata>([mockMetadata(MetadataType.Mosaic)], 1, 20, 1, 1)));
).thenReturn(observableOf(new Page<Metadata>([mockMetadata(MetadataType.Mosaic)], 1, 20)));

when(
mockMetadataRepository.search(
Expand All @@ -102,7 +102,7 @@ describe('MetadataTransactionService', () => {
metadataType: MetadataType.Namespace,
}),
),
).thenReturn(observableOf(new Page<Metadata>([mockMetadata(MetadataType.Namespace)], 1, 20, 1, 1)));
).thenReturn(observableOf(new Page<Metadata>([mockMetadata(MetadataType.Namespace)], 1, 20)));

const metadataRepository = instance(mockMetadataRepository);
metadataTransactionService = new MetadataTransactionService(metadataRepository);
Expand Down