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
| downloadImage$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(IpfsImageActions.download_image), | |
| map((action) => action.ipfsHash), | |
| switchMap((ipfsHash: string) => | |
| this.ipfsSrv.getFile(ipfsHash).pipe( | |
| map((image: Blob) => IpfsImageActions.download_image_success({ image })), | |
| catchError((err: Error) => | |
| of(ErrorActions.errorMessage({ errorMsg: err.message }), IpfsImageActions.download_image_error()) |
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
| abortContract$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(PurchaseContractActions.abortSelectedPurchaseContract), | |
| withLatestFrom(this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
| switchMap(([action, contract]) => { | |
| const dialogConfig = new MatDialogConfig(); | |
| dialogConfig.width = '420px'; | |
| dialogConfig.disableClose = true; |
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); |
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
| reload$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType( | |
| PurchaseContractActions.abortSelectedPurchaseContractSuccess, | |
| PurchaseContractActions.confirmBuySuccess, | |
| PurchaseContractActions.confirmDeliverySuccess), | |
| withLatestFrom(this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
| tap(async ([action, contract]) => { | |
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
| removeProduct$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(PurchaseContractActions.removePurchaseContract), | |
| map(payload => payload.key), | |
| switchMap(key => { | |
| const dialogConfig = new MatDialogConfig(); | |
| dialogConfig.width = '420px'; | |
| dialogConfig.disableClose = true; |
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 |
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
| confirmBuy$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(PurchaseContractActions.confirmBuy), | |
| withLatestFrom(this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
| switchMap(([payload, contract]) => { | |
| const dialogConfig = new MatDialogConfig(); | |
| dialogConfig.width = '420px'; | |
| dialogConfig.disableClose = true; |
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 confirmPurchase(contractAddress: string, etherValue: string): Observable<string> { | |
| // Connect to the Contract using a Provider | |
| const contract: Contract = new ethers.Contract(contractAddress, this.abi, this.provider.getSigner()); | |
| const wei = utils.parseEther(etherValue); | |
| // Call the contract method, getting back the transaction tx | |
| const token = contract.buyerConfirmPurchase({ | |
| value: wei |
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
| confirmDelivery$ = createEffect( | |
| () => | |
| this.actions$.pipe( | |
| ofType(PurchaseContractActions.confirmDelivery), | |
| withLatestFrom(this.store$.pipe(select(fromStore.getSelectedPurchaseContract))), | |
| switchMap(([payload, contract]) => { | |
| const dialogConfig = new MatDialogConfig(); | |
| dialogConfig.width = '420px'; | |
| dialogConfig.disableClose = true; |
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 confirmDelivery(contractAddress: string): Observable<string> { | |
| // We connect to the Contract using a Provider | |
| const contract: Contract = new ethers.Contract(contractAddress, this.abi, this.provider.getSigner()); | |
| // Call the contract method, getting back the transaction tx | |
| const token = contract.buyerConfirmReceived(); | |
| return from(token) | |
| .pipe( | |
| switchMap((tx: any) => { |