Skip to content

Instantly share code, notes, and snippets.

View mattlockyer's full-sized avatar
💭
🥳

Matt Lockyer mattlockyer

💭
🥳
View GitHub Profile
@mattlockyer
mattlockyer / HelloMarketToken.sol
Created June 6, 2018 17:56
HelloMarket smart contract example with a token for Solidity tutorials (not ERC-20 compliant)
//jshint ignore: start
pragma solidity ^0.4.21;
contract Owner {
address public owner;
modifier onlyOwner() {
require(msg.sender == owner);
@mattlockyer
mattlockyer / hellomarket.js
Created June 6, 2018 17:58
Tests for HelloMarket smart contract example for Solidity tutorials
//jshint ignore: start
// contracts
const contracts = [
{ name: 'HelloMarket' }
];
contracts.forEach(c => c.artifact = artifacts.require('./' + c.name + '.sol'))
/**************************************
* Tests
@mattlockyer
mattlockyer / hellomarkettoken.js
Created June 6, 2018 17:59
Tests for HelloMarketToken smart contract example for Solidity tutorials
//jshint ignore: start
// contracts
const contracts = [
{ name: 'HelloMarketToken' }
];
contracts.forEach(c => c.artifact = artifacts.require('./' + c.name + '.sol'))
/**************************************
* Tests
@mattlockyer
mattlockyer / hellomarket-testrunner.js
Created June 6, 2018 20:10
Test Runner for HelloMarket.sol / HelloMarketToken.sol (empty)
//jshint ignore: start
// contracts
const contracts = [
{ name: 'HelloMarket' }
];
contracts.forEach(c => c.artifact = artifacts.require('./' + c.name + '.sol'))
/**************************************
* Tests
@mattlockyer
mattlockyer / Lecture-week6.md
Last active June 23, 2018 22:26
Lighthouse Labs Week 6 Lecture Notes - Web3.js, TruffleContract, Frontends, Accounts and Transactions

Web3.js, TruffleContract and Frontend Development of Decentralized Applications

To date, we've been writing and testing contracts using JavaScript tests.

Those tests are a lot like our frontend code that we need to create in order to allow users of our decentralized applications (dapps) to talk to the Ethereum Blockchain.

However, there's a lot of initial setup and network configuration code that was automated (black boxed) by our test runner.

User experience, waiting for transactions and returning the updated state to the application and user interface are also a primary concern for developing these dapps.

@mattlockyer
mattlockyer / wait.js
Last active January 11, 2019 16:41
Wait for function to return true uses promise for async / await
/**************************************
* Wait for function to return true, default 50ms for 100 attempts (5s)
**************************************/
export const wait = (func, del = 50, lim = 100) => new Promise((resolve, reject) => {
let attempt = 0
const test = () => {
if (func()) resolve()
else if (attempt < lim) setTimeout(test, del)
else reject("ran out of attempts")
console.log('wait attempt', attempt)
@mattlockyer
mattlockyer / generic-reducer.js
Created January 5, 2019 17:52
Generic Reducer for Redux - update state with any action key/vaue passed (excluding type)
//generic event type for updating state
export const UPDATE = 'STATE_UPDATE'
//generic reducer for updating state
export const reducer = (state, action) => {
//console.log(action)
const { type } = action
switch (type) {
case UPDATE:
const a = { ...action }
delete a.type
@mattlockyer
mattlockyer / redux-connect-multiple.js
Created January 5, 2019 18:45
Connect multiple Redux states and dispatches ... elegantly
export default connect(
(state) => ({
state1: state1(state),
state2: state2(state),
}),
(dispatch) => ({
dispatch1: dispatch1(dispatch),
dispatch2: dispatch2(dispatch),
})
)(App);
@mattlockyer
mattlockyer / custom-grunt.js
Created January 10, 2019 15:46
Custom Gruntfile for materializecss
const files = [
'js/cash.js',
'js/component.js',
'js/global.js',
'js/anime.min.js',
// 'js/collapsible.js',
// 'js/dropdown.js',
// 'js/modal.js',
3Box is a social profiles network for web3. This post links my 3Box profile to my Github account!
✅ did:muport:Qme8gP1U9LfNe5J75N19QXqghFg5DUQ5gtwJBFjjdaBmMz ✅
Create your profile today to start building social connection and trust online. https://3box.io/