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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist

/coverage/lcov-report
/coverage/coverage-summary.json
/coverage/lcov.info
/coverage/lcov.info
**/*.DS_Store
6 changes: 6 additions & 0 deletions src/lightbridge/lightbridge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export class LightBridgeGraphQLService extends GraphQLService {
toBlock?: string | number,
minDepositId?: string | number,
contract?: string,
orderBy?: string,
orderDirection?: 'asc' | 'desc',
first?: number
): Promise<LightBridgeAssetReceivedEvent[]> {
// contract: in the graph it is case insensitive and nocase only exists in Goldsky
const query = gql(`query Teleportation(
Expand All @@ -42,6 +45,9 @@ export class LightBridgeGraphQLService extends GraphQLService {
${targetChainId ? `{ toChainId: $targetChainId },` : ''}
${contract ? `{ contract: $contract }` : ''}
]}
${orderBy ? `orderBy: ${orderBy}` : ''}
${orderDirection ? `orderDirection: ${orderDirection}` : ''}
${first ? `first: ${first}` : ''}
) {
token
sourceChainId
Expand Down
31 changes: 31 additions & 0 deletions tests/integration/light-bridge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
import {lightBridgeGraphQLService} from "../../src";

describe('LightBridge Integration Test', function () {
it('should query AssetReceivedEvent with sorting parameters', async () => {
const res = await lightBridgeGraphQLService.queryAssetReceivedEvent(
288,
null,
null,
null,
null,
null,
null,
'depositId',
'asc',
100
);

expect(res[0].block_number).toBeDefined();
expect(res[0].token).toBeDefined();
expect(res[0].sourceChainId).toBeDefined();
expect(res[0].toChainId).toBeDefined();
expect(res[0].depositId).toBeDefined();
expect(res[0].emitter).toBeDefined();
expect(res[0].amount).toBeDefined();
expect(res[0].transactionHash_).toBeDefined();
expect(res[0].block_number).toBeDefined();
expect(res[0].timestamp_).toBeDefined();

expect(res.length).toBeLessThanOrEqual(100);

if (res.length > 1) {
expect(Number(res[0].depositId)).toBeLessThanOrEqual(Number(res[1].depositId));
}
});
it('should query AssetReceivedEvent', async () => {
const res = await lightBridgeGraphQLService.queryAssetReceivedEvent(288);
expect(res[0].block_number).toBeDefined();
Expand Down
Loading
Loading