Skip to content

Commit

Permalink
🔊 Capture log for 0 gas
Browse files Browse the repository at this point in the history
  • Loading branch information
nwingt committed Dec 10, 2020
1 parent ecb1a0b commit d752465
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/models/tx-store/tx-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
CosmosTxQueryResult,
} from "../../services/cosmos"
import { parseCosmosCoin } from "../../services/cosmos/cosmos.utils"
import { logError } from "../../utils/error"
import { logError, logMessage } from "../../utils/error"

import { translateWithFallbackText } from "../../i18n"

Expand Down Expand Up @@ -128,6 +128,7 @@ export const TxStoreModel = types
let estimatedGas: number = yield message.simulate({ memo: self.memo })
if (estimatedGas === 0) {
estimatedGas = 200000
logMessage('[TxStore] Estimated gas is 0')
}
self.gas = new BigNumber(estimatedGas)
} catch (error) {
Expand Down
11 changes: 10 additions & 1 deletion app/utils/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sentryCaptureError } from './sentry'
import { sentryCaptureError, sentryCaptureMessage } from './sentry'

export function logError(err: any) {
if (__DEV__) {
Expand All @@ -8,3 +8,12 @@ export function logError(err: any) {
sentryCaptureError(err)
}
}

export function logMessage(msg: string) {
if (__DEV__) {
console.tron.warn(msg)
} else {
console.warn(msg)
sentryCaptureMessage(msg)
}
}
4 changes: 4 additions & 0 deletions app/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export function initSentry(dsn: string, environment: string) {
})
}

export function sentryCaptureMessage(msg: string) {
return Sentry.captureMessage(msg)
}

export function sentryCaptureError(err: unknown) {
return Sentry.captureException(err)
}
Expand Down

0 comments on commit d752465

Please sign in to comment.