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

🥅 Prevent 0 gas #237

Merged
merged 2 commits into from
Feb 8, 2021
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
8 changes: 6 additions & 2 deletions 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 @@ -125,7 +125,11 @@ export const TxStoreModel = types
self.errorMessage = ""
self.txHash = ""
try {
const estimatedGas: number = yield message.simulate({ memo: self.memo })
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) {
logError(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