-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapolloClient.js
More file actions
36 lines (28 loc) · 1 KB
/
apolloClient.js
File metadata and controls
36 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { ApolloClient } from 'apollo-client'
import { ApolloLink } from 'apollo-link'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { withClientState } from 'apollo-link-state'
import { EthereumLink } from 'apollo-link-ethereum'
import { EthersResolver } from 'apollo-link-ethereum-resolver-ethersjs'
import { AbiMapping } from 'apollo-link-ethereum'
import { ethers } from 'ethers'
import mkrAbi from './mkrAbi'
export const abiMapping = new AbiMapping()
abiMapping.addAbi('MKR', mkrAbi)
abiMapping.addAddress('MKR', 1, '0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2')
window.abiMapping = abiMapping
const provider = new ethers.getDefaultProvider('homestead')
window.provider = provider
const ethersResolver = new EthersResolver({
abiMapping,
provider
})
const ethereumLink = new EthereumLink(ethersResolver)
const cache = new InMemoryCache()
const stateLink = withClientState({
cache
})
export const apolloClient = new ApolloClient({
cache,
link: ApolloLink.from([stateLink, ethereumLink])
})