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
455ac4bb
Commit
455ac4bb
authored
Jan 12, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tx fixes
parent
0e071390
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
ContractWrite.tsx
ui/address/contract/ContractWrite.tsx
+4
-4
utils.ts
ui/address/contract/utils.ts
+17
-0
No files found.
ui/address/contract/ContractWrite.tsx
View file @
455ac4bb
...
...
@@ -15,7 +15,7 @@ import { useContractContext } from './context';
import
ContractConnectWallet
from
'
./ContractConnectWallet
'
;
import
ContractMethodCallable
from
'
./ContractMethodCallable
'
;
import
ContractWriteResult
from
'
./ContractWriteResult
'
;
import
{
getNativeCoinValue
}
from
'
./utils
'
;
import
{
getNativeCoinValue
,
isExtendedError
}
from
'
./utils
'
;
interface
Props
{
isProxy
?:
boolean
;
...
...
@@ -68,11 +68,11 @@ const ContractWrite = ({ isProxy }: Props) => {
return
{
hash
:
result
.
hash
as
string
};
}
catch
(
error
)
{
if
(
error
instanceof
Error
)
{
if
(
isExtendedError
(
error
)
)
{
if
(
'
reason
'
in
error
&&
error
.
reason
===
'
underlying network changed
'
)
{
if
(
'
detectedNetwork
'
in
error
)
{
const
networkName
=
(
error
.
detectedNetwork
as
{
name
:
string
})
.
name
;
if
(
'
detectedNetwork
'
in
error
&&
typeof
error
.
detectedNetwork
===
'
object
'
&&
error
.
detectedNetwork
!==
null
)
{
const
networkName
=
error
.
detectedNetwork
.
name
;
if
(
networkName
)
{
throw
new
Error
(
// eslint-disable-next-line max-len
...
...
ui/address/contract/utils.ts
View file @
455ac4bb
...
...
@@ -6,3 +6,20 @@ export const getNativeCoinValue = (value: string | Array<string>) => {
const
_value
=
Array
.
isArray
(
value
)
?
value
[
0
]
:
value
;
return
BigNumber
(
_value
).
times
(
10
**
config
.
network
.
currency
.
decimals
).
toString
();
};
interface
ExtendedError
extends
Error
{
detectedNetwork
?:
{
chain
:
number
;
name
:
string
;
};
reason
?:
string
;
}
export
function
isExtendedError
(
error
:
unknown
):
error
is
ExtendedError
{
return
(
typeof
error
===
'
object
'
&&
error
!==
null
&&
'
message
'
in
error
&&
typeof
(
error
as
Record
<
string
,
unknown
>
).
message
===
'
string
'
);
}
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