Skip to content

Commit 9696f4a

Browse files
authored
Added fromHeight & toHeight filter in transactionSearch (#676)
* Fixed #675 - Added fromHeight & toHeight filter in transactionSearch * Updated pckage-lock
1 parent 12a3f7a commit 9696f4a

File tree

8 files changed

+48
-11
lines changed

8 files changed

+48
-11
lines changed

e2e/infrastructure/ReceiptHttp.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import { expect } from 'chai';
1818
import { toArray } from 'rxjs/operators';
19-
import { ReceiptHttp } from '../../src/infrastructure/infrastructure';
2019
import { ReceiptPaginationStreamer } from '../../src/infrastructure/paginationStreamer/ReceiptPaginationStreamer';
2120
import { ReceiptRepository } from '../../src/infrastructure/ReceiptRepository';
2221
import { ReceiptType, UInt64 } from '../../src/model/model';

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"ts-node": "^8.6.2",
8888
"typescript": "^3.7.5",
8989
"typedoc": "^0.18.0",
90-
"typescript-require": "^0.2.10"
90+
"typescript-require": "^0.2.10",
91+
"node-forge": ">=0.10.0"
9192
},
9293
"dependencies": {
9394
"bluebird": "^3.7.2",
@@ -108,7 +109,7 @@
108109
"ripemd160": "^2.0.2",
109110
"rxjs": "^6.5.3",
110111
"rxjs-compat": "^6.5.3",
111-
"symbol-openapi-typescript-fetch-client": "0.9.7-SNAPSHOT.202009141633",
112+
"symbol-openapi-typescript-fetch-client": "0.9.7-SNAPSHOT.202009171123",
112113
"tweetnacl": "^1.0.3",
113114
"utf8": "^3.0.0",
114115
"ws": "^7.2.3"

src/infrastructure/TransactionHttp.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ export class TransactionHttp extends Http implements TransactionRepository {
224224
criteria.recipientAddress?.plain(),
225225
criteria.signerPublicKey,
226226
criteria.height?.toString(),
227+
criteria.fromHeight?.toString(),
228+
criteria.toHeight?.toString(),
227229
criteria.type?.map((type) => type.valueOf()),
228230
criteria.embedded,
229231
criteria.pageSize,
@@ -237,6 +239,8 @@ export class TransactionHttp extends Http implements TransactionRepository {
237239
criteria.recipientAddress?.plain(),
238240
criteria.signerPublicKey,
239241
criteria.height?.toString(),
242+
criteria.fromHeight?.toString(),
243+
criteria.toHeight?.toString(),
240244
criteria.type?.map((type) => type.valueOf()),
241245
criteria.embedded,
242246
criteria.pageSize,
@@ -250,6 +254,8 @@ export class TransactionHttp extends Http implements TransactionRepository {
250254
criteria.recipientAddress?.plain(),
251255
criteria.signerPublicKey,
252256
criteria.height?.toString(),
257+
criteria.fromHeight?.toString(),
258+
criteria.toHeight?.toString(),
253259
criteria.type?.map((type) => type.valueOf()),
254260
criteria.embedded,
255261
criteria.pageSize,

src/infrastructure/searchCriteria/TransactionSearchCriteria.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,14 @@ export interface TransactionSearchCriteria extends SearchCriteria {
6767
* returned. (optional, default to false)
6868
*/
6969
embedded?: boolean;
70+
71+
/*
72+
* Only blocks with height greater or equal than this one are returned.
73+
*/
74+
fromHeight?: UInt64;
75+
76+
/*
77+
* Only blocks with height smaller or equal than this one are returned.
78+
*/
79+
toHeight?: UInt64;
7080
}

src/model/account/AccountLinkVotingKey.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { UInt64 } from '../UInt64';
1716
/**
1817
* Account link voting key
1918
*/

test/infrastructure/TransactionHttp.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ describe('TransactionHttp', () => {
130130
undefined,
131131
undefined,
132132
undefined,
133+
undefined,
134+
undefined,
133135
),
134136
).thenReturn(Promise.resolve(page));
135137

@@ -145,6 +147,8 @@ describe('TransactionHttp', () => {
145147
undefined,
146148
undefined,
147149
undefined,
150+
undefined,
151+
undefined,
148152
),
149153
).thenReturn(Promise.resolve(page));
150154

@@ -160,6 +164,8 @@ describe('TransactionHttp', () => {
160164
undefined,
161165
undefined,
162166
undefined,
167+
undefined,
168+
undefined,
163169
),
164170
).thenReturn(Promise.resolve(page));
165171

test/infrastructure/TransactionSearchCriteria.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ describe('TransactionSearchCriteria', () => {
3636
embedded: true,
3737
group: TransactionGroup.Confirmed,
3838
height: UInt64.fromUint(1),
39+
fromHeight: UInt64.fromUint(1),
40+
toHeight: UInt64.fromUint(1),
3941
offset: '6789',
4042
recipientAddress: account.address,
4143
signerPublicKey: account.publicKey,
@@ -49,6 +51,8 @@ describe('TransactionSearchCriteria', () => {
4951
expect(criteria.embedded).to.be.equal(true);
5052
expect(criteria.group.toString()).to.be.equal(TransactionGroup.Confirmed.toString());
5153
expect(criteria.height?.toString()).to.be.equal('1');
54+
expect(criteria.fromHeight?.toString()).to.be.equal('1');
55+
expect(criteria.toHeight?.toString()).to.be.equal('1');
5256
expect(criteria.offset).to.be.equal('6789');
5357
expect(criteria.recipientAddress?.plain()).to.be.equal(account.address.plain());
5458
expect(criteria.signerPublicKey).to.be.equal(account.publicKey);
@@ -63,6 +67,8 @@ describe('TransactionSearchCriteria', () => {
6367
embedded: false,
6468
group: TransactionGroup.Unconfirmed,
6569
height: UInt64.fromUint(2),
70+
fromHeight: UInt64.fromUint(1),
71+
toHeight: UInt64.fromUint(1),
6672
offset: 'bbb',
6773
recipientAddress: address,
6874
signerPublicKey: 'publicKey',
@@ -80,6 +86,8 @@ describe('TransactionSearchCriteria', () => {
8086
expect(criteria.recipientAddress?.plain()).to.be.equal(address.plain());
8187
expect(criteria.signerPublicKey).to.be.equal('publicKey');
8288
deepEqual(criteria.type, [TransactionType.TRANSFER]);
89+
expect(criteria.fromHeight?.toString()).to.be.equal('1');
90+
expect(criteria.toHeight?.toString()).to.be.equal('1');
8391
});
8492

8593
it('should create TransactionSearchCriteria - default', () => {
@@ -90,6 +98,8 @@ describe('TransactionSearchCriteria', () => {
9098
expect(criteria.embedded).to.be.undefined;
9199
expect(criteria.group).to.be.equal(TransactionGroup.Confirmed);
92100
expect(criteria.height).to.be.undefined;
101+
expect(criteria.fromHeight).to.be.undefined;
102+
expect(criteria.toHeight).to.be.undefined;
93103
expect(criteria.offset).to.be.undefined;
94104
expect(criteria.pageNumber).to.be.undefined;
95105
expect(criteria.pageSize).to.be.undefined;

0 commit comments

Comments
 (0)