Skip to content

Instantly share code, notes, and snippets.

@alexytiger
alexytiger / package.json
Created February 17, 2019 18:44
Blog = Eth + Ang + MgRx
{
"name": "client-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"lint": "ng lint",
"clean:dist": "rimraf ./dist/",
"clean:node_modules": "rimraf ./node_modules/"
@alexytiger
alexytiger / angular.json
Created February 17, 2019 22:15
Blog = Eth + Ang + NgRx - custom webpack builder
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./extra-webpack.config.js"
} ,
@alexytiger
alexytiger / extra-webpack.config.js
Created February 17, 2019 22:17
Blog = Eth + Angular + NgRx + custom webpack
module.exports = {
node: {
crypto: true,
http: true,
https: true,
os: true,
vm: true,
stream: true
}
}
@alexytiger
alexytiger / PokemonAttack.sol
Last active March 10, 2019 02:46
Blog = Eth + Angular + NgRx sol file
pragma solidity ^0.5.2;
contract PokemonAttack {
//this declares a state variable which means it belongs to the contract's state
//This will give us a way to store a string value to the blockchain inside the smart contract.
string attack;
constructor(string memory initialAttack) public {
attack = initialAttack;
@alexytiger
alexytiger / tokens.ts
Last active March 4, 2019 16:48
injection token for Web3 and TruffleContract
import { InjectionToken} from '@angular/core';
import Web3 from 'web3';
import TruffleContract from 'truffle-contract';
import ContractAbi from '../../../../build/contracts/PokemonAttack.json';
export const WEB3 = new InjectionToken<Web3>('web3Token', {
providedIn: 'root',
factory: () => {
// based on https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PokemonComponent } from './components/pokemon/pokemon.component';
const routes: Routes = [
{
path: '', redirectTo: '/pokey-home', pathMatch: 'full',
},
{
import { Injectable } from '@angular/core';
import { CanActivate } from '@angular/router';
import { Store, select } from '@ngrx/store';
import { Observable, of } from 'rxjs';
import { map, take, tap, filter, switchMap, catchError } from 'rxjs/operators';
import {EthAnchorModule} from '../eth.anchor.module';
import * as fromEth from '../../ethereum';
@Injectable({
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import * as guards from './guards';
import { EthPanelComponent } from './components/eth-panel/eth-panel.component';
const routes: Routes = [
{
path: '',
component: EthPanelComponent,
canActivate: [guards.EthInitGuard],
import { Injectable, Inject } from '@angular/core';
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable, of, from } from 'rxjs';
import {exhaustMap, switchMap, map, tap, catchError } from 'rxjs/operators';
import { WEB3, SmartContract } from '../services/tokens';
import Web3 from 'web3';
import {TruffleContract} from 'truffle-contract';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Store, select } from '@ngrx/store';
import * as fromAttackChange from '../../index';
import { Observable, Subject } from 'rxjs';
import { takeUntil, tap } from 'rxjs/operators';
@Component({
selector: 'app-attack-change',
templateUrl: './attack-change.component.html',