Skip to content

Instantly share code, notes, and snippets.

@jefflau
Created April 2, 2019 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jefflau/b0f531012aafd5f3ff6fa2720f58e78b to your computer and use it in GitHub Desktop.
Save jefflau/b0f531012aafd5f3ff6fa2720f58e78b to your computer and use it in GitHub Desktop.
sendHelper
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
const txState = 'Confirmed'
addTransaction({ txHash, txState })
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment