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
51e929bd
Unverified
Commit
51e929bd
authored
May 16, 2020
by
Moody Salem
Committed by
GitHub
May 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clear all transactions (#778)
parent
af892c1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
index.tsx
src/components/AccountDetails/index.tsx
+18
-2
actions.ts
src/state/transactions/actions.ts
+1
-0
reducer.ts
src/state/transactions/reducer.ts
+11
-1
No files found.
src/components/AccountDetails/index.tsx
View file @
51e929bd
import
React
,
{
useContext
}
from
'
react
'
import
React
,
{
useCallback
,
useContext
}
from
'
react
'
import
{
useDispatch
}
from
'
react-redux
'
import
styled
,
{
ThemeContext
}
from
'
styled-components
'
import
styled
,
{
ThemeContext
}
from
'
styled-components
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
{
isMobile
}
from
'
react-device-detect
'
import
{
isMobile
}
from
'
react-device-detect
'
import
{
AppDispatch
}
from
'
../../state
'
import
{
clearAllTransactions
}
from
'
../../state/transactions/actions
'
import
{
AutoRow
}
from
'
../Row
'
import
Copy
from
'
./Copy
'
import
Copy
from
'
./Copy
'
import
Transaction
from
'
./Transaction
'
import
Transaction
from
'
./Transaction
'
...
@@ -240,6 +244,7 @@ export default function AccountDetails({
...
@@ -240,6 +244,7 @@ export default function AccountDetails({
}:
AccountDetailsProps
)
{
}:
AccountDetailsProps
)
{
const
{
chainId
,
account
,
connector
}
=
useWeb3React
()
const
{
chainId
,
account
,
connector
}
=
useWeb3React
()
const
theme
=
useContext
(
ThemeContext
)
const
theme
=
useContext
(
ThemeContext
)
const
dispatch
=
useDispatch
<
AppDispatch
>
()
function
formatConnectorName
()
{
function
formatConnectorName
()
{
const
{
ethereum
}
=
window
const
{
ethereum
}
=
window
...
@@ -296,6 +301,14 @@ export default function AccountDetails({
...
@@ -296,6 +301,14 @@ export default function AccountDetails({
}
}
}
}
const
clearAllTransactionsCallback
=
useCallback
(
(
event
:
React
.
MouseEvent
)
=>
{
event
.
preventDefault
()
dispatch
(
clearAllTransactions
({
chainId
}))
},
[
dispatch
,
chainId
]
)
return
(
return
(
<>
<>
<
UpperSection
>
<
UpperSection
>
...
@@ -380,7 +393,10 @@ export default function AccountDetails({
...
@@ -380,7 +393,10 @@ export default function AccountDetails({
</
UpperSection
>
</
UpperSection
>
{
!!
pendingTransactions
.
length
||
!!
confirmedTransactions
.
length
?
(
{
!!
pendingTransactions
.
length
||
!!
confirmedTransactions
.
length
?
(
<
LowerSection
>
<
LowerSection
>
<
TYPE
.
body
>
Recent Transactions
</
TYPE
.
body
>
<
AutoRow
style=
{
{
justifyContent
:
'
space-between
'
}
}
>
<
TYPE
.
body
>
Recent Transactions
</
TYPE
.
body
>
<
Link
onClick=
{
clearAllTransactionsCallback
}
>
(clear all)
</
Link
>
</
AutoRow
>
{
renderTransactions
(
pendingTransactions
)
}
{
renderTransactions
(
pendingTransactions
)
}
{
renderTransactions
(
confirmedTransactions
)
}
{
renderTransactions
(
confirmedTransactions
)
}
</
LowerSection
>
</
LowerSection
>
...
...
src/state/transactions/actions.ts
View file @
51e929bd
...
@@ -19,6 +19,7 @@ export const addTransaction = createAction<{
...
@@ -19,6 +19,7 @@ export const addTransaction = createAction<{
summary
?:
string
summary
?:
string
}
>
(
'
addTransaction
'
)
}
>
(
'
addTransaction
'
)
export
const
checkTransaction
=
createAction
<
{
chainId
:
number
;
hash
:
string
;
blockNumber
:
number
}
>
(
'
checkTransaction
'
)
export
const
checkTransaction
=
createAction
<
{
chainId
:
number
;
hash
:
string
;
blockNumber
:
number
}
>
(
'
checkTransaction
'
)
export
const
clearAllTransactions
=
createAction
<
{
chainId
:
number
}
>
(
'
clearAllTransactions
'
)
export
const
finalizeTransaction
=
createAction
<
{
export
const
finalizeTransaction
=
createAction
<
{
chainId
:
number
chainId
:
number
hash
:
string
hash
:
string
...
...
src/state/transactions/reducer.ts
View file @
51e929bd
import
{
createReducer
}
from
'
@reduxjs/toolkit
'
import
{
createReducer
}
from
'
@reduxjs/toolkit
'
import
{
addTransaction
,
checkTransaction
,
finalizeTransaction
,
SerializableTransactionReceipt
}
from
'
./actions
'
import
{
addTransaction
,
checkTransaction
,
clearAllTransactions
,
finalizeTransaction
,
SerializableTransactionReceipt
}
from
'
./actions
'
const
now
=
()
=>
new
Date
().
getTime
()
const
now
=
()
=>
new
Date
().
getTime
()
...
@@ -34,6 +40,10 @@ export default createReducer(initialState, builder =>
...
@@ -34,6 +40,10 @@ export default createReducer(initialState, builder =>
state
[
chainId
]
=
state
[
chainId
]
??
{}
state
[
chainId
]
=
state
[
chainId
]
??
{}
state
[
chainId
][
hash
]
=
{
hash
,
approvalOfToken
,
summary
,
from
,
addedTime
:
now
()
}
state
[
chainId
][
hash
]
=
{
hash
,
approvalOfToken
,
summary
,
from
,
addedTime
:
now
()
}
})
})
.
addCase
(
clearAllTransactions
,
(
state
,
{
payload
:
{
chainId
}
})
=>
{
if
(
!
state
[
chainId
])
return
state
[
chainId
]
=
{}
})
.
addCase
(
checkTransaction
,
(
state
,
{
payload
:
{
chainId
,
blockNumber
,
hash
}
})
=>
{
.
addCase
(
checkTransaction
,
(
state
,
{
payload
:
{
chainId
,
blockNumber
,
hash
}
})
=>
{
if
(
!
state
[
chainId
]?.[
hash
])
{
if
(
!
state
[
chainId
]?.[
hash
])
{
throw
Error
(
'
Attempted to check non-existent transaction.
'
)
throw
Error
(
'
Attempted to check non-existent transaction.
'
)
...
...
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