Skip to content

Commit

Permalink
feat: add debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
heisenberg-2077 committed Dec 18, 2024
1 parent 63d2eb2 commit 859244b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ui/utils/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ export const sendTransaction = async ({
? (await Browser.storage.local.get('DEBUG_OTHER_CHAIN_GAS_USD_LIMIT'))
.DEBUG_OTHER_CHAIN_GAS_USD_LIMIT || 5
: 5;
const DEBUG_SIMULATION_FAILED = process.env.DEBUG
? (await Browser.storage.local.get('DEBUG_SIMULATION_FAILED'))
.DEBUG_SIMULATION_FAILED
: false;

// generate tx with gas
const transaction: Tx = {
Expand All @@ -271,7 +275,10 @@ export const sendTransaction = async ({
let failedCode;
let canUseGasAccount: boolean = false;

if (!preExecResult?.balance_change?.success) {
// random simulation failed for test
if (DEBUG_SIMULATION_FAILED && Math.random() > 0.5) {
failedCode = FailedCode.SimulationFailed;
} else if (!preExecResult?.balance_change?.success) {
failedCode = FailedCode.SimulationFailed;
} else if (isGasNotEnough) {
// native gas not enough check gasAccount
Expand Down

0 comments on commit 859244b

Please sign in to comment.