Created
April 2, 2019 04:21
-
-
Save jefflau/b0f531012aafd5f3ff6fa2720f58e78b to your computer and use it in GitHub Desktop.
sendHelper
This file contains hidden or 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 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