Skip to content

Commit 86e5bb9

Browse files
authored
Merge pull request #17 from bobanetwork/fix/wsdt/sorting
fix: sorting
2 parents 365c713 + b36af2a commit 86e5bb9

File tree

4 files changed

+274
-61
lines changed

4 files changed

+274
-61
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ dist
66

77
/coverage/lcov-report
88
/coverage/coverage-summary.json
9-
/coverage/lcov.info
9+
/coverage/lcov.info
10+
**/*.DS_Store

src/lightbridge/lightbridge.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export class LightBridgeGraphQLService extends GraphQLService {
2121
toBlock?: string | number,
2222
minDepositId?: string | number,
2323
contract?: string,
24+
orderBy?: string,
25+
orderDirection?: 'asc' | 'desc',
26+
first?: number
2427
): Promise<LightBridgeAssetReceivedEvent[]> {
2528
// contract: in the graph it is case insensitive and nocase only exists in Goldsky
2629
const query = gql(`query Teleportation(
@@ -42,6 +45,9 @@ export class LightBridgeGraphQLService extends GraphQLService {
4245
${targetChainId ? `{ toChainId: $targetChainId },` : ''}
4346
${contract ? `{ contract: $contract }` : ''}
4447
]}
48+
${orderBy ? `orderBy: ${orderBy}` : ''}
49+
${orderDirection ? `orderDirection: ${orderDirection}` : ''}
50+
${first ? `first: ${first}` : ''}
4551
) {
4652
token
4753
sourceChainId

tests/integration/light-bridge.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
import {lightBridgeGraphQLService} from "../../src";
22

33
describe('LightBridge Integration Test', function () {
4+
it('should query AssetReceivedEvent with sorting parameters', async () => {
5+
const res = await lightBridgeGraphQLService.queryAssetReceivedEvent(
6+
288,
7+
null,
8+
null,
9+
null,
10+
null,
11+
null,
12+
null,
13+
'depositId',
14+
'asc',
15+
100
16+
);
17+
18+
expect(res[0].block_number).toBeDefined();
19+
expect(res[0].token).toBeDefined();
20+
expect(res[0].sourceChainId).toBeDefined();
21+
expect(res[0].toChainId).toBeDefined();
22+
expect(res[0].depositId).toBeDefined();
23+
expect(res[0].emitter).toBeDefined();
24+
expect(res[0].amount).toBeDefined();
25+
expect(res[0].transactionHash_).toBeDefined();
26+
expect(res[0].block_number).toBeDefined();
27+
expect(res[0].timestamp_).toBeDefined();
28+
29+
expect(res.length).toBeLessThanOrEqual(100);
30+
31+
if (res.length > 1) {
32+
expect(Number(res[0].depositId)).toBeLessThanOrEqual(Number(res[1].depositId));
33+
}
34+
});
435
it('should query AssetReceivedEvent', async () => {
536
const res = await lightBridgeGraphQLService.queryAssetReceivedEvent(288);
637
expect(res[0].block_number).toBeDefined();

0 commit comments

Comments
 (0)