Skip to content

Commit 4fd8a6b

Browse files
committed
fix(suite-native): fix custom fee validation
1 parent 33fb8bf commit 4fd8a6b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

suite-native/transaction-management/src/feesFormSchema.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const feesFormValidationSchema = yup.object({
4040
customFeePerUnit: yup
4141
.string()
4242
.test('too-many-decimals', 'Too many decimals.', function (value) {
43+
if (!value) return true;
4344
const { translate, ...context } = this.options.context as FeesFormContext;
4445
if (!validateFeeDecimalLength(value, context)) {
4546
return this.createError({
@@ -69,9 +70,10 @@ export const feesFormValidationSchema = yup.object({
6970
return true;
7071
})
7172
.test('fee-too-high', 'Fee is too high.', function (value) {
73+
if (!value) return true;
7274
const { networkFeeInfo, translate } = this.options.context as FeesFormContext;
7375

74-
if (!value || !networkFeeInfo) return false;
76+
if (!networkFeeInfo) return false;
7577

7678
const feeBig = new BigNumber(value);
7779
const { maxFee } = networkFeeInfo;
@@ -92,6 +94,7 @@ export const feesFormValidationSchema = yup.object({
9294
'Value is too low.',
9395

9496
function (value) {
97+
if (!value) return true;
9598
const { symbol, minimalFeeLimit, translate } = this.options.context as FeesFormContext;
9699

97100
if (!symbol) return true;
@@ -120,6 +123,8 @@ export const feesFormValidationSchema = yup.object({
120123
customMaxFeePerGas: yup
121124
.string()
122125
.test('too-many-decimals', 'Too many decimals.', function (value) {
126+
if (!value) return true;
127+
123128
const { translate, ...context } = this.options.context as FeesFormContext;
124129
if (!validateFeeDecimalLength(value, context)) {
125130
return this.createError({
@@ -132,8 +137,11 @@ export const feesFormValidationSchema = yup.object({
132137
return true;
133138
})
134139
.test('max-fee-per-gas-range', 'Max fee per gas is out of range.', function (value) {
135-
const { translate, networkFeeInfo } = this.options.context as FeesFormContext;
136-
if (!value || !networkFeeInfo) return false;
140+
if (!value) return true;
141+
142+
const { translate, networkFeeInfo, symbol } = this.options.context as FeesFormContext;
143+
144+
if (!networkFeeInfo || !symbol) return false;
137145

138146
const { maxFee, minFee } = networkFeeInfo;
139147

0 commit comments

Comments
 (0)