Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add satp logging in all satges #3665

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
4 changes: 3 additions & 1 deletion packages/cactus-plugin-satp-hermes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"db:migrate": "knex migrate:latest --knexfile src/knex/knexfile.js",
"db:migrate:production": "knex migrate:latest --env production --knexfile src/knex/knexfile.ts",
"db:seed": "knex seed:run --knexfile src/knex/knexfile.ts",
"db:cleanup": "find src/knex/data -name '.dev-*.sqlite3' -delete"
"db:cleanup": "find src/knex/ -name '.dev.local-*.sqlite3' -delete"
},
"jest": {
"moduleNameMapper": {
Expand Down Expand Up @@ -137,6 +137,7 @@
"kubo-rpc-client": "3.0.1",
"npm-run-all": "4.1.5",
"openzeppelin-solidity": "3.4.2",
"pg": "8.13.1",
"safe-stable-stringify": "2.5.0",
"secp256k1": "4.0.3",
"socket.io": "4.6.2",
Expand All @@ -160,6 +161,7 @@
"@types/fs-extra": "11.0.4",
"@types/google-protobuf": "3.15.12",
"@types/node": "18.18.2",
"@types/pg": "8.11.10",
"@types/swagger-ui-express": "4.1.6",
"@types/tape": "4.13.4",
"@types/uuid": "10.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import path from "path";
import { v4 as uuidv4 } from "uuid";
import dotenv from "dotenv";
import { Knex } from "knex";

const envPath = process.env.ENV_PATH;
dotenv.config({ path: envPath });

module.exports = {
const config: { [key: string]: Knex.Config } = {
development: {
client: "sqlite3",
connection: {
Expand All @@ -20,7 +21,7 @@ module.exports = {
client: "pg",
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
port: Number(process.env.DB_PORT),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
Expand All @@ -30,3 +31,5 @@ module.exports = {
},
},
};

export default config;
9 changes: 6 additions & 3 deletions packages/cactus-plugin-satp-hermes/src/knex/knexfile.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import path from "path";
import { v4 as uuidv4 } from "uuid";
import dotenv from "dotenv";
import { Knex } from "knex";

const envPath = process.env.ENV_PATH;
dotenv.config({ path: envPath });

module.exports = {
const config: { [key: string]: Knex.Config } = {
development: {
client: "sqlite3",
connection: {
filename: path.join(__dirname, "data", "/.dev-" + uuidv4() + ".sqlite3"),
filename: path.resolve(__dirname, `.dev.local-${uuidv4()}.sqlite3`),
},
migrations: {
directory: path.resolve(__dirname, "migrations"),
Expand All @@ -23,7 +24,7 @@ module.exports = {
client: "pg",
connection: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
port: Number(process.env.DB_PORT),
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
Expand All @@ -33,3 +34,5 @@ module.exports = {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import { IntegrationsEndpointV1 } from "../web-services/integrations-endpoint";
import { executeGetHealthCheck } from "./admin/get-healthcheck-handler-service";
import { executeGetStatus } from "./admin/get-status-handler-service";
import { executeTransact } from "./transaction/transact-handler-service";
import {
ILocalLogRepository,
IRemoteLogRepository,
} from "../repository/interfaces/repository";

export interface BLODispatcherOptions {
logger: Logger;
Expand All @@ -41,6 +45,8 @@ export interface BLODispatcherOptions {
signer: JsObjectSigner;
bridgesManager: SATPBridgesManager;
pubKey: string;
localRepository: ILocalLogRepository;
remoteRepository: IRemoteLogRepository;
}

export class BLODispatcher {
Expand All @@ -54,19 +60,26 @@ export class BLODispatcher {
private manager: SATPManager;
private orchestrator: GatewayOrchestrator;
private bridgeManager: SATPBridgesManager;
private localRepository: ILocalLogRepository;
private remoteRepository: IRemoteLogRepository;

constructor(public readonly options: BLODispatcherOptions) {
const fnTag = `${BLODispatcher.CLASS_NAME}#constructor()`;
Checks.truthy(options, `${fnTag} arg options`);

this.level = this.options.logLevel || "INFO";
this.label = this.className;
this.logger = LoggerProvider.getOrCreate({ level: this.level, label: this.label });
this.logger = LoggerProvider.getOrCreate({
level: this.level,
label: this.label,
});
this.instanceId = options.instanceId;
this.logger.info(`Instantiated ${this.className} OK`);
this.orchestrator = options.orchestrator;
const signer = options.signer;
const ourGateway = this.orchestrator.ourGateway;
this.localRepository = options.localRepository;
this.remoteRepository = options.remoteRepository;

this.bridgeManager = options.bridgesManager;

Expand All @@ -78,6 +91,8 @@ export class BLODispatcher {
bridgeManager: this.bridgeManager,
orchestrator: this.orchestrator,
pubKey: options.pubKey,
localRepository: this.localRepository,
remoteRepository: this.remoteRepository,
};

this.manager = new SATPManager(SATPManagerOpts);
Expand Down
Loading
Loading