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 { AttackChangeService } from './attack-change.services'; | |
| import { Effect, Actions, ofType } from '@ngrx/effects'; | |
| import { Action } from '@ngrx/store'; | |
| import { Observable, of, from } from 'rxjs'; | |
| import { tap, switchMap, exhaustMap, map, catchError } from 'rxjs/operators'; | |
| import * as fromAction from './attack-change.actions'; |
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
| @Effect() | |
| GetAttack$: Observable<Action> = this.actions$.pipe( | |
| ofType(fromAction.ActionTypes.GET_ATTACK), | |
| switchMap(() => this.ethSrv.getAttack().pipe( | |
| map((name: string) => new fromAction.GetAttackSuccess(name)), | |
| catchError(err => of(new fromAction.EthError(err))) | |
| )), | |
| ); |
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
| public getAttack(): Observable<string> { | |
| return from(this.smartContract.deployed()).pipe( | |
| switchMap((instance: any) => from<string>(instance.currentAttack()) | |
| )); | |
| } |
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
| @Effect() | |
| SetAttack$: Observable<Action> = this.actions$.pipe( | |
| ofType(fromAction.ActionTypes.SET_ATTACK), | |
| map((action: fromAction.SetAttack) => action.payload), | |
| exhaustMap((name: string) => this.ethSrv.setAttack(name).pipe( | |
| tap(result => console.log('result', result)), | |
| // retrieve the log information that will contain the event data. | |
| map(result => result.logs[0].args[0]), | |
| map((newName: string) => new fromAction.SetAttackSuccess(newName)), | |
| catchError(err => of(new fromAction.EthError(err))) |
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
| public setAttack(name: string): Observable<any> { | |
| return from(this.smartContract.deployed()).pipe( | |
| switchMap((instance: any) => | |
| from(instance.changeAttack(name, {from: this.web3.eth.defaultAccount})) | |
| )); | |
| } |
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
| pragma solidity ^0.5.5; | |
| // Importing OpenZeppelin's SafeMath Implementation | |
| import 'openzeppelin-solidity/contracts/math/SafeMath.sol'; | |
| contract FleaMarket { | |
| mapping(string => address) elements; | |
| string[] keys; | |
| address public lastContractAddress; |
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
| { | |
| "name": "fleamarketdapp", | |
| "version": "1.0.0", | |
| "description": "", | |
| "author": "Alex Yevseyevich", | |
| "dependencies": { | |
| "fs": "0.0.1-security", | |
| "openzeppelin-solidity": "^2.2.0", | |
| "truffle-hdwallet-provider": "^1.0.5" | |
| } |
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
| module.exports = { | |
| networks: { | |
| ropsten: { | |
| provider: () => { | |
| try { | |
| const fileContents = readFileSync(path.join(__dirname, 'secret.json'), 'utf8') | |
| const data = JSON.parse(fileContents); | |
| const privateKey = data.mnemonic; |
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 { createAction, union } from '@ngrx/store'; | |
| export const show = createAction('[Spinner] Show'); | |
| export const hide = createAction('[Spinner] Hide'); |
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 { createAction, props } from '@ngrx/store'; | |
| export const errorMessage = createAction('[Error] Error Message', props<{ errorMsg: string }>()); |