Created
September 28, 2019 13:20
-
-
Save alexytiger/ddfe583d85130e73aa65c2328d7a024a 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 removePurchaseContract(productKey: string): Observable<string> { | |
| const bytes32Key = utils.formatBytes32String(productKey); | |
| const token = this.contractToken.removeContractByKey(bytes32Key); | |
| return from(token) | |
| .pipe( | |
| switchMap((tx: any) => { | |
| console.log('removeContractByKey Transaction', 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('TransactionReceipt: ', txReceipt)), | |
| // The receipt will have an "events" Array, which will have | |
| // the emitted event from the Contract. The "logRemovePurchaseContract(address sender, bytes32 key)) | |
| // call is the last event. | |
| map(txReceipt => txReceipt.events.pop()), | |
| tap(txEvent => console.log('txEvent: ', txEvent)), | |
| map(txEvent => { | |
| // retrieve the key parameter value from the event | |
| const key = txEvent.args['key']; | |
| return utils.parseBytes32String(key as ethers.utils.Arrayish) | |
| }), | |
| ) | |
| })) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment