Skip to content

Instantly share code, notes, and snippets.

loadFile$ = createEffect(
() =>
this.actions$.pipe(
ofType(IpfsUploadActions.load_image),
withLatestFrom(this.store$.pipe(select(fromStore.getIpfsHash))),
map(([action, ipfsHash]) => ipfsHash),
exhaustMap((ipfsHash: string) =>
this.ipfsSrv.getFile(ipfsHash).pipe(
map((image: Blob) => IpfsUploadActions.load_image_success({ image })),
catchError((err: Error) =>
pragma solidity 0.5.11;
import "./HitchensUnorderedKeySet.sol";
contract FleaMarket {
using HitchensUnorderedKeySetLib for HitchensUnorderedKeySetLib.Set;
HitchensUnorderedKeySetLib.Set widgetSet;
struct WidgetStruct {
address contractAddress;
<mat-card>
<mat-card-subtitle>SnackBar Message</mat-card-subtitle>
<mat-card-content>
<p [ngClass]="{
'accent-color': data.color == 'accent',
'primary-color': data.color == 'primary',
'red-color': data.color == 'warn'
}">
{{data.message}}
</p>
import { createAction, props } from '@ngrx/store';
import { SnackBarInterface } from '../../models';
export const open = createAction('[SnackBar] Open', props<{ payload: SnackBarInterface }>());
import { Injectable } from '@angular/core';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { tap, map } from 'rxjs/operators';
import { SnackBarActions } from '../actions';
import { MatSnackBar } from '@angular/material';
import { SnackBarComponent } from '../../components/snackbar/snack-bar.component';
@Injectable()
export class SnackBarEffects {
handleError$ = createEffect(
() =>
this.actions$.pipe(
ofType(ErrorActions.errorMessage),
map(action => action.errorMsg),
tap(errorMsg => console.error('Got error:', errorMsg)),
map(errorMsg => {
const msg: SnackBarInterface = {
message: errorMsg,
export const routes: Routes = [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{
path: 'dashboard',
component: DashboardComponent,
},
{
path: 'p2p-bazaar',
loadChildren: () => import('./p2p-bazaar/p2p-bazaar.module').then(mod => mod.P2pBazaarModule),
canActivate: [guards.EthInitGuard],
import { Injectable } from '@angular/core';
import { Contract } from 'ethers';
import { Provider } from '../../../core/services/tokens';
import { P2pBazaarAnchorModule } from '../../p2p-bazaar.anchor.module';
import { environment } from 'src/environments/environment'
const FLEA_MARKET_CONTRACT_ADDRESS = environment.fleaMarketContractAddress;
const abi = [
'event logNewPurchaseContract(address contractAddress)',
'function createPurchaseContract(bytes32 key, string title, string ipfsHash) payable returns(bool createResult)',
import { FleaMarketContractToken } from './tokens/flea-market-contract-token';
import { Observable, from, of } from 'rxjs';
import { map, tap, switchMap } from 'rxjs/operators';
import { utils } from 'ethers';
@Injectable({ providedIn: P2pBazaarAnchorModule })
export class FleaMarketContractService {
constructor( private contractToken: FleaMarketContractToken ) {
}
public createPurchaseContract(product: any): Observable<string> {
export interface State extends EntityState<PurchaseWidgetModel> {
loaded: boolean;
selectedPurchaseContract: PurchaseContractModel;
}
export function sortByKey(a: PurchaseWidgetModel, b: PurchaseWidgetModel): number {
return a.productKey.localeCompare(b.productKey);
}
// based on https://next.ngrx.io/guide/entity/adapter