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
eeef306b
Unverified
Commit
eeef306b
authored
Jul 10, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(🧦): 🧦
parent
63a491d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
508 additions
and
5 deletions
+508
-5
index.tsx
src/components/Web3Status/index.tsx
+5
-2
unisocks.json
src/constants/abis/unisocks.json
+471
-0
useContract.ts
src/hooks/useContract.ts
+13
-3
useSocksBalance.ts
src/hooks/useSocksBalance.ts
+19
-0
No files found.
src/components/Web3Status/index.tsx
View file @
eeef306b
...
@@ -5,6 +5,7 @@ import { useWeb3React, UnsupportedChainIdError } from '@web3-react/core'
...
@@ -5,6 +5,7 @@ import { useWeb3React, UnsupportedChainIdError } from '@web3-react/core'
import
{
darken
,
lighten
}
from
'
polished
'
import
{
darken
,
lighten
}
from
'
polished
'
import
{
Activity
}
from
'
react-feather
'
import
{
Activity
}
from
'
react-feather
'
import
useENSName
from
'
../../hooks/useENSName
'
import
useENSName
from
'
../../hooks/useENSName
'
import
{
useHasSocks
}
from
'
../../hooks/useSocksBalance
'
import
{
useWalletModalToggle
}
from
'
../../state/application/hooks
'
import
{
useWalletModalToggle
}
from
'
../../state/application/hooks
'
import
{
TransactionDetails
}
from
'
../../state/transactions/reducer
'
import
{
TransactionDetails
}
from
'
../../state/transactions/reducer
'
...
@@ -143,7 +144,7 @@ export default function Web3Status() {
...
@@ -143,7 +144,7 @@ export default function Web3Status() {
const
confirmed
=
sortedRecentTransactions
.
filter
(
tx
=>
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
const
confirmed
=
sortedRecentTransactions
.
filter
(
tx
=>
tx
.
receipt
).
map
(
tx
=>
tx
.
hash
)
const
hasPendingTransactions
=
!!
pending
.
length
const
hasPendingTransactions
=
!!
pending
.
length
const
hasSocks
=
useHasSocks
()
const
toggleWalletModal
=
useWalletModalToggle
()
const
toggleWalletModal
=
useWalletModalToggle
()
// handle the logo we want to show with the account
// handle the logo we want to show with the account
...
@@ -186,7 +187,9 @@ export default function Web3Status() {
...
@@ -186,7 +187,9 @@ export default function Web3Status() {
<
Text
>
{
pending
?.
length
}
Pending
</
Text
>
<
Loader
stroke=
"white"
/>
<
Text
>
{
pending
?.
length
}
Pending
</
Text
>
<
Loader
stroke=
"white"
/>
</
RowBetween
>
</
RowBetween
>
)
:
(
)
:
(
<
Text
>
{
ENSName
||
shortenAddress
(
account
)
}
</
Text
>
<
Text
>
{
hasSocks
?
'
🧦
'
:
''
}
{
ENSName
||
shortenAddress
(
account
)
}
</
Text
>
)
}
)
}
{
!
hasPendingTransactions
&&
getStatusIcon
()
}
{
!
hasPendingTransactions
&&
getStatusIcon
()
}
</
Web3StatusConnected
>
</
Web3StatusConnected
>
...
...
src/constants/abis/unisocks.json
0 → 100644
View file @
eeef306b
[
{
"name"
:
"Transfer"
,
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_from"
,
"indexed"
:
true
},
{
"type"
:
"address"
,
"name"
:
"_to"
,
"indexed"
:
true
},
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
,
"indexed"
:
true
}
],
"anonymous"
:
false
,
"type"
:
"event"
},
{
"name"
:
"Approval"
,
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_owner"
,
"indexed"
:
true
},
{
"type"
:
"address"
,
"name"
:
"_approved"
,
"indexed"
:
true
},
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
,
"indexed"
:
true
}
],
"anonymous"
:
false
,
"type"
:
"event"
},
{
"name"
:
"ApprovalForAll"
,
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_owner"
,
"indexed"
:
true
},
{
"type"
:
"address"
,
"name"
:
"_operator"
,
"indexed"
:
true
},
{
"type"
:
"bool"
,
"name"
:
"_approved"
,
"indexed"
:
false
}
],
"anonymous"
:
false
,
"type"
:
"event"
},
{
"outputs"
:
[],
"inputs"
:
[],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"constructor"
},
{
"name"
:
"tokenURI"
,
"outputs"
:
[
{
"type"
:
"string"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
22405
},
{
"name"
:
"tokenByIndex"
,
"outputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"_index"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
631
},
{
"name"
:
"tokenOfOwnerByIndex"
,
"outputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_owner"
},
{
"type"
:
"uint256"
,
"name"
:
"_index"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
1248
},
{
"name"
:
"transferFrom"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_from"
},
{
"type"
:
"address"
,
"name"
:
"_to"
},
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
259486
},
{
"name"
:
"safeTransferFrom"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_from"
},
{
"type"
:
"address"
,
"name"
:
"_to"
},
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
},
{
"name"
:
"safeTransferFrom"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_from"
},
{
"type"
:
"address"
,
"name"
:
"_to"
},
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
},
{
"type"
:
"bytes"
,
"name"
:
"_data"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
},
{
"name"
:
"approve"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_approved"
},
{
"type"
:
"uint256"
,
"name"
:
"_tokenId"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
38422
},
{
"name"
:
"setApprovalForAll"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_operator"
},
{
"type"
:
"bool"
,
"name"
:
"_approved"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
38016
},
{
"name"
:
"mint"
,
"outputs"
:
[
{
"type"
:
"bool"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_to"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
182636
},
{
"name"
:
"changeMinter"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_minter"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
35897
},
{
"name"
:
"changeURI"
,
"outputs"
:
[],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"_newURI"
}
],
"constant"
:
false
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
35927
},
{
"name"
:
"name"
,
"outputs"
:
[
{
"type"
:
"string"
,
"name"
:
"out"
}
],
"inputs"
:
[],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
6612
},
{
"name"
:
"symbol"
,
"outputs"
:
[
{
"type"
:
"string"
,
"name"
:
"out"
}
],
"inputs"
:
[],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
6642
},
{
"name"
:
"totalSupply"
,
"outputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"out"
}
],
"inputs"
:
[],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
873
},
{
"name"
:
"minter"
,
"outputs"
:
[
{
"type"
:
"address"
,
"name"
:
"out"
}
],
"inputs"
:
[],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
903
},
{
"name"
:
"socks"
,
"outputs"
:
[
{
"type"
:
"address"
,
"name"
:
"out"
,
"unit"
:
"Socks"
}
],
"inputs"
:
[],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
933
},
{
"name"
:
"newURI"
,
"outputs"
:
[
{
"type"
:
"address"
,
"name"
:
"out"
}
],
"inputs"
:
[],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
963
},
{
"name"
:
"ownerOf"
,
"outputs"
:
[
{
"type"
:
"address"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"arg0"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
1126
},
{
"name"
:
"balanceOf"
,
"outputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"arg0"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
1195
},
{
"name"
:
"getApproved"
,
"outputs"
:
[
{
"type"
:
"address"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"uint256"
,
"name"
:
"arg0"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
1186
},
{
"name"
:
"isApprovedForAll"
,
"outputs"
:
[
{
"type"
:
"bool"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"address"
,
"name"
:
"arg0"
},
{
"type"
:
"address"
,
"name"
:
"arg1"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
1415
},
{
"name"
:
"supportsInterface"
,
"outputs"
:
[
{
"type"
:
"bool"
,
"name"
:
"out"
}
],
"inputs"
:
[
{
"type"
:
"bytes32"
,
"name"
:
"arg0"
}
],
"constant"
:
true
,
"payable"
:
false
,
"type"
:
"function"
,
"gas"
:
1246
}
]
\ No newline at end of file
src/hooks/useContract.ts
View file @
eeef306b
...
@@ -3,10 +3,11 @@ import { ChainId } from '@uniswap/sdk'
...
@@ -3,10 +3,11 @@ import { ChainId } from '@uniswap/sdk'
import
{
abi
as
IUniswapV2PairABI
}
from
'
@uniswap/v2-core/build/IUniswapV2Pair.json
'
import
{
abi
as
IUniswapV2PairABI
}
from
'
@uniswap/v2-core/build/IUniswapV2Pair.json
'
import
{
useMemo
}
from
'
react
'
import
{
useMemo
}
from
'
react
'
import
{
ERC20_BYTES32_ABI
}
from
'
../constants/abis/erc20
'
import
{
ERC20_BYTES32_ABI
}
from
'
../constants/abis/erc20
'
import
UNISOCKS_ABI
from
'
../constants/abis/unisocks.json
'
import
ERC20_ABI
from
'
../constants/abis/erc20.json
'
import
ERC20_ABI
from
'
../constants/abis/erc20.json
'
import
{
MIGRATOR_ABI
,
MIGRATOR_ADDRESS
}
from
'
../constants/abis/migrator
'
import
{
MIGRATOR_ABI
,
MIGRATOR_ADDRESS
}
from
'
../constants/abis/migrator
'
import
{
V1_EXCHANGE_ABI
,
V1_FACTORY_ABI
,
V1_FACTORY_ADDRESSES
}
from
'
../constants/v1
'
import
{
MULTICALL_ABI
,
MULTICALL_NETWORKS
}
from
'
../constants/multicall
'
import
{
MULTICALL_ABI
,
MULTICALL_NETWORKS
}
from
'
../constants/multicall
'
import
{
V1_EXCHANGE_ABI
,
V1_FACTORY_ABI
,
V1_FACTORY_ADDRESSES
}
from
'
../constants/v1
'
import
{
getContract
}
from
'
../utils
'
import
{
getContract
}
from
'
../utils
'
import
{
useActiveWeb3React
}
from
'
./index
'
import
{
useActiveWeb3React
}
from
'
./index
'
...
@@ -27,7 +28,7 @@ function useContract(address?: string, ABI?: any, withSignerIfPossible = true):
...
@@ -27,7 +28,7 @@ function useContract(address?: string, ABI?: any, withSignerIfPossible = true):
export
function
useV1FactoryContract
():
Contract
|
null
{
export
function
useV1FactoryContract
():
Contract
|
null
{
const
{
chainId
}
=
useActiveWeb3React
()
const
{
chainId
}
=
useActiveWeb3React
()
return
useContract
(
V1_FACTORY_ADDRESSES
[
chainId
as
C
hainId
],
V1_FACTORY_ABI
,
false
)
return
useContract
(
chainId
&&
V1_FACTORY_ADDRESSES
[
c
hainId
],
V1_FACTORY_ABI
,
false
)
}
}
export
function
useV2MigratorContract
():
Contract
|
null
{
export
function
useV2MigratorContract
():
Contract
|
null
{
...
@@ -52,5 +53,14 @@ export function usePairContract(pairAddress?: string, withSignerIfPossible?: boo
...
@@ -52,5 +53,14 @@ export function usePairContract(pairAddress?: string, withSignerIfPossible?: boo
export
function
useMulticallContract
():
Contract
|
null
{
export
function
useMulticallContract
():
Contract
|
null
{
const
{
chainId
}
=
useActiveWeb3React
()
const
{
chainId
}
=
useActiveWeb3React
()
return
useContract
(
MULTICALL_NETWORKS
[
chainId
as
ChainId
],
MULTICALL_ABI
,
false
)
return
useContract
(
chainId
&&
MULTICALL_NETWORKS
[
chainId
],
MULTICALL_ABI
,
false
)
}
export
function
useSocksController
():
Contract
|
null
{
const
{
chainId
}
=
useActiveWeb3React
()
return
useContract
(
chainId
===
ChainId
.
MAINNET
?
'
0x65770b5283117639760beA3F867b69b3697a91dd
'
:
undefined
,
UNISOCKS_ABI
,
false
)
}
}
src/hooks/useSocksBalance.ts
0 → 100644
View file @
eeef306b
import
{
JSBI
}
from
'
@uniswap/sdk
'
import
{
useMemo
}
from
'
react
'
import
{
useSingleCallResult
}
from
'
../state/multicall/hooks
'
import
{
useActiveWeb3React
}
from
'
./index
'
import
{
useSocksController
}
from
'
./useContract
'
export
default
function
useSocksBalance
():
JSBI
|
undefined
{
const
{
account
}
=
useActiveWeb3React
()
const
socksContract
=
useSocksController
()
const
{
result
}
=
useSingleCallResult
(
socksContract
,
'
balanceOf
'
,
[
account
??
undefined
],
{
blocksPerFetch
:
100
})
const
data
=
result
?.[
0
]
return
data
?
JSBI
.
BigInt
(
data
.
toString
())
:
undefined
}
export
function
useHasSocks
():
boolean
|
undefined
{
const
balance
=
useSocksBalance
()
return
useMemo
(()
=>
balance
&&
JSBI
.
greaterThan
(
balance
,
JSBI
.
BigInt
(
0
)),
[
balance
])
}
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