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
c7f0af69
Unverified
Commit
c7f0af69
authored
Nov 15, 2022
by
vignesh mohankumar
Committed by
GitHub
Nov 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove unused nft utils (#5239)
parent
49b09148
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
0 additions
and
209 deletions
+0
-209
address.ts
src/nft/utils/address.ts
+0
-4
claimLooks.ts
src/nft/utils/claimLooks.ts
+0
-48
colors.ts
src/nft/utils/colors.ts
+0
-19
eu-timezones.ts
src/nft/utils/eu-timezones.ts
+0
-72
groupBy.ts
src/nft/utils/groupBy.ts
+0
-6
isAssetOwnedByUser.ts
src/nft/utils/isAssetOwnedByUser.ts
+0
-25
isIPhoneOrSafari.ts
src/nft/utils/isIPhoneOrSafari.ts
+0
-11
numbers.ts
src/nft/utils/numbers.ts
+0
-7
rarity.ts
src/nft/utils/rarity.ts
+0
-1
shortenId.ts
src/nft/utils/shortenId.ts
+0
-3
uniqBy.ts
src/nft/utils/uniqBy.ts
+0
-13
No files found.
src/nft/utils/address.ts
View file @
c7f0af69
...
...
@@ -13,7 +13,3 @@ export function shortenAddress(address: string, charsStart = 4, charsEnd?: numbe
return
`
${
address
.
substring
(
0
,
charsStart
+
2
)}
...
${
address
.
substring
(
42
-
(
charsEnd
||
charsStart
))}
`
}
export
function
shortenEnsName
(
name
?:
string
):
string
|
undefined
{
return
!
name
||
name
.
length
<=
12
?
name
:
`
${
name
.
substring
(
0
,
6
)}
...eth`
}
src/nft/utils/claimLooks.ts
deleted
100644 → 0
View file @
49b09148
import
{
Signer
}
from
'
@ethersproject/abstract-signer
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
type
{
BaseProvider
}
from
'
@ethersproject/providers
'
const
looksRareContract
=
new
Contract
(
'
0xea37093ce161f090e443f304e1bf3a8f14d7bb40
'
,
[
{
anonymous
:
false
,
inputs
:
[
{
indexed
:
true
,
internalType
:
'
address
'
,
name
:
'
user
'
,
type
:
'
address
'
},
{
indexed
:
true
,
internalType
:
'
uint256
'
,
name
:
'
rewardRound
'
,
type
:
'
uint256
'
},
{
indexed
:
false
,
internalType
:
'
uint256
'
,
name
:
'
amount
'
,
type
:
'
uint256
'
},
],
name
:
'
RewardsClaim
'
,
type
:
'
event
'
,
},
{
inputs
:
[
{
internalType
:
'
uint256
'
,
name
:
'
amount
'
,
type
:
'
uint256
'
},
{
internalType
:
'
bytes32[]
'
,
name
:
'
merkleProof
'
,
type
:
'
bytes32[]
'
},
],
name
:
'
claim
'
,
outputs
:
[],
stateMutability
:
'
nonpayable
'
,
type
:
'
function
'
,
},
{
inputs
:
[{
internalType
:
'
address
'
,
name
:
''
,
type
:
'
address
'
}],
name
:
'
amountClaimedByUser
'
,
outputs
:
[{
internalType
:
'
uint256
'
,
name
:
''
,
type
:
'
uint256
'
}],
stateMutability
:
'
view
'
,
type
:
'
function
'
,
},
])
export
const
getClaimedAmount
=
async
({
address
,
provider
}:
{
address
:
string
;
provider
:
BaseProvider
})
=>
provider
&&
(
await
looksRareContract
.
connect
(
provider
).
amountClaimedByUser
(
address
))
export
const
claimLooks
=
async
({
signer
,
looksTotal
,
proof
,
}:
{
signer
:
Signer
looksTotal
:
string
proof
:
string
[]
})
=>
{
await
looksRareContract
.
connect
(
signer
).
functions
.
claim
(
looksTotal
,
proof
)
}
src/nft/utils/colors.ts
View file @
c7f0af69
export
const
foregrounds
=
[
'
#001FAA
'
,
'
#5D31FF
'
,
'
#8EC3E4
'
,
'
#F10B00
'
,
'
#E843D3
'
,
'
#C4B5FC
'
,
'
#F88DD5
'
]
export
const
backgrounds
=
[
'
#5DCCB9
'
,
'
#9AFBCF
'
,
'
#D1F8E7
'
,
'
#73F54B
'
,
'
#D3FB51
'
,
'
#FCF958
'
]
export
function
hashCode
(
text
:
string
)
{
let
hash
=
0
if
(
text
.
length
===
0
)
return
hash
for
(
let
i
=
0
;
i
<
text
.
length
;
i
++
)
{
const
chr
=
text
.
charCodeAt
(
i
)
hash
=
(
hash
<<
3
)
-
hash
+
chr
hash
|=
0
}
return
hash
}
export
function
addressToHashedColor
(
colors
:
string
[],
address
:
string
|
null
):
string
|
undefined
{
if
(
address
==
null
)
return
undefined
return
colors
[
Math
.
abs
(
hashCode
(
address
.
toLowerCase
())
%
colors
.
length
)]
}
src/nft/utils/eu-timezones.ts
deleted
100644 → 0
View file @
49b09148
export
function
consentRequired
(
tz
:
string
):
boolean
{
switch
(
tz
)
{
case
'
Europe/Vienna
'
:
return
true
case
'
Europe/Brussels
'
:
return
true
case
'
Europe/Sofia
'
:
return
true
case
'
Europe/Zagreb
'
:
return
true
case
'
Asia/Famagusta
'
:
return
true
case
'
Asia/Nicosia
'
:
return
true
case
'
Europe/Prague
'
:
return
true
case
'
Europe/Copenhagen
'
:
return
true
case
'
Europe/Tallinn
'
:
return
true
case
'
Europe/Helsinki
'
:
return
true
case
'
Europe/Paris
'
:
return
true
case
'
Europe/Berlin
'
:
return
true
case
'
Europe/Busingen
'
:
return
true
case
'
Europe/Athens
'
:
return
true
case
'
Europe/Budapest
'
:
return
true
case
'
Europe/Dublin
'
:
return
true
case
'
Europe/Rome
'
:
return
true
case
'
Europe/Riga
'
:
return
true
case
'
Europe/Vilnius
'
:
return
true
case
'
Europe/Luxembourg
'
:
return
true
case
'
Europe/Malta
'
:
return
true
case
'
Europe/Amsterdam
'
:
return
true
case
'
Europe/Warsaw
'
:
return
true
case
'
Atlantic/Azores
'
:
return
true
case
'
Atlantic/Madeira
'
:
return
true
case
'
Europe/Lisbon
'
:
return
true
case
'
Europe/Bucharest
'
:
return
true
case
'
Europe/Bratislava
'
:
return
true
case
'
Europe/Ljubljana
'
:
return
true
case
'
Africa/Ceuta
'
:
return
true
case
'
Atlantic/Canary
'
:
return
true
case
'
Europe/Madrid
'
:
return
true
case
'
Europe/Stockholm
'
:
return
true
default
:
return
false
}
}
src/nft/utils/groupBy.ts
deleted
100644 → 0
View file @
49b09148
export
const
groupBy
=
<
T
>
(
xs
:
T
[],
key
:
string
)
=>
{
return
xs
.
reduce
((
rv
:
any
,
x
:
any
)
=>
{
;(
rv
[
x
[
key
]]
=
rv
[
x
[
key
]]
||
[]).
push
(
x
)
return
rv
},
{})
}
src/nft/utils/isAssetOwnedByUser.ts
deleted
100644 → 0
View file @
49b09148
import
{
Provider
}
from
'
@ethersproject/abstract-provider
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
ERC721
from
'
../../abis/erc721.json
'
import
{
TokenType
}
from
'
../types
'
export
const
isAssetOwnedByUser
=
async
({
tokenId
,
assetAddress
,
userAddress
,
tokenType
,
provider
,
}:
{
tokenId
:
string
assetAddress
:
string
userAddress
:
string
tokenType
:
TokenType
provider
:
Provider
})
=>
{
if
(
tokenType
===
TokenType
.
ERC721
)
{
const
c
=
new
Contract
(
assetAddress
,
ERC721
,
provider
)
return
(
await
c
.
functions
.
ownerOf
(
tokenId
))
===
userAddress
}
else
return
false
}
src/nft/utils/isIPhoneOrSafari.ts
deleted
100644 → 0
View file @
49b09148
const
iOSDevices
=
[
'
iPhone
'
,
'
iPad
'
,
'
iPod
'
,
'
iPhone Simulator
'
,
'
iPod Simulator
'
,
'
iPad Simulator
'
]
export
const
isIPhoneOrSafari
=
()
=>
{
const
uA
=
navigator
.
userAgent
const
vendor
=
navigator
.
vendor
const
platform
=
navigator
.
platform
return
(
iOSDevices
.
includes
(
platform
)
||
(
/Safari/i
.
test
(
uA
)
&&
/Apple Computer/
.
test
(
vendor
)
&&
!
/Mobi|Android/i
.
test
(
uA
))
)
}
src/nft/utils/numbers.ts
View file @
c7f0af69
...
...
@@ -6,13 +6,6 @@ export const isNumber = (s: string): boolean => {
return
reg
.
test
(
s
)
&&
!
isNaN
(
parseFloat
(
s
))
&&
isFinite
(
parseFloat
(
s
))
}
export
const
formatPercentage
=
(
percentage
:
string
):
string
=>
{
if
(
!
percentage
)
return
'
-
'
return
`
${
parseFloat
(
percentage
)
.
toFixed
(
2
)
.
replace
(
/
\B(?=(\d{3})
+
(?!\d))
/g
,
'
,
'
)}
%`
}
export
const
floorFormatter
=
(
n
:
number
):
string
=>
{
if
(
n
===
0
)
return
'
0.00
'
if
(
!
n
)
return
''
...
...
src/nft/utils/rarity.ts
View file @
c7f0af69
// change this if we change the fallback provider
export
const
fallbackProvider
=
'
PopRank
'
export
const
shouldLinkToFallbackProvider
=
false
export
const
fallbackProviderLogo
=
'
/nft/logos/poprank.png
'
/**
...
...
src/nft/utils/shortenId.ts
deleted
100644 → 0
View file @
49b09148
export
const
shortenId
=
(
id
:
string
,
chars
=
4
)
=>
{
return
id
.
length
>
chars
*
2
+
3
?
`
${
id
.
substring
(
0
,
chars
)}
...
${
id
.
substring
(
id
.
length
-
chars
)}
`
:
id
}
src/nft/utils/uniqBy.ts
deleted
100644 → 0
View file @
49b09148
export
function
uniqBy
<
T
>
(
arr
:
T
[],
key
:
keyof
T
)
{
const
seen
=
new
Set
()
return
arr
.
filter
((
it
)
=>
{
const
val
=
it
[
key
]
if
(
seen
.
has
(
val
))
{
return
false
}
else
{
seen
.
add
(
val
)
return
true
}
})
}
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