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
285b3a23
Commit
285b3a23
authored
Mar 24, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more strict condition
parent
d19fcbdb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
ContractMethodField.tsx
ui/address/contract/ContractMethodField.tsx
+2
-1
utils.ts
ui/address/contract/utils.ts
+18
-0
No files found.
ui/address/contract/ContractMethodField.tsx
View file @
285b3a23
...
@@ -14,6 +14,7 @@ import type { SmartContractMethodArgType } from 'types/api/contract';
...
@@ -14,6 +14,7 @@ import type { SmartContractMethodArgType } from 'types/api/contract';
import
InputClearButton
from
'
ui/shared/InputClearButton
'
;
import
InputClearButton
from
'
ui/shared/InputClearButton
'
;
import
ContractMethodFieldZeroes
from
'
./ContractMethodFieldZeroes
'
;
import
ContractMethodFieldZeroes
from
'
./ContractMethodFieldZeroes
'
;
import
{
addZeroesAllowed
}
from
'
./utils
'
;
interface
Props
{
interface
Props
{
control
:
Control
<
MethodFormFields
>
;
control
:
Control
<
MethodFormFields
>
;
...
@@ -43,7 +44,7 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
...
@@ -43,7 +44,7 @@ const ContractMethodField = ({ control, name, valueType, placeholder, setValue,
onChange
();
onChange
();
},
[
getValues
,
name
,
onChange
,
setValue
]);
},
[
getValues
,
name
,
onChange
,
setValue
]);
const
hasZerosControl
=
valueType
.
includes
(
'
int
'
)
&&
!
valueType
.
includes
(
'
[]
'
);
const
hasZerosControl
=
addZeroesAllowed
(
valueType
);
const
renderInput
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
MethodFormFields
>
})
=>
{
const
renderInput
=
React
.
useCallback
(({
field
}:
{
field
:
ControllerRenderProps
<
MethodFormFields
>
})
=>
{
return
(
return
(
...
...
ui/address/contract/utils.ts
View file @
285b3a23
...
@@ -7,6 +7,24 @@ export const getNativeCoinValue = (value: string | Array<string>) => {
...
@@ -7,6 +7,24 @@ export const getNativeCoinValue = (value: string | Array<string>) => {
return
BigNumber
(
_value
).
times
(
10
**
config
.
network
.
currency
.
decimals
).
toString
();
return
BigNumber
(
_value
).
times
(
10
**
config
.
network
.
currency
.
decimals
).
toString
();
};
};
export
const
addZeroesAllowed
=
(
valueType
:
string
)
=>
{
if
(
valueType
.
includes
(
'
[]
'
))
{
return
false
;
}
const
REGEXP
=
/u
?
int
(\d
+
)
/i
;
const
match
=
valueType
.
match
(
REGEXP
);
const
power
=
match
?.[
1
];
if
(
power
)
{
// show control for all inputs which allows to insert 10^18 or greater numbers
return
Number
(
power
)
>=
64
;
}
return
false
;
};
interface
ExtendedError
extends
Error
{
interface
ExtendedError
extends
Error
{
detectedNetwork
?:
{
detectedNetwork
?:
{
chain
:
number
;
chain
:
number
;
...
...
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