Skip to content

Commit

Permalink
remove sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
carolk-dev committed Dec 19, 2024
1 parent 14e0091 commit 1e6de69
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 34 deletions.
2 changes: 0 additions & 2 deletions bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
"@safe-global/safe-core-sdk-types": "^1.9.0",
"@safe-global/safe-ethers-lib": "^1.9.2",
"@safe-global/safe-service-client": "^2.0.0",
"@sentry/node": "^6.4.1",
"@sentry/tracing": "^6.4.1",
"@slack/web-api": "^6.2.3",
"@truffle/hdwallet-provider": "^1.3.0",
"@types/asn1js": "^2.0.2",
Expand Down
7 changes: 0 additions & 7 deletions bridge/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Web3 from "web3";
import { init } from "@sentry/node";
import { KmsProvider } from "@planetarium/aws-kms-provider";

import { BscBurnEventMonitor } from "./monitors/bsc-burn-event-monitor";
Expand Down Expand Up @@ -115,12 +114,6 @@ process.on("uncaughtException", console.error);
"boolean"
);
const BSCSCAN_ROOT_URL: string = Configuration.get("BSCSCAN_ROOT_URL");
const SENTRY_DSN: string | undefined = Configuration.get("SENTRY_DSN", false);
if (SENTRY_DSN !== undefined) {
init({
dsn: SENTRY_DSN,
});
}

// Environment Variables for using Google Spread Sheet API
const SLACK_URL: string = Configuration.get("SLACK_URL");
Expand Down
2 changes: 0 additions & 2 deletions bridge/src/monitors/triggerable-monitor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Monitor } from ".";
import { captureException } from "@sentry/node";
import { TransactionLocation } from "../types/transaction-location";
import { BlockHash } from "../types/block-hash";

Expand Down Expand Up @@ -88,7 +87,6 @@ export abstract class TriggerableMonitor<TEventData> extends Monitor<
"Ignore and continue loop without breaking though unexpected error occurred:",
error
);
captureException(error);
}
}
}
Expand Down
23 changes: 0 additions & 23 deletions bridge/src/sqlite3-exchange-history-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class Sqlite3ExchangeHistoryStore implements IExchangeHistoryStore {
static async open(path: string): Promise<Sqlite3ExchangeHistoryStore> {
const database = new Database(path);
await this.initialize(database);
await this.ensureStatusColumn(database);
return new Sqlite3ExchangeHistoryStore(database);
}

Expand All @@ -93,29 +92,7 @@ export class Sqlite3ExchangeHistoryStore implements IExchangeHistoryStore {
});
});
}
/** 운영테이블에 status 컬럼 추가후 삭제될 코드 START */
private static async ensureStatusColumn(database: Database): Promise<void> {
interface ColumnInfo {
name: string;
}

const columns = (await promisify(database.all.bind(database))(
"PRAGMA table_info(exchange_histories)"
)) as ColumnInfo[];

const hasStatusColumn = columns.some((col) => col.name === "status");

if (!hasStatusColumn) {
await promisify(database.run.bind(database))(
`ALTER TABLE exchange_histories ADD COLUMN status TEXT DEFAULT '${TransactionStatus.PENDING}'`
);

await promisify(database.run.bind(database))(
`UPDATE exchange_histories SET status = '${TransactionStatus.COMPLETED}' WHERE status IS NULL`
);
}
}
/** 운영테이블에 status 컬럼 추가후 삭제될 코드 END */
close(): void {
this.checkClosed();

Expand Down
6 changes: 6 additions & 0 deletions bridge/test/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ describe("Configuration", () => {
expect(Configuration.get(ENV_NAME, false, "boolean")).toEqual(false);
expect(Configuration.get("UNDEFINED", false, "boolean")).toEqual(false);
});

it("should throw an error", () => {
expect(() => {
Configuration.get("UNDEFINED", true, "string");
}).toThrowError("Please set 'UNDEFINED' at .env");
});
});

for (const testcase of [".1", "FALSE", "", "*"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,69 @@ Array [
]
`;

exports[`BscBurnEventObserver notify should handle existing transaction in exchange history 1`] = `
Array [
Array [
Object {
"attachments": Array [
Object {
"author_name": "Bridge Warning",
"color": "#ffcc00",
"fallback": "wNCG → NCG event already seems executed so it skipped.",
"fields": Array [
Object {
"title": "Binance Smart Chain network transaction id",
"value": "TX-EXISTING",
},
],
},
],
"text": "wNCG → NCG event already seems executed so it skipped.",
},
],
]
`;

exports[`BscBurnEventObserver notify should handle existing transaction in exchange history 2`] = `
Array [
Array [
"error",
Object {
"amount": "1.00",
"cause": "Exchange history exist",
"content": "wNCG -> NCG request failure",
"ethereumTxId": "TX-EXISTING",
"network": "BSC",
"recipient": "0x6d29f9923C86294363e59BAaA46FcBc37Ee5aE2e",
"sender": "0x2734048eC2892d111b4fbAB224400847544FC872",
},
],
]
`;

exports[`BscBurnEventObserver notify should handle existing transaction in exchange history 3`] = `
Array [
Array [
Object {
"attachments": Array [
Object {
"author_name": "Bridge Warning",
"color": "#ffcc00",
"fallback": "wNCG → NCG event already seems executed so it skipped.",
"fields": Array [
Object {
"title": "Binance Smart Chain network transaction id",
"value": "TX-EXISTING",
},
],
},
],
"text": "wNCG → NCG event already seems executed so it skipped.",
},
],
]
`;

exports[`BscBurnEventObserver notify slack/opensearch 9c transfer error message - snapshot 1`] = `
Array [
Array [
Expand Down
38 changes: 38 additions & 0 deletions bridge/test/observers/burn-event-observer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,5 +570,43 @@ describe(BscBurnEventObserver.name, () => {

expect(mockIntegration.error.mock.calls).toMatchSnapshot();
});

it("should handle existing transaction in exchange history", async () => {
const transactionHash = "TX-EXISTING";
const events = [
{
blockHash: "BLOCK-HASH",
address: "0x4029bC50b4747A037d38CF2197bCD335e22Ca301",
logIndex: 0,
blockNumber: 0,
event: "Burn",
raw: {
data: "",
topics: [],
},
signature: "",
transactionIndex: 0,
transactionHash: transactionHash,
txId: transactionHash,
returnValues: {
_sender: "0x2734048eC2892d111b4fbAB224400847544FC872",
_to: "0x6d29f9923C86294363e59BAaA46FcBc37Ee5aE2e",
amount: 1000000000000000000,
},
},
];

// Mocking the exist method to return true
mockExchangeHistoryStore.exist.mockResolvedValue(true);

await observer.notify({
blockHash: "BLOCK-HASH",
events,
});

expect(mockSlackChannel.sendMessage.mock.calls).toMatchSnapshot();
expect(mockOpenSearchClient.to_opensearch.mock.calls).toMatchSnapshot();
expect(mockSlackChannel.sendMessage.mock.calls).toMatchSnapshot();
});
});
});

0 comments on commit 1e6de69

Please sign in to comment.