This file contains 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 { Store } from './store'; | |
export type StoreConfigOptions = { | |
name: string; | |
idKey?: string; | |
initialState?: any | |
}; | |
export interface Type<T> extends Function { | |
new (...args: any[]): T; |
This file contains 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
export type StoreConfigOptions = { | |
name: string; | |
idKey?: string; | |
initialState?: any | |
}; | |
export interface Type<T> extends Function { | |
new (...args: any[]): T; | |
} |
This file contains 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
module.exports = { | |
node: { | |
crypto: true, | |
http: true, | |
https: true, | |
os: true, | |
vm: true, | |
stream: true, | |
fs: 'empty', | |
child_process: 'empty' |
This file contains 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 { WEB3 } from './web3'; | |
import { Component, OnInit, Inject } from '@angular/core'; | |
import { ThreeBox } from './3box/3box.service'; | |
@Component({ | |
selector: 'app-root', | |
template: '<p>3Box and Angular</p>' | |
}) | |
export class AppComponent implements OnInit { |
This file contains 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
export interface Threebox { | |
public: KeyValueStore; | |
private: KeyValueStore; | |
close(): void; | |
logout(): void; | |
} | |
export interface KeyValueStore { | |
log(): Array<Object>; | |
get(key: string): string; |
This file contains 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 { Inject, Injectable } from '@angular/core'; | |
import { WEB3 } from '../web3'; | |
import { BoxOptions, GetProfileOptions, Threebox } from './3box'; | |
import Web3 from 'web3'; | |
import * as ThreeboxFactory from '3box'; | |
import { BehaviorSubject } from 'rxjs'; | |
@Injectable({ providedIn: 'root' }) | |
export class ThreeBox { |
This file contains 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
module.exports = { | |
node: { | |
crypto: true, | |
path: true, | |
os: true, | |
stream: true, | |
buffer: true | |
} | |
} |
This file contains 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 { InjectionToken } from '@angular/core'; | |
import ipfs from 'ipfs'; | |
export const IPFS = new InjectionToken( | |
'The IPFS instance', | |
{ | |
providedIn: 'root', | |
factory: () => new ipfs() | |
}, | |
); |
This file contains 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 { Component, Inject, OnInit } from '@angular/core'; | |
import { IPFS } from './ipfs'; | |
import {Buffer} from 'buffer'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent implements OnInit { |
This file contains 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
// Before this function you should have the ipfs injection token | |
/** | |
* Wait for the IPFS node to be initialized when the app is launched | |
* @param node The Instance of the ipfs constructor | |
*/ | |
export function initIPFS(node) { | |
return function() { | |
return new Promise((resolve, reject) => { | |
node.on('error', () => reject()); | |
node.on('ready', () => resolve()); |