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
521f3aae
Unverified
Commit
521f3aae
authored
Apr 29, 2022
by
Jordan Frankfurt
Committed by
GitHub
Apr 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(monitoring): trm cleanup (#3783)
* remove old monitoring code * cleanup * remove unneeded .then
parent
9318c120
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
123 deletions
+12
-123
Copy.tsx
src/components/AccountDetails/Copy.tsx
+2
-2
index.tsx
src/components/TopLevelModals/index.tsx
+2
-2
index.tsx
src/components/WalletModal/index.tsx
+7
-15
useMonitoringEventCallback.ts
src/hooks/useMonitoringEventCallback.ts
+0
-98
hooks.tsx
src/state/transactions/hooks.tsx
+1
-6
No files found.
src/components/AccountDetails/Copy.tsx
View file @
521f3aae
...
@@ -39,6 +39,8 @@ export default function CopyHelper({ color, toCopy, children }: CopyHelperProps)
...
@@ -39,6 +39,8 @@ export default function CopyHelper({ color, toCopy, children }: CopyHelperProps)
return
(
return
(
<
CopyIcon
onClick=
{
copy
}
color=
{
color
}
>
<
CopyIcon
onClick=
{
copy
}
color=
{
color
}
>
{
isCopied
?
''
:
children
}
{
isCopied
?
(
{
isCopied
?
(
<
TransactionStatusText
>
<
TransactionStatusText
>
<
CheckCircle
size=
{
'
12
'
}
/>
<
CheckCircle
size=
{
'
12
'
}
/>
...
@@ -51,8 +53,6 @@ export default function CopyHelper({ color, toCopy, children }: CopyHelperProps)
...
@@ -51,8 +53,6 @@ export default function CopyHelper({ color, toCopy, children }: CopyHelperProps)
<
Copy
size=
{
'
12
'
}
/>
<
Copy
size=
{
'
12
'
}
/>
</
TransactionStatusText
>
</
TransactionStatusText
>
)
}
)
}
{
isCopied
?
''
:
children
}
</
CopyIcon
>
</
CopyIcon
>
)
)
}
}
src/components/TopLevelModals/index.tsx
View file @
521f3aae
...
@@ -13,11 +13,11 @@ export default function TopLevelModals() {
...
@@ -13,11 +13,11 @@ export default function TopLevelModals() {
const
{
account
}
=
useActiveWeb3React
()
const
{
account
}
=
useActiveWeb3React
()
useAccountRiskCheck
(
account
)
useAccountRiskCheck
(
account
)
const
open
=
Boolean
(
blockedAccountModalOpen
&&
account
)
return
(
return
(
<>
<>
<
AddressClaimModal
isOpen=
{
addressClaimOpen
}
onDismiss=
{
addressClaimToggle
}
/>
<
AddressClaimModal
isOpen=
{
addressClaimOpen
}
onDismiss=
{
addressClaimToggle
}
/>
<
ConnectedAccountBlocked
account=
{
account
}
isOpen=
{
Boolean
(
blockedAccountModalOpen
&&
account
)
}
/>
<
ConnectedAccountBlocked
account=
{
account
}
isOpen=
{
open
}
/>
</>
</>
)
)
}
}
src/components/WalletModal/index.tsx
View file @
521f3aae
...
@@ -2,7 +2,6 @@ import { Trans } from '@lingui/macro'
...
@@ -2,7 +2,6 @@ import { Trans } from '@lingui/macro'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
AutoColumn
}
from
'
components/Column
'
import
{
PrivacyPolicy
}
from
'
components/PrivacyPolicy
'
import
{
PrivacyPolicy
}
from
'
components/PrivacyPolicy
'
import
Row
,
{
AutoRow
,
RowBetween
}
from
'
components/Row
'
import
Row
,
{
AutoRow
,
RowBetween
}
from
'
components/Row
'
import
{
useWalletConnectMonitoringEventCallback
}
from
'
hooks/useMonitoringEventCallback
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
useEffect
,
useState
}
from
'
react
'
import
{
ArrowLeft
,
ArrowRight
,
Info
}
from
'
react-feather
'
import
{
ArrowLeft
,
ArrowRight
,
Info
}
from
'
react-feather
'
import
ReactGA
from
'
react-ga4
'
import
ReactGA
from
'
react-ga4
'
...
@@ -151,8 +150,6 @@ export default function WalletModal({
...
@@ -151,8 +150,6 @@ export default function WalletModal({
const
previousAccount
=
usePrevious
(
account
)
const
previousAccount
=
usePrevious
(
account
)
const
logMonitoringEvent
=
useWalletConnectMonitoringEventCallback
()
// close on connection, when logged out before
// close on connection, when logged out before
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
account
&&
!
previousAccount
&&
walletModalOpen
)
{
if
(
account
&&
!
previousAccount
&&
walletModalOpen
)
{
...
@@ -200,18 +197,13 @@ export default function WalletModal({
...
@@ -200,18 +197,13 @@ export default function WalletModal({
}
}
connector
&&
connector
&&
activate
(
connector
,
undefined
,
true
)
activate
(
connector
,
undefined
,
true
).
catch
((
error
)
=>
{
.
then
(
async
()
=>
{
if
(
error
instanceof
UnsupportedChainIdError
)
{
const
walletAddress
=
await
connector
.
getAccount
()
activate
(
connector
)
// a little janky...can't use setError because the connector isn't set
logMonitoringEvent
({
walletAddress
})
}
else
{
})
setPendingError
(
true
)
.
catch
((
error
)
=>
{
}
if
(
error
instanceof
UnsupportedChainIdError
)
{
})
activate
(
connector
)
// a little janky...can't use setError because the connector isn't set
}
else
{
setPendingError
(
true
)
}
})
}
}
// close wallet modal if fortmatic modal is active
// close wallet modal if fortmatic modal is active
...
...
src/hooks/useMonitoringEventCallback.ts
deleted
100644 → 0
View file @
9318c120
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
initializeApp
}
from
'
firebase/app
'
import
{
getDatabase
,
push
,
ref
}
from
'
firebase/database
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useCallback
}
from
'
react
'
import
{
TransactionInfo
,
TransactionType
}
from
'
state/transactions/types
'
type
PartialTransactionResponse
=
Pick
<
TransactionResponse
,
'
hash
'
|
'
v
'
|
'
r
'
|
'
s
'
>
const
SUPPORTED_TRANSACTION_TYPES
=
[
TransactionType
.
ADD_LIQUIDITY_V2_POOL
,
TransactionType
.
ADD_LIQUIDITY_V3_POOL
,
TransactionType
.
CREATE_V3_POOL
,
TransactionType
.
REMOVE_LIQUIDITY_V3
,
TransactionType
.
SWAP
,
]
const
FIREBASE_API_KEY
=
process
.
env
.
REACT_APP_FIREBASE_KEY
const
firebaseEnabled
=
typeof
FIREBASE_API_KEY
!==
'
undefined
'
if
(
firebaseEnabled
)
initializeFirebase
()
function
useMonitoringEventCallback
()
{
const
{
chainId
}
=
useActiveWeb3React
()
return
useCallback
(
async
function
log
(
type
:
string
,
{
transactionResponse
,
walletAddress
,
}:
{
transactionResponse
:
PartialTransactionResponse
;
walletAddress
:
string
|
undefined
}
)
{
if
(
!
firebaseEnabled
)
return
const
db
=
getDatabase
()
if
(
!
walletAddress
)
{
console
.
debug
(
'
Wallet address required to log monitoring events.
'
)
return
}
try
{
push
(
ref
(
db
,
'
trm
'
),
{
chainId
,
origin
:
window
.
location
.
origin
,
timestamp
:
Date
.
now
(),
tx
:
transactionResponse
,
type
,
walletAddress
,
})
}
catch
(
e
)
{
console
.
debug
(
'
Error adding document:
'
,
e
)
}
},
[
chainId
]
)
}
export
function
useTransactionMonitoringEventCallback
()
{
const
{
account
}
=
useActiveWeb3React
()
const
log
=
useMonitoringEventCallback
()
return
useCallback
(
(
info
:
TransactionInfo
,
transactionResponse
:
TransactionResponse
)
=>
{
if
(
SUPPORTED_TRANSACTION_TYPES
.
includes
(
info
.
type
))
{
log
(
TransactionType
[
info
.
type
],
{
transactionResponse
:
(({
hash
,
v
,
r
,
s
}:
PartialTransactionResponse
)
=>
({
hash
,
v
,
r
,
s
}))(
transactionResponse
),
walletAddress
:
account
??
undefined
,
})
}
},
[
account
,
log
]
)
}
export
function
useWalletConnectMonitoringEventCallback
()
{
const
log
=
useMonitoringEventCallback
()
return
useCallback
(
(
walletAddress
)
=>
{
log
(
'
WALLET_CONNECTED
'
,
{
transactionResponse
:
{
hash
:
''
,
r
:
''
,
s
:
''
,
v
:
-
1
},
walletAddress
})
},
[
log
]
)
}
function
initializeFirebase
()
{
initializeApp
({
apiKey
:
process
.
env
.
REACT_APP_FIREBASE_KEY
,
authDomain
:
'
interface-monitoring.firebaseapp.com
'
,
databaseURL
:
'
https://interface-monitoring-default-rtdb.firebaseio.com
'
,
projectId
:
'
interface-monitoring
'
,
storageBucket
:
'
interface-monitoring.appspot.com
'
,
messagingSenderId
:
'
968187720053
'
,
appId
:
'
1:968187720053:web:acedf72dce629d470be33c
'
,
})
}
src/state/transactions/hooks.tsx
View file @
521f3aae
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
{
useTransactionMonitoringEventCallback
}
from
'
hooks/useMonitoringEventCallback
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
state/hooks
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
state/hooks
'
...
@@ -13,8 +12,6 @@ export function useTransactionAdder(): (response: TransactionResponse, info: Tra
...
@@ -13,8 +12,6 @@ export function useTransactionAdder(): (response: TransactionResponse, info: Tra
const
{
chainId
,
account
}
=
useActiveWeb3React
()
const
{
chainId
,
account
}
=
useActiveWeb3React
()
const
dispatch
=
useAppDispatch
()
const
dispatch
=
useAppDispatch
()
const
logMonitoringEvent
=
useTransactionMonitoringEventCallback
()
return
useCallback
(
return
useCallback
(
(
response
:
TransactionResponse
,
info
:
TransactionInfo
)
=>
{
(
response
:
TransactionResponse
,
info
:
TransactionInfo
)
=>
{
if
(
!
account
)
return
if
(
!
account
)
return
...
@@ -25,10 +22,8 @@ export function useTransactionAdder(): (response: TransactionResponse, info: Tra
...
@@ -25,10 +22,8 @@ export function useTransactionAdder(): (response: TransactionResponse, info: Tra
throw
Error
(
'
No transaction hash found.
'
)
throw
Error
(
'
No transaction hash found.
'
)
}
}
dispatch
(
addTransaction
({
hash
,
from
:
account
,
info
,
chainId
}))
dispatch
(
addTransaction
({
hash
,
from
:
account
,
info
,
chainId
}))
logMonitoringEvent
(
info
,
response
)
},
},
[
account
,
chainId
,
dispatch
,
logMonitoringEvent
]
[
account
,
chainId
,
dispatch
]
)
)
}
}
...
...
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