Last active
January 20, 2020 00:58
-
-
Save alexytiger/cb621175ecbdc451a8b46ac4090f97d4 to your computer and use it in GitHub Desktop.
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
| public abortPurchaseContract(contractAddress: string): Observable<string> { | |
| const contract: Contract = new ethers.Contract(contractAddress, this.abi, this.provider.getSigner()); | |
| // Call the contract method, getting back the transaction tx | |
| const token = contract.abortBySeller(); | |
| return from(token) | |
| .pipe( | |
| switchMap((tx: any) => { | |
| console.log('abortBySeller Tx:', tx); | |
| // Wait for transaction to be mined | |
| // Returned a Promise which would resolve to the TransactionReceipt once it is mined. | |
| return from(tx.wait()).pipe( | |
| tap((txReceipt: any) => console.log('txReceipt: ', txReceipt)), | |
| // The receipt will have an "events" Array, which will have | |
| // the emitted event from the Contract. | |
| // The "Aborted" is the only event. | |
| map(txReceipt => txReceipt.events.pop()), | |
| tap(txEvent => console.log('event: ', txEvent.event)), | |
| mapTo(contractAddress), | |
| ) | |
| })) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment