Skip to content

Instantly share code, notes, and snippets.

Avatar
🏪
Working from Taipei

Jeff Lau jefflau

🏪
Working from Taipei
View GitHub Profile
@jefflau
jefflau / multisig.sol
Last active Oct 11, 2020
MultiSig 1st attempt
View multisig.sol
pragma solidity >=0.6.0 <0.7.0;
import "@nomiclabs/buidler/console.sol";
// SPDX-License-Identifier: MIT
contract MultiSig {
address[] public owners;
mapping(address => bool) isOwner;
uint256 public confirmations;
Transaction[] public transactions;
@jefflau
jefflau / loss.js
Created Sep 16, 2020
Calculate pool value loss
View loss.js
function calcPoolValueLoss(x){
return Math.pow(x, 0.02)*((1)^0.98)
}
@jefflau
jefflau / ensApi.md
Last active Sep 20, 2020
ENS Javascript API design
View ensApi.md

API design for ENS

The ENS library is to be used in dapps and possibly other tools that need to connect to the set of ENS contracts on the Ethereum blockchain. It should give them all the tools they need to resolve and set records for their ENS names, as well as abstracting implementation details including, but not limited to:

  • namehashes (could be provided as an advanced option)
  • resolvers (unless it's absolutely required for custom resolvers)
  • using the graph for getting textRecord or non-eth address keys
  • decoders/encoders of addresses

Instantiation

View gist:b0f531012aafd5f3ff6fa2720f58e78b
export function sendHelper(tx) {
return new Promise((resolve, reject) => {
tx()
.on('transactionHash', txHash => {
const txState = 'Pending'
addTransaction({ txHash, txState })
resolve(txHash)
})
.on('receipt', receipt => {
const txHash = receipt.transactionHash
@jefflau
jefflau / cloudinary.js
Created Feb 28, 2019
Cloudinary unsigned upload
View cloudinary.js
const cloudName = 'xxxxxx'
const cloudinaryUrl = `https://api.cloudinary.com/v1_1/${cloudName}/upload`
const unsignedUploadPreset = 'xxxxxx'
export function upload(file) {
const body = new FormData()
body.append('file', file)
body.append('upload_preset', unsignedUploadPreset)
return (
View useMedia.js
const useMedia = (query, defaultState) => {
const [state, setState] = useState(defaultState)
useEffect(
() => {
let mounted = true
const mql = window.matchMedia(query)
const onChange = () => {
if (!mounted) return
setState(!!mql.matches)
View useEditable.js
export function useEditable(
initialState = {
editing: false,
newValue: '',
pending: false,
confirmed: false,
txHash: undefined
}
) {
const types = {
@jefflau
jefflau / mediaQuery.js
Last active Oct 14, 2018
mediaQuery.js
View mediaQuery.js
import { css } from 'styled-components'
const sizes = {
giant: 1170,
desktop: 992,
tablet: 768,
phone: 376
}
// iterate through the sizes and create a media template
@jefflau
jefflau / ensTypes.graphql
Last active Sep 26, 2018
ensTypes.graphql
View ensTypes.graphql
type Address {
address: String
}
type Node {
name: String
nameHash: String
label: String
node: String
subNodes: [Node]
View gist:763ae8197fee2a872fedbe062007c13c
[
{
"constant": false,
"inputs": [
{
"name": "_hash",
"type": "bytes32"
}
],
"name": "releaseDeed",
You can’t perform that action at this time.