This file contains 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
// the example from typescript's docs | |
// The type T is never explicitly specified and can be any type that supports keyof | |
function getProperty<T, K extends keyof T>(obj: T, key: K) { | |
return obj[key]; | |
} | |
let x = { a: 1, b: 2, c: 3, d: 4 }; | |
getProperty(x, "a"); // okay | |
getProperty(x, "m"); // error: Argument of type 'm' isn't assignable to 'a' | 'b' | 'c' | 'd'. |
This file contains 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
// basic type inference | |
function inferred() { | |
const a = 'hi' | |
return a | |
} | |
// inferred from interface definition | |
interface DefinesTypes { | |
inferred: (first: number, second: string) => number | |
} |
This file contains 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 BlockchainHandler from './blockchainHandler/BlockchainHandler' | |
import { | |
ConstantsType, | |
BlockchainData, | |
FetchWindow, | |
SetTimeoutWindow, | |
} from './blockchainHandler/blockChainTypes' | |
import { isValidPaywallConfig } from '../utils/validators' | |
import { PaywallConfig, PurchaseKeyRequest } from '../unlockTypes' | |
import { IframePostOfficeWindow } from '../windowTypes' |
This file contains 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 { PaywallConfig, Locks, Lock, Transactions } from '../../unlockTypes' | |
import { EventEmitter } from 'events' | |
import linkKeysToLocks from './linkKeysToLocks' | |
import { POLLING_INTERVAL } from '../../constants' | |
type Web3ProviderType = string | Object | |
export interface WalletServiceType extends EventEmitter { | |
ready: boolean | |
connect: (provider: Web3ProviderType) => Promise<void> |
This file contains 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
gregorybeaver@Gregorys-MacBook-Pro ~/Documents/GitHub/unlock (greg-1882-show-lock-int-test) $ scripts/build-image.sh unlock | |
Sending build context to Docker daemon 89.34MB | |
Step 1/53 : FROM node:8.11.4-alpine | |
8.11.4-alpine: Pulling from library/node | |
a073c86ecf9e: Pull complete | |
db7179d8c6cd: Pull complete | |
66b9cfaecc8c: Pull complete | |
Digest: sha256:1c38d992f89ae389450bc69799a0f2b7d1f9f2e6c445080a4648448e6449e8e4 | |
Status: Downloaded newer image for node:8.11.4-alpine | |
---> 8adf3c3eb26c |
This file contains 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
regorybeaver@Gregorys-MacBook-Pro ~/Documents/GitHub/unlock (greg-1882-show-lock-int-test) $ scripts/build-image.sh unlock | |
Sending build context to Docker daemon 89.34MB | |
Step 1/53 : FROM node:8.11.4-alpine | |
8.11.4-alpine: Pulling from library/node | |
a073c86ecf9e: Pull complete | |
db7179d8c6cd: Pull complete | |
66b9cfaecc8c: Pull complete | |
Digest: sha256:1c38d992f89ae389450bc69799a0f2b7d1f9f2e6c445080a4648448e6449e8e4 | |
Status: Downloaded newer image for node:8.11.4-alpine | |
---> 8adf3c3eb26c |
This file contains 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
export function makeGetTransactionInfo({ | |
web3, | |
transactionHash, | |
mineTransaction, | |
failTransaction, | |
}) { | |
const getTransactionInfo = async transaction => { | |
if (!transactionHash) return | |
const [blockNumber, blockTransaction] = await Promise.all([ | |
web3.eth.getBlockNumber(), |
This file contains 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
export function sendNewKeyPurchaseTransaction({ | |
to, | |
from, | |
data, | |
value, | |
gas, | |
wallet, | |
newTransaction, | |
mineTransaction, | |
failTransaction, |
This file contains 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
export function makeGetTransactionInfo({ | |
web3, | |
transactionHash, | |
startTransaction, | |
mineTransaction, | |
failTransaction, | |
}) { | |
const getTransactionInfo = async transaction => { | |
if (!transactionHash) return | |
const [blockNumber, blockTransaction] = await Promise.all([ |
This file contains 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
https://codesandbox.io/s/73w2kq8mvj |