Created
June 3, 2019 02:10
-
-
Save alexytiger/372dccdee5f05f4aac17c7e44b3b40f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable, InjectionToken, Inject } from '@angular/core'; | |
| import { providers } from 'ethers'; | |
| import IpfsHttpClient from 'ipfs-http-client'; | |
| export const ipfsToken = new InjectionToken('The IPFS Token', { | |
| providedIn: 'root', | |
| factory: () => { | |
| try { | |
| return new IpfsHttpClient('ipfs.infura.io', '5001', { | |
| protocol: 'https' | |
| }); | |
| } catch (err) { | |
| console.log('Error', err); | |
| throw new Error('Unable to access IPFS node daemon on Infura network'); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment