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
6fc31579
Unverified
Commit
6fc31579
authored
May 29, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(strict): strict connectors directory
parent
9c1fe53e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
9 deletions
+30
-9
Fortmatic.ts
src/connectors/Fortmatic.ts
+17
-7
fortmatic.d.ts
src/connectors/fortmatic.d.ts
+1
-0
index.ts
src/connectors/index.ts
+8
-2
tsconfig.json
src/connectors/tsconfig.json
+4
-0
No files found.
src/connectors/Fortmatic.ts
View file @
6fc31579
import
{
ChainId
}
from
'
@uniswap/sdk
'
import
{
FortmaticConnector
as
FortmaticConnectorCore
}
from
'
@web3-react/fortmatic-connector
'
export
const
OVERLAY_READY
=
'
OVERLAY_READY
'
const
chainIdToNetwork
=
{
1
:
'
mainnet
'
,
3
:
'
ropsten
'
,
4
:
'
rinkeby
'
,
42
:
'
kovan
'
type
FormaticSupportedChains
=
Extract
<
ChainId
,
ChainId
.
MAINNET
|
ChainId
.
ROPSTEN
|
ChainId
.
RINKEBY
|
ChainId
.
KOVAN
>
const
CHAIN_ID_NETWORK_ARGUMENT
:
{
readonly
[
chainId
in
FormaticSupportedChains
]:
string
|
undefined
}
=
{
[
ChainId
.
MAINNET
]:
undefined
,
[
ChainId
.
ROPSTEN
]:
'
ropsten
'
,
[
ChainId
.
RINKEBY
]:
'
rinkeby
'
,
[
ChainId
.
KOVAN
]:
'
kovan
'
}
export
class
FortmaticConnector
extends
FortmaticConnectorCore
{
...
...
@@ -14,7 +17,11 @@ export class FortmaticConnector extends FortmaticConnectorCore {
if
(
!
this
.
fortmatic
)
{
const
{
default
:
Fortmatic
}
=
await
import
(
'
fortmatic
'
)
const
{
apiKey
,
chainId
}
=
this
as
any
this
.
fortmatic
=
new
Fortmatic
(
apiKey
,
chainId
===
1
||
chainId
===
4
?
undefined
:
chainIdToNetwork
[
chainId
])
if
(
chainId
in
CHAIN_ID_NETWORK_ARGUMENT
)
{
this
.
fortmatic
=
new
Fortmatic
(
apiKey
,
CHAIN_ID_NETWORK_ARGUMENT
[
chainId
as
FormaticSupportedChains
])
}
else
{
throw
new
Error
(
`Unsupported network ID:
${
chainId
}
`
)
}
}
const
provider
=
this
.
fortmatic
.
getProvider
()
...
...
@@ -29,7 +36,10 @@ export class FortmaticConnector extends FortmaticConnectorCore {
},
200
)
})
const
[
account
]
=
await
Promise
.
all
([
provider
.
enable
().
then
(
accounts
=>
accounts
[
0
]),
pollForOverlayReady
])
const
[
account
]
=
await
Promise
.
all
([
provider
.
enable
().
then
((
accounts
:
string
[])
=>
accounts
[
0
]),
pollForOverlayReady
])
return
{
provider
:
this
.
fortmatic
.
getProvider
(),
chainId
:
(
this
as
any
).
chainId
,
account
}
}
...
...
src/connectors/fortmatic.d.ts
0 → 100644
View file @
6fc31579
declare
module
'
formatic
'
src/connectors/index.ts
View file @
6fc31579
...
...
@@ -8,6 +8,12 @@ import { FortmaticConnector } from './Fortmatic'
const
POLLING_INTERVAL
=
10000
const
NETWORK_URL
=
process
.
env
.
REACT_APP_NETWORK_URL
const
FORMATIC_KEY
=
process
.
env
.
REACT_APP_FORTMATIC_KEY
const
PORTIS_ID
=
process
.
env
.
REACT_APP_PORTIS_ID
if
(
typeof
NETWORK_URL
===
'
undefined
'
)
{
throw
new
Error
(
`REACT_APP_NETWORK_URL must be a defined environment variable`
)
}
export
const
network
=
new
NetworkConnector
({
urls
:
{
[
Number
(
process
.
env
.
REACT_APP_CHAIN_ID
)]:
NETWORK_URL
},
...
...
@@ -28,13 +34,13 @@ export const walletconnect = new WalletConnectConnector({
// mainnet only
export
const
fortmatic
=
new
FortmaticConnector
({
apiKey
:
process
.
env
.
REACT_APP_FORTMATIC_KEY
,
apiKey
:
FORMATIC_KEY
??
''
,
chainId
:
1
})
// mainnet only
export
const
portis
=
new
PortisConnector
({
dAppId
:
process
.
env
.
REACT_APP_PORTIS_ID
,
dAppId
:
PORTIS_ID
??
''
,
networks
:
[
1
]
})
...
...
src/connectors/tsconfig.json
0 → 100644
View file @
6fc31579
{
"extends"
:
"../../tsconfig.strict.json"
,
"include"
:
[
"**/*"
]
}
\ No newline at end of file
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