Skip to content

Commit

Permalink
remove unused column deployment. add onError handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ramilexe committed Jan 18, 2021
1 parent c16fe77 commit bcab147
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/graphqlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export default class GraphqlClient {
},
error(value) {
onError && onError(value);
},
complete() {
console.log('Graphql subscription is completed');
}
});
}
Expand Down
14 changes: 14 additions & 0 deletions src/migrations/1611150552872-RemoveDeployment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class RemoveDeployment1611150552872 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE eth.transaction_cids DROP COLUMN deployment`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE eth.transaction_cids ADD deployment boolean NULL`);

}

}
3 changes: 0 additions & 3 deletions src/models/eth/transactionCids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export default class TransactionCids {
@Column("character varying", { name: "src", length: 66 })
src: string;

@Column("boolean", { name: "deployment" })
deployment: boolean;

@Column("bytea", { name: "tx_data", nullable: true })
txData: Buffer | null;

Expand Down
2 changes: 0 additions & 2 deletions src/repositories/eth/transactionCidsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default class TransactionCidsRepository extends Repository<TransactionCid

public async add(headerId: number, {
cid,
deployment,
index,
mhKey,
dst,
Expand All @@ -16,7 +15,6 @@ export default class TransactionCidsRepository extends Repository<TransactionCid
}): Promise<TransactionCids> {
return this.save({
cid,
deployment,
headerId,
index,
mhKey,
Expand Down
15 changes: 7 additions & 8 deletions src/repositories/graphqlRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class GraphqlRepository {

return GraphqlRepository.repository;
}

public constructor(graphqlClient: GraphqlClient) {
this.graphqlClient = graphqlClient;
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export default class GraphqlRepository {
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public subscriptionReceiptCids(onNext: (value: any) => void): Promise<void> {
public subscriptionReceiptCids(onNext: (value: any) => void, onError: (error: any) => void): Promise<void> {
return this.graphqlClient.subscribe(`
subscription MySubscription {
listen(topic: "receipt_cids") {
Expand All @@ -144,7 +144,6 @@ export default class GraphqlRepository {
ethTransactionCidByTxId {
id
cid
deployment
headerId
index
mhKey
Expand Down Expand Up @@ -177,11 +176,11 @@ export default class GraphqlRepository {
}
}
}
`, onNext);
`, onNext, onError);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public subscriptionHeaderCids(onNext: (value: any) => void): Promise<void> {
public subscriptionHeaderCids(onNext: (value: any) => void, onError: (error: any) => void): Promise<void> {
return this.graphqlClient.subscribe(`
subscription MySubscription {
listen(topic: "header_cids") {
Expand All @@ -208,11 +207,11 @@ export default class GraphqlRepository {
}
}
}
`, onNext);
`, onNext, onError);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public subscriptionStateCids(onNext: (value: any) => void): Promise<void> {
public subscriptionStateCids(onNext: (value: any) => void, onError?: (error: any) => void): Promise<void> {
return this.graphqlClient.subscribe(`
subscription MySubscription {
listen(topic: "state_cids") {
Expand Down Expand Up @@ -247,7 +246,7 @@ export default class GraphqlRepository {
}
}
}
`, onNext);
`, onNext, onError);
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/services/graphqlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ export default class GraphqlService {
const relatedNode = data?.data?.listen?.relatedNode;
const result = await DecodeService.decodeReceiptCid(relatedNode, contracts, events);
return func(result);
});
}, (error) => {console.log(error)});
}

public async subscriptionHeaderCids(func: (value: any) => void): Promise<void> {
return this.graphqlRepository.subscriptionHeaderCids(func);
return this.graphqlRepository.subscriptionHeaderCids(func, (error) => {console.log(error)});
}

public async subscriptionStateCids(contracts: Contract[] | Function, states: State[] | Function, func: (value: any) => void): Promise<void> {
return this.graphqlRepository.subscriptionStateCids(async (data) => {
const relatedNode = data?.data?.listen?.relatedNode;
const result = await DecodeService.decodeStateCid(relatedNode, contracts, states);
return func(result);
});
}, (error) => {console.log(error)});
}

}

0 comments on commit bcab147

Please sign in to comment.