diff --git a/src/graphqlClient.ts b/src/graphqlClient.ts index 1fa42c3..0c54264 100644 --- a/src/graphqlClient.ts +++ b/src/graphqlClient.ts @@ -61,6 +61,9 @@ export default class GraphqlClient { }, error(value) { onError && onError(value); + }, + complete() { + console.log('Graphql subscription is completed'); } }); } diff --git a/src/migrations/1611150552872-RemoveDeployment.ts b/src/migrations/1611150552872-RemoveDeployment.ts new file mode 100644 index 0000000..b47f9d3 --- /dev/null +++ b/src/migrations/1611150552872-RemoveDeployment.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class RemoveDeployment1611150552872 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE eth.transaction_cids DROP COLUMN deployment`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE eth.transaction_cids ADD deployment boolean NULL`); + + } + +} diff --git a/src/models/eth/transactionCids.ts b/src/models/eth/transactionCids.ts index 3c0e742..b1acdd4 100644 --- a/src/models/eth/transactionCids.ts +++ b/src/models/eth/transactionCids.ts @@ -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; diff --git a/src/repositories/eth/transactionCidsRepository.ts b/src/repositories/eth/transactionCidsRepository.ts index 1a2511c..d16f0d0 100644 --- a/src/repositories/eth/transactionCidsRepository.ts +++ b/src/repositories/eth/transactionCidsRepository.ts @@ -6,7 +6,6 @@ export default class TransactionCidsRepository extends Repository { return this.save({ cid, - deployment, headerId, index, mhKey, diff --git a/src/repositories/graphqlRepository.ts b/src/repositories/graphqlRepository.ts index 98ddc5f..4ac32a6 100644 --- a/src/repositories/graphqlRepository.ts +++ b/src/repositories/graphqlRepository.ts @@ -13,7 +13,7 @@ export default class GraphqlRepository { return GraphqlRepository.repository; } - + public constructor(graphqlClient: GraphqlClient) { this.graphqlClient = graphqlClient; } @@ -121,7 +121,7 @@ export default class GraphqlRepository { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - public subscriptionReceiptCids(onNext: (value: any) => void): Promise { + public subscriptionReceiptCids(onNext: (value: any) => void, onError: (error: any) => void): Promise { return this.graphqlClient.subscribe(` subscription MySubscription { listen(topic: "receipt_cids") { @@ -144,7 +144,6 @@ export default class GraphqlRepository { ethTransactionCidByTxId { id cid - deployment headerId index mhKey @@ -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 { + public subscriptionHeaderCids(onNext: (value: any) => void, onError: (error: any) => void): Promise { return this.graphqlClient.subscribe(` subscription MySubscription { listen(topic: "header_cids") { @@ -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 { + public subscriptionStateCids(onNext: (value: any) => void, onError?: (error: any) => void): Promise { return this.graphqlClient.subscribe(` subscription MySubscription { listen(topic: "state_cids") { @@ -247,7 +246,7 @@ export default class GraphqlRepository { } } } - `, onNext); + `, onNext, onError); } } diff --git a/src/services/graphqlService.ts b/src/services/graphqlService.ts index c4c8558..267ca78 100644 --- a/src/services/graphqlService.ts +++ b/src/services/graphqlService.ts @@ -32,11 +32,11 @@ 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 { - 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 { @@ -44,7 +44,7 @@ export default class GraphqlService { const relatedNode = data?.data?.listen?.relatedNode; const result = await DecodeService.decodeStateCid(relatedNode, contracts, states); return func(result); - }); + }, (error) => {console.log(error)}); } }