Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
4f799da1
Commit
4f799da1
authored
Dec 08, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bool validation
parent
88abf613
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
ContractMethodField.tsx
ui/address/contract/ContractMethodField.tsx
+8
-1
utils.ts
ui/address/contract/utils.ts
+19
-0
No files found.
ui/address/contract/ContractMethodField.tsx
View file @
4f799da1
...
@@ -17,7 +17,7 @@ import type { SmartContractMethodArgType } from 'types/api/contract';
...
@@ -17,7 +17,7 @@ import type { SmartContractMethodArgType } from 'types/api/contract';
import
ClearButton
from
'
ui/shared/ClearButton
'
;
import
ClearButton
from
'
ui/shared/ClearButton
'
;
import
ContractMethodFieldZeroes
from
'
./ContractMethodFieldZeroes
'
;
import
ContractMethodFieldZeroes
from
'
./ContractMethodFieldZeroes
'
;
import
{
INT_REGEXP
,
getIntBoundaries
}
from
'
./utils
'
;
import
{
INT_REGEXP
,
getIntBoundaries
,
formatBooleanValue
}
from
'
./utils
'
;
interface
Props
{
interface
Props
{
control
:
Control
<
MethodFormFields
>
;
control
:
Control
<
MethodFormFields
>
;
...
@@ -122,6 +122,13 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
...
@@ -122,6 +122,13 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
return
true
;
return
true
;
}
}
if
(
valueType
===
'
bool
'
)
{
const
formattedValue
=
formatBooleanValue
(
value
);
if
(
formattedValue
===
undefined
)
{
return
'
Invalid boolean format. Allowed values: 0, 1, true, false
'
;
}
}
return
true
;
return
true
;
},
[
intMatch
,
valueType
]);
},
[
intMatch
,
valueType
]);
...
...
ui/address/contract/utils.ts
View file @
4f799da1
...
@@ -11,6 +11,25 @@ export const getIntBoundaries = (power: number, isUnsigned: boolean) => {
...
@@ -11,6 +11,25 @@ export const getIntBoundaries = (power: number, isUnsigned: boolean) => {
return
[
min
,
max
];
return
[
min
,
max
];
};
};
export
const
formatBooleanValue
=
(
value
:
string
)
=>
{
const
formattedValue
=
value
.
toLowerCase
();
switch
(
formattedValue
)
{
case
'
true
'
:
case
'
1
'
:
{
return
'
true
'
;
}
case
'
false
'
:
case
'
0
'
:
{
return
'
false
'
;
}
default
:
return
;
}
};
export
const
getNativeCoinValue
=
(
value
:
string
|
Array
<
unknown
>
)
=>
{
export
const
getNativeCoinValue
=
(
value
:
string
|
Array
<
unknown
>
)
=>
{
const
_value
=
Array
.
isArray
(
value
)
?
value
[
0
]
:
value
;
const
_value
=
Array
.
isArray
(
value
)
?
value
[
0
]
:
value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment