Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public confirmDelivery(contractAddress: string): Observable<string> {
  2.  
  3. // We connect to the Contract using a Provider
  4. const contract: Contract = new ethers.Contract(contractAddress, this.abi, this.provider.getSigner());
  5.  
  6. // Call the contract method, getting back the transaction tx
  7. const token = contract.buyerConfirmReceived();
  8. return from(token)
  9. .pipe(
  10. switchMap((tx: any) => {
  11.  
  12. console.log('buyerConfirmReceived Tx:', tx);
  13. // Wait for transaction to be mined
  14. // Returned a Promise which would resolve to the TransactionReceipt once it is mined.
  15. return from(tx.wait()).pipe(
  16. tap((txReceipt: any) => console.log('txReceipt: ', txReceipt)),
  17.  
  18. // The receipt will have an "events" Array, which will have
  19. // the emitted event "ItemReceived" from the contract
  20. map(txReceipt => txReceipt.events.pop()),
  21. tap(txEvent => console.log('event: ', txEvent.event)),
  22. mapTo(contractAddress),
  23.  
  24. )
  25. }))
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement