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 } from '@angular/core'; | |
import { Contract } from 'ethers'; | |
import { EthersWeb3Provider } from '../../../core/services/ethers-web3-provider'; | |
import { MarketPlaceAnchorModule } from '../../market-place-anchor.module'; | |
import { environment } from 'src/environments/environment'; | |
const FLEA_MARKET_CONTRACT_ADDRESS = environment.fleaMarketContractAddress; | |
const abi = [ | |
'event LogCreatePurchaseContract(address sender, address contractAddress)', | |
'event LogRemovePurchaseContract(address sender, bytes32 key)', |
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
downloadImage$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType(IpfsImageActions.downloadImage), | |
map((action) => action.ipfsHash), | |
switchMap((ipfsHash: string) => | |
this.ipfsSrv.getFile(ipfsHash).pipe( | |
map((image: Blob) => IpfsImageActions.downloadImageSuccess({ image })), | |
catchError((err: Error) => | |
of(this.handleError(err), IpfsImageActions.downloadImageError()) |
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 { ChangeDetectionStrategy, Component, Inject, OnInit, ViewChild , ElementRef } from '@angular/core'; | |
import { MatDialogRef } from '@angular/material'; | |
import { windowRefToken } from '../../../core/services/tokens'; | |
import { Observable } from 'rxjs'; | |
import { withLatestFrom, map, tap, filter, take } from 'rxjs/operators'; | |
import { Store, select } from '@ngrx/store'; | |
import * as fromPurchaseContract from '../../store/reducers'; | |
import * as IpfsActions from '../../store/actions/ipfs-product-image.actions'; | |
@Component({ |
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
export enum FileUploadStatus { | |
Pending = 'Pending', | |
Success = 'Success', | |
Error = 'Error', | |
Progress = 'Progress', | |
} | |
export interface State { | |
status: FileUploadStatus; | |
ipfsHash: string | null; |
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
uploadImage$ = createEffect( | |
() => | |
this.actions$.pipe( | |
ofType(IpfsImageActions.uploadImage), | |
map(action => action.file), | |
exhaustMap((file) => { | |
return this.ipfsSrv.addFile(file).pipe( | |
tap(ipfsHash => console.log(`IPFS file hash: ${ipfsHash}`)), | |
map(ipfsHash => IpfsImageActions.uploadImageSuccess({ ipfsHash })), |
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 { Component, ViewChild, ElementRef, OnInit, OnDestroy } | |
from '@angular/core'; | |
import { FormBuilder, FormGroup, Validators, AbstractControl } | |
from '@angular/forms'; | |
import { MatDialog, MatDialogConfig } from '@angular/material'; | |
import { Observable } from 'rxjs'; | |
import { tap } from 'rxjs/operators'; | |
import { utils } from 'ethers'; | |
import { Store, select } from '@ngrx/store'; |
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 { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { DashboardComponent } from './core/components/dashboard/dashboard.component'; | |
import { NotFoundPageComponent } from './core/containers/not-found-page.component'; | |
import * as guards from './core/guards'; | |
export const routes: Routes = [ | |
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' }, | |
{ |
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 } from '@angular/core'; | |
import { Actions, ofType, createEffect, ROOT_EFFECTS_INIT } from '@ngrx/effects'; | |
import { serializeError } from 'serialize-error'; | |
import { of } from 'rxjs'; | |
import { switchMap, map, tap, catchError } from 'rxjs/operators'; | |
import { IpfsDaemonService } from '../../services/ipfs-daemon.services'; | |
import { IpfsDaemonActions, ErrorActions } from '../actions'; | |
@Injectable() |
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
const path = require('path'); | |
module.exports = { | |
node: { | |
crypto: true, | |
path: true, | |
os: true, | |
stream: true, | |
buffer: true, | |
}, |
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, Inject } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { Observable, from, empty } from 'rxjs'; | |
import { switchMap, map, tap } from 'rxjs/operators'; | |
import { ipfsToken } from './tokens'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class IpfsDaemonService { |