File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
TransactionEventsClasses ,
19
19
TransactionEventsStatus ,
20
20
} from "types/events" ;
21
+ import { toErrorDetail } from "utils" ;
21
22
import { getSdkInstance } from "utils/sdk" ;
22
23
23
24
export type TransactionPair < T > = {
@@ -234,7 +235,7 @@ export const broadcastTxWithEvents = async <T>(
234
235
if ( result . status === "fulfilled" ) {
235
236
return result . value . commitments ;
236
237
} else {
237
- throw new Error ( result . reason . toString ( ) ) ;
238
+ throw new Error ( toErrorDetail ( encodedTx . txs , result . reason ) ) ;
238
239
}
239
240
} ) ;
240
241
Original file line number Diff line number Diff line change 1
1
import { Asset , AssetDenomUnit } from "@chain-registry/types" ;
2
2
import namadaAssets from "@namada/chain-registry/namada/assetlist.json" ;
3
- import { ProposalStatus , ProposalTypeString } from "@namada/types" ;
3
+ import {
4
+ BroadcastTxError ,
5
+ ProposalStatus ,
6
+ ProposalTypeString ,
7
+ ResultCode ,
8
+ TxMsgValue ,
9
+ } from "@namada/types" ;
4
10
import { localnetConfigAtom } from "atoms/integrations/atoms" ;
5
11
import BigNumber from "bignumber.js" ;
6
12
import { getDefaultStore } from "jotai" ;
@@ -114,3 +120,22 @@ export const toBaseAmount = (
114
120
}
115
121
return displayAmount . shiftedBy ( displayUnit . exponent ) ;
116
122
} ;
123
+
124
+ /**
125
+ * Returns formatted error message based on tx props and error code
126
+ */
127
+ export const toErrorDetail = (
128
+ tx : TxMsgValue [ ] ,
129
+ error : BroadcastTxError
130
+ ) : string => {
131
+ const { gasLimit } = tx [ 0 ] . args ;
132
+ const { code } = error . toProps ( ) ;
133
+
134
+ // TODO: Over time we may expand this to format errors for more result codes
135
+ switch ( code ) {
136
+ case ResultCode . TxGasLimit :
137
+ return `${ error . toString ( ) } Please raise the Gas Amount above the previously provided ${ gasLimit } in the fee options for your transaction.` ;
138
+ default :
139
+ return error . toString ( ) ;
140
+ }
141
+ } ;
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export const ResultCodes: Record<ResultCode, string> = {
108
108
[ ResultCode . ReplayTx ] : "Replayed tx" ,
109
109
[ ResultCode . InvalidChainId ] : "Invalid chain ID" ,
110
110
[ ResultCode . ExpiredTx ] : "Expired tx" ,
111
- [ ResultCode . TxGasLimit ] : "Exceeded gas limit" ,
111
+ [ ResultCode . TxGasLimit ] : "Transaction gas required exceeds the gas limit. " ,
112
112
[ ResultCode . FeeError ] : "Error in paying tx fee" ,
113
113
[ ResultCode . InvalidVoteExtension ] : "Invalid vote extension" ,
114
114
[ ResultCode . TooLarge ] : "Tx is too large" ,
You can’t perform that action at this time.
0 commit comments