Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
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
LuckySwap
interface
Commits
685bb174
Unverified
Commit
685bb174
authored
May 13, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve rendering of failed transactions
parent
9006acb4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
32 deletions
+33
-32
Transaction.tsx
src/components/AccountDetails/Transaction.tsx
+29
-28
index.tsx
src/components/AccountDetails/index.tsx
+4
-4
No files found.
src/components/AccountDetails/Transaction.tsx
View file @
685bb174
import
React
from
'
react
'
import
React
from
'
react
'
import
styled
,
{
keyframes
}
from
'
styled-components
'
import
styled
,
{
keyframes
}
from
'
styled-components
'
import
{
Check
}
from
'
react-feather
'
import
{
Check
,
Triangle
}
from
'
react-feather
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
{
getEtherscanLink
}
from
'
../../utils
'
import
{
getEtherscanLink
}
from
'
../../utils
'
...
@@ -43,17 +43,25 @@ const rotate = keyframes`
...
@@ -43,17 +43,25 @@ const rotate = keyframes`
}
}
`
`
const
TransactionState
=
styled
.
div
<
{
pending
?:
boolean
}
>
`
const
TransactionState
=
styled
.
div
<
{
pending
:
boolean
;
success
?:
boolean
}
>
`
display: flex;
display: flex;
background-color:
${({
pending
,
theme
})
=>
background-color:
${({
pending
,
success
,
theme
})
=>
pending
?
transparentize
(
0.95
,
theme
.
primary1
)
:
transparentize
(
0.95
,
theme
.
green1
)}
;
pending
?
transparentize
(
0.95
,
theme
.
primary1
)
:
success
?
transparentize
(
0.95
,
theme
.
green1
)
:
transparentize
(
0.95
,
theme
.
red1
)}
;
border-radius: 1.5rem;
border-radius: 1.5rem;
padding: 0.5rem 0.75rem;
padding: 0.5rem 0.75rem;
font-weight: 500;
font-weight: 500;
font-size: 0.75rem;
font-size: 0.75rem;
border: 1px solid;
border: 1px solid;
border-color:
${({
pending
,
theme
})
=>
border-color:
${({
pending
,
success
,
theme
})
=>
pending
?
transparentize
(
0.75
,
theme
.
primary1
)
:
transparentize
(
0.75
,
theme
.
green1
)}
;
pending
?
transparentize
(
0.75
,
theme
.
primary1
)
:
success
?
transparentize
(
0.75
,
theme
.
green1
)
:
transparentize
(
0.75
,
theme
.
red1
)}
;
#pending {
#pending {
animation: 2s
${
rotate
}
linear infinite;
animation: 2s
${
rotate
}
linear infinite;
...
@@ -64,17 +72,21 @@ const TransactionState = styled.div<{ pending?: boolean }>`
...
@@ -64,17 +72,21 @@ const TransactionState = styled.div<{ pending?: boolean }>`
pending
?
transparentize
(
0
,
theme
.
primary1
)
:
transparentize
(
0
,
theme
.
green1
)}
;
pending
?
transparentize
(
0
,
theme
.
primary1
)
:
transparentize
(
0
,
theme
.
green1
)}
;
}
}
`
`
const
ButtonWrapper
=
styled
.
div
<
{
pending
:
boolean
}
>
`
const
ButtonWrapper
=
styled
.
div
<
{
pending
:
boolean
;
success
?:
boolean
}
>
`
a {
a {
color:
${({
pending
,
theme
})
=>
(
pending
?
theme
.
primary1
:
theme
.
green
1
)}
;
color:
${({
pending
,
success
,
theme
})
=>
(
pending
?
theme
.
primary1
:
success
?
theme
.
green1
:
theme
.
red
1
)}
;
}
}
`
`
export
default
function
Transaction
({
hash
,
pending
}:
{
hash
:
string
;
pending
:
boolean
})
{
export
default
function
Transaction
({
hash
}:
{
hash
:
string
})
{
const
{
chainId
}
=
useWeb3React
()
const
{
chainId
}
=
useWeb3React
()
const
allTransactions
=
useAllTransactions
()
const
allTransactions
=
useAllTransactions
()
const
summary
=
allTransactions
?.[
hash
]?.
summary
const
summary
=
allTransactions
?.[
hash
]?.
summary
const
pending
=
!
allTransactions
?.[
hash
]?.
receipt
const
success
=
!
pending
&&
(
allTransactions
[
hash
].
receipt
.
status
===
1
||
typeof
allTransactions
[
hash
].
receipt
.
status
===
'
undefined
'
)
return
(
return
(
<
TransactionWrapper
key=
{
hash
}
>
<
TransactionWrapper
key=
{
hash
}
>
...
@@ -82,25 +94,14 @@ export default function Transaction({ hash, pending }: { hash: string; pending:
...
@@ -82,25 +94,14 @@ export default function Transaction({ hash, pending }: { hash: string; pending:
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
{
summary
?
summary
:
hash
}
↗
</
Link
>
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
{
summary
?
summary
:
hash
}
↗
</
Link
>
<
Copy
toCopy=
{
hash
}
/>
<
Copy
toCopy=
{
hash
}
/>
</
TransactionStatusWrapper
>
</
TransactionStatusWrapper
>
{
pending
?
(
<
ButtonWrapper
pending=
{
false
}
success=
{
success
}
>
<
ButtonWrapper
pending=
{
pending
}
>
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
<
TransactionState
pending=
{
pending
}
>
<
Spinner
src=
{
Circle
}
id=
"pending"
/>
<
TransactionStatusText
>
Pending
</
TransactionStatusText
>
</
TransactionState
>
</
Link
>
</
ButtonWrapper
>
)
:
(
<
ButtonWrapper
pending=
{
pending
}
>
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
<
Link
href=
{
getEtherscanLink
(
chainId
,
hash
,
'
transaction
'
)
}
>
<
TransactionState
pending=
{
pending
}
>
<
TransactionState
pending=
{
pending
}
success=
{
success
}
>
<
Check
size=
"16"
/>
{
pending
?
<
Spinner
src=
{
Circle
}
/>
:
success
?
<
Check
size=
"16"
/>
:
<
Triangle
size=
"16"
/>
}
<
TransactionStatusText
>
Confirmed
</
TransactionStatusText
>
<
TransactionStatusText
>
{
pending
?
'
Pending
'
:
success
?
'
Success
'
:
'
Failed
'
}
</
TransactionStatusText
>
</
TransactionState
>
</
TransactionState
>
</
Link
>
</
Link
>
</
ButtonWrapper
>
</
ButtonWrapper
>
)
}
</
TransactionWrapper
>
</
TransactionWrapper
>
)
)
}
}
src/components/AccountDetails/index.tsx
View file @
685bb174
...
@@ -213,11 +213,11 @@ const MainWalletAction = styled(WalletAction)`
...
@@ -213,11 +213,11 @@ const MainWalletAction = styled(WalletAction)`
color:
${({
theme
})
=>
theme
.
primary1
}
;
color:
${({
theme
})
=>
theme
.
primary1
}
;
`
`
function
renderTransactions
(
transactions
,
pending
)
{
function
renderTransactions
(
transactions
)
{
return
(
return
(
<
TransactionListWrapper
>
<
TransactionListWrapper
>
{
transactions
.
map
((
hash
,
i
)
=>
{
{
transactions
.
map
((
hash
,
i
)
=>
{
return
<
Transaction
key=
{
i
}
hash=
{
hash
}
pending=
{
pending
}
/>
return
<
Transaction
key=
{
i
}
hash=
{
hash
}
/>
})
}
})
}
</
TransactionListWrapper
>
</
TransactionListWrapper
>
)
)
...
@@ -381,8 +381,8 @@ export default function AccountDetails({
...
@@ -381,8 +381,8 @@ export default function AccountDetails({
{
!!
pendingTransactions
.
length
||
!!
confirmedTransactions
.
length
?
(
{
!!
pendingTransactions
.
length
||
!!
confirmedTransactions
.
length
?
(
<
LowerSection
>
<
LowerSection
>
<
TYPE
.
body
>
Recent Transactions
</
TYPE
.
body
>
<
TYPE
.
body
>
Recent Transactions
</
TYPE
.
body
>
{
renderTransactions
(
pendingTransactions
,
true
)
}
{
renderTransactions
(
pendingTransactions
)
}
{
renderTransactions
(
confirmedTransactions
,
false
)
}
{
renderTransactions
(
confirmedTransactions
)
}
</
LowerSection
>
</
LowerSection
>
)
:
(
)
:
(
<
LowerSection
>
<
LowerSection
>
...
...
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