Skip to content

Commit

Permalink
Merge pull request #5 from maticnetwork/changes
Browse files Browse the repository at this point in the history
Changes
  • Loading branch information
nitinmittal23 authored Aug 17, 2023
2 parents e445950 + 3610c71 commit 3823826
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 40 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Polygon (previously Matic)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,4 +885,4 @@ Made with [contributors-img](https://contrib.rocks).

## License

[UNLICENSED](./LICENSE)
[MIT](./LICENSE)
4 changes: 2 additions & 2 deletions example/consumer/src/interfaces/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* be saved there for all transfers.
*/
export interface ITransfer {
transactionIndex: Number,
transactionIndex: number,
transactionHash: string,
transactionInitiator: string,
tokenAddress: string,
senderAddress: string,
receiverAddress: string,
amount: string,
timestamp: Date,
blockNumber: Number
blockNumber: number
}
2 changes: 1 addition & 1 deletion internal/block_getters/block_getter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class BlockGetter extends BlockFormatter implements IBlockGetter {
}

return this.formatBlockWithTransactions(
block as BlockTransactionObject,
block,
transactions
);
}
Expand Down
3 changes: 1 addition & 2 deletions internal/interfaces/consumer_config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ConsumerGlobalConfig } from "node-rdkafka";
import { ConsumerTopicConfig } from "node-rdkafka";
import { ConsumerGlobalConfig, ConsumerTopicConfig } from "node-rdkafka";
import { ICoderConfig } from "./coder_config.js";
import { IKafkaCoderConfig } from "./kafka_coder_config.js";

Expand Down
4 changes: 2 additions & 2 deletions internal/interfaces/raw_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export interface IRawTransaction {
transactionIndex?: string,
from: string,
to: string | null,
value: string | string,
gasPrice: string | string,
value: string,
gasPrice: string,
gas: string,
input: string,
maxFeePerGas?: string,
Expand Down
21 changes: 0 additions & 21 deletions internal/kafka/consumer/abstract_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,6 @@ export abstract class AbstractConsumer extends noderdkafka.KafkaConsumer {
// Can alternatively use this.assign();
this.subscribe(this.topics);

// if (Object.keys(this.startOffsets).length) {
// await new Promise(r => setTimeout(r, 10000));
// for (let topic of Object.keys(this.startOffsets)) {
// Logger.info(`Seeking offset number: ${this.startOffsets[topic]}, for topic: ${topic}`);

// await new Promise(
// (res, rej) => this.seek({
// topic: topic,
// offset: this.startOffsets[topic],
// partition: 0
// }, this.connectionTimeout, (err) => {
// if (err) {
// return rej(err);
// }

// res(undefined);
// })
// );
// }
// }

this.consume();
} catch (error) {
throw KafkaError.createUnknown(error);
Expand Down
11 changes: 4 additions & 7 deletions internal/mongo/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ export class Database {
* @returns {Promis<boolean>}
*/
public async connect(): Promise<boolean> {
if (this.database.connection.readyState === 1 || this.database.connection.readyState === 2) {
return true;
if (!(this.database.connection.readyState === 1 || this.database.connection.readyState === 2)) {
await this.database.connect(this.url);
}

await this.database.connect(this.url);
return true;
}

Expand All @@ -47,12 +46,10 @@ export class Database {
* @returns {Promise<boolean>}
*/
public async disconnect(): Promise<boolean> {
if (this.database.connection.readyState === 0 || this.database.connection.readyState === 3) {
return true;
if (!(this.database.connection.readyState === 0 || this.database.connection.readyState === 3)) {
await this.database.disconnect();
}

await this.database.disconnect();

return true;
}

Expand Down
3 changes: 2 additions & 1 deletion internal/queue/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class Queue<T> {
* @returns {number} - The queue length after clearing.
*/
public clear(): number {
return this.items.length = 0;
this.items.length = 0;
return this.items.length;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint:fix": "npx eslint --fix \"./internal/**/*.ts\" \"./public/**/*.ts\""
},
"author": "nitinmittal23",
"license": "UNLICENSED",
"license": "MIT",
"publishConfig": {
"@maticnetwork:registry": "https://npm.pkg.github.com/maticnetwork"
},
Expand Down
2 changes: 1 addition & 1 deletion public/kafka/consumer/asynchronous_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class AsynchronousConsumer extends InternalAsynchronousConsumer {

super(
topic,
coders as IKafkaCoderConfig,
coders,
config
);
}
Expand Down
2 changes: 1 addition & 1 deletion public/kafka/consumer/synchronous_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class SynchronousConsumer extends InternalSynchronousConsumer {

super(
topic,
coders as IKafkaCoderConfig,
coders,
config
);
}
Expand Down

0 comments on commit 3823826

Please sign in to comment.